django-superform icon indicating copy to clipboard operation
django-superform copied to clipboard

RelatedObjectDoesNotExist

Open mverleg opened this issue 7 years ago • 0 comments

I have this form

class StudioAppointmentForm(SuperModelForm):
	who = ForeignKeyFormField(form_class=CustomerForm, field_name='who', blank=True)

	class Meta:
		model = StudioAppointment
		fields = ()

with a model

class StudioAppointmentForm(SuperModelForm):
	who = ForeignKeyFormField(form_class=CustomerForm, field_name='who', blank=True)

	class Meta:
		model = StudioAppointment
		fields = ()

But when I do

form = StudioAppointmentForm(request.POST or None)

I get

RelatedObjectDoesNotExist at /new/studio/
StudioAppointment has no who.

...
at .../django_superform/fields.py in get_instance
313.        return getattr(form.instance, field_name)

StudioAppointment has a who field, but it's None because this is a new instance.

Am I doing something wrong?

Django Version: 2.0.2
Python version: 3.5.2

mverleg avatar Feb 26 '18 21:02 mverleg