Sandro Basharuli
Sandro Basharuli

Reputation: 35

Django, store internal link in database

I want to save the internal URL (you can see in the picture below, the last input), and then access it from the code, so I will be able to change it from the admin panel, but it shows error like in image 2

enter image description here

enter image description here

Upvotes: 0

Views: 220

Answers (1)

Maxim Danilov
Maxim Danilov

Reputation: 3350

you save django template of your url and not an url itself:

{% url 'main-page' %}  # this is template

/main-page/  # this is relative url

in your case you can simply save the relative part of url. or you should before use 'url' in render made render_to_string. more here: https://docs.djangoproject.com/en/4.1/topics/templates/#django.template.loader.render_to_string

Upvotes: 1

Related Questions