Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Question regarding Intermediary Models and concepts [RSS Feed]

#1 Dec. 11, 2010 01:12:37

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Question regarding Intermediary Models and concepts

I have one part of a project that's responsible for registration of
Users and associations with a UserProfile and a Phone Extension.

The models involved include User, UserProfile, Client, Extension, and

So here's the business logic:
1. Usually the Users are created through the Admin interface.
2. I have the UserAdmin with an "inline" for UserProfileInLine,
UserProfileExtensionInline, and ExtensionInline
3. Each User has to have only 1 UserProfile, which is where I choose
which Client this User will be associated to.
4. Each User can have 0 or more unique phone Extension numbers.
5. A Client cannot have duplicate Extension numbers.
6. Different Clients may share the same Extension number.
7. Inside Extension, the numbers are unique.

I thought that in order to do this while fulfilling the last
requirement would be to create an intermediary model called

Here are the classes with the relevant code:

class Extension(models.Model):
user = models.ForeignKey(User, verbose_name=u"User")
date_created = models.DateTimeField(auto_now_add=True,
number = models.CharField(u"Extension", max_length=16,

class UserProfile(models.Model):
user = models.ForeignKey(User, verbose_name=u"User", unique=True)
client = models.ForeignKey(Client, verbose_name=u"Client")
extension = models.ManyToManyField(Extension,

class UserProfileExtension(models.Model):
extension = models.ForeignKey(Extension,
verbose_name=u"Extension", unique=False)
userprofile = models.ForeignKey(UserProfile, verbose_name=u"User
Profile", unique=False)
user = models.ForeignKey(User, verbose_name=u"User", unique=False)
date_created = models.DateTimeField(u"Date Created",
auto_now_add=False, auto_now=False)

class Client(models.Model):
name = models.CharField(u"Name", max_length=64)
last_update = models.DateTimeField(u"Last Update", null=True,
last_inbound_call = models.DateTimeField(u"Last Inbound Call",
null=True, blank=True)
last_outbound_call = models.DateTimeField(u"Last Outbound Call",
null=True, blank=True)
username = models.CharField(u"Login", max_length=32)
password = models.CharField(u"Password", max_length=16)

When I create/edit a User, beyond the standard fields, there will be
an Inline for UserProfile with a dropdown menu with Client names to
choose from. Then there is an Inline for Extension that will hold the
Extension numbers. Since I'm still a bit new to Django, I'm not sure
if I'm on the right path to what I have in mind. I'd really appreciate
any comment/suggestion or even a fix ;).


You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.


  • Root
  • » Django
  • » Question regarding Intermediary Models and concepts [RSS Feed]

Board footer

Moderator control

Enjoy the 12th of December

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support