#14678: Users are able to add more than one page to the same url
-------------------------------------+-------------------------------------
               Reporter:  seler      |          Owner:  j4nu5
                   Type:  Bug        |         Status:  assigned
              Milestone:             |      Component:  contrib.flatpages
                Version:  SVN        |       Severity:  Normal
             Resolution:             |       Keywords:  flatpages, unique,
           Triage Stage:  Accepted   |  sites
    Needs documentation:  1          |      Has patch:  1
Patch needs improvement:  1          |    Needs tests:  0
                  UI/UX:  0          |  Easy pickings:  0
-------------------------------------+-------------------------------------

Comment (by j4nu5):

 Replying to [comment:18 carljm]:
 > In any case, comment 9 is still inaccurate since m2m's can't go in
 unique_together. And j4nu5 is right that it can't go in the model
 validation code on the `FlatPage` model because m2ms haven't even been
 saved at that point. I think the options are either m2m_changed signal, or
 adding an explicit through model to the m2m and doing the validation
 there. In the end those will look pretty similar. In either case, the
 trick is finding a way that that error can be caught and presented nicely
 at the `ModelForm` layer (most importantly for the admin, but it should
 ideally not be implemented just for the admin), rather than just raising
 an `IntegrityError`. I don't think the current patch takes care of this.
 > > I can catch the exception in Flatpage's ModelForm and display a
 message (from django.contrib) or something similar but the calling view is
 expecting the object to be successfully saved when it calls form's save
 method and thus, those view have to be made aware of the fact that an
 error may occur when form.save is called and therefore have to be patched.

 > > Since the views have to be patched anyway, why don't we leave the
 error catching mechanism in ModelForm and instead put it the views which
 call form.save (add_view and change_view in admin specifically). We can
 then update the documentation stating that custom Flatpage views should
 expect IntegrityError when calling the save method. Its a bit ugly but
 prettier than other options. Tell me what you think.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/14678#comment:19>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to