List Info

Thread: How to prepopulate a slug field with a foreign key?




How to prepopulate a slug field with a foreign key?
country flaguser name
United States
2007-03-29 14:33:53
I have just written a model to extend the user model a bit
and now I'd
like to
add a slug field for the username, however, I can't get the
slug field
to
prepopulate from the user foreign key.

A simplified version of the model would be this:

from django.db import models
from django.contrib.auth.models import User

class Login(models.Model):
    user = models.ForeignKey(User, unique=True)
    slug =
models.SlugField(prepopulate_from=('user__username',),
unique=True)

I have also tried prepopulating with 'username' but that
didn't work
either,
is it at all possible to prepopulate from a foreign key?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )