예제 #1
0
 def post(self, request, *args, **kwargs):
     """
     Grab the POST data
     """
     gallery_form = GalleryForm(request.POST)
     # Validate the form
     if gallery_form.is_valid():
         # Save and create a new gallery
         self.gallery = gallery_form.save()
         return self.form_valid(gallery_form)
     else:
         return self.form_invalid(gallery_form)
예제 #2
0
    def post(self, request, *args, **kwargs):
        """
        Create a valid form from the gallery, pass that in and use the super
        class to handle the rest
        """
        # Get the gallery or go to a 404 page
        self.gallery = get_object_or_404(Gallery, id=self.kwargs['gallery_id'])
        gallery_form = GalleryForm({'name':self.gallery.name,
                                    'description':self.gallery.description})

        if gallery_form.is_valid():
            return self.form_valid(gallery_form)
        else:
            return self.form_invalid(gallery_form)