#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,))
Beispiel #2
0
    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'


class {{ model_name }}DeleteView(SuccessMessageMixin, DeleteView):
    model = {{ model_name }}
    template_name = '{{ template_path }}/delete_confirm.html'
    success_url = reverse_lazy('{{ routes.list }}')
    success_message = '{{ model_name }} %({{ model_fields.1 }})s deleted successfully!'