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: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+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