Re: Django Admin doesn't show all fields from model when registered.
Thomas' reply actually did help me narrow down my search efforts to 'namespaces' which is a term I'm actually new to (as a noob) and I was able to get links to articles that did make me understand a little bit more of what goes on beneath the hood of my program especially this: http://docs.python.org/tutorial/classes.html#python-scopes-and-namespaces . My previous google-fu had been failing me and now I do agree that it has nothing to do with django or python and my earlier request can just be ignored.
On Sat, Aug 18, 2012 at 10:03 AM, bruno desthuilliers <bruno.desthuilliers@gmail.com> wrote:
Le jeudi 16 août 2012 21:00:56 UTC+2, Tundebabzy a écrit :Ok I fixed it and in case someone else falls into such a trap, here's
how I fixed it.
My Answer model had a field with name 'is_correct' and had a method
with name 'is_correct'.
Everything in Python is an object, including functions, classes, modules etc. In a class statement's body, if you first bind name "is_correct" to something (here a field but it could have been anything) then to something else (here a function but it could have been anything too), then the second binding will replace the first one.
I think django should be able to detect such things and raise an error
"Django" (that is, in this case, django models metaclass) doesn't even know about this - all it gets is the namespace (ie: a dict) obtained by evaluating the class statement's body. This is how Python work, and expecting something else just means that you assume it works like some other language you already know (bad luck: no two languages work the same).
or there should be a note in the documentation warning people not to
name their model methods with model field names.
Why should Django documents Python features ? Python is already (and quite extensively) documented on it's own : http://docs.python.org/
--To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/fspuOAnnWwIJ.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home