Daniel,
On Monday, 3 November 2014 10:12:10 UTC, Daniel Roseman wrote:
-- Gosh. Tail between legs. Clearly, my eyes aren't what they used to be. Not, and should have been, using my Retina screen for this work! Well spotted. Yes this is real code (edited down). Yes, I have "g" in the real code rather than a "q". When I fixed that (global fixing 62 errors), all is well.
What I did (not excuses...just what happened which in engineering is important to understand!): In reading the documentation for the upgrade I saw that get_query_set() was changed to get_queryset(), i.e. the "_" removed. I did a global search and replace in the model.py file, but mistakenly put in "get_gueryset()" as new code. I didn't then and continued till now not notice. Interestingly, neither did Django or Python complain (far as I can tell). Replacing the "g" for a "q" it now works as expected.
Thanks!!!!!!!!!
--rms
On Monday, 3 November 2014 10:12:10 UTC, Daniel Roseman wrote:
On Sunday, 2 November 2014 18:12:10 UTC, rmschne wrote:I've upgraded to Django 1.7.1Following the upgrade most (haven't tested all, but for all tested this true) the over-rided queryset is not functioning.when the code callsqs=Member.Active_objects.all()then all members are returned, not just those which confrom to the filter specified in the Class MemberActive(models.Manager)this all worked for many years and only now works following upgrade to 1.7.1. I upgraded just to keep up. Now regret that decision, but difficult to go back.I've tried both get_query_set() and get_queryset() ... I understand the latter is required in 1.7.Any suggestions?===the code snippets:class MemberActive(models.Manager):def get_guery_set(self):qs=super(MemberActive, self).get_query_set().filter(status='Active') return qsclass Member(models.Model):membertype=models.ForeignKey(Membertype,related_name=' members',db_column='mtypeid', null=True, on_delete=models.SET_NULL, help_text='Type of member.',verbose_name='Member Type') lname = models.CharField(max_length=150, db_column='lame', blank=True, help_text='Last name.',verbose_name='Last Name') fname = models.CharField(max_length=150, db_column='fame', blank=True, help_text='First name.',verbose_name='First Name') status = models.CharField(max_length=12,db_column="status", blank=True,help_text=" Membership status) objects = models.Manager() # the default managerActive_objects = MemberActive()Is this your real code? You have two typos in the name of the overridden method: it should be `get_queryset`, not `get_guery_set` (you have a g for a q, and an extra underscore).--DR.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f3f2bec0-8986-43f2-b64e-14ed53d71545%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment