mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-20 21:41:04 +03:00
Merge branch 'master' into experimental
This commit is contained in:
commit
ebbb6ac2d5
|
@ -30,11 +30,6 @@ To clone the project from GitHub using git::
|
|||
git clone git@github.com:tomchristie/django-rest-framework.git
|
||||
|
||||
|
||||
To clone the project from Bitbucket using mercurial::
|
||||
|
||||
hg clone https://tomchristie@bitbucket.org/tomchristie/django-rest-framework
|
||||
|
||||
|
||||
To install django-rest-framework in a virtualenv environment::
|
||||
|
||||
cd django-rest-framework
|
||||
|
|
|
@ -229,21 +229,21 @@ class Serializer(object):
|
|||
|
||||
# serialize each required field
|
||||
for fname in fields:
|
||||
if hasattr(self, smart_str(fname)):
|
||||
# check first for a method 'fname' on self first
|
||||
meth = getattr(self, fname)
|
||||
if inspect.ismethod(meth) and len(inspect.getargspec(meth)[0]) == 2:
|
||||
obj = meth(instance)
|
||||
elif hasattr(instance, '__contains__') and fname in instance:
|
||||
# check for a key 'fname' on the instance
|
||||
obj = instance[fname]
|
||||
elif hasattr(instance, smart_str(fname)):
|
||||
# finally check for an attribute 'fname' on the instance
|
||||
obj = getattr(instance, fname)
|
||||
else:
|
||||
continue
|
||||
|
||||
try:
|
||||
if hasattr(self, smart_str(fname)):
|
||||
# check first for a method 'fname' on self first
|
||||
meth = getattr(self, fname)
|
||||
if inspect.ismethod(meth) and len(inspect.getargspec(meth)[0]) == 2:
|
||||
obj = meth(instance)
|
||||
elif hasattr(instance, '__contains__') and fname in instance:
|
||||
# check for a key 'fname' on the instance
|
||||
obj = instance[fname]
|
||||
elif hasattr(instance, smart_str(fname)):
|
||||
# finally check for an attribute 'fname' on the instance
|
||||
obj = getattr(instance, fname)
|
||||
else:
|
||||
continue
|
||||
|
||||
key = self.serialize_key(fname)
|
||||
val = self.serialize_val(fname, obj)
|
||||
data[key] = val
|
||||
|
|
|
@ -149,7 +149,7 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
|
|||
# Always add these headers.
|
||||
#
|
||||
# TODO - this isn't actually the correct way to set the vary header,
|
||||
# also it's currently sub-obtimal for HTTP caching - need to sort that out.
|
||||
# also it's currently sub-optimal for HTTP caching - need to sort that out.
|
||||
response.headers['Allow'] = ', '.join(self.allowed_methods)
|
||||
response.headers['Vary'] = 'Authenticate, Accept'
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ You can install Django REST framework using ``pip`` or ``easy_install``::
|
|||
|
||||
Or get the latest development version using mercurial or git::
|
||||
|
||||
hg clone https://bitbucket.org/tomchristie/django-rest-framework
|
||||
git clone git@github.com:tomchristie/django-rest-framework.git
|
||||
|
||||
Or you can `download the current release <http://pypi.python.org/pypi/djangorestframework>`_.
|
||||
|
|
18
examples/permissionsexample/fixtures/initial_data.json
Normal file
18
examples/permissionsexample/fixtures/initial_data.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
[
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "auth.user",
|
||||
"fields": {
|
||||
"username": "test",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": false,
|
||||
"groups": [],
|
||||
"user_permissions": [],
|
||||
"password": "sha1$b3dff$671b4ab97f2714446da32670d27576614e176758",
|
||||
"email": ""
|
||||
}
|
||||
}
|
||||
]
|
|
@ -1,12 +0,0 @@
|
|||
- fields:
|
||||
first_name: ''
|
||||
groups: []
|
||||
is_active: true
|
||||
is_staff: true
|
||||
is_superuser: true
|
||||
last_name: ''
|
||||
password: sha1$b3dff$671b4ab97f2714446da32670d27576614e176758
|
||||
user_permissions: []
|
||||
username: test
|
||||
model: auth.user
|
||||
pk: 2
|
|
@ -7,7 +7,7 @@ from djangorestframework.views import View
|
|||
class Sandbox(View):
|
||||
"""This is the sandbox for the examples provided with [Django REST framework](http://django-rest-framework.org).
|
||||
|
||||
These examples are provided to help you get a better idea of the some of the features of RESTful APIs created using the framework.
|
||||
These examples are provided to help you get a better idea of some of the features of RESTful APIs created using the framework.
|
||||
|
||||
All the example APIs allow anonymous access, and can be navigated either through the browser or from the command line...
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user