How to make a Django ForeignKey optional
Looks like you need to have both blank=True and null=True to make a ForeignKey optional in a django model…
Looks like you need to have both blank=True and null=True to make a ForeignKey optional in a django model…
September 3rd, 2007 at 8:22 am
Thanks ; )
April 12th, 2008 at 12:21 pm
Thanks Rachel
April 16th, 2008 at 1:00 am
Rachel, pretty awesome tip, thanks!!
April 22nd, 2008 at 8:09 am
Thanks, that just helped me a bunch!
I also noticed I had to redefine the foreign key column in my database (MySQL) to accept NULL values, since it had already been created before I added null=True:
alter table articles_article change category_id category_id integer NULL;