Skip to content

Commit

Permalink
Merge commit 'bf41c7623804856326b09f0724b4cb7d14440d7e'
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
	README.rst
	dajaxice/__init__.py
	dajaxice/tests/ajax.py
	dajaxice/views.py
	setup.py
  • Loading branch information
difanz committed May 6, 2015
2 parents 7bb7caa + bf41c76 commit 461d7d7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- DJANGO=django==1.4.10
- DJANGO=django==1.5.5
- DJANGO=django==1.6.2
- DJANGO=django==1.7

install:
- pip install -q $DJANGO --use-mirrors
Expand All @@ -27,5 +28,7 @@ matrix:
- python: "2.6"
env: DJANGO=django==1.5.5
- python: "2.6"
env: DJANGO=django==1.5.5
env: DJANGO=django==1.6.2
- python: "2.6"
env: DJANGO=django==1.7

10 changes: 9 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ From ``v0.6`` this project is not going to accept new features. In order to not

Should I use django-dajaxice?
------------------------------
In a word, No. I created this project 4 years ago as a cool tool in order to solve one specific problem I had at that time. These days using this project is a bad idea. Perhaps my vision of how my django projects should be coupled to libraries like this, or perhaps these days I really treasure the purity and simplicity of a vanilla django development.
In a word, No. I created this project 4 years ago as a cool tool in order to solve one specific problem I had at that time.

These days using this project is a bad idea.

Perhaps I'm more pragmatic now, perhaps my vision of how my django projects should be coupled to libraries like this has change, or perhaps these days I really treasure the purity and simplicity of a vanilla django development.

If you want to mimic what this project does, you would only need some simple views and jQuery.

Forget about adding more unnecessary complexity. Keep things simple.


Project Aims
Expand Down
3 changes: 1 addition & 2 deletions dajaxice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = (0, 6, 0, 0)
__version__string__ = '.'.join(map(str, __version__))
__version__ = (0, 7, 'beta')
2 changes: 1 addition & 1 deletion dajaxice/tests/ajax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dajaxice.decorators import dajaxice_register
import json
from dajaxice.decorators import dajaxice_register


@dajaxice_register
Expand Down
9 changes: 5 additions & 4 deletions dajaxice/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import logging

import django
from django.conf import settings
from django.views.generic.base import View
from django.http import HttpResponse, Http404
Expand Down Expand Up @@ -57,9 +57,10 @@ def dispatch(self, request, name=None):
if settings.DEBUG:
raise
response = dajaxice_config.DAJAXICE_EXCEPTION

return HttpResponse(
response, content_type="application/json; charset=utf-8")
if django.get_version() >= '1.7':
return HttpResponse(response, content_type="application/x-json; charset=utf-8")
else:
return HttpResponse(response, mimetype="application/x-json; charset=utf-8")
else:
log.error('Function %s is not callable. method=%s', name,
request.method)
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ Changelog
* Enhanced debugging facilities.
* A bunch of other enhancements.

0.7
^^^^^
* Make ``django-dajaxice`` work with ``django 1.7``

0.6
^^^^^
* Make ``django-dajaxice`` work with ``django 1.6``

0.5.5
^^^^^
* Return XMLHttpRequest from concreate functions as well as from function call.
Expand Down
14 changes: 7 additions & 7 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Create a file named ``ajax.py`` inside any of your apps. For example ``example/a

Inside this file create a simple function that return json.::

from django.utils import simplejson
import json

def sayhello(request):
return simplejson.dumps({'message':'Hello World'})
return json.dumps({'message':'Hello World'})

Now you'll need to register this function as a dajaxice function using the ``dajaxice_register`` decorator::

from django.utils import simplejson
from django.utils import json
from dajaxice.decorators import dajaxice_register

@dajaxice_register
def sayhello(request):
return simplejson.dumps({'message':'Hello World'})
return json.dumps({'message':'Hello World'})

Invoque it from your JS
-----------------------
Expand All @@ -46,12 +46,12 @@ How can I do a GET request instead of a POST one?

When you register your functions as ajax functions, you can choose the http method using::

from django.utils import simplejson
from django.utils import json
from dajaxice.decorators import dajaxice_register

@dajaxice_register(method='GET')
def saybye(request):
return simplejson.dumps({'message':'Bye!'})
return json.dumps({'message':'Bye!'})

This function will be executed doing a GET request and not a POST one.

Expand All @@ -61,7 +61,7 @@ Can I combine both?

Yes! You can register a function as many times as you want, for example::

from django.utils import simplejson
from django.utils import json
from dajaxice.decorators import dajaxice_register

@dajaxice_register(method='POST', name='user.update')
Expand Down

0 comments on commit 461d7d7

Please sign in to comment.