'Django : How do we automatically hide the parts of a form that requests information that we have already entered?
Saying that, I have two classes (service and product) which are linked with a foreign key. Each class contains a number of forms. I want that each information entered in the form of the product class is no longer requested in the form of the service class and if it has detected it I want to hide the fields which request it in the template! (to avoid repetition) Do you have a method for doing this pleaaaaaase? Product : model.py
class Product :
name = models.CharField(max_length=100, null=True)
length = models.CharField(max_length=2, null=True)
type = models.CharField(max_length=2, null=True)
Service : model.py
class Service :
date_creation = models.DateTimeField(auto_now_add=True)
product = models.ForeignKey(Product, on_delete=models.PROTECT, null=True, blank=True)
Solution 1:[1]
You can programatically remove form fields by overriding it's init method in the forms.py.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chandragupta Borkotoky |
