2021-02-28 10:56:42 +01:00
# django_example_ynh
2020-12-23 19:53:13 +01:00
2021-10-10 16:12:25 +02:00
[![pytest ](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/pytest.yml/badge.svg )](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/pytest.yml) [![YunoHost apps package linter ](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/package_linter.yml/badge.svg )](https://github.com/YunoHost-Apps/django_example_ynh/actions/workflows/package_linter.yml)
2021-02-28 10:56:42 +01:00
Demo [YunoHost Application ](https://install-app.yunohost.org/?app=django_example_ynh ) to demonstrate the integration of a Django project under YunoHost.
2020-12-23 19:53:13 +01:00
2021-02-28 10:56:42 +01:00
[![Integration level ](https://dash.yunohost.org/integration/django_example_ynh.svg )](https://dash.yunohost.org/appci/app/django_example_ynh) ![](https://ci-apps.yunohost.org/ci/badges/django_example_ynh.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/django_example_ynh.maintain.svg)
[![Install django_example_ynh with YunoHost ](https://install-app.yunohost.org/install-with-yunohost.svg )](https://install-app.yunohost.org/?app=django_example_ynh)
2020-12-29 15:08:56 +01:00
Pull requests welcome ;)
## local test
2021-09-15 19:16:35 +02:00
For quicker developing of django_example_ynh in the context of YunoHost app,
2020-12-29 15:08:56 +01:00
it's possible to run the Django developer server with the settings
and urls made for YunoHost installation.
e.g.:
```bash
2021-02-28 10:56:42 +01:00
~$ git clone https://github.com/YunoHost-Apps/django_example_ynh.git
2021-09-15 19:16:35 +02:00
~$ cd django_example_ynh/
2021-02-28 10:56:42 +01:00
~/django_example_ynh$ make
2020-12-29 15:08:56 +01:00
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
2021-02-28 10:56:42 +01:00
~/django_example_ynh$ make install-poetry
~/django_example_ynh$ make install
~/django_example_ynh$ make local-test
2020-12-29 15:08:56 +01:00
```
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/`
2020-12-28 20:15:38 +01:00
## history
2021-09-15 19:16:35 +02:00
* [compare v0.1.5...master ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.2.0...master ) **dev**
2020-12-28 20:15:38 +01:00
* tbc
2021-09-15 19:16:35 +02:00
* [v0.2.0 - 15.09.2021 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.5...v0.2.0 )
* rename/split `django_example_ynh` into:
* [django_yunohost_integration ](https://github.com/jedie/django_yunohost_integration ) - Python package with the glue code to integrate a Django project with YunoHost
* [django_example_ynh ](https://github.com/YunoHost-Apps/django_example_ynh ) - Demo YunoHost App to demonstrate the integration of a Django project under YunoHost
* [v0.1.5 - 19.01.2021 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.4...v0.1.5 )
2021-01-17 10:56:22 +01:00
* Make some deps `gunicorn` , `psycopg2-binary` , `django-redis` , `django-axes` optional
2021-09-15 19:16:35 +02:00
* [v0.1.4 - 08.01.2021 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.3...v0.1.4 )
* Bugfix [CSRF verification failed on POST requests #7 ](https://github.com/YunoHost-Apps/django_example_ynh/issues/7 )
* [v0.1.3 - 08.01.2021 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.2...v0.1.3 )
2021-01-08 08:54:03 +01:00
* set "DEBUG = True" in local_test (so static files are served and auth works)
* Bugfixes and cleanups
2021-09-15 19:16:35 +02:00
* [v0.1.2 - 29.12.2020 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.1...v0.1.2 )
2020-12-29 12:06:04 +01:00
* Bugfixes
2021-09-15 19:16:35 +02:00
* [v0.1.1 - 29.12.2020 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/v0.1.0...v0.1.1 )
* Refactor "create_superuser" to a manage command, useable via "django_example_ynh" in `INSTALLED_APPS`
2020-12-29 11:49:52 +01:00
* Generate "conf/requirements.txt" and use this file for install
* rename own settings and urls (in `/conf/` )
2021-09-15 19:16:35 +02:00
* [v0.1.0 - 28.12.2020 ](https://github.com/YunoHost-Apps/django_example_ynh/compare/f578f14...v0.1.0 )
2020-12-28 20:15:38 +01:00
* first working state
2021-09-15 19:16:35 +02:00
* [23.12.2020 ](https://github.com/YunoHost-Apps/django_example_ynh/commit/f578f144a3a6d11d7044597c37d550d29c247773 )
2020-12-28 20:15:38 +01:00
* init the project
2020-12-23 19:53:13 +01:00
## Links
2021-09-15 19:16:35 +02:00
* Report a bug about this package: https://github.com/YunoHost-Apps/django_example_ynh
2020-12-29 15:04:36 +01:00
* YunoHost website: https://yunohost.org/
* PyPi package: https://pypi.org/project/django-ynh/
2021-09-15 19:16:35 +02:00
These projects used `django_example_ynh` :
2020-12-29 15:04:36 +01:00
2021-02-28 10:56:42 +01:00
* https://github.com/YunoHost-Apps/django_example_ynh
2020-12-29 15:04:36 +01:00
* https://github.com/YunoHost-Apps/django-for-runners_ynh
2020-12-23 19:53:13 +01:00
---
# Developer info
## package installation / debugging
2021-09-15 19:16:35 +02:00
Please send your pull request to https://github.com/YunoHost-Apps/django_example_ynh
2020-12-23 19:53:13 +01:00
Try 'main' branch, e.g.:
```bash
2021-09-15 19:16:35 +02:00
sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh/tree/master --debug
2020-12-23 19:53:13 +01:00
or
2021-09-15 19:16:35 +02:00
sudo yunohost app upgrade django_example_ynh -u https://github.com/YunoHost-Apps/django_example_ynh/tree/master --debug
2020-12-23 19:53:13 +01:00
```
Try 'testing' branch, e.g.:
```bash
2021-09-15 19:16:35 +02:00
sudo yunohost app install https://github.com/YunoHost-Apps/django_example_ynh/tree/testing --debug
2020-12-23 19:53:13 +01:00
or
2021-09-15 19:16:35 +02:00
sudo yunohost app upgrade django_example_ynh -u https://github.com/YunoHost-Apps/django_example_ynh/tree/testing --debug
2020-12-23 19:53:13 +01:00
```
To remove call e.g.:
```bash
2021-09-15 19:16:35 +02:00
sudo yunohost app remove django_example_ynh
2020-12-23 19:53:13 +01:00
```
Backup / remove / restore cycle, e.g.:
```bash
2021-09-15 19:16:35 +02:00
yunohost backup create --apps django_example_ynh
2020-12-23 19:53:13 +01:00
yunohost backup list
archives:
2021-09-15 19:16:35 +02:00
- django_example_ynh-pre-upgrade1
2020-12-23 19:53:13 +01:00
- 20201223-163434
2021-09-15 19:16:35 +02:00
yunohost app remove django_example_ynh
yunohost backup restore 20201223-163434 --apps django_example_ynh
2020-12-23 19:53:13 +01:00
```
Debug installation, e.g.:
```bash
2021-09-15 19:16:35 +02:00
root@yunohost:~# ls -la /var/www/django_example_ynh/
2020-12-23 19:53:13 +01:00
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
2021-09-15 19:16:35 +02:00
root@yunohost:~# ls -la /opt/yunohost/django_example_ynh/
2020-12-23 19:53:13 +01:00
total 58
2021-09-15 19:16:35 +02:00
drwxr-xr-x 5 django_example_ynh django_example_ynh 11 Dec 8 08:39 .
2020-12-23 19:53:13 +01:00
drwxr-xr-x 3 root root 3 Dec 8 08:36 ..
2021-09-15 19:16:35 +02:00
-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:~# cd /opt/yunohost/django_example_ynh/
root@yunohost:/opt/yunohost/django_example_ynh# source venv/bin/activate
(venv) root@yunohost:/opt/yunohost/django_example_ynh# ./manage.py check
django_example_ynh v0.8.2 (Django v2.2.17)
DJANGO_SETTINGS_MODULE='django_example_ynh_demo_settings'
PROJECT_PATH:/opt/yunohost/django_example_ynh/venv/lib/python3.7/site-packages
BASE_PATH:/opt/yunohost/django_example_ynh
2020-12-23 19:53:13 +01:00
System check identified no issues (0 silenced).
2021-09-15 19:16:35 +02:00
root@yunohost:~# tail -f /var/log/django_example_ynh/django_example_ynh.log
root@yunohost:~# cat /etc/systemd/system/django_example_ynh.service
2020-12-23 19:53:13 +01:00
2021-09-15 19:16:35 +02:00
root@yunohost:~# systemctl reload-or-restart django_example_ynh
root@yunohost:~# journalctl --unit=django_example_ynh --follow
2020-12-23 19:53:13 +01:00
```