According to Daniel on IRC they should be `False` not `None` (i.e. the
documentation is correct).
--
Ticket URL: <https://code.djangoproject.com/ticket/24665>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: pirosb3 => yoongkang
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:1>
Comment (by pirosb3):
yoongkang, are you doing this?
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:2>
Comment (by yoongkang):
pirosb3, sorry I think I must have mixed this up with a different issue.
How do I assign it back to you?
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:3>
* owner: pirosb3 => honya121
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:4>
Comment (by honya121):
It seems that the relational attributes are `None` only for non-relational
fields (`Field.is_relation=False`). For relational fields these attributes
are `False` or `True`. This is right behaviour according to the
documentation (the values should only be meaningful if
`Field.is_relation=True`), but it is possible, that I tested it badly. So
there are 2 options:
a) keep default relational values in the non-relational fields `None`
b) set default relational values for ALL fields to `False`
For both options, it would be good to write what values are default even
for fields with `Field.is_relation=False`, instead of writing that these
fields will have unmeaningful values.
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:5>
Comment (by MarkusH):
Hi honya121, in my opinion you should go forward with option b. I don't
understand what you mean with your last sentence.
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:6>
Comment (by honya121):
Hi, ok, I'll do the b) option. The last sentence is about documentation.
Sorry, I forgot to mention that. Anyway, in the documentation, there
should be also mentioned, that the relational attributes will be `False`
for non-relational fields.
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:7>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/4540 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:8>
Comment (by timgraham):
I'd like to better understand the rationale for this change. In my mind,
`None` for non-relational fields seems like it may make debugging easier,
e.g. if you find a `None` value, then you'll know you forgot to check
`is_relation`.
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:9>
Comment (by carljm):
I agree with timgraham. It seems entirely sensible to me to have the
relation-cardinality attributes be `None` (as in, neither `True` nor
`False` because they are not even applicable in the first place) for non-
relational fields. I don't see the rationale for changing them to `False`.
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:10>
Comment (by MarkusH):
Either way makes sense in my eyes. E.g. "Am I a one_to_many field?" --
"No" --> `False`. In that case I think we still need to update the docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:11>
Comment (by timgraham):
{{{
#!diff
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 01ff654..f8144c1 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -1883,7 +1883,7 @@ Attributes for fields with relations
These attributes are used to query for the cardinality and other details
of a
relation. These attribute are present on all fields; however, they will
only
-have meaningful values if the field is a relation type
+have boolean values (rather than ``None``) if the field is a relation
type
(:attr:`Field.is_relation=True <Field.is_relation>`).
.. attribute:: Field.many_to_many
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:12>
* status: assigned => closed
* resolution: => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:13>
* resolution: invalid => fixed
Comment:
In [changeset:"2b086229a2a6c786e32da37b6b122c2cc894450f" 2b08622]:
{{{
#!CommitTicketReference repository=""
revision="2b086229a2a6c786e32da37b6b122c2cc894450f"
Fixed #24665 -- Clarified model field flag defaults.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:14>
Comment (by Tim Graham <timograham@…>):
In [changeset:"afae8ff916e85488a31384a681cd4d4fedea58b8" afae8ff]:
{{{
#!CommitTicketReference repository=""
revision="afae8ff916e85488a31384a681cd4d4fedea58b8"
[1.8.x] Fixed #24665 -- Clarified model field flag defaults.
Backport of 2b086229a2a6c786e32da37b6b122c2cc894450f from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24665#comment:15>