-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathviews.py
More file actions
38 lines (26 loc) · 776 Bytes
/
views.py
File metadata and controls
38 lines (26 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from django.urls import reverse_lazy
from django.views.generic import (
CreateView,
DeleteView,
DetailView,
ListView,
UpdateView,
)
from .models import Entry
class EntryListView(ListView):
model = Entry
queryset = Entry.objects.all().order_by("-date_created")
class EntryDetailView(DetailView):
model = Entry
class EntryCreateView(CreateView):
model = Entry
fields = ["title", "content"]
success_url = reverse_lazy("entry-list")
class EntryUpdateView(UpdateView):
model = Entry
fields = ["title", "content"]
def get_success_url(self):
return reverse_lazy("entry-detail", kwargs={"pk": self.object.pk})
class EntryDeleteView(DeleteView):
model = Entry
success_url = reverse_lazy("entry-list")