leifos/tango_with_django_book — pull request #2 by canibanoglu (2013-10-18 13:08:55+00:00)
Title: The current implementation lets users add duplicate Page entries

Contrary to the Category model (which has ```unique=True``` for the title field), the Page model doesn't enforce such a thing. Because of this users can create duplicate Pages with the same URL field and the application will happily add the duplicate entries to the database.

In order to make Django check if the Page is already present in the database before adding a new instance, I propose setting ```unique=True``` in the URLField of the Page model. Moreover, since we are overriding the clean method of PageForm, we should call the parent class's clean method so that Django validates the uniqueness before saving to the database.