Skip to content
Advertisement

I am trying to add a new field to the default Django Form and am getting an error when I’m trying to import a class from a forms.py file I made

The error is occurring in views.py file in which when I try to import the form class I made from my forms .py file I get an error of…

JavaScript

Here is what my views.py file looks like:

JavaScript

And here is my forms.py file

JavaScript

Why am I getting that error/what am I missing?

Advertisement

Answer

You problem comes from importing “from django.contrib.auth import forms” so i figure out that when you comment it out or just delete it, everything should work fine!.

JavaScript

Well in your view the conditional statement wasn’t meeting the condition after the form is saved and so it wouldn’t redirect to the home page, you needed to put the redirect right below the form.save() for it to meet the condition as in what i have done.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement