django-newsletter icon indicating copy to clipboard operation
django-newsletter copied to clipboard

django.template.exceptions.TemplateDoesNotExist: No template names provided during installation

Open ricopicone opened this issue 9 months ago • 8 comments

After following the installation instructions through step 11, the command

./manage.py submit_newsletter -v 2

Yields the following stack trace:

Traceback (most recent call last):
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/backends/django.py", line 107, in render
    return self.template.render(context)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
           ~~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/test/utils.py", line 114, in instrumented_test_render
    return self.nodelist.render(context)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/base.py", line 1008, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/base.py", line 969, in render_annotated
    return self.render(context)
           ~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/defaulttags.py", line 243, in render
    nodelist.append(node.render_annotated(context))
                    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/base.py", line 969, in render_annotated
    return self.render(context)
           ~~~~~~~~~~~^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/loader_tags.py", line 199, in render
    template = context.template.engine.select_template(template_name)
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/engine.py", line 204, in select_template
    raise TemplateDoesNotExist("No template names provided")
django.template.exceptions.TemplateDoesNotExist: No template names provided

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/ricopicone/prrparty/./manage.py", line 22, in <module>
    main()
    ~~~~^^
  File "/Users/ricopicone/prrparty/./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/newsletter/management/commands/submit_newsletter.py", line 32, in handle
    Submission.submit_queue()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/newsletter/models.py", line 664, in submit_queue
    submission.submit()
    ~~~~~~~~~~~~~~~~~^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/newsletter/models.py", line 598, in submit
    self.send_message(subscription)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/newsletter/models.py", line 635, in send_message
    self.message.html_template.render(variable_dict),
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/backends/django.py", line 109, in render
    reraise(exc, self.backend)
    ~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/ricopicone/anaconda3/envs/prrparty/lib/python3.13/site-packages/django/template/backends/django.py", line 130, in reraise
    raise new from exc
django.template.exceptions.TemplateDoesNotExist: No template names provided

Here is my TEMPLATES variable from settings.py:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / "templates"],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

I copied the template "stubs" into the /templates/newsletter directory (where / is the project root). I have checked that the BASE_DIR variable is properly set to the project root.

I'm relatively new to Django. I'm at a loss because, up to this point, the setup seems to have worked correctly. Thanks for any guidance!

ricopicone avatar Feb 16 '25 09:02 ricopicone