Git Product home page Git Product logo

learn-django-rest-apis's Introduction

learn-django-rest-apis

How to create REST APIs using Django: Talk delivered at Slack Community Jaipur

Setting up Django and DRF on unix based OS

Step-1: Install python3 pip and mysql server

sudo apt-get install python3-pip mysql-server

Step-2: Install virtual env and MySQL

pip3 install virtualenv pymysql

Step-3: Create a virtualenv

virtualenv -p python3 -v env

Step-4: Activate virtualenv

. env/bin/activate

Step-5: Create a Django project

django-admin startproject slackrestapis

Step-6: Create a mysql database

mysql -u root -p
create database slackjaipur;
ALTER DATABASE slackjaipur CHARACTER SET 'utf8';
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON slackjaipur.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
exit

Step-7: Update settings.py for our db

ENGINE: django.db.backends.mysql NAME: 'slackjaipur' USER: 'user' PASSWORD: 'password' HOST: '127.0.0.1' PORT: '3306'

Step-8: Run migrations

python manage.py makemigrations
python manage.py migrate

Step-9: Install Django Rest Framework

pip install djangorestframework

Step-10: Create an App

python manage.py startapp restapis

And add 'rest_framework' to your INSTALLED_APPS setting

Step-11: Verify proper setup of project

python manage.py runserver

Setting up Django and DRF project on Windows

Follow this short offical django tutotrial on how to install Django on windows

Now to setup a Django project follow this tutorial

Follow Step-2 of this tutorial to install and connect MySQL to Django on Windows

Then follow step-7 to step-11 in previous part

Alternate: Setting up Django with MySQL can be a little bit tricky on windows if you are new. You can use this method instead :-

Install virtualbox on windows

Install Ubuntu 20.04.2.0 LTS on it using this iso image

Follow this tutorial on how to install Ubuntu on virtalbox

After the installation is complete, run these commands in your terminal

sudo apt-get install update
sudo apt-get install upgrade

Then follow step-1 to step-11 in above instructions

learn-django-rest-apis's People

Contributors

metalheadani avatar

Stargazers

Roman avatar

Watchers

James Cloos 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.