Added a view that return all the textures in json format
This commit is contained in:
parent
a24be0c6f9
commit
eeac0b2088
|
@ -50,6 +50,7 @@ urlpatterns = patterns('',
|
|||
'blog.views.blog_item', name='blog_item'),
|
||||
|
||||
# Admin only
|
||||
url(r'^studio/textures/$', 'studio.views.textures', name='studio_textures'),
|
||||
url(r'^studio/', 'studio.views.main', name='studio_main'),
|
||||
|
||||
# Robots
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.http import HttpResponse
|
||||
from database.models import Texture
|
||||
from django.utils import simplejson as json
|
||||
from django.core import serializers
|
||||
|
||||
|
||||
def main(request):
|
||||
|
@ -12,3 +15,10 @@ def main(request):
|
|||
|
||||
context = RequestContext(request, data)
|
||||
return render_to_response('studio/main.html', context_instance=context)
|
||||
|
||||
|
||||
def textures(request):
|
||||
textures = Texture.objects.all()
|
||||
data = serializers.serialize('json', textures, fields=('name', 'type', 'image',))
|
||||
response = HttpResponse(data, 'application/json')
|
||||
return response
|
||||
|
|
Loading…
Reference in New Issue