0
votes

I have a function in my views.py which inserts data into Table1 but one of the fields in Table1 is a Foreign Key to the primary key of another table known as Table2.

Note:- Table2 is empty as of now(no data).

For now, I just want to check if data is getting inserted properly in Table1, so, I have skipped the foreign key in Django ORM, but I am getting the error like "Null value in column “name” violates not-null constraint "

Can someone please tell a way to bypass this (or) any new way is appreciated.

1

1 Answers

3
votes

You should make your ForeignKeyField nullable by adding null=True to your column definition.