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 7864527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:48:51+00:00 2026-06-02T23:48:51+00:00

I have followed the django documentation[1] to implement i18n on a hello word kind

  • 0

I have followed the django documentation[1] to implement i18n on a “hello word” kind of google app engine website.

unfortunately, after reading dozens of html pages, django and appengine documentation I can’t figure out what is happening:

  • changing the language code into the django_settings.py do change the language of the page and update a dropdown with the current language (i.e. LANGUAGE_CODE = ‘fr’ or ‘es’ or ‘en’)
  • change the dropdown and clicking on “change language” do lead to a “error 404” and the URL shows http:///i18n/setlang/

where can I find a list of django middlewares that app engine use by default? this might help me to digg deeper.

technical requirements (we don’t plan to upgrade before i18n works 🙂 :

  • python 2.5.4
  • google app engine 1.6.2
  • Django 1.2

[1] [https://docs.djangoproject.com/en/1.2/topics/i18n/]

[2] [cssjanus.googlecode.com] a piece of code that do exactly what I want to do. but I miss a small trick

index.html contains this

<form action="/i18n/setlang/" method="post">
    <input name="next" type="hidden" value="/MainPage">
    <select name="language">
        {% for lang in LANGUAGES %} <option value="{{ lang.0 }}"
            {% ifequal LANGUAGE_CODE lang.0 %}
            selected="selected"
            {% endifequal %}>{{ lang.1 }}</option>
        {% endfor %}
    </select>
    <input type="submit" value="{% trans "Change Language" %}">
</form>

app.yaml:

application: i18n
version: 1
runtime: python
api_version: 1

handlers:

- url: .*
  script: helloworld.py`

django_seetings.py

import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG

LANGUAGE_CODE = 'fr'
USE_I18N = True

gettext = lambda s: s
LANGUAGES = (
  ('en', gettext('English')),
  ('fr', gettext('French')),
  ('es', gettext('Spanish')),
)

INSTALLED_APPS = (
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions', 
)
SESSION_ENGINE = 'gae_sessions'

helloworld.py (I don’t use urls.py)

# coding=UTF-8

# Standard Python imports.
import os
import sys
import logging
import __builtin__

# Google App Hosting imports.
from google.appengine.dist import use_library
use_library('django', '1.2')

# Enable info logging by the app (this is separate from appserver's
# logging).
logging.getLogger().setLevel(logging.INFO)

# Must set this env var *before* importing any part of Django.
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_settings'

from google.appengine.ext.webapp import util 
# Import the part of Django that we use here.


from google.appengine.ext import webapp

from views import MainPage

from django.conf.urls.defaults import include

def main():
    # Create a Django application for WSGI
    application = webapp.WSGIApplication([('/', MainPage),                                        
                                    (r'^i18n/', include('django.conf.urls.i18n')),
                                     ], debug=True)


    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()

views.py

'''
Created on Apr 24, 2012

@author:xxxx
'''
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from django.utils.translation import ugettext #ok

from django import http
from django.http import HttpResponseRedirect
import django_settings  
from django.utils.translation import check_for_language
#from django.shortcuts import render_to_response

#def MainPage(request):

class MainPage(webapp.RequestHandler):
    def get(self):
        template_values = {
            'helloworld': ugettext("helloworld!"),
            'title': ugettext("home page"),
        }

        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))
        #return render_to_response('index.html', template_values)  

helloworld.py

# coding=UTF-8

# Standard Python imports.
import os
import sys
import logging
import __builtin__

# Google App Hosting imports.
from google.appengine.dist import use_library
use_library('django', '1.2')

# Enable info logging by the app (this is separate from appserver's
# logging).
logging.getLogger().setLevel(logging.INFO)

# Must set this env var *before* importing any part of Django.
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_settings'

from google.appengine.ext.webapp import util 
 # Import the part of Django that we use here.


from google.appengine.ext import webapp

from views import MainPage

from django.conf.urls.defaults import include

def main():
    # Create a Django application for WSGI
    application = webapp.WSGIApplication([('/', MainPage),                                        
                                        (r'^i18n/', include('django.conf.urls.i18n')),
                                         ], debug=True)


    # Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()
  • 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-06-02T23:48:52+00:00Added an answer on June 2, 2026 at 11:48 pm

    It seems that you are confusing django routing with webapp’s one. I don’t think you can use statement like include('django.conf.urls.i18n') in the initialization process of webapp.WSGIApplication.

    Additionally, as greg says, I also recommend using Python2.7 runtime, because it is much easier for you to use django(Believe me, it’s super easy) with the new runtime.

    Updated: added a procedure for running django-1.3 with Python2.7 runtime

    Here is a rough procedure to make django work with python2.7 runtime.

    Create a project

    $ env PYTHONPATH=/somewhere/google_appengine/lib/django_1_3 \
       python /somewhere/google_appengine/lib/django_1_3/django/bin/django-admin.py\
       startproject my_django_project
    $ cd my_django_project
    

    You can use settings.py for your django settings file by configuring
    an env_variables in your app.yaml.

    Create an app.yaml

    application: tmatsuo-hr
    version: 1
    runtime: python27
    api_version: 1
    threadsafe: true
    
    env_variables:
      DJANGO_SETTINGS_MODULE: 'settings'
    
    handlers:
    - url: /.*                                                                                                                                                     
      script: main.app                                                                                                                                             
    
    libraries:                                                                                                                                                     
    - name: django                                                                                                                                                 
      version: 1.3                                                                                                                                                 
    

    Create your django app

    $ env PYTHONPATH=/somewhere/google_appengine/lib/django_1_3 \
       python manage.py startapp myapp                                                                    
    

    Create your main.py

    import django.core.handlers.wsgi
    
    app = django.core.handlers.wsgi.WSGIHandler()
    

    Configure your settings.py

    ROOT_URLCONF = 'urls'
    Add 'myapp' to your INSTALLED_APPS
    

    Configure urls.py

    url(r'^$', 'myapp.views.index', name='index'),
    

    Create your views at myapp/views.py

    # Create your views here.
    
    from django.http import HttpResponse
    
    def index(request):
        return HttpResponse('Hello World!')
    

    Done. You should be able to configure this project in the same way as usual django applications.

    However, you can not use Django’s model because it needs SQL backends. If you’d like to do so, go check django-nonrel, or consider using django with CloudSQL.

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

Sidebar

Related Questions

I'm a newbie to Google App Engine but have played around with Django in
I have downloaded django and have followed the instructions to deploy my first website:
I have installed django-mptt and have followed the documentation regarding setting up a Django
I am trying to implement the message middleware in my Django App engine project
I have followed the suggestion in this question as I am using Django, I
I have followed the instructions found at http://code.google.com/p/pubsubhubbub/wiki/DeveloperGettingStartedGuide to setup a hub. When I
I have followed Apple's documentation on localizing iPhone software, using the genstrings ruby script
I have followed Custom Pagination article to implement the custom pagination using GridView. I
I'm creating custom template tags for my django site. I've followed the django documentation
Im building a customized comments app for django, using django comments itself. Ive followed

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.