Note that there are some explanatory texts on larger screens.

plurals
  1. POform.is_valid() always returning false
    text
    copied!<p>Model class</p> <pre><code>class Fuzz_Engine(models.Model): id = PositiveTinyIntField(primary_key = True) engine_name = models.CharField(max_length=16) version = models.CharField(max_length = 16) class Meta: db_table = 'fuzz_engine' unique_together = ('engine_name', 'version') class AddFuzzEngineForm(ModelForm): class Meta: model = Fuzz_Engine </code></pre> <p>View Class</p> <pre><code>def addengine(request) if request.method == 'POST': form = AddFuzzEngineForm(request.POST) # input validation for add phone model form if form.is_valid(): fuzzEngineToAdd = Fuzz_Engine (engine_name = request.POST['engine_name'], version = request.POST['version']) fuzzEngineToAdd.save(force_insert=True) return render_to_response('fuzz/fuzz_cengine_results.html', {'fid': fuzzEngineToAdd.id,'fe': fuzzEngineToAdd,},context_instance=RequestContext(request)) else: form = AddFuzzEngineForm() return render_to_response('fuzz/add_fuzz_engine.html', {'form': form},context_instance=RequestContext(request)) </code></pre> <p>I have looked into a few similar questions on this issue, tried to print out the errors but doesn't seem to appear. </p> <p><a href="https://stackoverflow.com/questions/1682069/django-formsets-form-is-valid-is-false-preventing-formset-validation">Django Formsets - form.is_valid() is False preventing formset validation</a> <a href="https://stackoverflow.com/questions/5254470/form-is-valid-always-returning-false">form.is_valid() always returning false</a></p> <p>I have a feeling that the cause of the error lies in the structure of my model form class. </p> <p>The .is_valid is false as I have placed a code in that if statement and it doesn't run, however if I have an else statement(which is not here) for if it is not valid, it will appear. </p> <p>Can anyone provide another way of debugging this kind of error? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload