#22047: Cannot resolve keyword u'group_ptr' into field. Choices are: group, id,
name, permissions, user
-------------------------------------+-------------------------------------
     Reporter:  ctcbmw               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.6
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by ctcbmw):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 My model looks like so.

 import json, logging, hashlib, random, time, base64, sys, urlparse
 from django.contrib.auth.models import User as DjangoUser, Group as
 DjangoGroup, GroupManager as DjangoGroupManager

 class GroupManager(DjangoGroupManager):
     pass

 class Group(DjangoGroup):
     group_name = models.CharField(max_length=80, null=False)
     users = models.ManyToManyField('User', through='Membership',
 related_name="groups")

     objects = GroupManager()

     def __str__(self):
         return self.group_name

     def __unicode__(self):
         return self.__str__()

     def save(self, *args, **kwargs):
         # Per django, name needs to be unique
         # But in our case, different companies can have the same group
 name
         if not self.id:
             self.name = generateSalt()
         super(Group, self).save(*args, **kwargs)

 def generateSalt():
     salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
     t = int(time.time())
     if isinstance(t, unicode):
         t = t.encode('utf-8')
     return hashlib.sha1(salt + str(t)).hexdigest()

 class User(DjangoUser):
     deleted = models.BooleanField(default=False, null=False)
     active = models.BooleanField(default=True, null=False)

     def __str__(self):
         return self.getFullName()

     def __unicode__(self):
         return unicode(self.__str__())

 class Membership(models.Model):
     user = models.ForeignKey(User)
     group = models.ForeignKey(Group)
     date_joined = models.DateField()

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22047#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.abbaa6681b91fbd53cf36dd621dd0328%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to