Re: Why can't a Model have the same name as a View?
Python variables don't have types. They're just references.
You can call models and views by the same name. But a bare name can only have one value in a given python scope.
Thus, if in your views.py you do:You can call models and views by the same name. But a bare name can only have one value in a given python scope.
...
...
On Thu, Aug 8, 2013 at 2:13 PM, JJ Zolper <codingatmt@gmail.com> wrote:
Hello everyone,--I've only been working with Python and Django for a couple of years now and whenever I can I like to learn more about certain rationalizations for certain decisions made within each of them.In Django we define a Python class with a name to represent our model (I think it's a python class at least) and then we write "def" for definition of a view function or python function. To me I view this as two separate types of structures and thus fairly often I give a model the same name as a view. It isn't until later that I realize that my app isn't working because of the fact that they have the same name. I'm here just wondering if anyone would be willing to explain how this comes about from how Python/Django treats this instance? Why does Django see a confliction between a class and a function with the same name? Aren't they entirely separate entities?I'm by all means okay with going in and changing the names of the view or model to something slightly different so everything works, I just would like to understand conceptually why it is an issue?Thanks a lot,JJ Zolper
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+unsubscribe@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.
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home