Kurtis
unread,Sep 10, 2011, 7:18:28 PM9/10/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hey Guys,
I have a very simple stub of a project. I'm trying to do something
that should be very simple but isn't as easy as I hoped.
I have a UserProfile class. This object is basically just an extension
of the standard User Class. Within my UserProfile class, I want to
have a list of PublicProfile foreign keys. PublicProfile itself is an
abstract class with multiple classes extending it. For example, a User
can create an ArtistProfile, a BandProfile, etc...
To give you a sense of what I'm trying to accomplish from a user's
perspective: A user can sign up and create multiple Pages (represented
as PublicProfile) for bands, artists, etc...
Here's some simple code I started with but I have no idea how to
proceed:
###########################################################
class UserProfile(models.Model):
# The Associated User
user = models.OneToOneField(User)
# The User's Profiles
# What do I do here? I don't know how to start out with an empty
list and add
# ForeignKeys to it as I go.
# profiles = ...?
class PublicProfile(models.Model):
username = models.CharField(max_length = 40)
zipcode = models.CharField(max_length = 10)
# ....
class Meta:
abstract = True
class ArtistProfile(PublicProfile):
pass
class BandProfile(PublicProfile):
pass
###########################################################
Thanks!