Published

14 May 2014

Sharing

Introduction

I want to migrate RTD from sqlite to postgres.

To do so, I first need to find the settings file. Unfortunately, I'm a Django newbie :-)

Settings

To start, read Chapter 12 of the Django Book. It's all about deployment.

In checkouts/readthedocs, have a look at manage.py :

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.sqlite")
    sys.path.append('readthedocs')

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

As you can see: * DJANGO_SETTINGS_MODULE=settings.sqlite

which means settings are filled from the settings/sqlite.py file.

To migrate in production, we just need to replace it with "settings". The settings/init.py file will then be used instead.

Migrations

Before using production settings, dump the sqlite database:

  • python manage.py dumpdata --indent=4 > sqlite.json

See [Django migration tips] before continuing...

Set production settings, then:

  • python manage.py syncdb

Problems

Module settings not found

sys.path.insert(0, '/opt/src/rtd/checkouts/readthedocs.org/readthedocs')

Module djangodocs not found

It is in fact stored into read-the-docs example, beside rst files

Can't sign

http://stackoverflow.com/questions/4808105/cant-sign-in-to-django-admin

Finally, because it is required to set: * SESSION_COOKIE_DOMAIN = None

DEBUG = False

When DEBUG = True, everything is OK but messages are too informative for usual people.

Test

cd /opt/src/rtd source bin/activate cd checkouts/readthedocs.org/user_builds

sphinx-build -E -b readthedocs -D language=en_build/html /opt/src/rtd/checkouts/readthedocs.org/user_builds/side-for-alfresco/checkouts/latest/side-for-alfresco/src/rst side-for-alfresco/rtd-builds/latest

Ressources

  • Django migration tips
  • http://stackoverflow.com/questions/11476210/getting-site-matching-query-does-not-exist-error-after-creating-django-admin



blog comments powered by Disqus