Skip to content

Marina Mele's site

Reflections on family, values, and personal growth

Menu
  • Home
  • About
Menu

How to deploy a Django app on Heroku. Part IV

Posted on February 10, 2014September 26, 2014 by Marina Mele

This is the fourth part of a series on how to deploy a Django app on Heroku.

How to deploy a Django app on Heroku. Part I.

How to deploy a Django app on Heroku. Part II.

How to deploy a Django app on Heroku. Part III.

You will see that the main idea behind these posts is not to build a functional Django app. Instead, what I want to do is to give you a bunch of good practices on how to build a Django app with different environments for testing, developing and production, useful packages installed, Internationalization and Localization properly configured, PostgreSQL installed, and much more.

PART IV

The topics covered here are:

  • Install South and run it both on your local machine and on Heroku
  • Prepare your app to support different languages
  • Prepare your app to support Localization

Installing South

South is a very useful Django package that manages changes in your database. To install it, activate your virtual environment and type:

$ pip install South

You should include the installed version of South in your requirements.txt file. If you followed this tutorial from Part I, you should have created a common.txt file with the common requirements of the development, production and testing environments. Type

$ pip freeze

to see which version of South you have installed, and add that line into your common.txt file (for me it was South==0.8.4). If you only have one requirements.txt file, you can type directly

$ pip freeze > requirements.txt

to save all the dependencies needed to a single file.

On your settings.py add:

INSTALLED_APPS = (
    …
    ‘south’,
    …
)

As we don’t have any app created, we can sync the database to see if South is installed properly. If on the contrary, you have created an app, and you want it to be managed by South, don’t do this step yet.

$ python manage.py syncdb

We can do the same on Heroku:

$ git add .

$ git commit -m “South installed”

$ git push heroku master

$ heroku run python manage.py syncdb

Every time you make a change on your models, you should use South following these steps:

  • run a schema migration on your development environment
  • perform the migration on the development environment
  • push your changes on Heroku
  • perform the migration on Heroku.

Preparing your app to support different languages

Another thing you might need is to prepare your app to support different languages. First, create a folder named locale at the same level of your settings.py file.

$ mkdir locale

Open your settings.py file and make sure you have the internationalization flag set to true: USE_I18N = True. Then, add the following at the bottom (change your languages accordingly):

ugettext = lambda s : s
LANGUAGES = (
    (‘en’, ugettext(‘English’)),
    (‘ca’, ugettext(‘Catalan’)),
)
LOCALE_PATHS = os.path.join(BASE_DIR, ‘locale’)

And finally, add the locale middleware in the correct position:

MIDDLEWARE_CLASSES = (
    …
    ‘django.contrib.sessions.middleware.SessionMiddleware’,
    ‘django.middleware.locale.LocaleMiddleware’,
    ‘django.middleware.common.CommonMiddleware’,
    …
)

These are the first steps for preparing your app to allow different languages. Later on we will discuss the next steps.

Time zone

You might also want to change the variable TIME_ZONE in your settings.py file to your local time zone. In my case, that was

TIME_ZONE = ‘Europe/Madrid’

This is very important if you want to use Localization on your project.

This is the end of this Series of Posts on How to Deploy a Django app on Heroku. For more information about how to write your models, views and forms, stay tuned to this Blog! 😉

Hope it was useful! 🙂

Marina Melé
Marina Mele

Marina Mele has experience in artificial intelligence implementation and has led tech teams for over a decade. On her personal blog (marinamele.com), she writes about personal growth, family values, AI, and other topics she’s passionate about. Marina also publishes a weekly AI newsletter featuring the latest advancements and innovations in the field (marinamele.substack.com)

Leave a Reply Cancel reply

You must be logged in to post a comment.

Categories

  • Personal Growth and Development
  • Artificial Intelligence
  • Mindful Parenting and Family Life
  • Productivity and Time Management
  • Mindfulness and Wellness
  • Values and Life Lessons
  • Posts en català
  • Other things to learn

Recent Posts

  • Understanding Frustration in Children
  • What is ChatGPT and how it compares to Bard and Claude
  • BlueSky Social – A Sneak Peek at the Future of Social Media
  • The Incredible Journey of AI Image Generation
  • AI and Fundamental Rights: How the AI Act Aims to Protect Individuals

RSS

  • Entries RSS
Follow @marina_mele
  • Cookie Policy
  • Privacy Policy
©2025 Marina Mele's site | Built using WordPress and Responsive Blogily theme by Superb
This website uses cookies to improve your experience. If you keep navigating through this website, we'll assume you're ok with this, but you can opt-out if you wish.Accept Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT