diff --git a/config/photoapp/forms.py b/config/photoapp/forms.py index 6dc8542..91e2fee 100644 --- a/config/photoapp/forms.py +++ b/config/photoapp/forms.py @@ -1,21 +1 @@ '''Photo app Forms''' - -from django import forms - -from .models import Photo - -class CreatePhotoForm(forms.ModelForm): - - class Meta: - model = Photo - - fields = ('title', 'description', 'image', 'tags') - - -class UpdatePhotoForm(forms.ModelForm): - - class Meta: - model = Photo - - fields = ('title', 'description', 'tags') - diff --git a/config/photoapp/views.py b/config/photoapp/views.py index 3981d59..3fd9bcf 100644 --- a/config/photoapp/views.py +++ b/config/photoapp/views.py @@ -4,8 +4,6 @@ from django.core.exceptions import PermissionDenied -from django.urls.resolvers import get_resolver - from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin @@ -14,8 +12,6 @@ from .models import Photo -from .forms import CreatePhotoForm, UpdatePhotoForm - class PhotoListView(ListView): model = Photo @@ -53,10 +49,12 @@ class PhotoDetailView(DetailView): class PhotoCreateView(LoginRequiredMixin, CreateView): - template_name = 'photoapp/create.html' + model = Photo - form_class = CreatePhotoForm + fields = ['title', 'description', 'image', 'tags'] + template_name = 'photoapp/create.html' + success_url = reverse_lazy('photo:list') def form_valid(self, form): @@ -84,7 +82,7 @@ class PhotoUpdateView(UserIsSubmitter, UpdateView): model = Photo - form_class = UpdatePhotoForm + fields = ['title', 'description', 'tags'] success_url = reverse_lazy('photo:list')