Thank you C. Kirby. This is great, and will work very well for what I am 
trying to accomplish. Thanks again.

On Monday, March 17, 2014 2:01:19 PM UTC-4, C. Kirby wrote:
>
> I would do it with a recursive ForeignKey
>
> class Employee(models.Model):
>     employee = models.OneToOneField(User)
>     supervisor = models.ForeignKey('self', blank=True, null=True)
>
> This keeps the information in one table and pretty clean looking.
> Allows all employees to have a supervisor, but they don't have to have one 
> (say, CEO)
> If an employee may have more than one supervisor you can use a ManyToMany 
> instead of ForeignKey 
>
>
>
> On Sunday, March 16, 2014 5:59:59 PM UTC-5, Gene Coetzee wrote:
>>
>> Hi There!
>>
>> Starting out with Django, and was looking for a bit of guidance. I am 
>> trying to establish a Organizational structure for employee/supervisor type 
>> relationships. Since each of these individuals will be a user, I am 
>> extending trying to also take advantage of django's built-in contrib.auth 
>> package. 
>>
>> In Short, employees report to supervisors, and in turn supervisors in 
>> themselves can report to their respective supervisors... I developed the 
>> following models, but was curious if there might be a better way to do this:
>>
>> class Supervisor(models.Model):
>> supervisor = models.OneToOneField(User)
>>  def __unicode__(self):
>> return self.supervisor.username
>>
>> class Employee(models.Model):
>> employee = models.OneToOneField(User)
>> supervisor = models.ForeignKey(Supervisor)
>>  def __unicode__(self):
>> return self.employee.username
>>
>> Thank you!
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9d6bbac1-5f89-4774-be84-e2618d00763c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to