Exemplo n.º 1
0
def edit_entry(request, blog_slug, object_id):
    if request.method == 'POST':
        entry = Article.objects.get(id=object_id)
        entry.body = request.POST['body']
        entry.save()
        return HttpResponse(str(entry.body))
    return UpdateView(
        form_class=BlogEntryForm,
        object_id=object_id,
        login_required=True,
        template_name="blogs/add_entry.html",
    )
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
#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,))
Exemplo n.º 4
0
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'


class {{ model_name }}DeleteView(SuccessMessageMixin, DeleteView):
    model = {{ model_name }}
    template_name = '{{ template_path }}/delete_confirm.html'