A simple CRUD project using the django framework
This repo consists of a source code of a python script and SQLAlchemy to make an interactive student management system using Django framework
You might be wondering that how the application performs many operations like creation, deletion, and update of assignments. Well, it was not that complicated as you may think. All these were achieved with the help of Database operation.
We all know that computers can store and retrieve data easily, so in order to do this operation, we used the Database. We have used queries to pick and formulate the data in a specific structure from Database. This repo consists of a basic example of how to do that.
To get started with the code on this repo, you need to either clone or download this repo into your machine just as shown below;
git clone [email protected]:mountblue/cohort-16-python/gopinath_v/django-toy-project.git
$ sudo -u postgres psql
postgres=# \i create_db.sql
postgres=# \q
$ pip install virtualenv
To create a virtual environment, you must specify a path. You may provide any name in the place of :
$ virtualenv <mypython>
$ source mypython/bin/activate
Now you can load the requirements.txt.
Before running the application, you need to have some packages preinstalled. So I have provided all the required packages and their versions in requirements.txt file by running the below command you will be able to install all the packages.
$ pip install -r requirements.txt
To run this, you need to create and provide the environment values in .env file.
$ cd django-toy-project
create a .env file inside studentapp folder
$ cd studentapp
$ touch .env
EMAIL_USER=YOUR_EMAIL_ID
EMAIL_PASSWORD=YOUR_PASSWORD
SECURITY_KEY=GENERATED_ONE
$ python3
>>> import secrets
>>> secrets.token_hex(16)
Provide email id and password in .env file.
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py createsuperuser
$ python3 manage.py runserver
Now you can access the app on your local server
if you have followed step1, use this command to get out of virtualenv
$ deactivate
$ sudo -u postgres psql
postgres=# \i delete_db.sql
postgres=# \q