Can I call a Flatpage from with a view. Say I have some code like:
def myview(request):
if request.subdomain != "www":
return HttpResponseRedirect("http://"+request.subdomain+".mydomain/login/")
else:
call the flatpage here...
Can I call a Flatpage from with a view. Say I have some code like:
def myview(request):
if request.subdomain != "www":
return HttpResponseRedirect("http://"+request.subdomain+".mydomain/login/")
else:
call the flatpage here...
You sure can. Just make sure you have the flatpage
function included in your view code:
from django.contrib.flatpages.views import flatpage
And stick the following in your else:
return flatpage(request, '/path/to/your/flatpage/')
Or if you'd like to configure the flatpage to use the same URL being called, you can always do it like this:
return flatpage(request, request.path)
I just tested this and it worked just fine. Let me know if it doesn't for you.