Last active
December 14, 2017 21:58
-
-
Save teschmitt/70ee53fa7ed98f0442bd184539223d5b to your computer and use it in GitHub Desktop.
Django ModelForm Label Transation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"%} »</a></p> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment