The output unit of Django generic view.
This is the Python package whose name is dj-cref .
dj-cref outputs a template of django generic view you wanted.
- View
- FormView
- CreateView
- UpdateView
- DeleteView
- DetailView
- TemplateView
- ListView
- RedirectView
- Python3
-type [kind of view]
: Which type of generic view to output.--initial
: Whether to include import statements.
Case1
$ dj-cref -type FormView
class MyFormView(FormView):
# template_name = 'my_template.html'
# form_class = 'MyForm'
# success_url = '/my/success'
def dispatch(self, request, *args, **kwargs):
super().dispatch(request, *args, **kwargs)
# please implement here
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
...
Case2
$ dj-cref -type FormView --initial
from django.views import FormView
class MyFormView(FormView):
# template_name = 'my_template.html'
# form_class = 'MyForm'
# success_url = '/my/success'
def dispatch(self, request, *args, **kwargs):
super().dispatch(request, *args, **kwargs)
...
$ pip install dj-cref