On 10/1/13 6:36 AM, Derek wrote:
We encountered the same problem for a complex model ... we ended up defining "acceptable" default values that are used instead of None/NULL, but essentially mean the same thing to the user. (We are using MySQL which adopts the same approach as Postgresql - I believe Oracle does it otherwise).
(Just meant for general discussion, not specific to other suggestions in this thread)

This would seem to be a problem that explicit constraints are meant to solve. One could check that the row is unique either with or without the foreign key, depending on whether it is specified. Postgres supports those very well (others may also nowadays), and if necessary one could use python or another language supported by the backend to implement complex logic.

That does not solve the validation problem at the user level, but keeps invalid data from leaking into the database.

hth

                               - Tom


On Monday, 30 September 2013 23:17:00 UTC+2, Karen Tracey wrote:

    On Mon, Sep 30, 2013 at 4:55 PM, Berndt Jung <ber...@brkt.com
    <javascript:>> wrote:

        Because the lookup_value of a null field is None, the
        validation check is aborted entirely.  This seems wrong to me,
        and I'm wondering if I'm doing something wrong here.
         Redefining the models is not something I can do at this point.


    None in Python corresponds to NULL in SQL. SQL defines that NULL
    != NULL. So when checking for unique values the database will not
    consider two NULLs to be the same value; the NULLs will be
    considered to be different and will not violate the unique
    constraint. The Django code is doing the same check for uniquess
    that the database will be enforcing. There is no way I know of to
    make a database enforce uniqueness among NULL values...


--
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/75c02ade-18a4-4e38-a75c-f75b756f831f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/524B3547.8000607%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to