Before running any command remember to install eventual new dependencies:
pipenv install and activate the virtual environment:
pipenv shell Copy .env.example file and rename it into .env. Here you will add eventual enviroment configurations.
To run this application you need a database. It can be a PostgreSQL or an SQLite:
-
if you want an SQLite, set
$USE_POSTGRESQL=False$ in your ENV file -
if you want PostgreSQL instead,
- install it somewhere or connect to an existent (through settings in ENV file, see
.env.example) - ensure user has permission to CREATEDB
- if it is a local one, ensure it is running (
sudo service postgresql start)
- install it somewhere or connect to an existent (through settings in ENV file, see
-
if you just switched between the two, ensure you have runned (in
python manage.py shell) commands:from django.contrib.contenttypes.models import ContentType ContentType.objects.all().delete()
Run the following command before start the server, in order to create all the tables in your database:
python manage.py migrate TODO: add a brief procedure
To run the server:
python manage.py runserver To see all available CLIs run:
python manage.py --help python manage.py [cli_command]- poll_seeder
This project is based on Django, so all usual Django rules and commands are valid here. Here it follows a quick brief.
-
project is divided into applications. To create a new application you may use command:
python manage.py startapp APP_NAME
(more info: https://docs.djangoproject.com/en/4.1/intro/tutorial01/)
-
to iterate with database you will use models and migrations. After creating a model, you wanna run this command to create a migration file:
python manage.py makemigrations APP_NAME
(more info: https://docs.djangoproject.com/en/4.1/intro/tutorial02/#database-setup)
-
if you quickly need to run some code on a running application:
python manage.py shell
then you can call services, models code, etc. (https://docs.djangoproject.com/en/4.1/intro/tutorial02/#playing-with-the-api)
For example, this sequence of commands will make you create a dummy survey:
- import service:
from apps.polls_management.services.poll_service import PollService - use service to create dummy survey
PollService.create("scelta di prova", "che scelta facciamo?", [{"key": "risposta-1", "value": "Risposta 1"}, {"key": "risposta-2", "value": "Risposta 2"}])
- import service:
To create a new version use the bump2version command. The version system follow the Semantic Versioning 2.0.0 guidelines.
According to Semantic Versioning 2.0.0 the type of version increment can be:
major: version when you make incompatible API changesminor: version when you add functionality in a backwards compatible mannerpatch: version when you make backwards compatible bug fixes
bump2version minorIf you have updated or if you only want to see the documentation in locale, run:
mkdocs serveTo use admin panel you have to create a super-user. You can do it through command:
python manage.py createsuperuser --username NAME --email EMAILSystem will make you set your password.