Demo YunoHost Application to demonstrate the integration of a Django project under YunoHost.
Find a file
2023-11-26 15:57:47 +01:00
.github Apply manageprojects updates 2023-11-26 15:57:47 +01:00
conf Apply manageprojects updates 2023-11-26 15:57:47 +01:00
django_example_ynh Apply manageprojects updates 2023-11-26 15:57:47 +01:00
doc Apply manageprojects updates 2023-11-26 15:57:47 +01:00
scripts Apply manageprojects updates 2023-11-26 15:57:47 +01:00
tests Apply manageprojects updates 2023-11-26 15:57:47 +01:00
.editorconfig Apply manageprojects updates 2023-11-26 15:57:45 +01:00
.flake8 Apply manageprojects update 2022-12-21 19:19:37 +01:00
.gitignore Apply manageprojects updates 2023-11-26 15:57:47 +01:00
config_panel.toml Apply manageprojects updates 2023-11-26 15:57:47 +01:00
dev-cli.py Apply manageprojects updates 2023-11-26 15:57:47 +01:00
LICENSE Apply manageprojects updates 2023-11-26 15:57:45 +01:00
Makefile Apply manageprojects updates 2023-11-26 15:57:45 +01:00
manifest.toml Apply manageprojects updates 2023-11-26 15:57:47 +01:00
pyproject.toml Apply manageprojects updates 2023-11-26 15:57:47 +01:00
README.md Auto-update README 2023-08-25 21:24:03 +00:00
README_fr.md Auto-update README 2023-08-25 21:24:03 +00:00
requirements.dev.txt Apply manageprojects updates 2023-11-26 15:57:47 +01:00
tests.toml Migrate to manifest v2 2023-08-22 08:39:10 +02:00

Django Example for YunoHost

Integration level Working status Maintenance status

Install Django Example with YunoHost

Lire ce readme en français.

This package allows you to install Django Example quickly and simply on a YunoHost server. If you don't have YunoHost, please consult the guide to learn how to install it.

Overview

tests codecov django_example_ynh @ PyPi Python Versions License GPL-3.0

Demo YunoHost Application to demonstrate the integration of a Python/Django project under YunoHost using django_yunohost_integration.

To demonstrate the functionality the small django-example app will be installed.

Integration level Install django_example_ynh with YunoHost

Pull requests welcome ;)

Shipped version: 0.2.0~ynh2

Disclaimers / important information

local test

For quicker developing of django_example_ynh in the context of YunoHost app, it's possible to run the Django developer server with the settings and urls made for YunoHost installation.

e.g.:

~$ git clone https://github.com/YunoHost-Apps/django_example.git
~$ cd django_example_ynh/
~/django_example$ make
install-poetry         install or update poetry
install                install project via poetry
update                 update the sources and installation and generate "conf/requirements.txt"
lint                   Run code formatters and linter
fix-code-style         Fix code formatting
tox-listenvs           List all tox test environments
tox                    Run pytest via tox with all environments
pytest                 Run pytest
publish                Release new version to PyPi
local-test             Run local_test.py to run the project locally
local-diff-settings    Run "manage.py diffsettings" with local test

~/django_example$ make install-poetry
~/django_example$ make install
~/django_example$ make local-test

Notes:

  • SQlite database will be used
  • A super user with username test and password test is created
  • The page is available under http://127.0.0.1:8000/app_path/

history

These projects used django_example_ynh:


Developer info

The App project will be stored under __DATA_DIR__ (e.g.: /home/yunohost.app/$app/) that's Django's settings.DATA_DIR_PATH "static" / "media" files to serve via nginx are under __INSTALL_DIR__ (e.g.: /var/www/$app/) that's settings.INSTALL_DIR_PATH

package installation / debugging

This app is not in YunoHost app catalog. Test install, e.g.:

~# git clone https://github.com/YunoHost-Apps/django_example_ynh.git
~# yunohost app install django_example_ynh/ -f

To update:

~# cd django_example_ynh
~/django_example_ynh# git fetch && git reset --hard origin/testing
~/django_example_ynh# yunohost app upgrade django_example -u . -F

To remove call e.g.:

sudo yunohost app remove django_example

Backup / remove / restore cycle, e.g.:

yunohost backup create --apps django_example
yunohost backup list
archives:
  - django_example_ynh-pre-upgrade1
  - 20230822-062848
yunohost app remove django_example
yunohost backup restore 20230822-062848 --apps django_example

Debug the installation, e.g.:

root@yunohost:~# cat /etc/yunohost/apps/django_example/settings.yml
...
app: django_example
...
data_dir: /home/yunohost.app/django_example
...
install_dir: /var/www/django_example
...
log_file: /var/log/django_example/django_example.log
...

root@yunohost:~# ls -la /var/www/django_example/
total 18
drwxr-xr-x 4 root root 4 Dec  8 08:36 .
drwxr-xr-x 6 root root 6 Dec  8 08:36 ..
drwxr-xr-x 2 root root 2 Dec  8 08:36 media
drwxr-xr-x 7 root root 8 Dec  8 08:40 static

root@yunohost:~# ls -la /home/yunohost.app/django_example/
total 58
drwxr-xr-x 5 django_example_ynh django_example_ynh   11 Dec  8 08:39 .
drwxr-xr-x 3 root        root           3 Dec  8 08:36 ..
-rw-r--r-- 1 django_example_ynh django_example_ynh  460 Dec  8 08:39 gunicorn.conf.py
-rw-r--r-- 1 django_example_ynh django_example_ynh    0 Dec  8 08:39 local_settings.py
-rwxr-xr-x 1 django_example_ynh django_example_ynh  274 Dec  8 08:39 manage.py
-rw-r--r-- 1 django_example_ynh django_example_ynh  171 Dec  8 08:39 secret.txt
drwxr-xr-x 6 django_example_ynh django_example_ynh    6 Dec  8 08:37 venv
-rw-r--r-- 1 django_example_ynh django_example_ynh  115 Dec  8 08:39 wsgi.py
-rw-r--r-- 1 django_example_ynh django_example_ynh 4737 Dec  8 08:39 django_example_ynh_demo_settings.py

root@yunohost:~# /home/yunohost.app/django_example/manage.py diffsettings
...
root@yunohost:~# /home/yunohost.app/django_example/manage.py check
ENV_TYPE:None
PROJECT_PATH:/home/yunohost.app/django_example/venv/lib/python3.9/site-packages
BASE_PATH:/root/django_example
System check identified no issues (0 silenced).

root@yunohost:~# cat /etc/systemd/system/django_example.service
...

root@yunohost:~# systemctl reload-or-restart django_example
root@yunohost:~# journalctl --unit=django_example --follow
...
root@yunohost:~# tail -f /var/log/django_example/django_example.log
...
root@yunohost:~# tail -f /var/log/nginx/*.log
...

root@yunohost:~# ls -la /etc/nginx/conf.d/
root@yunohost:~# cat /etc/nginx/conf.d/$domain.d/django_example.conf

Documentation and resources

Developer info

Please send your pull request to the testing branch.

To try the testing branch, please proceed like that.

sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh/tree/testing --debug
or
sudo yunohost app upgrade django_example -u https://github.com/YunoHost-Apps/django_example_ynh/tree/testing --debug

More info regarding app packaging: https://yunohost.org/packaging_apps