Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django static page?

I want to make a static page which will be shown to the user only if he/she clicks on a link provided in one of my models. I can do this by making a Python page alone and calling it, but I want it be called from Django. The user interface should be constructed using the Django API only.

Any suggestions?

like image 946
ha22109 Avatar asked Jul 14 '09 07:07

ha22109


People also ask

What is static URL in Django?

"STATIC_ROOT" sets the absolute path to the folder where static files used for the apps and admin in a django project are stored and this command below creates the folder and collects static files from the apps and admin in a django project into the folder (*Setting "STATIC_ROOT" never ever influence to static file URL ...

Is Django static website?

django-static-sites is an easy to use Django app that allow you to create a static sites with the power of Django template system. You can render an existing Django view by adding a decorator or you can create an empty project optimized for django-static-sites use.


2 Answers

With the class-based views in newer Django versions, one can use this in urls.py:

from django.views.generic import TemplateView url(r'^about',      TemplateView.as_view(template_name='path/to/about_us.html'),     name='about'), 
like image 134
David Grellscheid Avatar answered Sep 17 '22 14:09

David Grellscheid


Bypassing views to render a static template, add this line in "urls.py". For example "About Us" page could be

(r'^about', 'django.views.generic.simple.direct_to_template', {'template': 'path/to/about_us.html'}), 
like image 45
rubayeet Avatar answered Sep 16 '22 14:09

rubayeet