Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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

Description

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.

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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 3 years ago by anonymous

This may be another report of #15771.

comment:3 Changed 3 years ago by anonymous

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.