My first open-source contribution
@@ -257,6 +257,13 @@ def construct_relative_path( return relative_name if current_template_name is None: # Unknown origin (e.g. Template('...').render(Context({...})). raise TemplateSyntaxError( f"The relative path {relative_name} cannot be evaluated due to " "an unknown template origin." )
I was working on another Django ticket when I ran into an error that was technically true but practically useless. That annoyance turned into my first upstream patch.
The bug I stumbled on
A template created directly in code can have an unknown origin. If that template used a relative path like ./base.html, Django raised an AttributeError that pointed away from the actual problem.
The real issue was that the template had no location to resolve the path against, and that was the error people needed to see. I traced the cause, reported it as ticket #36271, and took it on.
Writing the fix and the tests
Setting up Django’s contributor workflow was its own lesson. The test suite is large, and the project has standards for good reasons. Once it ran locally, I found the issue in django/template/loader_tags.py.
The code change was short: detect the missing template name and raise a clear TemplateSyntaxError. The important part was the regression test, which proves the new behaviour and protects it from being broken later.
Review is part of the work
Sarah Boyce, a Django Fellow, reviewed the pull request and asked for a change to the test structure. I updated it, the checks passed, and on 24 March 2025 it merged as django/django #19295.
Open source taught me that a small fix can still demand careful reading, test discipline and good collaboration. The first contribution doesn’t have to be huge. It has to make something clearer or better.