Because, Why not?
Steps are different for PC/VPS and Heroku. But for both of them, You need to prepare an SMTP server.
SMTP server is needed for account management system. If you don't know what SMTP is, check out this for a detailed explaining, and this for a just-want-to-know-what-does-this-stands-for explaining
If you just want to test this on your own PC, consider using some dummy SMTP server like smtp4dev(offline) or Mailtrap dummy email server(online) (plenty out there)
If you want to use Neveshtar in production and present it to public, You should use a proper SMTP provider (some free ones are elasticemail and gmail). If you just want to test it in production (which I don't understand why you would), You can use something like Mailtrap.
You need these variables in the next steps:
-
SMTP_HOST
IP / Address of the SMTP server
-
SMTP_PORT
Port of running SMTP server
-
USE_TLS_SMTP
Your provider specifies this, But originally it's true. If your provider does not support TLS OR you are using an offline dummy SMTP server like smtp4dev, set this to "False".
Otherwise, choose between one of these words (capital alphabets or not):
- True
- 1
- T
- Y
- Yes
- Yeah
- Yup
- Certainly
- Uh-huh
-
SMTP_USERNAME
Username of your SMTP account (credentials, this is different from your account at provider site)
-
SMTP_PASSWORD
Password of your SMTP account (credentials, this is different from your account at provider site)
-
EMAIL_HOST_USER
The email address that is used when sending emails.
Be careful about this. This is the address users see in their inbox
-
SECRET_KEY
As Django official documentation says:
A secret key used to provide cryptographic signing, and should be set to a unique, unpredictable value.
...
Running Django with a known SECRET_KEY defeats many of Django’s security protections, and can lead to privilege escalation and remote code execution vulnerabilities.
You can generate a key using this tool (safe to use)
You can use any database Django supports (or can support with plugins) but usually defaults (sqlite3 for PC/VPS and PostgreSQL for Heroku) are enough.
The steps are pretty simple:
-
Clone this repository (
git clone https://github.com/radiumatic/Neveshtar
) -
Set the variables mentioned before using this way or Heroku dashboard
-
Add these lines to the file Neveshtar/settings.py (make sure you add them before the statement
import django_on_heroku
, preferably afterSTATIC_ROOT = os.path.join(BASE_DIR, 'static')
):CSRF_TRUSTED_ORIGINS = [ 'https://example.herokuapp.com' ]
Rename example to your Heroku project name
-
Commit changes to git and run this command to make sure you have Heroku git remote configured:
heroku git:remote -a example
Change example to your Heroku project name
-
Run this command to deploy project to Heroku:
git push heroku HEAD:main
-
Create a SuperUser to moderate the blog with this command:
heroku run "python manage.py createsuperuser"
It will ask you in order for Email, Username, Name, Last name, and password
-
Run this command to create Writers permissions:
heroku run "python manage.py setupwriters"
-
You need to add yourself to writers with this command:
heroku run "python manage.py addwriter '[email protected]'"
Change [email protected] to the email you entered in creating super user. You can give more than one email and make multiple users writer at the same time
You should do this everytime you want to add a new writer. First, Tell that person to create an account using register form, and then run this command(same syntex as the
addwriter
command) to make him/her staff, then run theaddwriter
again with his/her email:heroku run "python manage.py addstaff '[email protected]'"
Done. Enjoy!
The steps are even simpler:
-
Install Python if you don't have it already
-
Clone this repository (
git clone https://github.com/radiumatic/Neveshtar
) and navigate to the created directory -
Eeither run this command to configure automatically:
python3 scripts/setup.py
or follow these steps to do it yourself:
-
Create a Virtual Environment and enable it using these commands:
#Windows python -m venv .venv .venv\Scripts\activate #Linux and Mac python3 -m venv .venv source .venv/bin/activate
-
Add variables using
.env
file. Please notice that you should name the file exactly the sameUse this pattern and add all the variables:
Variable = "Value"
-
Install required packages using this command:
pip install -r requirements.txt
-
Run these commands in order to prepare database:
python3 manage.py makemigrations python3 manage.py makemigrations blog python3 manage.py makemigrations accounts python3 manage.py migrate
-
Run this command to create Writers permissions:
python3 manage.py setupwriters
-
Create a SuperUser to moderate the blog with this command:
python3 manage.py createsuperuser
It will ask you in order for Email, Username, Name, Last name, and password
-
-
Enable virtual environment for two next commands:
Windows:
.venv\Scripts\activate
Linux:
source .venv/bin/activate
-
You need to add yourself to writers with this command:
python3 manage.py addwriter '[email protected]'
Change [email protected] to the email you entered in creating super user. You can give more than one email and make multiple users writer at the same time
You should do this everytime you want to add a new writer. First, Tell that person to create an account using register form, and then run this command(same syntex as the
addwriter
command) to make him/her staff, then run theaddwriter
again with his/her email:python3 manage.py addstaff '[email protected]'
-
Run server with this command:
python3 manage.py runserver
-
FOR VPS, Add these lines to the file Neveshtar/settings.py (make sure you add them before the statement
import django_on_heroku
, preferably afterSTATIC_ROOT = os.path.join(BASE_DIR, 'static')
):CSRF_TRUSTED_ORIGINS = [ 'https://your-address.com/' ]
Change https://your-address.com to the IP/Address of your VPS
-
FOR VPS, You should configure a web server too. You can follow this tutorial, but please change the details to make sure it's compatible with this project.
- If you enter invalid (not incorrect, invalid) information in registering, resetting password and login forms, it just returns you to the form without any error
- Wrong favicon
- Too fast like and dislike, knocks like and comment script up, and you can't put like or comment until you refresh the page
These will be fixed.
Neveshtar means writing in Persian.
GPLv3 You can find full text in LICENSE file