Skip to content

Commit

Permalink
Change package name: djangorestframework -> rest_framework
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Sep 20, 2012
1 parent a1bcfbf commit 4b691c4
Show file tree
Hide file tree
Showing 105 changed files with 9,797 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ html/
coverage/
build/
dist/
djangorestframework.egg-info/
rest_framework.egg-info/
MANIFEST

!.gitignore
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
recursive-include djangorestframework/static *.ico *.txt *.css
recursive-include djangorestframework/templates *.txt *.html
recursive-include rest_framework/static *.ico *.txt *.css
recursive-include rest_framework/templates *.txt *.html
recursive-include examples .keep *.py *.txt
recursive-include docs *.py *.rst *.html *.txt
include AUTHORS LICENSE CHANGELOG.rst requirements.txt tox.ini
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For more information, check out [the documentation][docs], in particular, the tu

Install using `pip`...

pip install djangorestframework
pip install rest_framework

...or clone the project from github.

Expand All @@ -47,7 +47,7 @@ To build the docs.

To run the tests.

./djangorestframework/runtests/runtests.py
./rest_framework/runtests/runtests.py

# Changelog

Expand Down
14 changes: 7 additions & 7 deletions docs/api-guide/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ The value of `request.user` and `request.auth` for unauthenticated requests can

The default authentication policy may be set globally, using the `DEFAULT_AUTHENTICATION` setting. For example.

API_SETTINGS = {
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION': (
'djangorestframework.authentication.UserBasicAuthentication',
'djangorestframework.authentication.SessionAuthentication',
'rest_framework.authentication.UserBasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
)
}

Expand Down Expand Up @@ -75,11 +75,11 @@ If successfully authenticated, `BasicAuthentication` provides the following cred

This policy uses a simple token-based HTTP Authentication scheme. Token authentication is appropriate for client-server setups, such as native desktop and mobile clients.

To use the `TokenAuthentication` policy, include `djangorestframework.authtoken` in your `INSTALLED_APPS` setting.
To use the `TokenAuthentication` policy, include `rest_framework.authtoken` in your `INSTALLED_APPS` setting.

You'll also need to create tokens for your users.

from djangorestframework.authtoken.models import Token
from rest_framework.authtoken.models import Token

token = Token.objects.create(user=...)
print token.key
Expand All @@ -91,7 +91,7 @@ For clients to authenticate, the token key should be included in the `Authorizat
If successfully authenticated, `TokenAuthentication` provides the following credentials.

* `request.user` will be a `django.contrib.auth.models.User` instance.
* `request.auth` will be a `djangorestframework.tokenauth.models.BasicToken` instance.
* `request.auth` will be a `rest_framework.tokenauth.models.BasicToken` instance.

**Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https` only.

Expand All @@ -102,7 +102,7 @@ This policy uses the [OAuth 2.0][oauth] protocol to authenticate requests. OAut
If successfully authenticated, `OAuthAuthentication` provides the following credentials.

* `request.user` will be a `django.contrib.auth.models.User` instance.
* `request.auth` will be a `djangorestframework.models.OAuthToken` instance.
* `request.auth` will be a `rest_framework.models.OAuthToken` instance.

## SessionAuthentication

Expand Down
6 changes: 3 additions & 3 deletions docs/api-guide/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Object level permissions are run by REST framework's generic views when `.get_ob

The default permission policy may be set globally, using the `DEFAULT_PERMISSIONS` setting. For example.

