Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6233293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:16:26+00:00 2026-05-24T10:16:26+00:00

I read a tutorial in Django site but I don’t understand how to use

  • 0

I read a tutorial in Django site but I don’t understand how to use the set_language() function. For example, I have a demo follow as:

index.html

{% trans "Hello World." %}

<form action="/i18n/setlang/" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="/next/page/" />
<select name="language">
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}">{{ language.name_local }} ({{ language.code}})</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>

urls.py

urlpatterns = patterns('',
    (r'^i18n/', include('django.conf.urls.i18n')),
)

views.py

What need I write to display the languages, which were chosen from user in this file?

Thanks,

Thinh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:16:27+00:00Added an answer on May 24, 2026 at 10:16 am

    With the code you are using, you don’t need to write your own views. The form will make a POST request to /i18n/setlang/, with the language code and (optional) the redirect-to (next) page as parameters.

    The django view does the following (from the django documentation)

    Django looks for a next parameter in the POST data.
    – If that doesn’t exist, or is empty, Django tries the URL in the Referrer header.
    – If that’s empty — say, if a user’s browser suppresses that header — then the user will be – redirected to / (the site root) as a fallback.

    So in essence, the user will be redirected after submitting the form, and the django view will set the language for that user according to what was submitted.

    Hope this helps,

    Hoff

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this tutorial . I try, but i get error. We have Mysql
I'm new for playframework. and I read this tutorial. http://www.playframework.org/documentation/1.1/i18n#messages but I didn't understand
I've just read tutorial about enums and have one question. I've studied example: public
I have read the boost asio reference, gone through the tutorial and looked at
I have read several tutorials, but I just can't this to work. My apache
I read the tutorial http://wiki.fluentnhibernate.org/Auto_mapping#Getting_started but I couldn't undersatnd how the tables are accessed?
JasperReports newbie here. I have read the tutorial and the quick reference and read
I installed Django tagging. I read the tutorial and disassemble, how it works. In
I have read several tutorial concerning the for hibernate. I'm still getting confusion. Does
I have read the tutorial from ibm about xml parsing (http://www.ibm.com/developerworks/opensource/library/x-android/) In this example,there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.