Flask jinja templates with the same name - flask

I have 3 application states each with very different nav bars:
Public web
Admin Dashboard
Product Pages
One way I have looked to design this is with a layout.html that I extend with three different nav templates, one for each of the above (rather than having one nav template with lots of different conditions.
Is it ok to have these nav templates all having the same name (nav.html) but put them in their respective blueprint folders, or do I have to put different names like dashboard_nav.html to avoid conflicts?

Related

How to write a real self-contained Django app?

They say Django apps should be self-contained.
I find it hard to implement.
My website has 3 apps. All have their own static and templates folders.
But — like many other sites — they share same front-end design.
The problem is, I have a very small form at the footer of each page to sign up for my newsletter. First, I have to define the database model in one of apps, which means the other two rely on that one. Second, the view to update the database should be defined in an app — naturally, the same app that defines the model — which again means the other two have to call that view.
So, app1 provides the model and view, app2 and app3 use them; so they are not self-contained.
Isn't this against the philosophy?

how to force which base file is used in template

I would like to add custom view/template into the admin which I succeeded . But my issue here is that when I extends the base.html it takes the one from my project template and I would like to be able to tell django to take the one from mezzanine admin (as it is a admin page and i would like to have the same look and feel as the rest of the admin)
Any idea how to force the template resolution ?
There are no special template names in django; "base.html" is just the conventional name for the template at the top of the template inheritance tree (which is not required to have a single parent or any particular structure at all).
In terms of templating, django admin is just another django app. The first step is to figure out which template contains the style and content you want to inherit. For this task, I use django-debug-toolbar, which has a "Templates" panel which makes it very easy to figure out what content is coming from which template.
Looking at a django-debug-toolbar in the admin of a mezzanine site, you probably want to inherit from either "admin/base.html" or "admin/base_site.html" depending on how integrated your view is going to be with the admin site.

Is there a way to access custom template tags and filters in all apps of a Django project?

I have a dynamic html element that will appear on many pages in multiple apps. I'd like to resuse my custom templatetag / filter / inclusion tag code, say by putting it all in one app called utils. But when I try to load one such tag I am continually told that 'xyz' is not a registered tag library. Must be one of:...
Please help!

Django composing home pages or pages with several data sources

The site I am building includes a homepage composed of panels of summarised tabular data from applications within the Django project.
What is the recommended way of building these types of pages. In other MVC style frameworks this is usually handled by each application providing a summary view, each of these views is rendered into the panels to compose the page.
This makes a lot of sense as each sub view can then be cached individually, logic related to the particular summary is contained within the application and better follows the DRY mantra.
Is there general consensus on this?
Write template tags for each section, and assemble them in the appropriate template.

How should I setup my homepage in django?

I'm not familiar with django
conventions at all so if you do
provide advice could you be specific
Considering my homepage would contain components of articles:
In Zend, in my IndexController I would create models and populate the view with articles and data. What's a convention/structure I could use for the homepage view ( should I create a separate directory for home, dump a view.html file in it? or do I create a sub-application? ), how would you set your django structure up to accommodate this?
The basic component of a Django project is the application. Each app contains models, views, templates, template tags, and filters relevant to its portion of the project. The index view imports/uses resources from other apps to get its work done. Think of the homepage as parts brought into a whole, and put each independent part in its own application.