Introduction
An error appear when there is an access attempt to a specific URL address. It is appear upon accessing a default page of a certain module or application. It is a module or application with the name of ‘org’ stands for organization. The appearance of the error exist as in the following output :
TemplateSyntaxError at /org/ Could not parse the remainder: '['structure_status']' from 'context['structure_status']' Request Method:GET Request URL:http://localhost:8000/org/ Django Version:3.2.6 Exception Type:TemplateSyntaxError Exception Value:Could not parse the remainder: '['structure_status']' from 'context['structure_status']' Exception Location:C:\app\python39\lib\site-packages\django\template\base.py, line 662, in __init__ Python Executable:C:\app\python39\python.exe Python Version:3.9.7 Python Path:['C:\\programming\\python\\django\\myproject', 'C:\\app\\python39\\python39.zip', 'C:\\app\\python39\\DLLs', 'C:\\app\\python39\\lib', 'C:\\app\\python39', 'C:\\app\\python39\\lib\\site-packages'] Server time:Thu, 21 Oct 2021 05:22:10 +0000
Actually, the error is pointing in the template which is the target of the function executed by accessing the URL address of ‘/org/’. The following is the definition of the URL address of ‘/org/’ :
from django.contrib import admin from django.urls import path, include # add this from org import views urlpatterns = [ path("", views.index, name="org"), ]
On the other hand, the function with the name index in the file views.py exist in the ‘org’ module or application has the following content :
def index(request): context = "" return render(request, "org/index.html", context)
In that case, just check the file with the name of ‘index.html’ which is the template which is being rendered as an output of the index function execution. There is a specific line which is causing the error message to appear. Those lines are in the following :
<a class="nav-link structure_status" aria-current="page" href="{{ url 'org-structure' }}" >Organization Structure</a>
Solution
Just as the explanation in the above part. The error actually appear because of the miss-typed definition of the URL address in the HTML file template above. The definition of the URL address in a HTML file template should not be in that kind of format. It will trigger an error message which is information that the parsing process of the process fail at that point. So, the error message information is “Could not parse the remainder: : ‘[‘structure_status’]’ from ‘context[‘structure_status’]’”.
The solution for the above problem is very simple. Just modify the format into the correct one. What is the correct format for declaring URL address in the HTML file template ?. The following is the modification from the above definition :
<a class="nav-link structure_status" aria-current="page" href="{% url 'org-structure' %}" >Organization Structure</a>