API_SETTINGS = {
REST_FRAMEWORK = {
'DEFAULT_PERMISSIONS': (
'djangorestframework.permissions.IsAuthenticated',
'rest_framework.permissions.IsAuthenticated',
)
}

Expand Down Expand Up @@ -97,4 +97,4 @@ The method should return `True` if the request should be granted access, and `Fa
[authentication]: authentication.md
[throttling]: throttling.md
[contribauth]: https://docs.djangoproject.com/en/1.0/topics/auth/#permissions
[guardian]: https://github.com/lukaszb/django-guardian
[guardian]: https://github.com/lukaszb/django-guardian
6 changes: 3 additions & 3 deletions docs/api-guide/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This allows you to support file uploads from multiple content-types. For exampl

`request.parsers` may no longer be altered once `request.DATA`, `request.FILES` or `request.POST` have been accessed.

If you're using the `djangorestframework.views.View` class... **[TODO]**
If you're using the `rest_framework.views.View` class... **[TODO]**

## .stream

Expand All @@ -63,6 +63,6 @@ You will not typically need to access `request.stream`, unless you're writing a

`request.authentication` may no longer be altered once `request.user` or `request.auth` have been accessed.

If you're using the `djangorestframework.views.View` class... **[TODO]**
If you're using the `rest_framework.views.View` class... **[TODO]**

[cite]: https://groups.google.com/d/topic/django-developers/dxI4qVzrBY4/discussion
[cite]: https://groups.google.com/d/topic/django-developers/dxI4qVzrBY4/discussion
6 changes: 3 additions & 3 deletions docs/api-guide/reverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ There's no requirement for you to use them, but if you do then the self-describi

Has the same behavior as [`django.core.urlresolvers.reverse`][reverse], except that it returns a fully qualified URL, using the request to determine the host and port.

from djangorestframework.utils import reverse
from djangorestframework.views import APIView
from rest_framework.utils import reverse
from rest_framework.views import APIView

class MyView(APIView):
def get(self, request):
Expand All @@ -40,4 +40,4 @@ Has the same behavior as [`django.core.urlresolvers.reverse_lazy`][reverse-lazy]

[cite]: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_1_5
[reverse]: https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse
[reverse-lazy]: https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-lazy
[reverse-lazy]: https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-lazy
28 changes: 14 additions & 14 deletions docs/api-guide/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
>
> — [The Zen of Python][cite]
Configuration for REST framework is all namespaced inside a single Django setting, named `API_SETTINGS`.
Configuration for REST framework is all namespaced inside a single Django setting, named `REST_FRAMEWORK`.

For example your project's `settings.py` file might include something like this:

API_SETTINGS = {
REST_FRAMEWORK = {
'DEFAULT_RENDERERS': (
'djangorestframework.renderers.YAMLRenderer',
'rest_framework.renderers.YAMLRenderer',
)
'DEFAULT_PARSERS': (
'djangorestframework.parsers.YAMLParser',
'rest_framework.parsers.YAMLParser',
)
}

Expand All @@ -24,7 +24,7 @@ For example your project's `settings.py` file might include something like this:
If you need to access the values of REST framework's API settings in your project,
you should use the `api_settings` object. For example.

from djangorestframework.settings import api_settings
from rest_framework.settings import api_settings

print api_settings.DEFAULT_AUTHENTICATION

Expand All @@ -37,9 +37,9 @@ A list or tuple of renderer classes, that determines the default set of renderer
Default:

(
'djangorestframework.renderers.JSONRenderer',
'djangorestframework.renderers.DocumentingHTMLRenderer'
'djangorestframework.renderers.TemplateHTMLRenderer'
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.DocumentingHTMLRenderer'
'rest_framework.renderers.TemplateHTMLRenderer'
)

## DEFAULT_PARSERS
Expand All @@ -49,8 +49,8 @@ A list or tuple of parser classes, that determines the default set of parsers us
Default:

(
'djangorestframework.parsers.JSONParser',
'djangorestframework.parsers.FormParser'
'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser'
)

## DEFAULT_AUTHENTICATION
Expand All @@ -60,8 +60,8 @@ A list or tuple of authentication classes, that determines the default set of au
Default:

(
'djangorestframework.authentication.SessionAuthentication',
'djangorestframework.authentication.UserBasicAuthentication'
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.UserBasicAuthentication'
)

## DEFAULT_PERMISSIONS
Expand All @@ -80,13 +80,13 @@ Default: `()`

**TODO**

Default: `djangorestframework.serializers.ModelSerializer`
Default: `rest_framework.serializers.ModelSerializer`

## DEFAULT_PAGINATION_SERIALIZER

**TODO**

Default: `djangorestframework.pagination.PaginationSerializer`
Default: `rest_framework.pagination.PaginationSerializer`

## FORMAT_SUFFIX_KWARG

Expand Down
2 changes: 1 addition & 1 deletion docs/api-guide/status-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Using bare status codes in your responses isn't recommended. REST framework includes a set of named constants that you can use to make more code more obvious and readable.

from djangorestframework import status
from rest_framework import status

def empty_view(self):
content = {'please move along': 'nothing to see here'}
Expand Down
14 changes: 7 additions & 7 deletions docs/api-guide/throttling.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ If any throttle check fails an `exceptions.Throttled` exception will be raised,

The default throttling policy may be set globally, using the `DEFAULT_THROTTLES` and `DEFAULT_THROTTLE_RATES` settings. For example.

API_SETTINGS = {
REST_FRAMEWORK = {
'DEFAULT_THROTTLES': (
'djangorestframework.throttles.AnonThrottle',
'djangorestframework.throttles.UserThrottle',
'rest_framework.throttles.AnonThrottle',
'rest_framework.throttles.UserThrottle',
)
'DEFAULT_THROTTLE_RATES': {
'anon': '100/day',
Expand Down Expand Up @@ -95,7 +95,7 @@ For example, multiple user throttle rates could be implemented by using the foll

...and the following settings.

API_SETTINGS = {
REST_FRAMEWORK = {
'DEFAULT_THROTTLES': (
'example.throttles.BurstRateThrottle',
'example.throttles.SustainedRateThrottle',
Expand Down Expand Up @@ -130,9 +130,9 @@ For example, given the following views...

...and the following settings.

API_SETTINGS = {
REST_FRAMEWORK = {
'DEFAULT_THROTTLES': (
'djangorestframework.throttles.ScopedRateThrottle',
'rest_framework.throttles.ScopedRateThrottle',
)
'DEFAULT_THROTTLE_RATES': {
'contacts': '1000/day',
Expand All @@ -148,4 +148,4 @@ To create a custom throttle, override `BaseThrottle` and implement `.allow_reque

Optionally you may also override the `.wait()` method. If implemented, `.wait()` should return a recomended number of seconds to wait before attempting the next request, or `None`. The `.wait()` method will only be called if `.check_throttle()` has previously returned `False`.

[permissions]: permissions.md
[permissions]: permissions.md
12 changes: 7 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ Install using `pip`, including any optional packages you want...
pip install -r requirements.txt
pip install -r optionals.txt

Add `djangorestframework` to your `INSTALLED_APPS`.
Add `rest_framework` to your `INSTALLED_APPS`.

INSTALLED_APPS = (
...
'djangorestframework',
'rest_framework',
)

If you're intending to use the browserable API you'll want to add REST framework's login and logout views. Add the following to your root `urls.py` file.

urlpatterns = patterns('',
...
url(r'^api-auth/', include('djangorestframework.urls', namespace='djangorestframework'))
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
)


Note that the base URL can be whatever you want, but you must include `rest_framework.urls` with the `rest_framework` namespace.

## Quickstart

**TODO**
Expand Down Expand Up @@ -110,7 +112,7 @@ Build the docs:

Run the tests:

./djangorestframework/runtests/runtests.py
./rest_framework/runtests/runtests.py

## License

Expand Down
4 changes: 2 additions & 2 deletions docs/topics/browsable-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ API may stand for Application *Programming* Interface, but humans have to be abl

## URLs

If you include fully-qualified URLs in your resource output, they will be 'urlized' and made clickable for easy browsing by humans. The `djangorestframework` package includes a [`reverse`][drfreverse] helper for this purpose.
If you include fully-qualified URLs in your resource output, they will be 'urlized' and made clickable for easy browsing by humans. The `rest_framework` package includes a [`reverse`][drfreverse] helper for this purpose.


## Formats
Expand All @@ -14,7 +14,7 @@ By default, the API will return the format specified by the headers, which in th

## Customizing

To customize the look-and-feel, create a template called `api.html` and add it to your project, eg: `templates/djangorestframework/api.html`, that extends the `djangorestframework/base.html` template.
To customize the look-and-feel, create a template called `api.html` and add it to your project, eg: `templates/rest_framework/api.html`, that extends the `rest_framework/base.html` template.

The included browsable API template is built with [Bootstrap (2.1.1)][bootstrap], making it easy to customize the look-and-feel.

Expand Down
16 changes: 8 additions & 8 deletions docs/tutorial/1-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ The simplest way to get up and running will probably be to use an `sqlite3` data
}
}

