Giter Club home page Giter Club logo

django-rest-simpleproject's Introduction


Markdownify Markdownify
Learning-Django-REST-Framework

Creating a Django project with the tutorial given on the official website of Django-REST-Framework.

  Key FeaturesInstallationRun itHow to use itExtrasCredits

Key Features

Basic aspects about Django REST Framework:

  • Serialization.
  • Requests & Responses.
  • Class-based views.
  • Authentication & permissions.
  • Relationships & hyperlinked APIs.
  • Viewsets & routers.
  • Schemas & client libraries.

Installation

  1. Donwload Python 3 from https://www.python.org/downloads/.
  2. Install Pip with this link: https://pip.pypa.io/en/stable/installing/ , if you don't know if you have pip, type this command
# Verify pip
$ pip -V

Once you have pip installed, update pip with this command

# Update pip
$ pip install -U pip
  1. Download or clone this repository in your folder
# Clone this repository
$ git clone https://github.com/luisfelipe7/Learning-Django-REST-Framework
  1. Go into the repository
# Go into the repository
$ cd Learning-Django-REST-Framework
  1. Create a virtual environment
# Install virtualenv 
$ sudo pip install virtualenv 
# Create a virtual environment with Python3, env is the name of the environment
$ virtualenv env --python=python3 
# Activate your environment
$ cd env
$ source bin/activate 
  1. With the activated environment, install the requirements:
# Install requirements
$ pip install -r requirements.txt
  1. Run it.

Run it

  1. Install Postgresql
# Install postgresql
$ sudo apt-get install postgresql
  1. Connecting to PostgreSQL for first time

    a) Run the psql command from the postgres user account
# Enter with the user postgres
$ sudo -u postgres psql postgres

       b) Set the password

# Enter this command for set the password
$ \password postgres

       c) Enter a password
       d) Close psql

# Close psql
$ \q
  1. Create a new user and database

    a) Enter to Postgresql
# Enter with the user postgres
$ su - postgres  

       b) Create the new user and database

postgres=# CREATE USER admin WITH PASSWORD 'admin';
postgres=# CREATE DATABASE mydatabase OWNER admin;
  1. Configure your database, paste in settings.py file of your Django project the next configuration:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'mydatabase',
        'USER': 'admin',
        'PASSWORD': 'admin',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}
  1. Allow local connections, edit the file pg_hba.conf (/etc/postgresql/9.6/main/pg_hba.conf) as a superuser and replace the final lines of the file with these lines:
# Database administrative login by Unix domain socket
local   all             postgres                                md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

If you want to allow remote connections, visit this link: http://suite.opengeo.org/opengeo-docs/dataadmin/pgGettingStarted/firstconnect.html

  1. Sync your models
# Apply Migrations
$ python manage.py migrate
  1. Create a superuser for admin views
# Create a superuser
$ python manage.py createsuperuser
  1. Run your development server
# Run a development server
$ python manage.py runserver

How to use it

Enter to these URL's:

Extras

How to install and use Pgadmin :

  1. First, Pgadmin require Flask, so we need to install it with pip:
# Install flask
$ pip install flask
  1. Donwload the Pgadmin from the next url ( I don't recommend to download the last version, because it have some bugs ) : https://www.postgresql.org/ftp/pgadmin/pgadmin4/
  2. According to the dowloaded file, install it with the next command:
# Install Pgadmin
$ pip install pgadmin4-3.2-py2.py3-none-any.whl
  1. For run it use this command:
# Python Version - pgAdmin4.py file
$ sudo python3.5  "/home/felipe/Escritorio/Solvo/Documentacion Tecnica/Proyectos/Entornos Virtuales/env2/lib/python3.5/site-packages/pgadmin4/pgAdmin4.py"
  1. Configure it for your local databases, click on create server and follow these images:

Markdownify Markdownify

Credits

Thanks to Django-REST-Framework for the tutorial given on the official website.


GitHub @luisfelipe7  · 

django-rest-simpleproject's People

Contributors

luisfelipe7 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.