» Dynamic rendering of template
Dynamic rendering of template
|September 7, 2014
Posted by forumadmin
I have a model class
Product in which I am storing generic things related to a product like name, owner, price, image and type. Here the type attribute represents the category of the product and it is used for determining the other factors associated with this product.
Now I have several classes which have attributes related to different categories of a product.
So lets say I have a class
ShoesInfo which have additional attributes related to shoes like shoe color, show type (sports shoes, running shoes, etc). This class contains a foreign key to above class.
I have to split the details page in two parts. In the first part it will fill all the generic info (the fields in the
Product class) and the type. So according to the type he has entered, I have to show the additional fields in the form.
My question is how to do this at runtime. When a user enters a value in type, the additional attribute fields should appear in the django admin form.
More Related Questions
- Django – Overriding the Model.create() method? The Django docs only list examples for overriding save() and delete(). However, I'd like to define some extra processing for my models only when they are created. For anyone familiar with […]
- Unique BooleanField value in Django? Suppose my models.py is like so:
name = models.CharField(max_length=255)
is_the_chosen_one = models.BooleanField()
I want only one of my Character […]
- Django reverse foreign key in admin I have a Django related question about foreign keys in the admin panel. I'm facing the following situation:
name = models.CharField(max_length=200)
- Customize/remove Django select box blank option I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with […]
- Django Admin Forms with additional fields in ManyToMany relations I have 2 Entities with a ManyToMany Relation and some additional fields, here you can find an example diagram:
I created all models following the documentation and everything works, but […]
- Default value for field in Django model Suppose I have a model:
id = models.AutoField(primary_key=True)
a = models.CharField(max_length=10)
b = […]
- Adding model-wide help text to a django models admin form In my django app, I would like to be able to add customized help text to the admin change form for some of my models. Note I'm not talking about the field specific help_text attribute […]
- Django crispy forms pre-cooked formset inside a form Is there a way to get something described below without coding too much custom code with django crispy forms or this is no way supported at all?
I am building a status report thing based […]
- Django auto_now and auto_now_add For Django 1.1.
I have this in my models.py:
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
- Resize fields in Django Admin Django tends to fill up horizontal space when adding or editing entries on the admin, but, in some cases, is a real waste of space, when, i.e., editing a date field, 8 characters wide, or […]