2016-03-18 15:17 GMT-03:00 Stanislav Vasko <stanislav.va...@gmail.com>:
> Ufff, i hope there is another way. Something working so simple like > passing data from View to Template with direct access like {{ company.name > }} or {{ company.phone }}. I dont see the point why to modify Model and how > it helps with styling form. > You won't be modifying the model. Just the form. You need to tell Django to render the form using the css clases you want. There are a few ways of doing that. One is Fred's way: phone = forms.CharField( required = True, max_length = 50, label = u'', widget = forms.TextInput( attrs={ 'class' : 'form-control', } ) You can also do a custom template. So instead of letting Django render the form, you code the html yourself. This is, instead of: {{ form.as_p }} do something like: <form class="form" action="" method="post">{% csrf_token %} <div class="col-md-6 col-sm-6 col-xs-12 form-group has-feedback"> <input name="phone" class="form-control" id="id_phone" placeholder="Phone" type="text"> <span class="fa fa-phone form-control-feedback right" aria-hidden="true"></span> </div> ... </form> My favorite is to install django-crispy-forms, but may be overkill at the moment since you are just learning Django. If you are comfortable using modules/third-party apps, your template will be: {% load crispy_forms_tags %} {% crispy form %} HTH, Norberto -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADut3oAL_1bG1KOZb2DRhAN%2BcWqtbfDKYTTUSCqH-XVsSOECWw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.