-
Run command
git clone https://github.com/Gradient-IIITS/IIIT-Council-Backend.gitand movie in the repository -
Create a virtual environment
envin the repository (use virtualenv, etc) -
Activate virtual environment
Windows:
.\env\Scripts\activate
Ubuntu/Linux:source env/bin/activateInstall the requirements
pip install -r requirements.txt
Note: You might need to install dependencies for psycopg2
sudo apt install libpq-dev python3-dev -
Run
python manage.py checkto check any errors -
Run
python manage.py makemigrationsto make the migrations -
Run
python manage.py migrateto update the database schemaNote: You might need to add a dummy log file.
create a fileMAILGUN.pyin alogsfolder.
-
Install postgreSQL and configure it. (Set postgres password, Note down the PORT, etc).
-
Start postgreSQL shell and create a new user
user1.CREATE USER user1 WITH PASSWORD 'password';
-
Edit properties to optimize queries (optional)
ALTER ROLE user1 SET client_encoding TO 'utf8'; ALTER ROLE user1 SET default_transaction_isolation TO 'read committed'; ALTER ROLE user1 SET timezone TO 'UTC';
-
Create a new database named
iiits_counciland giveuser1the access using the following commandCREATE DATABASE iiits_council WITH OWNER = user1 ENCODING = 'UTF8' CONNECTION LIMIT = -1; GRANT ALL ON DATABASE iiits_council TO user1;
For sending mail you can import send_mail, send_mass_mail from either django.core.mail or mailgun module. Below are the example for both
For API Based Mailing import from
mailgun
Note: It only supports fail_silently kwargs
from mailgun import send_mail, send_mass_mailFor SMTP Based Mailing import from
django.core.mail
from django.core.mail import send_mail, send_mass_mail # Example code
# send mail to single person
send_mail(
'Subject',
'Body',
['to_person1@mail.com'],
'from@mail.com')
# To send mail to multiple people as CC
send_mail(
'Subject',
'Mail Body',
['to_person1@mail.com', 'to_person2@mail.com', ],
'from@example.com')
# For sending multiple mails or mails with BCC
x = send_mass_mail(
(
'Subject',
'Mail Body',
['to_person1@mail.com'],
'from@example.com'
),
(
'Subject',
'Mail Body',
['to_person3@mail.com', 'to_person2@mail.com', ]
'from@example.com'
),
)