Django Under the Impression that I'm Missiing Positional Arguements

So Django is currently under the impression that I am missing positional arguments when I'm putting together a help section for a website. This includes help articles which are sourced from the Django model.

Everything works as expected until I include the unique help article reference number into my views.py file.

Django believes that positional arguments are missing when this is simply not true. As you will see in my MRE below, there are no missing positional arguments.

The error message is as follows:

help_center_article_index() missing 1 required positional argument: 'support_article_reference'

MRE:

#utils.py
import requests, random, string
def generate_unique_number(charlimit):

    random_string = ''.join(random.choices(string.digits, k=charlimit))  # Generates a random string
    return f"{random_string}"
#models.py
from .import utils
class SupportArticles(models.Model):
    class TargetGroup(models.TextChoices):
        FOR_DEVELOPERS = 'developers','Developers'
        FOR_Clients = 'clients','Clients'
        FOR_FX_Providers = 'fx-providers','FX Providers'

    support_article_reference       =   models.CharField(max_length=50, default=utils.generate_unique_number(15), editable=False)
    support_article_title           =   models.CharField(max_length=255, verbose_name="Support Article Title")
    support_article_body            =   models.TextField(max_length=5000,verbose_name="Support Article Body")
    support_article_tags            =   models.CharField(max_length=100,default="Separate each tag category with a comma (,)", verbose_name="Support Topic Tags")
    support_article_group           =   models.CharField(max_length=15,choices=TargetGroup.choices,default=TargetGroup.FOR_Clients)
#views.py
from django.shortcuts import render, get_object_or_404
def help_center_article_index(request, group, support_article_reference):
   
   support_article_object     = SupportArticles.objects.filter(support_article_group = group, support_article_reference = support_article_reference)
   if support_article_object.exists():
      meta_property_title     = support_article_object.first().support_article_group)
   else:
      meta_property_title     = "No articles available for this group"

   context = {
      
      'meta_property_title'       : meta_property_title,
      'meta_property_description' : meta_property_description,
      'support_article_object'    : support_article_object,
      'group'                     : group,

  }
   
   return render (request, 'help_center_article_index.html', context
#urls.py
from django.urls import path
from django.shortcuts import render
from . import views

urlpatterns = [
    path('hc',views.help_center, name="help-center"),
    path('hc/<str:group>',views.help_center_article_index, name="help-center-article"),
    path('hc/<str:group>/<str:support_article_reference>',views.help_center_article, name="support_article")
]
#help_center_article_index.html
<div class="support-article-index__container">
        {% for support_article in support_article_object %}
        <a href="/hc/{{group}}/{{support_article_object.support_article_reference}}" class="support-article-index__inserted">
            <h3>{{ support_article.support_article_title | title}}</h3>
            <p>{{support_article.support_article_body}}</p>
        </a>
        {% empty %}
        <h3 style="text-align: center;">{{meta_property_title}}</h3>
        {% endfor %}
    </div>

I fail to see why Django returns this error when all positional arguments are present and correct. How would I essentially tell Django that this error message should not rear its ugly head?

Tried reading a few articles, but all here no good.

I was expecting to click on the url link, which will take me to the relavent article with the url being:

hc/<group>/<support_article_reference>

i.e.

hc/developers/123456789123

Full Traceback Message:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/support/hc/developers

Django Version: 5.0.6
Python Version: 3.12.4
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'legal',
 'careers',
 'media',
 'blog',
 'events',
 'servicestatus',
 'django_bootstrap_icons',
 'announcements',
 'support']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "C:\Users\xxx\OneDrive - xxx\xxx\.venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\OneDrive - xxx\xxx\.venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: TypeError at /support/hc/developers
Exception Value: help_center_article_index() missing 1 required positional argument: 'support_article_reference'

Solution:

#views.py
from django.shortcuts import render, get_object_or_404
def help_center_article_index(request, group):
   
   support_article_queryset    = SupportArticles.objects.filter(support_article_group = group)
   if support_article_queryset.exists():
      meta_property_title       = utils.meta_property_title("Support for "+support_article_queryset.first().support_article_group)
   else:
      meta_property_title       = "No articles available for this group"
   meta_property_description    = utils.meta_property_description("Explore our comprehensive collection of support articles tailored for software developers in the hedge fund industry. Discover best practices, technical insights, and practical guides to enhance your development process and optimize performance. Stay informed and empowered with expert knowledge and resources")
   form                         = create_and_submit_ticket(request)

   context = {
      
      'meta_property_title'         : meta_property_title,
      'meta_property_description'   : meta_property_description,
      'form'                        : form,
      'support_article_queryset'    : support_article_queryset,
      'group'                       : group,

  }
   
   return render (request, 'help_center_article_index.html', context)

The template is as follows:

#help_center_article_index.html
{% for support_article_object in support_article_queryset %}
        <a href="{{group}}/{{support_article_object.support_article_reference}}" class="support-article-index__inserted">
            <h3>{{ support_article_object.support_article_title | title}}</h3>
            <p>{{ support_article_object.support_article_body }}</p>
            <div class="support-article-index__tags-container">
                {% for article_tags in support_article_object.get_support_article_tags %}
                    <div class="support-article-index__tags">{{article_tags | title}}</div>
                {% endfor%}
            </div>
        </a>
        {% empty %}
        <h3 style="text-align: center;">{{meta_property_title}}</h3>
        {% endfor %}
Back to Top