scottpierce
2005-09-02 04:09:20 UTC
I am writing a little assignments app for my homeschooled children
where I and their mother can post assignments with a due date, etc...
My model looks like this so far:
from django.models.auth import User
from django.models.auth import users
from django.models.auth import groups
class Assignment(meta.Model):
assigner = meta.ForeignKey(User,
limit_choices_to={'assigner__contains': _getTeachers() },
verbose_name="user making assignment")
assignee = meta.ForeignKey(User, verbose_name="user receiving
assignment")#CharField(maxlength=50)
assignment_title = meta.SlugField()
assignment = meta.TextField()
date_assigned = meta.DateField(auto_now_add=True)
due_date = meta.DateField()
class META:
permissions = (("add_assignment","can add assignment"),)
admin = meta.Admin(
fields = (
('Users', {'fields': ('assigner','assignee',)}),
('Assignment Details', {'fields':
('assignment_title','due_date','assignment',)}),
),
)
The assigner and assignee currently correctly pull from users.name to
fill the select; however, I would like to limit based on groups:
teacher for assignee and student for assigner. I have a function:
def _getTeachers():
g = groups.get_object(name__exact='teacher', select_related=True)
return g.get_user_list()
in assignments.py that should return all teachers and it does, from a
python prompt. However, when running from the "django.admin.py
runserver ..." the get_user_list is mysteriousely missing. Any
direction as to why that is or if there is a better way to accomplish
this?
BTW, In case a developer or two are listening in, I haven't had this
much fun programming in a long time.
Scott Pierce
where I and their mother can post assignments with a due date, etc...
My model looks like this so far:
from django.models.auth import User
from django.models.auth import users
from django.models.auth import groups
class Assignment(meta.Model):
assigner = meta.ForeignKey(User,
limit_choices_to={'assigner__contains': _getTeachers() },
verbose_name="user making assignment")
assignee = meta.ForeignKey(User, verbose_name="user receiving
assignment")#CharField(maxlength=50)
assignment_title = meta.SlugField()
assignment = meta.TextField()
date_assigned = meta.DateField(auto_now_add=True)
due_date = meta.DateField()
class META:
permissions = (("add_assignment","can add assignment"),)
admin = meta.Admin(
fields = (
('Users', {'fields': ('assigner','assignee',)}),
('Assignment Details', {'fields':
('assignment_title','due_date','assignment',)}),
),
)
The assigner and assignee currently correctly pull from users.name to
fill the select; however, I would like to limit based on groups:
teacher for assignee and student for assigner. I have a function:
def _getTeachers():
g = groups.get_object(name__exact='teacher', select_related=True)
return g.get_user_list()
in assignments.py that should return all teachers and it does, from a
python prompt. However, when running from the "django.admin.py
runserver ..." the get_user_list is mysteriousely missing. Any
direction as to why that is or if there is a better way to accomplish
this?
BTW, In case a developer or two are listening in, I haven't had this
much fun programming in a long time.
Scott Pierce