Skip to content

Instantly share code, notes, and snippets.

@teschmitt
Last active December 14, 2017 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teschmitt/70ee53fa7ed98f0442bd184539223d5b to your computer and use it in GitHub Desktop.
Save teschmitt/70ee53fa7ed98f0442bd184539223d5b to your computer and use it in GitHub Desktop.
Django ModelForm Label Transation
from django import forms
from .models import Topic
from django.utils.translation import ugettext_lazy as _
class NewTopicForm(forms.ModelForm):
message = forms.CharField(
widget=forms.Textarea(
attrs={'rows': 5, 'placeholder': 'What is on your mind?'}
),
max_length=4000,
help_text='The max length of the text is 4000.'
)
class Meta:
model = Topic
fields = ['subject', 'message']
labels = {
'subject': _('Subject'),
'message': _('Message')
}
<div class="jumbotron">
<div class="container">
<h1>{% trans "Welcome on my website!"%}</h1>
<p>{% blocktrans %}Great big ol' wall of text. {% endblocktrans %}</p>
<p><a class="btn btn-primary btn-lg" role="button">{% trans "Learn more"%} &raquo;</a></p>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment