Luis Silva
Luis Silva

Reputation: 173

Create sub-folders inside app Templates in Django

I've created a sub-folder name Housekeeping inside Properties in my templates folder as can be seen in the picture below. I've done it to better organize things.

Project template folder

Problem

The situation here is that my UpdateView looks for the template inside the app folder Properties and not inside Housekeeping. This ends up showing me this error:

TemplateDoesNotExist at /properties/1/housekeeping/housekeeper/edit properties/propertyhousekeeper_update_form.html

Which in fact makes sense.. If I move the file to inside the properties folder it works fine.

For reference:

#views.py
class HousekeeperUpdateView(UpdateView):
    # login_url = '/login/'
    redirect_field_name = 'properties/housekeeping/housekeeping.html'
    template_name_suffix = '_update_form'
    form_class = HousekeeperAddForm

    model = PropertyHousekeeper

Is there a way to do this? Or can it be done?

Upvotes: 1

Views: 546

Answers (1)

Dipen Dadhaniya
Dipen Dadhaniya

Reputation: 4630

Try setting template_name = 'properties/housekeeping/housekeeping.html'. Also remove redirect_field_name and template_name_suffix.

Upvotes: 1

Related Questions