django-oscar-accounts icon indicating copy to clipboard operation
django-oscar-accounts copied to clipboard

Dashboard templates doesn't load after app override

Open filip-spaldon opened this issue 4 years ago • 2 comments

I override oscar_accounts app, because I want customize models, but dashboard templates doesn't load after that. Is it possible somehow reuse dashboard templates from original oscar_accounts app? Thank you!

my_project.oscar_accounts.apps.py

from oscar_accounts import apps

class AccountsConfig(apps.AccountsConfig):

    name = 'my_project.oscar_accounts'


my_project.oscar_accounts.models.py

from oscar_accounts import abstract_models


class AccountType(abstract_models.AccountType):
    pass



class Account(abstract_models.Account):
    pass


class Transfer(abstract_models.Transfer):
    pass


class Transaction(abstract_models.Transaction):
    pass


class IPAddressRecord(abstract_models.IPAddressRecord):
    pass

settings.py

...
# Oscar Accounts
'my_project.oscar_accounts.apps.AccountsConfig',
'oscar_accounts.dashboard.apps.AccountsDashboardConfig',
'oscar_accounts.api.apps.AccountsAPIConfig',
...

Error:

TemplateDoesNotExist at /en/dashboard/accounts/
accounts/dashboard/account_list.html, oscar_accounts/account_list.html

Request Method: GET
Request URL: http://localhost:8000/en/dashboard/accounts/
Django Version: 3.0.8
Exception Type: TemplateDoesNotExist
Exception Value: accounts/dashboard/account_list.html, oscar_accounts/account_list.html
Exception Location: ../site-packages/django/template/loader.py in select_template, line 47

filip-spaldon avatar Aug 25 '20 13:08 filip-spaldon

Django's app template loader will not work in this case - because the core accounts app is no longer installed. What you can do is add the path to the core accounts template folder in your TEMPLATES['DIRS'] setting.

solarissmoke avatar Nov 10 '20 04:11 solarissmoke

It seems that this is not the best solution for production, depending on the environment, the path to the folder may be different, and it will need to be specified for each case separately

Maybe the best way would be to spread the templates and models to different applications? for example, leave templates in oscar_accounts and transfer models to oscar_accounts.core, or vice versa, then the templates will work and the application with models can be forked using oscar_fork_app

dd avatar Feb 08 '23 16:02 dd