URL Concatenation Issue

101 views
Skip to first unread message

johnre...@gmail.com

unread,
May 30, 2018, 9:14:20 PM5/30/18
to Django users
Hello,

I'm debugging an issue that I'm having with my URL patterns. In my HTML I have an "about me" page that is linking to an about.html file in my templates/blog/ directory. When I load the homepage and click on the "about me" link than "domain.com/about/" loads, which matches the URL pattern in my blog/urls.py file, and the page renders perfectly fine.

However, while on the "about me" page I can't link to any other page because the URL pattern starts to concatenate instead of overwrite (if that makes any sense). For example, if I click on "about me" again than Django tries to load domain.com/about/about and I get an error.

I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to programming by the way (to include Python, Django, HTML/CSS).

Spence Patrick

unread,
May 30, 2018, 10:24:05 PM5/30/18
to django...@googlegroups.com
Is your link tag href="./about" or href="/about/"

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1213b3f9-c74b-4af9-b585-61f2423720f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aditya Singh

unread,
May 30, 2018, 10:43:48 PM5/30/18
to django...@googlegroups.com
For this you have provide an app inside your urls and refer to it as home:about where home is the app name and about is the page to be rendered. Also provide namespace in the urls so that the url is linked to the app name.
Kind Regards,
Aditya

John Regis, Jr.

unread,
May 31, 2018, 6:15:48 PM5/31/18
to django...@googlegroups.com
I have href="about/". Also tried href="./about/" and same result.

On Wed, May 30, 2018 at 10:23 PM, Spence Patrick <spence.d...@gmail.com> wrote:
Is your link tag href="./about" or href="/about/"

On Wed, May 30, 2018, 19:14 <johnre...@gmail.com> wrote:
Hello,

I'm debugging an issue that I'm having with my URL patterns. In my HTML I have an "about me" page that is linking to an about.html file in my templates/blog/ directory. When I load the homepage and click on the "about me" link than "domain.com/about/" loads, which matches the URL pattern in my blog/urls.py file, and the page renders perfectly fine.

However, while on the "about me" page I can't link to any other page because the URL pattern starts to concatenate instead of overwrite (if that makes any sense). For example, if I click on "about me" again than Django tries to load domain.com/about/about and I get an error.

I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to programming by the way (to include Python, Django, HTML/CSS).

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/UB1iqDXjy3g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

John Regis, Jr.

unread,
May 31, 2018, 6:18:25 PM5/31/18
to django...@googlegroups.com
In blog/urls.py I have my my homepage mapped to my view.index. Are you saying to also map view.about as well? Also, when you say namespace are you saying to create a dictionary and include my index (blog) and about pages as values? New to Python so I'm trying to still wrap my head around the utilization of python dictionaries.

On Wed, May 30, 2018 at 10:42 PM, Aditya Singh <adityasi...@gmail.com> wrote:
For this you have provide an app inside your urls and refer to it as home:about where home is the app name and about is the page to be rendered. Also provide namespace in the urls so that the url is linked to the app name.
Kind Regards,
Aditya

On Thu, May 31, 2018, 7:54 AM Spence Patrick <spence.d...@gmail.com> wrote:
Is your link tag href="./about" or href="/about/"

On Wed, May 30, 2018, 19:14 <johnre...@gmail.com> wrote:
Hello,

I'm debugging an issue that I'm having with my URL patterns. In my HTML I have an "about me" page that is linking to an about.html file in my templates/blog/ directory. When I load the homepage and click on the "about me" link than "domain.com/about/" loads, which matches the URL pattern in my blog/urls.py file, and the page renders perfectly fine.

However, while on the "about me" page I can't link to any other page because the URL pattern starts to concatenate instead of overwrite (if that makes any sense). For example, if I click on "about me" again than Django tries to load domain.com/about/about and I get an error.

I'm using a python 3.5.2 venv and I'm running Django 2.0.5. I'm new to programming by the way (to include Python, Django, HTML/CSS).

--
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.

--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/UB1iqDXjy3g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Melvyn Sopacua

unread,
Jun 1, 2018, 6:22:48 AM6/1/18
to django...@googlegroups.com

On vrijdag 1 juni 2018 00:14:32 CEST John Regis, Jr. wrote:

 

> I have *href="about/"*. Also tried *href="./about/"* and same result.

 

Please revisit this section in the tutorial. If you haven't done the tutorial at all, please do it before trying a project on your own. You are missing a few fundamentals the tutorial touches upon, such as the basics of URLs and URL paths.

--

Melvyn Sopacua

Reply all
Reply to author
Forward
0 new messages