-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename to django-rest-framework, get simpleexample working
- Loading branch information
tom christie tom@tomchristie.com
committed
Jan 30, 2011
1 parent
8a470f0
commit 42f2f9b
Showing
28 changed files
with
155 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# To install django-rest-framework... | ||
# | ||
# Requirements: | ||
# python2.6 | ||
# virtualenv | ||
# To install django-rest-framework in a virtualenv environment... | ||
|
||
hg clone https://tomchristie@bitbucket.org/tomchristie/django-rest-framework | ||
cd django-rest-framework/ | ||
virtualenv --no-site-packages --distribute --python=python2.6 env | ||
source ./env/bin/activate | ||
pip install -r ./requirements.txt | ||
python ./src/manage.py test | ||
pip install -r requirements.txt | ||
|
||
# To build the documentation... | ||
|
||
sphinx-build -c docs -b html -d cache docs html | ||
pip install -r docs/requirements.txt | ||
sphinx-build -c docs -b html -d docs-build docs html | ||
|
||
# To run the examples... | ||
|
||
pip install -r examples/requirements.txt | ||
cd examples | ||
export PYTHONPATH=.. | ||
python manage.py syncdb | ||
python manage.py runserver | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Documentation requires Django & Sphinx, and their dependencies... | ||
|
||
Django==1.2.4 | ||
Jinja2==2.5.5 | ||
Pygments==1.4 | ||
Sphinx==1.0.7 | ||
docutils==0.7 | ||
wsgiref==0.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# For the examples we need Django, pygments and httplib2... | ||
|
||
Django==1.2.4 | ||
wsgiref==0.1.2 | ||
Pygments==1.4 | ||
httplib2==0.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.db import models | ||
|
||
MAX_INSTANCES = 20 | ||
|
||
class MyModel(models.Model): | ||
foo = models.BooleanField() | ||
bar = models.IntegerField(help_text='Must be an integer.') | ||
baz = models.CharField(max_length=32, help_text='Free text. Max length 32 chars.') | ||
created = models.DateTimeField(auto_now_add=True) | ||
|
||
class Meta: | ||
ordering = ('created',) | ||
|
||
def save(self, *args, **kwargs): | ||
"""For the purposes of the sandbox, limit the maximum number of stored models.""" | ||
while MyModel.objects.all().count() > MAX_INSTANCES: | ||
MyModel.objects.all()[0].delete() | ||
super(MyModel, self).save(*args, **kwargs) | ||
|
||
@models.permalink | ||
def get_absolute_url(self): | ||
return ('simpleexample.views.MyModelResource', (self.pk,)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.conf.urls.defaults import patterns, url | ||
|
||
urlpatterns = patterns('simpleexample.views', | ||
url(r'^$', 'MyModelRootResource'), | ||
url(r'^([0-9]+)/$', 'MyModelResource'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from djangorestframework.modelresource import ModelResource, RootModelResource | ||
from simpleexample.models import MyModel | ||
|
||
FIELDS = ('foo', 'bar', 'baz', 'absolute_url') | ||
|
||
class MyModelRootResource(RootModelResource): | ||
"""A create/list resource for MyModel. | ||
Available for both authenticated and anonymous access for the purposes of the sandbox.""" | ||
model = MyModel | ||
allowed_methods = anon_allowed_methods = ('GET', 'POST') | ||
fields = FIELDS | ||
|
||
class MyModelResource(ModelResource): | ||
"""A read/update/delete resource for MyModel. | ||
Available for both authenticated and anonymous access for the purposes of the sandbox.""" | ||
model = MyModel | ||
allowed_methods = anon_allowed_methods = ('GET', 'PUT', 'DELETE') | ||
fields = FIELDS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
from django.conf.urls.defaults import patterns, include | ||
from django.contrib import admin | ||
#from django.contrib import admin | ||
from djangorestframework.resource import Resource | ||
|
||
#admin.autodiscover() | ||
|
||
class RootResource(Resource): | ||
allowed_methods = anon_allowed_methods = ('GET',) | ||
|
||
def get(self, request, auth): | ||
return {'simple example': self.reverse('simpleexample.views.MyModelRootResource'), | ||
'pygments example': self.reverse('pygments_api.views.PygmentsRoot'), | ||
'object store example': self.reverse('objectstore.views.ObjectStoreRoot'), | ||
'blog post example': self.reverse('blogpost.views.BlogPostRoot'),} | ||
|
||
admin.autodiscover() | ||
|
||
urlpatterns = patterns('', | ||
(r'^pygments-example/', include('pygments_api.urls')), | ||
(r'^blog-post-example/', include('blogpost.urls')), | ||
(r'^object-store-example/', include('objectstore.urls')), | ||
(r'^$', RootResource), | ||
(r'^simple-example/', include('simpleexample.urls')), | ||
(r'^object-store/', include('objectstore.urls')), | ||
(r'^pygments/', include('pygments_api.urls')), | ||
(r'^blog-post/', include('blogpost.urls')), | ||
(r'^accounts/login/$', 'django.contrib.auth.views.login'), | ||
(r'^accounts/logout/$', 'django.contrib.auth.views.logout'), | ||
(r'^admin/doc/', include('django.contrib.admindocs.urls')), | ||
(r'^admin/', include(admin.site.urls)), | ||
#(r'^admin/doc/', include('django.contrib.admindocs.urls')), | ||
#(r'^admin/', include(admin.site.urls)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Django and pip are required if installing into a virtualenv environment... | ||
|
||
Django==1.2.4 | ||
distribute==0.6.14 | ||
wsgiref==0.1.2 |