generated from SheCodesAus/plus-django-news-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_virtual-environment.txt
71 lines (49 loc) · 1.87 KB
/
install_virtual-environment.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
- open vscode in the dedicated folder:
code .
- create a virtual environment:
virtualenv venv
- activate the virtual environment:
. venv/bin/activate
- ALWAYS RUN IN A VIRTUAL ENVIRONMENT
- read the file
less requirements.txt (Ctrl+z to get out)
- install all the dependencies listed in requirements.txt file:
pip3 install -r requirements.txt
- resize image... https://pillow.readthedocs.io/en/latest/
pip install Pillow
- apply migration
python3 manage.py migrate
- run the app:
python3 manage.py runserver
- Delete the db if needed:
rm db.sqlite3
- Create a superUser to access to admin:
python manage.py createsuperuser
----------Start on the project-------------
1- add the news app in settings.py of django folder(here she_codes_news folder
python3 manage.py startapp news
2- check the model of the news installed in models.py in news folder
3- install the model:
//python3 manage.py makemigrations
//python3 manage.py migrate
4- Add news.urls file of News app in urls file of django folder
5- Looked at the json and load the jsonfile data
(django will automatically look for a fixtures folder in each app and load any json in it)
//python3 manage.py loaddata news
6- Add the templates file address in the settings file:
'DIRS': [(os.path.join(BASE_DIR, 'templates')),],
7- add the static directory at the end of settings:
//STATICFILES_DIRS (os.path.join(BASE_DIR, 'static'),)
8- add the statics to base and all the other pages:
//{% load static %}
9- link css on base:
//{% static 'style.css' %}
9- link css on other pages:
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="{% static 'news/styles.css' %}">
{% endblock %}
10- In dev mode, we have to delete the db to create users form:
- first save the dtata in a json in the fixtures folder
python3 manage.py dumpdata news
- then after makemigration and migrate, reload the data
python3 manage.py loaddata news