I know I'm doing things the wrong way so the solution to this problem is
to learn how to do it correctly if anyone can help please.
WARNINGS:
?: (urls.W005) URL namespace 'admin' isn't unique. You may not be able
to reverse all URLs in this namespace
In my home page template I have ...
{% if channel %}
{% include channel %}
{% endif %}
... where 'channel' is a short paragraph (one of six) aimed at six
different kinds of customers for the site. They are plain html with no
templating at all. The home page has a top menu of links one of which
has six sub-menu links each one pointing to a different 'channel'.
This worked well at inserting the selected paragraph. But it also picked
up random stuff and generated 404 errors. So I made the view only serve
the nominated six paras. Unfortunately 'admin' generated a 404 as well.
The solution was to rearrange url_conf as follows ...
urlpatterns = [
...
re_path(r"^admin/", adminurls),
# need this "admin" to gazump <channel> ... is a bit fragile
path("admin", adminurls),
path("<channel>", company_views.channel, name="channel"),
]
Here is the view ...
def channel(request, channel):
if channel in [
"formulators",
"regaffairs",
"cosmetics",
"coatings",
"polymers",
"consultants",
"disruption",
]:
templ = "home.html"
cont = {
"title": settings.BRAND,
"privacy": "/privacy",
"security": "/security",
"licence": "/licence",
"about": "/about",
"contact": "/contact",
"support": "/support",
"manager": ismanager(request),
}
cont["channel"] = f"{channel}.html"
else:
templ = "404.html"
cont = {}
return render(request=request, template_name=templ, context=cont)
Many thanks for advice
Cheers
Mike
--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/447e7c8d-355b-1c39-a3d6-e40183c9e0a8%40dewhirst.com.au.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment