|
|
# How to setup Linux
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
In order to create the virtual environment, you need python 3 installed. This wiki page is done using the following version: `Python 3.5.2`.
|
|
|
|
|
|
|
|
|
## Virtual Environment
|
|
|
|
|
|
To create the virtual environment, you need to execute the following command:
|
|
|
```bash
|
|
|
python3 -m venv venv
|
|
|
```
|
|
|
|
|
|
In order to activate your virtual environment, you need to execute the following command:
|
|
|
```bash
|
|
|
source venv/bin/activate
|
|
|
```
|
|
|
In order to execute the other commands, you will need your virtual environment activated
|
|
|
|
|
|
To execute the virtual environment:
|
|
|
```bash
|
|
|
deactivate
|
|
|
```
|
|
|
|
|
|
If you want to install requirements, execute the following command:
|
|
|
```bash
|
|
|
pip install --upgrade --requirement requirements.txt
|
|
|
```
|
|
|
|
|
|
|
|
|
## Setup the Django application
|
|
|
|
|
|
First, you need to create the settings file:
|
|
|
```bash
|
|
|
make init_settings
|
|
|
```
|
|
|
|
|
|
This command will create the file conf/settings.py
|
|
|
|
|
|
If needed :
|
|
|
```bash
|
|
|
chmod +x manage.py
|
|
|
```
|
|
|
You'll need to define your SECRET_KEY in it, you can generate one using this command:
|
|
|
```bash
|
|
|
make secret_key
|
|
|
```
|
|
|
Copy/paste the output of this command in your settings file for the variable SECRET_KEY.
|
|
|
|
|
|
You now need to create a superuser:
|
|
|
```bash
|
|
|
make migrate
|
|
|
make createsuperuser
|
|
|
```
|
|
|
|
|
|
Read the Migrations part and also the Messages part.
|
|
|
|
|
|
Once you have done the migrations part, you can add initial data to your application:
|
|
|
```bash
|
|
|
make init_data
|
|
|
```
|
|
|
|
|
|
You'll also need to assign group(s) to user(s). Go into the admin (usually it's [http://127.0.0.1:8000/admin](http://127.0.0.1:8000/admin)). If you have use initial data, groups should already be created. You'll just need to add group(s) to user(s) going in users part.
|
|
|
|
|
|
## Migrations
|
|
|
In order to create migrations file, you need to use the following command:
|
|
|
```bash
|
|
|
make makemigrations
|
|
|
```
|
|
|
|
|
|
And to apply those changes, this command:
|
|
|
```bash
|
|
|
make migrate
|
|
|
```
|
|
|
|
|
|
If you need to flush the database, you can use this command:
|
|
|
```bash
|
|
|
make flush
|
|
|
```
|
|
|
|
|
|
## Messages
|
|
|
Django supports i18n, it can automatically generates translations file (*.po) using this command:
|
|
|
```bash
|
|
|
make makemessages locale=your_locale
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
```bash
|
|
|
make makemessages locale=fr
|
|
|
```
|
|
|
|
|
|
Once you have completed this file, you can compile the messages:
|
|
|
```bash
|
|
|
make compilemessages locale=your_locale
|
|
|
```
|
|
|
|
|
|
Example:
|
|
|
```bash
|
|
|
make compilemessages locale=fr
|
|
|
```
|
|
|
|
|
|
## Run
|
|
|
To run your server, you can use this command:
|
|
|
```bash
|
|
|
make run
|
|
|
``` |