Django development
Database migrations are handle by South. Take a look at South's documentation for detailed information.
To avoid migration conflicts (Teams and Workflow):
- talk to the team before creating a new migration
- push migrations ASAP
- don’t edit migrations by hand to resolve conflicts (roll back and reapply)
Procedure:
- Make changes to Django model(s)
- Create a new migration:
./manage.py schemamigration <app_name> --auto
- Apply the migration:
./manage.py syncdb --migrate
or./manage.py migrate <app_name>
Note: that the
./manage.py schemamigration
command has an--update
mode that allows you to further iteratively refine your migration as such changes become necessary while working on your code. E.g../manage.py schemamigration <app_name> --auto --update
will update the most recent migration instead of creating a new one.
Troubleshooting:
-
The Admin interface still shows the old schema.
Make sure to restart the server. E.g. in dev mode run
$ supervisorctl restart runserver
. -
Error in Migration
Try reverting to an earlier migration. ./manage.py migrate {your_app_name} {migration_number}
For example:
./manage.py migrate analysis_manager 0001
A context processor has a very simple interface: It’s just a Python function that takes one argument, an HttpRequest object, and returns a dictionary that gets added to the template context. This allows us to expose specific Django settings throughout our templates and javascript.
Adding settings to the template context:
To add a specific Django setting to the template context, simply add that settings to the dict returned by core.context_processors.extra_context()
Accessing these values:
In Django templates: {{ name_of_setting }}
In JavaScript: name_of_setting
PyCharm includes a nifty feature that allows you to generate diagrams of your Django models and their dependencies.
Instructions here: https://www.jetbrains.com/help/pycharm/2016.1/viewing-model-dependency-diagram.html
Model diagram generated from commit: https://github.com/parklab/refinery-platform/commit/c107ba15029d30215e3a379448329a91a8911b1c
Sometimes we run into FileTypes & FileExtensions that Refinery doesn't know about. To combat this, we can add new types & extensions using a data migration.
See here for a good example: https://github.com/refinery-platform/refinery-platform/blob/develop/refinery/file_store/migrations/0002_filetypes_and_fileextensions.py
Administration
- Operations
- Setting Up Galaxy
- Galaxy CloudMan
- Annotating & Importing Refinery Tools
- Batch Import ISA-Tabs
- Backup & Restore
- Google reCAPTCHA v2
Development