Skip to content

RelatedObjectDoesNotExist #25

@mverleg

Description

@mverleg

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions