model.py:
class A():
contents N/A
class B():
keyToA = model.ForeignKey("A")
somefield = TextField()
View example url: localhost/model-A-object-slug/ calls BCreateForm (below)
form.py:
class BCreateForm(CreateView):
model = B
form_class = modelfactory_form(B, form=BCreateForm, field=("somefield"))
def form_valid(self, form):
form.instance.KeyToA = getAFromSlugInURL
....
How do I fill in form.instance.KeyToA
given the slug in the view's url?
Thank you!