I'm trying to get the hang of Django URL namespaces. But I can't find any examples or documentation.
Here is what I have tried.
foo.urls
from django.urls import path, include
from Foo.Views import FooView
app_name ="Foo"
urlpatterns = [
path('', referansView.referans_listele , name="foo"),
path('create/', olusturView.referans_olustur, name="foo_create"),
]
foo.html
<a class="btn btn-success"
href="{% url '{{foo}}:{{foo_create}}' %}?r=Foo: {{request.resolver_match.url_name}}">
fooview.py
from django.shortcuts import render
from Foo.models import FooModels
def foo_create(request):
result ={"Foo":"Foo"}
return render(request,"referanslar.html", result)
What I want is to be able to browse to /foo/X
fooeverywhere has made your example very confusing. It looks as if you want{% url 'Foo:foo_create' %}(Foowith a capitalFbecause you haveapp_name = 'Foo').fooorfoo_createin the template context, only'Foo'. Perhaps you can use theaddfilter, e.g.{% url foo|add:':'|add:foo_create %}.{% url Foo|add:':'|add:fooView %}. However, it might be simpler to pass {'fooView': 'Foo:fooView'}` to the template and do{% url fooView %}. Or you could pass the reversed url to the template with{'foourl': reverse('Foo:fooView')}, then use{{ foourl }}.