I am compiling admin for the satchmo application. Satchmo uses the OneToOne relationship to extend the base Product model, and I would like to edit it all on one page.
Is it possible to relate OneToOne as Inline? If not, how can I add several fields to a given page of my administrator, which will ultimately be saved with respect to OneToOne?
eg:
class Product(models.Model): name = models.CharField(max_length=100) ... class MyProduct(models.Model): product = models.OneToOne(Product) ...
I tried this for my administrator, but it does not work and seems to be expecting a foreign key:
class ProductInline(admin.StackedInline): model = Product fields = ('name',) class MyProductAdmin(admin.ModelAdmin): inlines = (AlbumProductInline,) admin.site.register(MyProduct, MyProductAdmin)
What causes this error: <class 'satchmo.product.models.Product'> has no ForeignKey to <class 'my_app.models.MyProduct'>
Is this the only way to do this custom form ?
edit: Just tried the following code to add fields directly ... also doesn't work:
class AlbumAdmin(admin.ModelAdmin): fields = ('product__name',)
python django django-admin inline one-to-one
Jiaaro Nov 16 '09 at 19:10 2009-11-16 19:10
source share