I'm pretty new to this, apologies if i'm unclear....
running django, with bootstrap, and i've been fiddling with django-bootstrap. BootstrapModelForm is pretty cool, i didn't include the django-bootstrap stuff in my example, but i though i should note.
I have models:
class spam(models.Model):
name = models.CharField()
class Eggs(models.Model):
spam = models.ForiegnKey('spam')
I use a modelform,something like:
class EggsForm(forms.ModelForm):
meta:
model=Eggs
EggsForm allows selection of which spam will be referenced by eggs. I noticed the admin interface has a cool way to either select or add another egg.
How can i get similar functionality into my create form?
Why not use a standard form (not a ModelForm) for this? Add the "add new" as an extra option and catch it in the form's clean() method where you should then create the new object, redirect to another form etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With