mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-28 04:53:43 +03:00
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
This commit is contained in:
commit
4ddbeb1634
|
@ -48,6 +48,7 @@ Let's take a look at a quick example of using REST framework to build a simple m
|
||||||
|
|
||||||
Here's our project's root `urls.py` module:
|
Here's our project's root `urls.py` module:
|
||||||
|
|
||||||
|
```python
|
||||||
from django.conf.urls.defaults import url, patterns, include
|
from django.conf.urls.defaults import url, patterns, include
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from rest_framework import viewsets, routers
|
from rest_framework import viewsets, routers
|
||||||
|
@ -72,11 +73,13 @@ Here's our project's root `urls.py` module:
|
||||||
url(r'^', include(router.urls)),
|
url(r'^', include(router.urls)),
|
||||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||||
)
|
)
|
||||||
|
```
|
||||||
|
|
||||||
We'd also like to configure a couple of settings for our API.
|
We'd also like to configure a couple of settings for our API.
|
||||||
|
|
||||||
Add the following to your `settings.py` module:
|
Add the following to your `settings.py` module:
|
||||||
|
|
||||||
|
```python
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
# Use hyperlinked styles by default.
|
# Use hyperlinked styles by default.
|
||||||
# Only used if the `serializer_class` attribute is not set on a view.
|
# Only used if the `serializer_class` attribute is not set on a view.
|
||||||
|
@ -89,7 +92,7 @@ Add the following to your `settings.py` module:
|
||||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
```
|
||||||
Don't forget to make sure you've also added `rest_framework` to your `INSTALLED_APPS` setting.
|
Don't forget to make sure you've also added `rest_framework` to your `INSTALLED_APPS` setting.
|
||||||
|
|
||||||
That's it, we're done!
|
That's it, we're done!
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -45,6 +45,7 @@ version = get_version('rest_framework')
|
||||||
|
|
||||||
if sys.argv[-1] == 'publish':
|
if sys.argv[-1] == 'publish':
|
||||||
os.system("python setup.py sdist upload")
|
os.system("python setup.py sdist upload")
|
||||||
|
os.system("python setup.py bdist_wheel upload")
|
||||||
print("You probably want to also tag the version now:")
|
print("You probably want to also tag the version now:")
|
||||||
print(" git tag -a %s -m 'version %s'" % (version, version))
|
print(" git tag -a %s -m 'version %s'" % (version, version))
|
||||||
print(" git push --tags")
|
print(" git push --tags")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user