We'll also need to add our new `blog` app and the `djangorestframework` app to `INSTALLED_APPS`.
We'll also need to add our new `blog` app and the `rest_framework` app to `INSTALLED_APPS`.

INSTALLED_APPS = (
...
'djangorestframework',
'rest_framework',
'blog'
)

Expand Down Expand Up @@ -81,7 +81,7 @@ Don't forget to sync the database for the first time.
We're going to create a simple Web API that we can use to edit these comment objects with. The first thing we need is a way of serializing and deserializing the objects into representations such as `json`. We do this by declaring serializers, that work very similarly to Django's forms. Create a file in the project named `serializers.py` and add the following.

from blog import models
from djangorestframework import serializers
from rest_framework import serializers


class CommentSerializer(serializers.Serializer):
Expand Down Expand Up @@ -114,8 +114,8 @@ Okay, once we've got a few imports out of the way, we'd better create a few comm

from blog.models import Comment
from blog.serializers import CommentSerializer
from djangorestframework.renderers import JSONRenderer
from djangorestframework.parsers import JSONParser
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser

c1 = Comment(email='leila@example.com', content='nothing to say')
c2 = Comment(email='tom@example.com', content='foo bar')
Expand Down Expand Up @@ -159,8 +159,8 @@ Edit the `blog/views.py` file, and add the following.

from blog.models import Comment
from blog.serializers import CommentSerializer
from djangorestframework.renderers import JSONRenderer
from djangorestframework.parsers import JSONParser
from rest_framework.renderers import JSONRenderer
from rest_framework.parsers import JSONParser
from django.http import HttpResponse


Expand Down Expand Up @@ -251,4 +251,4 @@ Our API views don't do anything particularly special at the moment, beyond serve
We'll see how we can start to improve things in [part 2 of the tutorial][tut-2].

[virtualenv]: http://www.virtualenv.org/en/latest/index.html
[tut-2]: 2-requests-and-responses.md
[tut-2]: 2-requests-and-responses.md
Loading

0 comments on commit 4b691c4

Please sign in to comment.