Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/8area8/django-rest-framework-articles
[ pypi library ] article application for Django Rest Framework
https://github.com/8area8/django-rest-framework-articles
personnal pypi tests
Last synced: 3 days ago
JSON representation
[ pypi library ] article application for Django Rest Framework
- Host: GitHub
- URL: https://github.com/8area8/django-rest-framework-articles
- Owner: 8area8
- Created: 2019-06-18T11:50:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-18T12:44:48.000Z (over 5 years ago)
- Last Synced: 2024-10-12T23:06:38.401Z (about 1 month ago)
- Topics: personnal, pypi, tests
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mb-drf-article
Mb-drf-article is a simple Django Rest Framework app to add some articles.
install the package with `pip install mb-drf-article`.## Quick start
### 1. Add "mb-drf-article" to your `INSTALLED_APPS` settings
```python
# settings.pyINSTALLED_APPS = [
...
'mb_drf_article',
]
```### 2. Include the articles URLconf in your project `urls.py`
```python
# urls.pyurlpatterns = [
# ...
path('articles/', include('mb_drf_article.urls')),
]
```### 3. Add the models in your Database
Run `python manage.py migrate` in your SHELL.
### 4. Update the Django Rest Framework Settings
Update the Django Rest Framework settings to add a pagination.
```python
# Django Rest Framework
# https://www.django-rest-framework.orgREST_FRAMEWORK = {
# ...
'DEFAULT_PAGINATION_CLASS': ('rest_framework.pagination.'
'LimitOffsetPagination'),
'PAGE_SIZE': 5
}
```## Try it
try the application with httpie :
```bash
http http://127.0.0.1:8000/articles/# OUTPUT :
HTTP/1.1 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Length: 341
Content-Type: application/json
Date: Tue, 18 Jun 2019 12:34:41 GMT
Server: WSGIServer/0.2 CPython/3.6.5rc1
Vary: Accept
X-Frame-Options: SAMEORIGIN{
"count": 1,
"next": null,
"previous": null,
"results": []
}
```## Methods
- **GET** `http://127.0.0.1:8000/articles/`: get the articles
- **POST** `http://127.0.0.1:8000/articles/`: post a new article
- **GET** `http://127.0.0.1:8000/articles/`: get a specific article
- **PUT** `http://127.0.0.1:8000/articles/`: update or create (all fields required)
- **PATCH** `http://127.0.0.1:8000/articles/`: update an article
- **DELETE** `http://127.0.0.1:8000/articles/`: delete an article> Note: Get methods doesn't require the admin permission. Others methods requires the admin permission.