Greetings, I am trying to solve what seems like an easy problem, but the solution eludes me even after many Google searches.
I have a simple model: class Site(models.Model): user = models.ForeignKey(User) url = models.URLField() class Meta: unique_together = (('user', 'url'),) And an equally simple ModelForm: class SiteForm(forms.ModelForm): class Meta: model = Site exclude = ('user',) I exclude the user field because I want to be able to save a Site object for the currently logged in user. But no matter how I try to set the user in the view, form.save() raises an IntegrityError ("Column 'user_id' cannot be null"). I know I could include the user field and generate the form with a hidden field using the pk of the current user, but that seems like it could be easily altered. What is the best approach for this? -- 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.