>
>
> We probably cannot move checks of `primary_key` and `unique` living in
> `FileField.__init__`. We test if one of these two parameters was passed; we
> don't check their values. Consider that an user passes unique=False. This 
> is
> the default value, but nevertheless, this should result in an error. We
> cannot check if the attributes where passed while performing system 
> checks. I'm
> not sure if I make myself clear.
>
>
Why not just store a reference to the original arguments (or the relevant 
subsets) in __init__(), and then validate them later in a system check? 
That may seem a little indirect, but I think the validation system will be 
much nicer if we can do everything in system checks instead of splitting 
the work with __init__().

I think there are other places as well where we'd like to do this kind of 
check. For example, right now you can create a OneToOneField with 
unique=False and Django will silently overwrite that value and your model 
will validate just fine. It would be much better if trying to specify 
unique on a OneToOneField caused a validation error, and the same sort of 
pattern could be applied there: storing a reference to the original value 
during __init__(), overwriting with unique=True for the purposes of 
initializing the parent ForeignKey, and then checking the user-supplied 
value in a separate system check. (This is just an example, I'm not saying 
that you should make this change to OneToOneField now, as it's 
backwards-incompatible.)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to