-1

Update 2

I think my confusion came because I did not account for the fact that my project django_project3 is the default project.

Update

I looked at Using {% url ??? %} in django templates but it didn't fully answer my question.

Original Post

I tried to Google my question but ended up with 1000s of pages of Python theory and no straight answer.

I have a project called Blog and in it there is a file called base.html. And it contains the line of code <a class="nav-item nav-link" href="{% url 'profile' %}">Home</a>.

But in Blogs urls.py file there is no URL pattern called profile.

Whereas in my project django_project3, in the urls.py file there is a URL pattern called profile.

Does the percentage sign get the code to look in every urls.py file?

enter image description here

  • Does this answer your question? [Using {% url ??? %} in django templates](https://stackoverflow.com/questions/4599423/using-url-in-django-templates) – metatoaster Jan 22 '20 at 04:45
  • I can see that post covers a similar issue to my own. But no that post doesn't fully answer my question. – Ross Symonds Jan 22 '20 at 04:50
  • 1
    This is a template tag for rendering URLs. How it works is described fairly thoroughly [in the documentation](https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#url). – solarissmoke Jan 22 '20 at 04:51

1 Answers1

1

url is a built-in template tag to avoid hard-coding.

{% %} is template render syntax

renqHIT
  • 174
  • 1
  • 10