Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard templates doesn't load after app override #108

Open
filip-spaldon opened this issue Aug 25, 2020 · 2 comments
Open

Dashboard templates doesn't load after app override #108

filip-spaldon opened this issue Aug 25, 2020 · 2 comments

Comments

@filip-spaldon
Copy link

filip-spaldon commented Aug 25, 2020

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

@solarissmoke
Copy link
Member

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.

@dd
Copy link

dd commented Feb 8, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants