How to package a Django project to behave and install like a Python package. Lessons learned packaging Mayan EDMS the free open source document manager based in Django.
requirements.txt vi <project>/settings.py # Setup database # Setup media files # Set secret key # Customize other settings $ ./manage.py syncdb You have installed Django's auth system, and don't have any superusers defined. Would you like to create one now? (yes/no): yes Username (leave blank to use 'rosarior'): admin Email address: [email protected] Password: Password (again): Superuser created successfully. $ ./manage.py migrate $ ./manage.py runserver
install • Hard to override settings • One settings.py file per instance • Manual SECRET_KEY creation • Flat structure: project, media files and apps at the same level • Media files? Where? • Initial setup is not configurable • Insecure initial admin user creation • Hard to manage after install • Least amount of installation steps
to base.py ./manage.py runserver # imports from local.py which imports from base.py wsgi.py # imports from production.py which imports from local.py which import from base.py
trans "First time login" %}</h2> <p>{% trans 'You have just finished installing <strong>Mayan EDMS</strong>,congratulations!' %}</p> <p>{% trans 'Login using the following credentials:' %}</p> <p>{% blocktrans with auto_admin_properties.account as account %}Username: <strong>{{ account }}</strong>{% endblocktrans %}</p> <p>{% blocktrans with auto_admin_properties.account.email as email %}Email: <strong>{{ email }}</strong>{% endblocktrans %}</p> <p>{% blocktrans with auto_admin_properties.password as password %}Password: <strong>{{ password }}</strong>{% endblocktrans %}</p> <p>{% trans 'Be sure to change the password to increase security and to disable this message.' %}</p> {% endif %}
if instance == auto_admin_properties.account and instance.password != auto_admin_properties.password_hash: # Only delete the auto admin properties when the password has been changed auto_admin_properties.account = None auto_admin_properties.password = None auto_admin_properties.password_hash = None auto_admin_properties.save()
must be assigned a document type, it is the basic way Mayan EDMS categorizes documents.'), condition=lambda: not DocumentType.objects.exists(), view='documents:document_type_list' )