How to show django cursor execute query
Posted In:
Django
.
By CreativeSolutions
Using for loop counter in django template
Posted In:
Django
.
By CreativeSolutions
Suppose you have a model
class User(models.Model):
TYPES = (
('Admin', 'Admin'),
('Staff', 'Staff'),
)
You can access this in the view using the following code
In your view file
from app.core.models import User
def save(request):
user_types = User.TYPES
render('user/form.hrml', {user_types:user_types})
If you want to use this variable in the template, Assign that value user_types as a dictionary variable then use the below code
{% for value, text in user_types %}
{{ value }} {{ text }}
{% endfor %}
class User(models.Model):
TYPES = (
('Admin', 'Admin'),
('Staff', 'Staff'),
)
You can access this in the view using the following code
In your view file
from app.core.models import User
def save(request):
user_types = User.TYPES
render('user/form.hrml', {user_types:user_types})
If you want to use this variable in the template, Assign that value user_types as a dictionary variable then use the below code
{% for value, text in user_types %}
{{ value }} {{ text }}
{% endfor %}
Older Posts
< ||| > > > Newer Posts