Skip to content

A simple articles HTTP api built with django + django rest framework

License

Notifications You must be signed in to change notification settings

stefanoandroni/myapi-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

!! IN PROGRESS !!

Overview

django      django-rest-framework      requests

A simple articles HTTP api built with django + django rest framework (+ requests for client examples).

Installation

  1. Clone git repository
  2. $ git clone https://github.com/stefanoandroni/myapi-django 
  3. (Optional) Create a Python virual environment and activate it (py version in runtime.txt)
  4. Install requirements
  5. $ cd myapi-django
    $ pip install -r requirements.txt
  6. Change directory to myapi
  7. $ cd src\myapi
  8. Make migrations and migrate
  9. $ py manage.py makemigrations
    $ py manage.py migrate
  10. Run server
  11. $ py manage.py runserver

API

Edpoints

CRUD views (and endpoints) kept separate for learning purposes.


api/
auth/ POST authentication
register/ POST registration
articles/ GET articles list
create/ POST create article
<slug:article_slug>/update/ PUT update article
<slug:article_slug>/delete/ DELETE delete article
<slug:article_slug>/ GET article detail
comments/ GET all comments list
<int:id>/delete/ DELETE delete comment
<int:id>/update PUT update comment
<int:id>/ GET comment detail
<slug:article_slug>/create/ POST comment create
<slug:article_slug>/ GET article comments list
search/ ?q=QUERY&topic=TOPIC&author=AUTHOR GET search

Authentication and Permission

DEFAULT_AUTHENTICATION_CLASSES

  • rest_framework.authentication.SessionAuthentication
  • api.authentication.TokenAuthentication
  • Example Token Authentication example in src\client\utils.py

DEFAULT_PERMISSION_CLASSES

  • rest_framework.permissions.IsAuthenticated
  • Note Accessing any API endpoint requires authentication

Custom Permission

Custom permissions have been implemented for CRUD operations (articles and comments).

Client Examples

Client examples in src\client.

$ cd src\client
$ py file_name.py

TODO

  • implement Users CRUD

About

A simple articles HTTP api built with django + django rest framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages