1

Why can't I set instance = None in my unbound model form?

def sample(request):

    prf_form = ProfileForm(instance=None)
    print prf_form.instance #debugger print
    return render_to_response(template, locals(), context_instance=RequestContext(request))

I get the following exception:DoesNotExist

2 Answers 2

2

An alternative is to instantiate an empty Profile and pass that:

profile = Profile()
prf_form = ProfileForm(instance=profile) 
Sign up to request clarification or add additional context in comments.

Comments

1

Just don't send it an instance:

def sample(request):

    prf_form = ProfileForm()
    return render_to_response(template, locals(), context_instance=RequestContext(request))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.