You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
613 B
24 lines
613 B
from django.views.generic.detail import BaseDetailView |
|
from django.http import HttpResponse |
|
from blog.models import Blog |
|
|
|
|
|
class BlogDetailView(BaseDetailView): |
|
model = Blog |
|
|
|
def render_to_response(self,context): |
|
blog = context['object'] |
|
data = { |
|
'blog': { |
|
'id': blog.id, |
|
'title': blog.title, |
|
'content': blog.content, |
|
'author': { |
|
'id': blog.author.id, |
|
'username': blog.author.username, |
|
} |
|
} |
|
} |
|
|
|
return HttpResponse(data.values()) |
|
|
|
|