Thursday, January 3, 2013

Re: Reserved Words

That's not a reserved word.  Case in point, "list" is not a python reserved word.  You can use it as a module level variable, but you will confuse yourself later on when you try to use the list constructor in some code in that module.  "else" is a reserved word.  You won't be able to redefine it, and will get an error if you try.

"pk" is a name that is special to the ORM, but not in the rest of django.  You can use it as a variable in your views, even in model methods, and no harm will befall you, so long as you don't prefix it with "self." in those model methods.  There are many such circumstances in plain python, that is, where a name is special is some particular context.  You aren't going to find a list of those for python either.

That being said, the model documentation, I believe, and certainly somewhere in the tutorial, I have seen documentation that "pk" is special in a field name context.

Good luck,
Bill

On Thu, Jan 3, 2013 at 1:08 PM, Sam Raker <sam.raker@gmail.com> wrote:
Is there a list of 'reserved words' for Django like there is for Python? I posted a question in here a few days ago about a mysterious recursion error I kept getting when I tried to load my data in with loaddata. Turns out, it was because I had defined a field called 'pk' with primary_key=True in my models. I later ran into trouble with manually-defined fields ending in "_id." AFAIK, neither of these little quirks are documented on the website; it'd be nice if they were.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/uGlhL-Fb8F8J.
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


Real Estate