Created
August 7, 2012 02:48
-
-
Save toastdriven/3280916 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <html> | |
| <head> | |
| <title></title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| $(document).ready(function() { | |
| $.ajax({ | |
| url: '/api/v1/sessionusers/', | |
| contentType: 'application/json', | |
| beforeSend: function(jqXHR, settings) { | |
| jqXHR.setRequestHeader('X-CSRFToken', $('input[name=csrfmiddlewaretoken]').val()); | |
| }, | |
| success: function(data, textStatus, jqXHR) { | |
| console.log(data); | |
| } | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| {% csrf_token %} | |
| </body> | |
| </html> |
This file contains hidden or 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
| from django.conf.urls import patterns, include, url | |
| from django.contrib import admin | |
| admin.autodiscover() | |
| from django.contrib.auth.models import User | |
| from tastypie.api import Api | |
| from tastypie.authentication import SessionAuthentication | |
| from tastypie.resources import ModelResource | |
| class SessionUserResource(ModelResource): | |
| class Meta: | |
| resource_name = 'sessionusers' | |
| queryset = User.objects.all() | |
| authentication = SessionAuthentication() | |
| v1_api = Api() | |
| v1_api.register(SessionUserResource()) | |
| def stupid_view(request): | |
| from django.shortcuts import render | |
| return render(request, 'grump.html', {}) | |
| urlpatterns = patterns('', | |
| url(r'^admin/', include(admin.site.urls)), | |
| url(r'^api/', include(v1_api.urls)), | |
| url(r'^grump/', stupid_view), | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment