Issue
For example I have a model like this:
class Wheel(models.Model):
wheel = models.CharField(max_length=20)
class Vehicle(models.Model):
wheel = models.ForeignKey(Wheel)
When I make a new Vehicle, I want the green plus sign to appear beside my wheel field and allow me to add new instances of Wheel. I'm quite new to django so I don't know if it's possible. Any help is appreciated!
Solution
Check the widget django.contrib.admin.widgets.RelatedFieldWidgetWrapper
. It's the widget used by Django Admin to add the functional '+' mark, here.
In order to use the widget in your custom form, you need to provide the admin_site
argument that serves the adding page of the Wheel.
Answered By - okm
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.