Wednesday, June 27, 2012

ManyToManyField is this right?

I'm a self taught programmer who hasn't done much of anything for years so please forgive me if this question is naive. I have a hard time sometimes understanding some of the lingo used by trained programmers.

With that said, I'm having trouble wrapping my brain around the ManyToMany and Many-To-One and OneToOne concepts. I'm trying to create a multi-select option for a user profile in which a user can have multiple attributes of a certain kind. Right now I'm just working on the model. This is what I have, is it right?

# Different licenses for instructors to select from
class Licenses(models.Model):
    nra = models.BooleanField()
    ccl = models.BooleanField()

# User Profile Model
class UserProfile(models.Model):
    user = models.OneToOneField(User)
   
     #.......

    licensed_instructor = models.ManyToManyField(Licenses)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/7dOg4S9_dPAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment