Coder Social home page Coder Social logo

django-rest-api-student-management-system's Introduction

Dataproject Django-rest-framework

A project using the django rest framework

This repo consists of a source code of a python script to make an interactive student management system using Django rest framework

How is it done?

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.

Explore the app

Click here

Getting start

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]:GopinathV-1/flask-student-management-system.git

## Running the App

### Part 1: Create Database and virtualenv

### Move to project directory
```bash
$ cd dataproject-django-rest-framework

Create Database

$ sudo -u postgres psql
postgres=# \i create_db.sql
postgres=# \q

Install the virtualenv package

$ cd ..
$ pip install virtualenv

Create the virtual environment

To create a virtual environment, you must specify a path. You may provide any name in the place of :

$ virtualenv <mypython>

Activate the virtual environment

$ source mypython/bin/activate

Now you can load the requirements.txt.

Dependencies

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.

$ cd dataproject-django-rest-framework
$ pip install -r requirements.txt

Part 2: Create and provide information to .env file.

To run this, you need to create and provide the environment values in .env file.

Create .env file

create a .env file inside studentapp folder

$ cd api
$ touch .env

provide these information inside .env file.

SECURITY_KEY=GENERATED_ONE
NOTE: Do not provide space inbetween = and key,value inside .env file

open the terminal

SECRET_KEY generation

$ python3
>>> import secrets
>>> secrets.token_hex(16)

Provide secret key in .env file.

for creating and accessing admin operations create superuser

cd ..
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py createsuperuser
Note: provide your username and password in required place to create admin user.

Part 3: Running the application on server

$ python3 manage.py runserver

you can create the user by visiting register page http://127.0.0.1:8000/

Now you can access the app on your local server but for performing operation in browser you need to provide the username and password of user created.

you can access the assignments api page through http://127.0.0.1:8000/viewset/assignments/

part 4: Postman

Install postman

sudo snap install postman

Import collection

  1. goto to import

you can see the import option in your work space, click that and drop the file Assignment api (AS ADMIN).postman_collection.json and Assignment api (AS STUDENT).postman_collection.json in that.

In get token request in Assignment api (AS ADMIN).postman_collection.json provide the superuser credentials.

In get token request in Assignment api (AS STUDENT).postman_collection.json provide normal user credentials.

Global variable

you need to set a global variable

API Authentication

To submit or view an order, you need to Authenticate.

You can login by both ways such as Basic Authentication and Token Authentication.

  1. Basic Authentication: In postman select basic auth in authorization and provide the provide the username and password of the registered user.

  2. Token Authentication:

POST /api-token-auth/

The request body needs to be in JSON format and include the following properties:

  • username - String
  • password - String

Example

{
    "username": "Valentin",
    "password": "1234"
}

you will get a token - yourusertoken and it will be automatically set as global variable.

Run collection

Now you will be able to run the collection for testing.

Deactivate the virtual environment

if you have followed step1, use this command to get out of virtualenv

$ deactivate

Delete Database

$ sudo -u postgres psql
postgres=# \i delete_db.sql
postgres=# \q

django-rest-api-student-management-system's People

Contributors

gopinathv-1 avatar mukund-mountblue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.