Exception Value: (1048, "Column 'active_year_id' cannot be null")

40 views
Skip to first unread message

Rain

unread,
Oct 20, 2019, 12:57:16 PM10/20/19
to Django users
Hello Guys Hopefully someone can help me on this.! any help i appreciate it.

My Problem is This.. I do my research and still cant figure out what the solution for this..!
i do Try alot of things but still cant get this right.
what i want is to populate the active_year_id. automatically when submitting the form..
Thanks in Advance...


My Model Look Like This:
And My Views Look Like This..

Gil Obradors

unread,
Oct 21, 2019, 1:28:43 AM10/21/19
to django...@googlegroups.com
Hi!
This field cant be null....

Add null=True, blank=True
To parameters of active_year and solved

El dg., 20 d’oct. 2019, 18:58, Rain <laracasa...@gmail.com> va escriure:
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53f9c9b6-fdb5-4a1a-b2b0-2ef384bd82a5%40googlegroups.com.

Gil Obradors

unread,
Oct 21, 2019, 1:33:25 AM10/21/19
to django...@googlegroups.com
Maybe you wan to fill this field, so last mail isn t the solution.

Can you paste the code of form? Html amb form py?

The user selects the year, or its automatically filled in view post class ?


El dl., 21 d’oct. 2019, 7:27, Gil Obradors <gil.ob...@gmail.com> va escriure:

Rain

unread,
Oct 21, 2019, 1:56:21 AM10/21/19
to django...@googlegroups.com
Hello Sir Thank you so much for your reply!!
what i want is to autofill the foreign key
Here is my form
image.png

image.png
Thank You so much sir!.

Gil Obradors

unread,
Oct 21, 2019, 5:05:09 AM10/21/19
to django...@googlegroups.com
Hi!

Please, have a look at official documentation of django, it's great


Add something like :  active_year = forms.ModelChoiceField(SchoolYear)
into modelForm




Missatge de Rain <laracasa...@gmail.com> del dia dl., 21 d’oct. 2019 a les 7:56:

Rain

unread,
Oct 21, 2019, 6:05:34 AM10/21/19
to django...@googlegroups.com
Hi! Sir. Thank You Very Much for your efforts..
I Found out that i lack on fields to get the actual value of fk thats why it raise this error
Thank you so much sirr.!!

Reply all
Reply to author
Forward
0 new messages