There are urls that I just need to set a session or consult a restful API ... anyway. What if I do not want a queryset? Why does django seem to force me to define one?
Would you have some kind of different view for this?
There are urls that I just need to set a session or consult a restful API ... anyway. What if I do not want a queryset? Why does django seem to force me to define one?
Would you have some kind of different view for this?
I believe you are using generic view (so your impression of needing a query), see all types of generic views: link
Generic view most basic:
from django.http import HttpResponse
from django.views import View
class MyView(View):
def get(self, request, *args, **kwargs):
return HttpResponse('Hello, World!')
If you need to render template:
from django.views.generic.base import TemplateView
from articles.models import Article
class HomePageView(TemplateView):
template_name = "home.html"
def get_context_data(self, **kwargs):
context = super(HomePageView, self).get_context_data(**kwargs)
context['latest_articles'] = Article.objects.all()[:5]
return context