i’ve a problem with my tabularinline field. I have model like this
class Product(models.Model):
....
class Pemesanan(models.Model):
produks = models.ManyToManyField(Product, verbose_name=u"Kode Produk", through='Foo')
class Foo(models.Model):
product = models.ForeignKey(Product)
...
Class Foo is an intermediary class (manytomany field) with class Pemesanan and Class Product. It has a foreign key field to Class Pemesanan. Class Foo is displayed as an tabularinline in change_form template like this http://upload.ui.ac.id/?a=d&i=845380
But my problem is that field product doesn’t show as a related lookup field as it is shown up as an ordinary form (not in inline). This is my Admin
class FooInline(admin.TabularInline):
model = Foo
extra = 0
allow_add = True
class PemesananAdmin(admin.ModelAdmin):
....
search_fields = ['produks']
raw_id_fields = ('produks',)
related_lookup_fields = {
'm2m': ['produks'],
}
inlines = [
FooInline,
]
exclude = ('produks',)
I have use autocomplete, but it seems so hard to implement here because the tutorial is incomplete. So is there a way for me to get my related lookup works in my tabularinline ? Thank you very much :D.
So, yeah, I think I did simply misunderstand what you were asking. You’re just wanting the related lookup popup to select a product in each inline, rather than a select box. You already know about
raw_id_fields; the problem is that you need to specify that on the inline model admin, not the main parent model admin.