Answer the question
In order to leave comments, you need to log in
How to display inlines OneToOneField with multiple links in Django Admin?
class BaseProduct(models.Model):
name = models.CharField(max_length=200)
class Image(models.Model):
base_product = models.ForeignKey(BaseProduct, related_name='images_product', on_delete=models.CASCADE)
image = models.ImageField()
class Product(models.Model):
descriptions = models.TextField(blank=True)
base_product = models.OneToOneField(BaseProduct, on_delete=models.CASCADE, related_name='product')
class ProductAdmin(ReverseModelAdmin):
model = Product
inline_reverse = ['base_product']
inline_type = 'stacked'
admin.site.register(Product, ProductAdmin)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question