Skip to content

me_hotsite URL uses capturing group, passing unwanted argument to view function #851

@vjpixel

Description

@vjpixel

Description

In src/core/urls.py, the URL pattern for the me_hotsite view uses a capturing regex group (me|ME), which causes Django to pass the captured string as a positional argument to the view. The view signature accepts this via _, but this creates fragility: if the regex is ever changed to stop capturing, the view will break. Using a non-capturing group is the correct approach.

Location

File: src/core/urls.py and src/core/views/static_views.py
Branch: develop

Current Code

# urls.py
re_path(
    r"^(me|ME)\/?$",   # Capturing group — passes match to view
    me_hotsite,
    name="mitologia-extendida",
)

# static_views.py
def me_hotsite(request, _):   # Accepts the captured group via _ 
    return render(request, "core/ME/hotsite.html", {})

Problem

The regex (me|ME) captures the matched string and Django passes it as a positional argument to me_hotsite. The view accepts it silently using _, but:

  1. The captured value is never used — it's unnecessary.
  2. If the URL pattern is refactored to remove the capturing group (e.g., (?:me|ME)), the view signature (request, _) will break with a TypeError.
  3. This pattern is inconsistent with Django best practices, which recommend non-capturing groups for URL matching.

Suggested Fix

Use a non-capturing group in the URL regex and remove the extra parameter from the view:

# urls.py
re_path(
    r"^(?:me|ME)\/?$",
    me_hotsite,
    name="mitologia-extendida",
)

# static_views.py
def me_hotsite(request):
    return render(request, "core/ME/hotsite.html", {})

Severity

Low — Currently works, but fragile and inconsistent with Django best practices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architecturebugSomething isn't workingpriority: highHigh priority - should be addressed soonpriority: mediumMedium priority - standard priority

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions