Skip to content

Commit ce88380

Browse files
authored
Create views.py
1 parent 8464dc2 commit ce88380

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

css-grid/views.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
CSS Grid Template
3+
"""
4+
5+
class CSSGridMixin(object):
6+
"""
7+
A mixin for adding css grid to any standard CBV
8+
"""
9+
10+
def get_context_data(self, **kwargs):
11+
"""
12+
Insert the single object into the context dict.
13+
"""
14+
context = {}
15+
if self.object:
16+
context['object'] = self.object
17+
context_object_name = self.get_context_object_name(self.object)
18+
if context_object_name:
19+
context[context_object_name] = self.object
20+
context.update(kwargs)
21+
return super(SingleObjectMixin, self).get_context_data(**context)

0 commit comments

Comments
 (0)