pythondjangosyntaxdjango-modeltranslation

Invalid syntax error in Django form translate


I try translate my forms.py (placeholder, choices, etc) but i take syntax error. my code is here;

from django import forms
from django.utils.translation import ugettext_lazy as _

class CreatePollForm(forms.Form):
        title = forms.CharField(max_length = 300, label="", widget=forms.Textarea(attrs={'rows':'1','cols':'20', 'placeholder': (_'Type your question here'),'class': 'createpoll_s'}))
        polls = forms.CharField(max_length = 160, required=False, label="", widget=forms.TextInput(attrs={ 'placeholder': (_'Enter poll option'), 'class': 'votes firstopt','id':'id_polls1','data-id':'1'}))
        ...     

if i use like this, i take syntax error.

how can i translate "Type your question here" and "Enter poll option" ?


Solution

  • The invalid syntax error is caused by the following code:

    (_'Type your question here')
    

    This should be:

    _('Type your question here')