Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Oct. 27, 2005 22:51:47

s.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

strange values in ManyToManyField


I get some strange values from auth.users that I hope someone can
explain.

I've extended the auth.users like so:

class User(auth.User):
primary_group = meta.ForeignKey(auth.Group, default = 1,
verbose_name = 'primary group')
new_password = meta.CharField(maxlength = 40, blank = True)
department = meta.ForeignKey(Department, default = 1)
country = meta.ForeignKey(Country, default = 1,
help_text = 'Country the user belongs to')
available = meta.IntegerField(maxlength = 3, default = 100,
verbose_name = 'available (%)',
help_text = 'Percentage of hours per week')
cost = meta.IntegerField(maxlength = 4, default = 500,
help_text = 'SEK per hour')
employee = meta.PositiveSmallIntegerField(unique = True,
help_text = 'Employee number')
notes = meta.TextField(blank = True)

def __repr__(self):
return "%s" % self.username

class META:
replaces_module = 'auth.users'

Then I created a model using the auth.User in a ManyToManyField:

class SubProject(meta.Model):
project = meta.ForeignKey(Project)
subproject = meta.CharField(maxlength = 12, help_text = 'Short name')
name = meta.CharField(maxlength = 40, help_text = 'Full name')
manager = meta.ForeignKey(auth.User, verbose_name = 'manager',
limit_choices_to = { 'primary_group__id__exact' : '3'
},
help_text = 'Subproject manager')
state = meta.ForeignKey(ProjectState, default = 'Open',
verbose_name = 'state')
type = meta.ForeignKey(SubProjectType, verbose_name = 'type')
members = meta.ManyToManyField(auth.User,
verbose_name = 'members', related_name = 'username',
filter_interface = meta.HORIZONTAL)

def __repr__(self):
return "%s" % self.subproject

The admin seems to work fine for both objects.
However, when I play with the objects it looks really strange:

Python 2.3.4 (#1, Feb 7 2005, 15:50:45)
on linux2
>>> from django.models.ttime import *
>>> auth.users.get_list()

>>> for sp in subprojects.get_list(id__in = ):
... sp.get_user_list()
...




A "mysql> select * from auth_users;" reveals that it's either the
date_joined, or last_login field that is displayed.

What gives? Anyone seen this strange behaviour?

/LarS

Offline

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support