django-forms

anyone face this issue in django?

anyone face this issue in django? Question: enter image description here when i created a employee form and view the form it show like as image. <tr> <td>{{ form.employee_name.label }}</td> <td>{{ record.employee_name }}</td> </tr> <tr> <td>{{ form.dob.label }}</td> <td>{{ record.dob }}</td> </tr> <tr> <td>{{ form.age.label }}</td> <td>{{ form.age }}</td> </tr> only age field show like …

Total answers: 1

Why it can't pass a validation with the django form when set data after initializing

Why it can't pass a validation with the django form when set data after initializing Question: Why it can’t pass a validation when I set data like this (form.data=request.POST) @login_required def add_delivery_view(request): user = request.user delivery = (Delivery.objects.filter(user=user) or [None])[0] form = AddDeliveryForm(instance=delivery) if request.method == ‘POST’: form.data = request.POST if form.is_valid(): delivery = form.save(commit=False) …

Total answers: 1

Better alternative for passing complex object from template to views.py on POST call

Better alternative for passing complex object from template to views.py on POST call Question: In views.py on GET call, I create a random list of questions (its a complex object, list of dictionaries) and I send that list to the template (HTML) file using return render(request, ‘some_page.html’, args). I show one question at a time …

Total answers: 1

django UniqueConstraint violation_error_message message not handled

django UniqueConstraint violation_error_message message not handled Question: I have this model: class DataMapping(models.Model): company = models.ForeignKey(Company, on_delete=models.CASCADE) location = models.ForeignKey(Location, null=True, blank=True, on_delete=models.CASCADE) department = models.ForeignKey(LocationDepartment, null=True, blank=True, on_delete=models.CASCADE) catagory = models.ForeignKey(CompanyCategory, on_delete=models.CASCADE) reason = models.ForeignKey(ReasonForProcessing, on_delete=models.CASCADE) class Meta: constraints = [ UniqueConstraint( name=’unique_data_map’, fields=[‘company’, ‘location’, ‘department’, ‘catagory’, ‘reason’], condition=Q(location__isnull=False), violation_error_message="This data map has already …

Total answers: 2

Django ModelForm as a layer of data validation

Django ModelForm as a layer of data validation Question: I have an authorization form, and I get an error – "already have a user with this email". I want to use the forms as a layer of validating the data. I now, that i can pass instance of CustomUser in my form, but i can`t …

Total answers: 2

How to add additional choices to forms which is taken from a model in django

How to add additional choices to forms which is taken from a model in django Question: As in the topic is it possible to add choices to the forms that take from the model. forms.py class BookGenreForm(forms.ModelForm): class Meta: model = Book fields = (‘genre’,) models.py class Book(Product): GENRE_CHOICES = ( (‘Fantasy’, ‘Fantasy’), (‘Sci-Fi’, ‘Sci-Fi’), …

Total answers: 1

using if else condition with for loop in Django

using if else condition with for loop in Django Question: I fairly new to Django, I have a list of usecase model shown in a a table, and a usecase progress model that includes a foreign key of the usecase. Initially a new usecase doesn’t have a progress yet, so in my template I’m trying …

Total answers: 1

Django form is not displaying all fields

Django form is not displaying all fields Question: I have a problem, i need to create form like scheme, i have my models and created forms.py.When i add my forms into the HTML, i have only 2 of all fields in my forms.What it can be? This is my models.py class Post(models.Model): full_name = models.CharField(max_length=60, …

Total answers: 3

Admin User model

Admin User model Question: My admin user model does not update new record when I register using UserCreationForm. Access the github code in the views I have imported Usercreationform has shown below and I did all the views coding. I do not know where I went wrong. I also rendered the form correctly into the …

Total answers: 1