After finally realizing that in django one cannot subclass models, and
then reading as much as I could find on alternative approaches, I
think I am close to a solution to the following problem, but I can't
quite seem to get all the way there on my own:

In simplified terms, I want multiple types of persons in my app, e.g.,
faculty, students, and staff. Each requires a common set of 'profile'
fields (e.g., first_name, last_name, email), but each has some unique
fields (e.g., degree, adviser, supervisor). I want to be able to add
and edit these using the admin site. The basic strategy would seem to
be to create Faculty, Student, Staff and Profile models, and then
create links between the first three and the Profile model. First,
here's how the different models might look:

#######################

class Profile(models.Model):
    First_name = models.CharField(max_length=30)
    Last_name = models.CharField(max_length=30)
    Email = models.EmailField()

class Faculty(models.Model):
    Degree=models.CharField(max_length=10)
    class Admin:
        pass

class Student(models.Model):
    Advisor = models.ForeignKey(Faculty)
    class Admin:
        pass

class Staff(models.Model):
    Supervisor =  models.CharField(max_length=30)
    class Admin:
        pass

#######################

The different person types have the "class Admin" statement so they
show up in the admin site. Ideally, I would then somehow be able to
edit the fields of a unique Profile instance inline for each of the
person types. But if I add a unique ForeignKey statement to the person
types, like so:

class Faculty(models.Model):
    Degree=models.CharField(max_length=10)
    profile = models.ForeignKey(Profile, edit_inline=models.STACKED,
num_in_admin=1, unique=True)
    class Admin:
        pass

I link the models the way I want to with a unique ForeignKey (or at
least I think I do), but the inline editing is backwards and illogical
(and doesn't work anyway). That is, for each of the person types, I
want to edit the fields of a Profile instance inline, not the other
way around.

Does that make sense? If so, any suggestions on how to do what I want,
or how to rethink the problem?

Thanks in advance!


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

Reply via email to