Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16450 closed Bug (worksforme)

UserProfile filtering breaks between Django 1.2.5 and 1.3

Reported by: bjorn@… Owned by: nobody
Component: Uncategorized Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I guess this will be closed as invalid, but here goes my best attempt.

When upgrading from Django 1.2.5 to 1.3 the following code breaks:

users = self.users.filter(userprofile__public_profile=True).order_by('first_name')

Cannot resolve keyword 'userprofile' into field.

UserProfile has a foregin key to User:

user = models.ForeignKey(User, unique=True)

Other foreignkey models are still valid keys so i figured it might have to do with the custom user profile feature.

Change History (3)

comment:1 Changed 5 years ago by Luke Plant

Resolution: worksforme
Status: newclosed

Your description is rather short on details (like what is 'self'? What is 'self.users'?). I tried to guess, and used the following class:

from django.db import models

from django.contrib.auth.models import User

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    public_profile = models.BooleanField()

Then ran the following:

>>> from django.contrib.auth.models import User 
>>> User.objects.filter(userprofile__public_profile=True).order_by('first_name')

AUTH_PROFILE_MODULE is irrelevant here (though I tried with and without it) - it only affects the 'get_profile()' method, as documented. What you are describing is simple ForeignKey functionality breaking, which is of course extremely unlikely, as hundreds of tests and thousands of projects would have broken if that had happened.

So I'm forced to mark this as WORKSFORME. If you can provide details that will allow us to reproduce this, please re-open the ticket.

comment:2 Changed 5 years ago by anonymous

This may be another report of #15771.

comment:3 Changed 5 years ago by anonymous

YES! That is the case. It is indeed the same as #15771. Thank you anonomous! :)

Note: See TracTickets for help on using tickets.
Back to Top