Skip to content

Commit

Permalink
modified manifest and setting
Browse files Browse the repository at this point in the history
  • Loading branch information
leoBitto committed Dec 2, 2023
1 parent a96ae68 commit 7a646ae
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 66 deletions.
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

84 changes: 41 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,12 @@
a repository to have a ready-to-deploy django project.
follow these steps to prepare the project :

### `manifest.json`
The `manifest.json` file is essential for turning your project into a Progressive Web App (PWA). It contains information such as the app name, icons, and other configurations. You can find it in the `static` folder of the website app. change name, short name, app description and icon name.

**Customization Tips:**

- `"name"`: Update this with the name of your app.
- `"short_name"`: Provide a shorter version of your app name for limited space.
- `"start_url"`: Set the starting URL of your app.
- `"icons"`: Replace the default icons with your own. Ensure they have the correct sizes and file paths.

For more details, refer to the [Web App Manifest documentation](https://developer.mozilla.org/en-US/docs/Web/Manifest).

### `service-worker.js`
The `service-worker.js` file handles Service Worker functionalities, such as resource caching. Customize it based on your project's needs. You can find it in the `static` folder inside the website app. you need to customize the caching of the icon.

**Customization Tips:**

- `CACHE_NAME`: This is the name of the cache. You can keep it as is or customize it.
- `urlsToCache`: Add URLs of resources you want to cache for offline access.
- `self.addEventListener('fetch', function(event) {...}`: This section determines how the Service Worker responds to network requests. Customize it if needed.

For more details, refer to the [Service Worker API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API).


# HOW TO START
## MOUNTING THE PROJECT
before doing all the production steps we need to mount the project in the **development**
machine, then create the new repo where the project will be launched.
before doing all the production steps we need to mount the project in the **development** machine, then create the new repo where the project will be launched.

1. clone the cliche_django project from github changing the name of the folder that will contain the project the recursive flag allow to download the submodules
`git clone --recursive https://github.com/leoBitto/cliche_django.git <name of the new project>`
`git clone --recursive https://github.com/leoBitto/DjangoForge.git <name of the new project>`

2. create a new empty repo in github that will contain the entire project

Expand All @@ -46,13 +21,11 @@ machine, then create the new repo where the project will be launched.

then git add, git commit, and push


5. the setting file must be updated with all the django apps we intend to use
and added the new set of urls the application use in the urls.py file.
In settings.py:

1. update the INSTALLED_APPS list with the apps we use
2. update the ALLOWED_HOSTS to include the ip address of the server and the domain name

In urls.py:
1. include the app urls inside the file
Expand All @@ -63,11 +36,10 @@ machine, then create the new repo where the project will be launched.
2. update the server
1. `apt update` #update repo
2. `apt upgrade` #upgrade repo a reboot may be necessary

2. `apt install virtualenv python3-venv python3-dev libpq-dev postgresql postgresql-contrib nginx curl` # install all the packages
3. `apt install virtualenv python3-venv python3-dev libpq-dev postgresql postgresql-contrib nginx curl` # install all the packages
3. create user
1. `adduser <choose a user name>` #create the user
2. `usermod -aG sudo <the user name chosen>` #modify the provileges of the user
2. `usermod -aG sudo <the user name chosen>` #modify the privileges of the user
3. `su <the user name chosen>` # switch to the user
4. change the directory to the home of the new user
5. clone from git
Expand All @@ -91,14 +63,18 @@ machine, then create the new repo where the project will be launched.
7. `GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;`
8. `\q` # close the prompt

#### IN .env (DO NOT USE SPACES)
#### IN .env (DO NOT USE SPACES), put .env inside /src
```
- DATABASE_NAME=myproject
- DATABASE_USER=myprojectuser
- DATABASE_PASS='password' # password must be between quotes
- SECRET_KEY=also create a new secret key
- DEBUG=FALSE
SECRET_KEY=thisisaverysecretkeyforthisdjangoforge
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
# aggiungi un indirizzo ip e un nome di dominio con la virgola e senza spazi
DATABASE_NAME=
DATABASE_USER=
DATABASE_PASS=
```
Also we need to update the allowed hosts to include the ip address of the server and the domain name.


# DJANGO
the django project is inside the /src folder, in here reside all the code necessary to make the django project work. inside the folder /base there are the basic setting and the .env file.
Expand All @@ -121,8 +97,6 @@ from the main folder
`deactivate`


Also we need to update the allowed hosts to include the ip address of the server and the domain name.

### SETTING PERMISSION
/home/ and all the contained folders MUST be owned by the nginx user www-data

Expand All @@ -139,6 +113,10 @@ cliche_django/ # Cartella principale del progetto
│ ├── ...
├── scripts/ # Script
│ ├── ...
├── log/ # log
│ ├── ...
├── static/ # static, its fille when collectstatic is used
│ ├── ...
└── src/ # Sorgenti principali dell'applicazione
├── base/ # Applicazione principale del progetto
│ ├── ...
Expand All @@ -157,6 +135,26 @@ contacts and opening hours. to use the module you need to:
seen by the user.
4. modify the favicon in the template base.html

N.B. every project should have it's own branch in the website repo. once the cloning
and the personalization is done a new branch in website repo should be created and
setted as the remote.

### `manifest.json`
The `manifest.json` file is essential for turning your project into a Progressive Web App (PWA). It contains information such as the app name, icons, and other configurations. You can find it in the `static` folder of the website app. change name, short name, app description and icon name.

**Customization Tips:**

- `"name"`: Update this with the name of your app.
- `"short_name"`: Provide a shorter version of your app name for limited space.
- `"start_url"`: Set the starting URL of your app.
- `"icons"`: Replace the default icons with your own. Ensure they have the correct sizes and file paths.

For more details, refer to the [Web App Manifest documentation](https://developer.mozilla.org/en-US/docs/Web/Manifest).

### `service-worker.js`
The `service-worker.js` file handles Service Worker functionalities, such as resource caching. Customize it based on your project's needs. You can find it in the `static` folder inside the website app. you need to customize the caching of the icon.

**Customization Tips:**

- `CACHE_NAME`: This is the name of the cache. You can keep it as is or customize it.
- `urlsToCache`: Add URLs of resources you want to cache for offline access.
- `self.addEventListener('fetch', function(event) {...}`: This section determines how the Service Worker responds to network requests. Customize it if needed.

For more details, refer to the [Service Worker API documentation](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API).
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
asgiref==3.6.0
Django==4.1.7
django-environ==0.10.0
gunicorn==20.1.0
Pillow==9.4.0
psycopg2==2.9.5
psycopg2-binary==2.9.5
python-decouple==3.8
sqlparse==0.4.3
asgiref
Django
django-environ
gunicorn
Pillow

psycopg2-binary
python-decouple
sqlparse
29 changes: 19 additions & 10 deletions src/base/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from pathlib import Path
from decouple import config
from decouple import config, Csv
import os
import logging

Expand All @@ -29,12 +29,7 @@



ALLOWED_HOSTS = [
'127.0.0.1',
'localhost',
# add the IP address and the domain name of the server

]
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='localhost,127.0.0.1', cast=Csv())


# Application definition
Expand Down Expand Up @@ -105,6 +100,8 @@
}




# Password validation
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators

Expand Down Expand Up @@ -165,9 +162,21 @@
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG', # Puoi impostare il livello desiderato (DEBUG, INFO, WARNING, ERROR, CRITICAL)
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'myapp.log', # Imposta il nome del file di registro
'filename': 'logs/forge.log', # Aggiorna il percorso del file
'formatter': 'verbose',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'formatters': {
'verbose': {
'format': '{levelname} {asctime} {module} {message}',
'style': '{',
},
},
'loggers': {
Expand All @@ -176,7 +185,7 @@
'level': 'DEBUG',
'propagate': True,
},
'myapp': { # Imposta il nome del tuo logger personalizzato
'myapp': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
Expand Down

0 comments on commit 7a646ae

Please sign in to comment.