Did you previously have a field named 'title' in this model that was marked
unique, that you have since removed?  If so, the column may still be in the
database with a unique constraint.  Since it's no longer in the model, some
default may be being used when you save, and that's obviously not unique.
Use suitable tools for your database (if PostgreSQL, I suggest PGAdminIII)
to examine the schema.  You may be able to drop the column, or at least the
constraint (back up the database first).

If there never was such a field, then the problem originates in another
model.  You still may be able to figure it out by inspecting the database
schema.  You can also temporarily set up to catch the Integrity Error close
to the origin, and call pdb.set_trace(), where you can examine the query to
see what models are involved.

Bill

On Sat, Feb 9, 2013 at 3:44 AM, Some Developer <someukdevelo...@gmail.com>wrote:

> On 08/02/13 14:08, Andre Terra wrote:
>
>> Please post traceback, settings.py, etc.
>>
>> On Fri, Feb 8, 2013 at 5:18 AM, Some Developer
>> <someukdevelo...@gmail.com 
>> <mailto:someukdeveloper@gmail.**com<someukdevelo...@gmail.com>>>
>> wrote:
>>
>>     I have a model for a Tag object with simply has two fields. A title
>>     (which has the unique constraint) and a description. I also have a
>>     FormView based view class which handles the creation of Tag objects.
>>
>>     When I try and save the object in the form_valid() method I always
>>     get an IntegrityError stating that the title column is not unique.
>>     This is somewhat puzzling as I have deleted the SQLite database file
>>     and recreated it using syncdb / migrate so it is completely empty.
>>
>>     I'm completely baffled by this error.
>>
>
> Opps. I forgot to post the code.
>
> class TagCreate(FormView):
>     template_name = 'blog/tag_create.html'
>     success_url = reverse_lazy('blog_tag_create_**confirmed')
>     model = BlogTag
>     form_class = CreateTagForm
>
>     def form_valid(self, form):
>         tag = BlogTag(
>             title=form.cleaned_data['**title'],
>             description=form.cleaned_data[**'description'],
>             num_articles=0)
>
>         tag.save()
>
>         return super(TagCreate, self).form_valid(form)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> django-users+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

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


Reply via email to