Sorry if this has been asked before, but how can I create a form that is a
combination of two models linked through a foreign key? For example, let's
say I have two models:

# models.py
class Myuser(User):
  bio = models.TextField()

class AddressBook(models.Model):
  userid = models.ForeignKey(CustomUser, blank=True, null=True)
  address = models.CharField(max_length=50)
  city = models.CharField(max_length=50)
  zip = models.CharField(max_length=20)
  state = models.CharField(max_length=50)

# admin.py
from django.contrib import admin
from models import *

class PhoneBookInline(admin.TabularInline):
  model = PhoneBook
  can_delete = True

class CustomUserAdmin(admin.ModelAdmin):
  inlines = ( PhoneBookInline )
  fk_name = 'userid'

admin.site.register(Myuser, CustomUserAdmin)

So when I go into django admin, I see all the fields for Myuser, but
PhoneBook fields appear three times. It doesn't matter whether I subclass
StackedInline or TabularInline, I get the PhoneBook three times.

Is there a better way to create a combo form that contains two (or more)
models linked with a foreign key (or manytomany, onetomany, etc.)??

Thanks,

S

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to