Re: define "_default_manager" and the admin-interface
As far as I can see in principle you would want to leave the live manager first as your default manager and then override it in your admin class as the exception - something like this: class EntryAdmin(admin.ModelAdmin): ... manager = Entry.objects But admin needs patching to make that work which is an open ticket http://code.djangoproject.com/ticket/7510. At the moment you would need to override every method in admin.ModelAdmin that gets the default manager, so it's easier at the moment just to make the standard manager the default instead of your custom manager. I'm writing a blog on this book - but I am only just finishing up chapter 5 which first defines the custom manager. http://blog.haydon.id.au/2008/08/notes-on-practical-django-projects.html --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: define "_default_manager" and the admin-interface
is there anybody out there who could answer this question? On 29 Aug., 07:59, Brot <[EMAIL PROTECTED]> wrote: > Hello, > > At the moment I am reading the "Practical Django Projects" - Book > written by James Bennett. > On page 120 there is a admonition about using Default Managers. Above > this paragraph there is the explanation about the Default Manager und > Entry.objects.all() and Entry.live.all(). > > It seems clear to define the live-Manager first, so it's the Default > Manager. But I noticed that the admin interface also uses this Default > Manager. > If I mark an Entry as HIDDEN or DRAFT I have no possibility to take it > LIVE with the admin interface, because the live-Default Manager don't > return this type of entries > > What do you think? What's good practice in relation to the Default > Manager? > > ~ Bernd --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: define "_default_manager" and the admin-interface
On Fri, Aug 29, 2008 at 7:59 AM, Brot <[EMAIL PROTECTED]> wrote: > > Hello, > > At the moment I am reading the "Practical Django Projects" - Book > written by James Bennett. > On page 120 there is a admonition about using Default Managers. Above > this paragraph there is the explanation about the Default Manager und > Entry.objects.all() and Entry.live.all(). > > It seems clear to define the live-Manager first, so it's the Default > Manager. But I noticed that the admin interface also uses this Default > Manager. > If I mark an Entry as HIDDEN or DRAFT I have no possibility to take it > LIVE with the admin interface, because the live-Default Manager don't > return this type of entries > > What do you think? What's good practice in relation to the Default > Manager? Good practice is "whatever works", maybe "whatever works best". Since defining the live manager first does not work it is not good practice. What is the problem about defining the objects manager first? (Btw, nobody said the default manager has to be called "objects". You could also do something like this if you want to use "objects": class Whatever(models.Model): all_items = models.Manager() objects = LiveManager() Matthias --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
define "_default_manager" and the admin-interface
Hello, At the moment I am reading the "Practical Django Projects" - Book written by James Bennett. On page 120 there is a admonition about using Default Managers. Above this paragraph there is the explanation about the Default Manager und Entry.objects.all() and Entry.live.all(). It seems clear to define the live-Manager first, so it's the Default Manager. But I noticed that the admin interface also uses this Default Manager. If I mark an Entry as HIDDEN or DRAFT I have no possibility to take it LIVE with the admin interface, because the live-Default Manager don't return this type of entries What do you think? What's good practice in relation to the Default Manager? ~ Bernd --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---