K
K
Karina2014-05-10 23:19:43
Python
Karina, 2014-05-10 23:19:43

Django. How to make the verbouse_name parameter from models displayed inside the input form

I assign the created form to the views variable (let it be called form), then I put it in the dictionary and pass it to render_to_response.
The {{ form }} tag displays everything, but in my page thumbnail it should be that the name (verbouse_name) is inside this input field, and I have a name outside.
How to make it inside the input field?
Thanks everyone for the replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ali Aliyev, 2014-05-11
@iKapex

If I understand you correctly https://docs.djangoproject.com/en/1.6/topics/forms...
verbose_name specifies a name, not a value, for a field.
PS
You need to add a placeholder for your inputs so that the text in the inputs is displayed, and when you click on them, it disappears:

q = forms.CharField(label='search', 
                    widget=forms.TextInput(attrs={'placeholder': 'Search'}))

an example of how it all works coolestguidesontheplanet.com/add-a-label-into-a-te...
you can also do this:
class AuthorForm(ModelForm):
    class Meta:
        model = Author
        widgets = {
            'name': TextInput(attrs={'placeholder': 'name'}),
        }

another example
from django import forms
class Form_registration(ModelForm):
    class Meta:
        model = Security
        fields = ['e_mail', 'password']
        widgets = {
            'e_mail': forms.TextInput(attrs = {'placeholder': 'E-mail'})
        }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question