Home > Back-end >  Django, store internal link in database
Django, store internal link in database

Time:10-02

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

CodePudding user response:

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

  • Related