Global variable

20 views
Skip to first unread message

luca72

unread,
Apr 19, 2016, 10:27:42 AM4/19/16
to Django users
hello my view.py is like this:

from django.contrib import auth
from django.contrib.auth.decorators import login_required
from django.db import models
from django.core.files.storage import FileSystemStorage
#from django.core.servers.basehttp import FileWrapper
from django.contrib.auth import authenticate, login
from .forms import FormContatti
from django.core.mail import send_mail
from django.views.decorators.csrf import csrf_protect
global lenguage
language = 'it'



def first_page(request):
    testo = ["aaaa ....." , 'bbbbbb'] 
    if language == 'it':
        testo = testo[0]
    else :
        testo = testo[1]
    return render(request,'polls/first_page.html',{'testo':testo,})

where language can be it or en, in the web page i have two flag where i have to place an <href and i need only to pass the global variable language, because any view have the if statement to the global varible language

Thanks for your help

Luca

Gabriel Marcondes

unread,
Apr 19, 2016, 3:13:16 PM4/19/16
to django...@googlegroups.com
Ciao Luca,

Take a look at django's i18n [0], it will spare you a lot of work.

[0] https://docs.djangoproject.com/es/1.9/topics/i18n/

--
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...@googlegroups.com.
To post to this group, send email to django...@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/157f35f6-7f52-4451-ae68-0fb704b9e64b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
---
Gabriel Marcondes
Engenheiro de Computação - UFSCar
Reply all
Reply to author
Forward
0 new messages