Django add inlines to CreateView -
i have following admin.py
class ainlineadmin(admin.tabularinline): model = class badmin(admin.modeladmin): fields = ['name'] list_display = ['name'] ordering = ['name'] inlines = [ainlineadmin] admin.site.register(b, badmin) class aadmin(admin.modeladmin): fields = ['identifier'] list_display = ['identifier'] ordering = ['identifier'] admin.site.register(a, aadmin)
and following models.py:
class b(models.model): name = models.charfield(max_length=100) def get_a(self): return "\n".join([i.identifier in self.a.all()]) def __unicode__(self): return self.name class a(models.model): identifier = models.charfield(max_length=200, blank=false, default="") c = models.foreignkey(b, related_name='a', default=0) def __unicode__(self): return self.identifier
and following views.py:
class bcreate(createview): model = b fields = ['name', 'a']
but not working 'a' inside "fields = ['name', 'a']", 'a' not found.
how can inlines view edit/delete/create inside b view?
the createview
not support this. use django-extra-views, comes createwithinlinesview
, updatewithinlinesview
views.
Comments
Post a Comment