1

I keep getting this error on form submission:

Exception Type:     ProgrammingError
Exception Value:    column "location_completed" of relation "core_dailyprogress" does not exist

My model looks likes this:

class DailyProgress(BaseModel):
    location_completed = models.BooleanField(default=False, blank=True)

My form is as follows:

class DailyProgressForm(forms.ModelForm):
    location_completed = forms.BooleanField(required=False, initial=False)

    class Meta:
        model = DailyProgress
        fields = '__all__'
        widgets = {
          'location_completed': forms.CheckboxInput(),
        }

Finally, my template is:

<label>{{ form.location_completed }} Location Completed</label>

2 Answers 2

2

Your code looks fine. You should probably check to see if this database table has this column (as the error message implies) or if you have migrations that have not yet run.

Sign up to request clarification or add additional context in comments.

Comments

1

Typically that error indicates a Database issue. By chance have you by chance recently added location_completed without a migration? There's a weird issue with Postges on Django 1.8+ that sometimes fails to alter tables after migrations. Are you able to access location_completed from the shell?

Also, I believe you can simplify your form code to:

class DailyProgressForm(forms.ModelForm):
    location_completed = forms.BooleanField(required=False, initial=False)

    class Meta:
        model = DailyProgress

Since CheckboxInput is the default widget for forms.BooleanField.

1 Comment

I had to run a pending migration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.