1

I tried to follow instructions in answer here but didn't work. I bet due to the following:

  1. We have an existing User class is models.py which is a proxy:

    class User(auth_models.User):
    """
        Wrapper to make methods on user_profile one call
    """
    objects = UserManager()
    def title(self):
        # TODO This probably makes too many SQL queries by default?
        return self.get_profile().title
    
    class Meta:
        proxy = True
    
  2. The UserProfile model has a 1-to-1 with the built-in User table:

    import django.contrib.auth.models as auth_models 
    
    class UserProfile(models.Model):
        user = models.OneToOneField(auth_models.User) ...
    
  3. But other model use the proxy class:

    class Job(models.Model):
        ...
        user = models.ForeignKey(User)
        ...
    

As you can imagine, some parts of the code refer to the proxy class.

Can someone suggest a variation on the above answer in this scenario? Can I just remove the Meta/proxy attribute and be happy? What will happen to the UserProfile relationship? I dont want to lost that in the process of updating, in oder to recover that data and put it in the new User model (as the new Django 1.5 allows)

UPDATE 1

I made some progress, I think. I also read this and did the following:

  1. I changed the reference to the proxy in Job for auth_models.User. The app continues to work: proxies are transparent to foreign keys, good.

  2. I then removed the proxy meta in our User, and generated the migration as in answer to question mentioned. Now I am getting this error report:

    CommandError: One or more models did not validate:
    auth.user: Accessor for m2m field 'groups' clashes with related m2m field     'Group.user_set'. Add a related_name argument to the definition for 'groups'.
    auth.user: Accessor for m2m field 'user_permissions' clashes with related m2m field 'Permission.user_set'. Add a related_name argument to the definition for 'user_permissions'.
    tao.user: Accessor for m2m field 'groups' clashes with related m2m field 'Group.user_set'. Add a related_name argument to the definition for 'groups'.
    tao.user: Accessor for m2m field 'user_permissions' clashes with related m2m field 'Permission.user_set'. Add a related_name argument to the definition for 'user_permissions'.
    

So, it seems to me that the related built-in tables for groups and permissions are having issues. Any ideas?

Community
  • 1
  • 1
carlosayam
  • 1,396
  • 1
  • 10
  • 15

0 Answers0