how to locate the template files of django-apps installed? - django

I am using Django Rest Framework in my project. I did pip install djangorestFramework.
Currently the template that is rendered is default ones that is shipped with djangorestFramework. I want to look into the template code so that I can override and customize to my needs.
It is specified in the documentation on how to override certain features/themes. But I want to change almost everything. so it would be great if I could have access to those templates to help build mine.
On a related note, how to find the templates directories of django-apps installed.

Maybe you could use django-debug-toolbar, you will have a template tab for every page where you can find all the used templates to build the page and for every template the absolute path is given.

Related

Changing the CSS on the Django admin page

I am trying to change the admin HTML templates but I don't really now how to find the already created Django templates in the first place.
Is there an easy way to find all the templates?
Right now I am making new html templates and extending them to Djangos templates.
If you just look for an easy way to change the admin template you can use the django-admin-interface. You can change colors and it looks a bit more attractive. This works in my case pretty good.
pip install django-admin-interface
Is there an easy way to find all the templates?
Yes, they're all in the django/contrib/admin/templates/admin. You should be able to find the top-level django directory in the site-packages directory where you installed your Python packages. For example, if you created a .venv directory, it could be in .venv/lib/python3.8/site-packages/.
Otherwise, you could find the templates in the Github repository here.
The Django guide recommends copying those templates over to your own templates directory.

How to integrate Foundation 5 in django

I'd like to starting use Foundation 5 in a django project.
My doubts are about how to setup folders of Foundation project.
Foundation now uses bower for js dipendencies.
I think it's not correct make a foundation 5 set up into the static folder of django.
Has anyone done a setup of foundation in a django project?
To compile scss files I'll use django-compressor.
My solution is use django-bower... that's all!
Check here. It should have all the instructions.
https://pypi.python.org/pypi/django-zurb-foundation
I've been playing with foundation on my django project using the django development server. All I did was download the Foundation 5 static files (JS,CSS) and add them to my django static files. Then I added in the necessary scripts to my base template as shown here: http://foundation.zurb.com/docs/css.html. I haven't put it into production yet but I don't see any reason why that wouldn't work or why using static files isn't correct (as you thought in your question).
There are benefits to compiling the CSS yourself with SASS if you're really hardcore and I imagine that using template tags with django-zurb-foundation is a little cleaner or maybe easier to implement if you have tons of templates that you would need to modify but if you're like me and you just want to try Foundation out on a small project then downloading the extra applications (django-bower, django-zurb-foundation) isn't necessary.

How to customize templates in vim-latex

I'm trying to use vim-latex, and as the existing templates are annoyingly simple and unsatisfactory, I'm trying to build some of my own. However, after composing my own templates and stored in "/ftplugin/latex-suite/templates", nothing happens. The software simply won't scan for new templates. Did I miss some steps to make it work?
I found out what's happening. If there's any one who ran into a similar problem, please check whether you have installed that plugin in your OS repo. I'm using fedora, and accidentally installed vim-latex from the repo, thus the place those templates are really located is
"/usr/share/vim/vimfiles/ftplugin/latex-suite/templates".
So either remove the add-on installed from the OS repo and reinstall it in "~/.vim/", or copy the templates to that folder is the solution to this problem.
I experienced the same problem using Xubuntu. There the template files are stored at /usr/share/vim/addons/ftplugin/latex-suite/templates/. But simply adding a new template file there won't create a new menu entry in gvim: you must also make a soft link from your new template file in the directory above to /var/lib/vim/addons/ftplugin/latex-suite/templates/your_new_template.tex

How can I use coffee script in a Django project?

I'm a new developer on Django and I want to use some CoffeeScript in my dummy project. However, documentation about this topic isn't good and I want to know from the experts which is the best option.
I was looking at possibilities like compressor but it is still confused. I'd really appreciate some pieces of advice.
Thanks in advance.
For automatic compilation, there's django-coffeescript. For a more complete toolchain (a bit like Rails Sprockets) there's Gears, a stand-alone project with plugins for Django, Flask or compilation on the command line.
When I've used CoffeeScript with Django however, I've mostly preferred to set up compilation as a part of a build process (great to have one in any case), there I mostly used custom Paver scripts together with directory watching tools (like watchdog/kicker) to compile .coffee files to Javascript and putting them in my static directory.
What exactly is your question? Django will let you use any JS libary you want. Just add it your HTML pages or templates as you would do without Django.
If it is about serving of staticfiles, check this: https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/

Automating Django documentation with Sphinx

I am using Sphinx to generate documentation for a Django project, and it is working really well. However it seems to be necessary to write the .rst files yourself, and once that is done, sphinx will compile the documentation from the docstrings when you run make HTML.
My questions is:
I am looking for the docs to reflect new additions to the project automatically without having to edit the .rst files manually.
As everything in Django always seems so simple, I find it odd that you have to create the rst files for the entire project manually, I would have thought that there is something that already exists, that automatically inspects the structure of the project, and builds the rst's from that.
I have looked at this project http://pypi.python.org/pypi/django-sphinx-autodoc/0.0 which looks promising, but I am surprised that there is not something more mature.
Since a while, Sphinx apidoc is bundled with Sphinx. This can create a full set of .rst files for you.
It becomes more of a problem if you want to document all the various django applications that you use in one site (this seems to be what you want). Sphinx apidoc wants a bunch of directories to scan for python packages.