Wednesday, April 17, 2013

Re: What is Model Manager?

On 18 April 2013 10:10, cha <mohammad3m@gmail.com> wrote:
> Hello how are you

Great, thanks for asking!

> I want to explain to me what is **"Model Managers"** in django ??? and What
> are the useful ?

They are a different way of collecting querysets of objects. Have you
read the documentation to this end?

https://docs.djangoproject.com/en/1.5/topics/db/managers/
https://docs.djangoproject.com/en/dev/topics/db/managers/


For instance, on my last project I had "students, subjects, courses, grades"

I wanted to be able to call some aspects of those quickly without
writing out the whole filter every time. So I created some filters
like these:

Male students in Accounting under 25 years as Student.men_account_25.all()
Male students in Accounting over 25 years as Student.men_account_26.all()
Female students in Accounting under 25 years as Student.women_account_25.all()
Female students in Accounting over 25 years as Student.women_account_25.all()

I could have gone very deep:

Male students in Accounting over 25 years that passed last semester
and are from province X.

I then added a .count() to the end of the call, and I had instant
enrollment statistics that were always up-to-date.

Does that clear it up for you?

cheers
L.



--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate