# TemplateDoesNotExist for \`forms\_widgets\` after migrating templates from app to project level

**URL:** <https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692>\
**Category:** Forms & APIs\
**Created:** [February 7, 2023, 11:16am UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692 "2023-02-07T11:16:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitagora04](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pitagora04/32/1019_2.png) [@pitagora04](https://forum.djangoproject.com/u/pitagora04)\
**Post date:** [February 7, 2023, 11:16am UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692/1 "2023-02-07T11:16:48Z")

</div>

Hello, I migrated templates from per-app level to project level. Now after the migration, everything is working except the pages where I’m using **custom checkboxes**.

Do you have any idea what is wrong ?

(As said, everything else is working so as a workaround I quickly created again templates folder inside of app and copy-pasted this single file back.)

This is the custom checkbox definition inside of my `forms.py`:

```auto
class CustomCheckboxInput(forms.CheckboxInput):
    template_name = 'myapp/forms_widgets/checkbox_custom.html'

```

And here is `TEMPLATES` from my `settings.py`:

```auto
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(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',
            ],
        },
    },
]

```

The error trace is also mentioning that the issue comes from my view function which looks like this:

```auto
def landing_page(request):
    ...
    return render(request, 'myapp/landing_page.html', context)

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 7, 2023, 12:11pm UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692/2 "2023-02-07T12:11:37Z")

</div>

Yes, that’s the way it works for custom form and widget rendering.

See the conversation at [Reusable form templates not working in Django 4.0?!](https://forum.djangoproject.com/t/reusable-form-templates-not-working-in-django-4-0/11886) along with the references at:

- [The render function for form widgets](https://docs.djangoproject.com/en/4.1/ref/forms/widgets/#django.forms.Widget.render) (uses `FORM_RENDERER`)

- [FORM\_RENDERER](https://docs.djangoproject.com/en/4.0/ref/settings/#form-renderer) (uses `DjangoTemplates` as the default)

- [DjangoTemplates](https://docs.djangoproject.com/en/4.0/ref/forms/renderers/#djangotemplates) (does _not_ use the `TEMPLATES` setting)

- [TemplatesSetting](https://docs.djangoproject.com/en/4.0/ref/forms/renderers/#templatessetting) (is an alternative for `FORM_RENDERER`)

---

<div class="post-metadata">

**Author:** ![pitagora04](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pitagora04/32/1019_2.png) [@pitagora04](https://forum.djangoproject.com/u/pitagora04)\
**Post date:** [February 7, 2023, 12:12pm UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692/3 "2023-02-07T12:12:45Z")

</div>

So you are saying I should just leave this things in the app-level templates folder ? Is that correct ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 7, 2023, 12:16pm UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692/4 "2023-02-07T12:16:09Z")

</div>

If you want to move those assets to the project level, you can. But to do so, you also need to make the appropriate settings change. It’s your choice. I’m not making a recommendation one way or the other.

It may or may not be the right choice for you - I’m not in a position to be able to answer that.

---

<div class="post-metadata">

**Author:** ![pitagora04](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/pitagora04/32/1019_2.png) [@pitagora04](https://forum.djangoproject.com/u/pitagora04)\
**Post date:** [February 7, 2023, 12:24pm UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692/5 "2023-02-07T12:24:35Z")

</div>

Yes, of course, was more asking if this would be the best practice 🙂  
Thank you!

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 7, 2023, 12:31pm UTC](https://forum.djangoproject.com/t/templatedoesnotexist-for-forms-widgets-after-migrating-templates-from-app-to-project-level/18692/6 "2023-02-07T12:31:22Z")

</div>

> [@pitagora04](#):
>
> … if this would be the best practice

So for clarity, _my_ answer would be that from _that_ perspective, there’s no “one right answer”. I can envision specific situations where each is preferable, depending upon the overall architecture of the system.
