Skip to content

Simple way to create static mock data at rest api endpoints in the Django admin

License

Notifications You must be signed in to change notification settings

mverleg/django_mock_rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django mock rest

Simple way to create static mock data at rest api endpoints in the Django admin.

If you're designing a rest api client, and want to create a simple mock server for testing, then this app lets you do that using the Django admin.

Install

  • Install using
pip install django-mock-rest
  • Add django_mock_rest to installed apps in settings.py:
INSTALLED_APPS = [
        ...
        'django_mock_rest',
        ...
]
  • By default the mock service is available only in DEBUG mode. You can override this with DJANGO_MOCK_REST = True or False.
  • Add the root url to url.py:
urlpatterns = [
        ...
        url(r'^api-mock/', include('django_mock_rest.urls')),
        ...
]

How to use

In the Django admin, you can create endpoints:

https://raw.githubusercontent.com/mverleg/django_mock_rest/master/resources/admin_preview.png

After that, you can do http(s) request to the endpoints you defined:

$ curl -X GET http://127.0.0.1:8000/api-mock/post/1/
{
        "post": "Hello world"
}

You can also see an overview of all the mock endpoints (if logged in) by visiting ~, i.e. http://127.0.0.1:8000/api-mock/~.

About

Simple way to create static mock data at rest api endpoints in the Django admin

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages