- Move media folder from /build to its own path
- Add author model
we can simplify the website to simply publication management
where each post(article) is considered either
- book
- Pray-card
- fatawi
- video
- audio
Article contains title, author, upload-date, category, klass, type and series as its fields
-
categories can be one of the following: book, Pray-card, fatawi, video or audio each category has its own unique fileds
-
klass is a custom model, klass can have many articles and article can have many klasses.
-
type is a custom model, article can have one type and type can have many articles
-
series is a custom model, article can be in one series and series can have many articles
Show don't tell
{
title: charfield(maxlength=500), Nullable=false
author: chartfiled(maxlength=500), Nullable=false
upload-date: Datefiled, Nullable=false
category: Book, Cards..., Nullable=false
Klass: Klass , Nullable=false
series: series, Nullable=true
type: type , Nullable=true
}
{
title: charfield(maxlength=500), Nullable=false
slug: models.CharField(max_length=300)
parent: models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True, related_name="children")
}
- Books( {...article}, book-type, cover, pdfs, audio )
- fatawi( {...article}, picture, content, pdf )
- Pray-cards( {...article}, card-type, picture )
- Audio( {...article}, mp3, session, album, duration, downloaded, played )
- Video( {...article}, youtube-link )
- klass(title)
- series(title)
# Install Postgres
sudo apt install postgresql
# Open Postgres, and create new super user
psql -U postgres
posgres=# CREATE USER alssahihin SUPERUSER PASSWORD 'stayAwayAlssahihin';
# Login with the new user and create database
alssahihin=# CREATE DATABASE alssahihin;
Your .env file must contains the next variables (you can change the values):
DEBUG = True
DB_NAME = 'alssahihin'
DB_USERNAME = 'alssahihin'
DB_PASSWORD = 'stayAwayAlssahihin'
DB_HOST = ''
- DEBUG: true : means we are in devolpement phase
- DB_NAME = '' : database name
- DB_USERNAME = '' : the username of the user we created before, we can use postgres but to keep our work clean we created a stand alone user
- DB_PASSWORD = '' : user password
- DB_HOST = '' : where you database hosted
python manage.py createsuperuser
When you create an new app(NEW_APP) you must:
- move it inside apps folder
- change the name in apps.py of the new created app to where the app is newly located
(e.g: if you move the new app inside backend>apps, the variable
name
in NEW_APP/apps.py must be sth likebackend.apps.APP_NAME
)
- you should include the new app in INSTALLED_APPS in settings.py (e.g:
backend.apps.NEW_APP.apps.NEW_APPConfig
)
- create api folder inside ur NEW_APP and add init.py, serializers.py, urls.py and
views
folder or python file, depends on complex is gonna be.
- if you create views folder with multiple views u must import them in your views/init.py and use it as in one view file (to make importing it in urls easy)
NOTE: for each new folder you create on your own you must also create init.py inside of it ( e.g: NEW_FOLDER/init.py )
npm install create-react-app
npm run build
If you want to test the react app alone run:
npm start
if django asks you to set a default value to some field when you try to makemigration after some
changes on models you have to delete migartions folder and drop the table of that changed model.
What causing this issue is django needs to add your new changes/fields to already created table in database and it has to set a value to those new added fields you can avoid that by adding default=
attribute to you new fields.
python3 manage.py collectstatic
- Admin (permissions=Allow all)
- Manager (permissions=restricted to the articles/site)
- Visitor (permissions=read only)