Help!!: creating a combined form linked via foreign key??

2010-11-09 Thread sosurim kim
This message isn't going through for some reason...

-- Forwarded message --
From: sosurim kim <sosuri...@gmail.com>
Date: Mon, Nov 8, 2010 at 1:55 PM
Subject: Re: creating a combined form linked via foreign key??
To: django-users@googlegroups.com


Oops, I meant to say addressbook, not phonebook... sorry.

# 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 AddressBookInline(admin.TabularInline):
  model = AddressBook
  can_delete = True

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

admin.site.register(Myuser, CustomUserAdmin)

>
>
> So when I go into django admin, I see all the fields for Myuser, but
> AddressBook fields appear three times. It doesn't matter whether I subclass
> StackedInline or TabularInline, I get the AddressBook 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.



Re: creating a combined form linked via foreign key??

2010-11-08 Thread sosurim kim
Oops, I meant to say addressbook, not phonebook... sorry.

# 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 AddressBookInline(admin.TabularInline):
  model = AddressBook
  can_delete = True

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

admin.site.register(Myuser, CustomUserAdmin)

>
>
> So when I go into django admin, I see all the fields for Myuser, but
> AddressBook fields appear three times. It doesn't matter whether I subclass
> StackedInline or TabularInline, I get the AddressBook 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.



creating a combined form linked via foreign key??

2010-11-08 Thread sosurim kim
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.