It just occurred to me where I went wrong. 

I have a line that makes the form field non-required which means the form 
won't flag the validation error. 

Thanks Florian

On Wednesday, 26 August 2015 20:18:48 UTC+8, khoobks wrote:
>
> That makes sense however I would have expected the ModelForm to give an 
> error indicating that the foreign key is blank (when it should not be) 
> instead of adding it to the exclusion list meaning that it never gets 
> updated when you call save.
>
>
>
> On Wednesday, 26 August 2015 19:43:16 UTC+8, Florian Schweikert wrote:
>>
>> On 26/08/15 11:59, khoobks wrote: 
>> > I just discovered some interesting behaviour in Django 1.8.4 and was 
>> > wondering if this was an unexpected side effect or specifically 
>> designed 
>> > behaviour. 
>>
>> That behaviour is intended and documented[0]. 
>>
>> blank and null working on completely different levels. 
>> blank is only for validation in the django code. 
>> null affects the database field. 
>>
>> It's useful if you like to force the user to input something in a field, 
>> but at the same time you have to initialise a model with null at some 
>> other place in your code. 
>> e.g you are importing email addresses, but don't have names in your 
>> current data. You can now easily force the user to set his/her name when 
>> changing settings, without overwriting fields in a form. 
>>
>> regards, 
>> Florian 
>>
>> [0] https://docs.djangoproject.com/en/1.8/ref/models/fields/#null 
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/101de680-22d4-4250-bee6-7695be943358%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to