Saturday, March 24, 2012

Re: all(), get(), create(), count(). More info?

.all(), .filter(), .get() are methods invoked through Django model managers ('objects' in this case).  The methods are made available when you create a model class that inherits from models.Model. To use any of them from a shell, you'll need to invoke the python interpreter using the following manage.py command to load the Django environment and then import the necessary models:
$ python manage.py shell
>>>from mysite.polls.models import Poll
>>>your code here...

On Sat, Mar 24, 2012 at 11:31 PM, MF-DOS <pwashington85@gmail.com> wrote:
Running this tut: https://docs.djangoproject.com/en/1.1/intro/tutorial01/

Here is a list of shell commands I'm asked to issue, but I don't
understand where the commands are coming from? Are these Django or
Python commands? I've attempted to query help and read the docs but
can't find them anywhere.

Poll.objects.all()
Poll.objects.filter()
Poll.objects.get()
p.choice_set.all()
p.choice_set.create()
p.choice_set.count()

--
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.




--
Jonathan D. Baker
Web Developer
http://jonathandbaker.com
303.257.4144

--
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