Skip to content
Advertisement

Tag: django-forms

Django forms.Form reflecting property field constraints

I’m implementing a Django Form witch should contain the field ‘fieldA’ from modelA: My question is: Is there a way to have Django form, which will automatically handle validation of fieldA (check the max_length)? I know I Could use form.ModelFormclass referring to ModelA, but then the form would reflect all the fields of the ModelA. I would like to use

get more than two foreign keys from another django table and perform calculations on them

In the Django app, I have created two tables. Product Invoice I have one table called Product which contains product name and product price columns are given. Then, I have a second table named Invoice which contains a product name(foreign key), product price(foreign key), discount, and total. My concern is how can I import both the values from the Product

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… Here is what my views.py file looks like: And here is my forms.py file Why am I getting that error/what am I missing? Answer You problem comes from importing “from django.contrib.auth

Advertisement