Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
User.objects.active() support.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
tWoolie  
View profile  
 More options Sep 23 2011, 2:57 am
From: tWoolie <thomas.woolf...@student.adelaide.edu.au>
Date: Thu, 22 Sep 2011 23:57:46 -0700 (PDT)
Local: Fri, Sep 23 2011 2:57 am
Subject: User.objects.active() support.
I've submitted a pull request (https://github.com/django/django/pull/
51) for an active() relatedmanager method on the models class. I
wanted to get some feedback from other devs about inclusion into
trunk. I've included a patch to the docs if you want more info.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aymeric Augustin  
View profile   Translate to Translated (View Original)
 More options Sep 23 2011, 8:26 am
From: Aymeric Augustin <aymeric.augus...@polytechnique.org>
Date: Fri, 23 Sep 2011 14:26:13 +0200
Local: Fri, Sep 23 2011 8:26 am
Subject: Re: User.objects.active() support.
2011/9/23 tWoolie <thomas.woolf...@student.adelaide.edu.au>:

> I've submitted a pull request (https://github.com/django/django/pull/
> 51) for an active() relatedmanager method on the models class. I
> wanted to get some feedback from other devs about inclusion into
> trunk. I've included a patch to the docs if you want more info.

Hello,

If I understand correctly, this is same idea as #16611.

This feature was rejected by a core developer, which means it won't be
added to Django.

The rationale is explained in
https://code.djangoproject.com/ticket/16611#comment:5

Thanks for the suggestion!

--
Aymeric Augustin.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tWoolie  
View profile  
 More options Sep 25 2011, 9:02 am
From: tWoolie <thomas.woolf...@student.adelaide.edu.au>
Date: Sun, 25 Sep 2011 06:02:32 -0700 (PDT)
Local: Sun, Sep 25 2011 9:02 am
Subject: Re: User.objects.active() support.
I never saw that ticket. I've been looking at it purely from the
perspective of trying to inject it into the model in my app to get
around doing expensive filtering in my template.
I see Jacob's point that saving a few chars in python is not worth it
for the cost of having to read docs to figure out what it does, but
this would be a fantastic thing to have in templates where there is no
way to specify filtering.

On Sep 23, 9:26 pm, Aymeric Augustin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Prometheus  
View profile  
 More options Sep 26 2011, 1:19 am
From: Prometheus <joonas.berg...@gmail.com>
Date: Sun, 25 Sep 2011 22:19:55 -0700 (PDT)
Local: Mon, Sep 26 2011 1:19 am
Subject: Re: User.objects.active() support.
On Sep 25, 8:02 am, tWoolie <thomas.woolf...@student.adelaide.edu.au>
wrote:

> I never saw that ticket. I've been looking at it purely from the
> perspective of trying to inject it into the model in my app to get
> around doing expensive filtering in my template.
> I see Jacob's point that saving a few chars in python is not worth it
> for the cost of having to read docs to figure out what it does, but
> this would be a fantastic thing to have in templates where there is no
> way to specify filtering.

Hello,

I believe for this purpose, the Proxy models feature would be the
perfect solution, please see: https://docs.djangoproject.com/en/1.3/topics/db/models/#proxy-models


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tomasz Zielinski  
View profile  
 More options Sep 28 2011, 4:48 am
From: Tomasz Zielinski <tomasz.zielin...@pyconsultant.eu>
Date: Wed, 28 Sep 2011 01:48:23 -0700 (PDT)
Local: Wed, Sep 28 2011 4:48 am
Subject: Re: User.objects.active() support.

I'm the author of #16611 ticket and after some consideration I also think
that proxy models are the way to go for such customizations.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tWoolie  
View profile  
 More options Sep 30 2011, 4:56 am
From: tWoolie <thomas.woolf...@student.adelaide.edu.au>
Date: Fri, 30 Sep 2011 01:56:02 -0700 (PDT)
Local: Fri, Sep 30 2011 4:56 am
Subject: Re: User.objects.active() support.
The thing is that I believe django as a whole would benefit from this
kind of functionality. The whole point of custom managers is to add
functionality, not just to your app, but to every app that FKs against
your models.

In the case of contrib.auth, this functionality is really handy
spanning across related fields.

Considder the case of a template that currently looks like this:

{% for moderator in forum.moderators.all %}
    {% if moderator.active %}
        {{ moderator|profilelink }}{% if not forloop.last %},{% endif
%}
    {% endif %}
{% endfor %}

This is an example of the template code that I add to djangobb by
overriding it's templates. djangobb currently has no custom User
subclass that it injects into it's moderator relationship, and hence i
have to do a filter in the template, or modify djangobb and give up on
getting auto updates without merging my code in every time.

If the user model had a active() or is_active custom manager method
that had use_for_related_fields set to True, then it enables you to
use a very easy syntax:

{% for moderator in forum.moderators.active %}
    {{ moderator|profilelink }}{% if not forloop.last %},{% endif %}
{% endfor %}

which does efficient datbase side filtering of active/inactive
members.

This is the kind of low-hanging fruit that is EASY to implement, would
be used by plenty of people (really, how many people ever want
deactivated users showing up all over their site) and would provide
instant benifit to template writers, and specifically to people who
don't want to modify external apps to add functionality/address
deficiencies in django.

On Sep 28, 5:48 pm, Tomasz Zielinski


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Plant  
View profile  
 More options Sep 30 2011, 6:15 am
From: Luke Plant <L.Plant...@cantab.net>
Date: Fri, 30 Sep 2011 11:15:43 +0100
Local: Fri, Sep 30 2011 6:15 am
Subject: Re: User.objects.active() support.
On 30/09/11 09:56, tWoolie wrote:

Isn't the problem here that 'forum.moderators' is returning users who
are not active? djangobb should do this filtering in the objects they
supply to their templates (or at least provide an alternative
'active_moderators'), because this kind of business logic decision
should be made by view code, not template code.

If djangobb is wrong here, you should be filing a bug with them. If they
are right, then your app is 'wrong' for overriding the business logic in
a template. If both are 'right', then this is just an example of a case
where a 3rd party app doesn't do exactly what you want. But there are
many examples of that, and we can't build everything into Django to fix
specific limitations of certain apps.

Regards,

Luke

--
"I think you ought to know I'm feeling very depressed." (Marvin the
paranoid android)

Luke Plant || http://lukeplant.me.uk/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »