Hi group,

This is my first time asking, so bear with me if I'm missing anything. I 
have an app in my project called *Users*, under *Users* currently I have 
classes - *Customer, Location, ContactNumber. *I added foreign keys in both 
*Location 
*and *ContactNumber* to point to *Customer.*

Everything is good so far. However, when I try to add another class - *Staff 
* and have those two foreign keys point to *Staff*, hell breaks loose. When 
I go to the admin page to add a *Staff*, the section where I want to add 
*Location 
*refers to *Customer *instead.

*models.py*
from django.db import models

# Create your models here.
class Staff(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    status = models.CharField(max_length=30)
    activation_code = models.CharField(max_length=50)
    email = models.EmailField(max_length=50)
    join_date = models.DateField()
    date_of_birth = models.DateField()
    def __str__(self):
        return self.email

class Customer(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    status = models.CharField(max_length=30)
    activation_code = models.CharField(max_length=50)
    email = models.EmailField(max_length=50)
    monetary_value = models.IntegerField()
    join_date = models.DateField()
    date_of_birth = models.DateField()
    def __str__(self):
        return self.email

class Location(models.Model):
    customer = models.ForeignKey(Customer)
    staff = models.ForeignKey(Staff)
    address = models.CharField(max_length=200)
    city = models.CharField(max_length=200)
    country = models.CharField(max_length=200)
    zipcode = models.CharField(max_length=200)

class ContactNumber(models.Model):
    customer = models.ForeignKey(Customer)
    staff = models.ForeignKey(Staff)
    number = models.PositiveIntegerField()

*admin.py*
from django.contrib import admin
from users.models import Customer, Staff, Location, ContactNumber

class LocationInLine(admin.StackedInline):
    model = Location
    extra = 1

class ContactNumberInLine(admin.StackedInline):
    model = ContactNumber
    extra = 2

class CustomerAdmin(admin.ModelAdmin):
inlines = [LocationInLine, ContactNumberInLine]

class StaffAdmin(admin.ModelAdmin):
inlines = [LocationInLine, ContactNumberInLine]

admin.site.register(Customer, CustomerAdmin)
admin.site.register(Staff, StaffAdmin)

I've attached a screenshot of how it appeared on the admin page.
Please help me. I'm not sure if I'm missing anything. 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/9e862722-75ae-4ad3-997d-5e38356e24a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to