from django.views.generic import DetailView, ListView, UpdateView, CreateView from .models import {{ cookiecutter.model_name }} from .forms import {{ cookiecutter.model_name }}Form class {{ cookiecutter.model_name }}ListView(ListView): model = {{ cookiecutter.model_name }} {{ cookiecutter.model_name|lower }}_list = {{ cookiecutter.model_name }}ListView.as_view() class {{ cookiecutter.model_name }}CreateView(CreateView): model = {{ cookiecutter.model_name }} form_class = {{ cookiecutter.model_name }}Form {{ cookiecutter.model_name|lower }}_create = {{ cookiecutter.model_name }}CreateView.as_view() class {{ cookiecutter.model_name }}DetailView(DetailView): model = {{ cookiecutter.model_name }} {{ cookiecutter.model_name|lower }}_detail = {{ cookiecutter.model_name }}DetailView.as_view() class {{ cookiecutter.model_name }}UpdateView(UpdateView): model = {{ cookiecutter.model_name }} form_class = {{ cookiecutter.model_name }}Form {{ cookiecutter.model_name|lower }}_update = {{ cookiecutter.model_name }}UpdateView.as_view()
#crudgenerator auto-generated code. #crudgenetaror date: {% now "jS F Y H:i" %} from django.core.urlresolvers import reverse from django.views.generic import ListView, CreateView, UpdateView, DeleteView from models import {{modelname}} from {{appname}}.forms import {{modelname}}ModelForm class {{modelname}}ListView(ListView): model={{modelname}} paginate_by=20 class {{modelname}}DeleteView(DeleteView): model={{modelname}} def get_success_url(self): return reverse("{{appname|lower}}:{{modelname|lower}}:list", args=(1,)) class {{modelname}}CreateView(CreateView): model={{modelname}} form_class={{modelname}}ModelForm def get_success_url(self): return reverse("{{appname|lower}}:{{modelname|lower}}:list", args=(1,)) class {{modelname}}UpdateView(UpdateView): model={{modelname}} def get_success_url(self): return reverse("{{appname|lower}}:{{modelname|lower}}:list", args=(1,))
from django.urls import reverse_lazy from django.views.generic import ListView, CreateView, UpdateView, DetailView, DeleteView from django.contrib.messages.views import SuccessMessageMixin from {{ app_model_module }} import {{ model_name }} class {{ model_name }}ListView(ListView): model = {{ model_name }} paginate_by = 25 template_name = '{{ template_path }}/list.html' class {{ model_name }}CreateView(SuccessMessageMixin, CreateView): model = {{ model_name }} fields = {{ model_fields|safe }} template_name = '{{ template_path }}/create.html' success_url = reverse_lazy('{{ routes.list }}') success_message = '{{ model_name }} %({{ model_fields.1 }})s created successfully!' class {{ model_name }}UpdateView(SuccessMessageMixin, UpdateView): model = {{ model_name }} fields = {{ model_fields|safe }} template_name = '{{ template_path }}/update.html' success_url = reverse_lazy('{{ routes.list }}') success_message = '{{ model_name }} %({{ model_fields.1 }})s updated successfully!' class {{ model_name }}DetailView(DetailView): model = {{ model_name }} template_name = '{{ template_path }}/detail.html'