Skip to content

Setting up RMG website

xiaoruiDong edited this page Sep 13, 2018 · 12 revisions

You should have RMG-Py already installed.

Clone the RMG-website repo into your local folder.

The following command will update your rmg_env environment with the necessary packages for RMG-website

source activate rmg_env
cd RMG-website
conda env update -f environment.yml

You may need to update django to 1.11:

pip install django==1.11

or

conda install django=1.11

In order to get the web server running, you must first create a secretsettings.py file. This file is intended to hold settings that are specific to a particular installation. An example file is provided in rmgweb/secretsettings.py.example. Make a copy of that file named secretsettings.py.

Django uses a secret key for cryptographic signing, which is set in secretsettings.py. A dummy key is provided in the example file, which will work for basic use. For production environments, it is strongly recommended to generate a custom key. Instructions to generate a key using Python are provided in the example file, or you can use an online tool.

If running the website for the first time, enter the commands

cd RMG-website
python manage.py migrate
python manage.py runserver

You may be prompted to create a superuser account, which you will need to access admin features in the website.

Now the website should appear on your localhost, you can visit it in any browser using the url: http://127.0.0.1:8000/. The website may take some time to load, as the RMG database must be loaded from disk every time the web server is restarted.

When you rebuild any Model class within a models.py file, you have to modify the sql tables. This step is more complex now that django has moved to a migration model.

For production, it is necessary to create a migration. However, RMG-website has not fully transitioned to using migrations, so detailed instructions are not available at this point.

For local development, it is possible to simply recreate the necessary database tables. For instance if you changed rmgweb/rmg/models.py, the module name is rmg.

  1. Generate sql commands for dropping the tables:

    python manage.py sqlclear rmg
    
  2. Copy the section starting with BEGIN and ending with COMMIT.

  3. Start the database shell:

    python manage.py dbshell
    
  4. Paste the copied commands, then use CRTL+D to exit.

  5. Regenerate the tables and start the server:

    python manage.py migrate
    python manage.py runserver