I have a list of organizations that full under different organization types. I have a table that holds the name, phone, etc... and then another table that has an id fixed to an organization type. Then a table that holds the many to many relationship because an organization can have many different organization types.
What I'm wanting to do is list all the clubs alphabetically that fall under every organizational type.
I'm not sure if this needs to be done in views.py
or if it should be done in my template file.
Here are my models:
class ClubType(models.Model):
name = models.CharField(max_length = 250)
def __unicode__(self):
return self.name
class Club(models.Model):
name = models.CharField(max_length = 250,
verbose_name = "Club or Organization Name",
)
created_date = models.DateTimeField(
auto_now_add = True,
)
updated_date = models.DateTimeField(
auto_now = True,
auto_now_add = True,
)
club_type = models.ManyToManyField(ClubType)
username = models.CharField(max_length = 100,
blank = True, null = True
)
contact_name = models.CharField(max_length = 250,
blank = True, null = True,
)
phone_number = models.CharField(max_length = 250,
blank = True, null = True,
)
def __unicode__(self):
return self.name
class Meta:
ordering = ('name', )
I'm a noob to python and Django so any help would be greatly appreciated.
Thanks