I have a model as such class Foo(models.Model): someattr = ... anotherattr = ForeignKey(...)
>From within my view I want to do this: bar, created = Foo.objects.get_or_create(someattr=somevalue) if created: bar.anotherattr = anothervalue bar.save() But the problem is I get an exception at .get_or_create(): sqlite3.IntegrityError: app_foo.anotherattr_id may not be NULL This is true, but I don't want the ORM to actually execute the INSERT until I save() (when it is no longer NULL). How do I accomplish this? Do I have to do a .get(), catch the exception and then create a new Foo object? I thought that is what get_or_create() was supposed to do? -a -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.