Search code examples
djangodjango-settingsdjango-oscar

Django-Oscar - Forking nested applications


I'm having trouble forking Django-oscar apps that are a part of a sub-set of other Django-oscar apps. For the documentation/tutorial I am following along with, view here.

I have gone though and successfully forked the applications that aren't nested in others and updated my installed apps accordingly. Heres a subset of the apps to demonstrate the general pattern of the nested applications

'dashboard_folder.dashboard.apps.DashboardConfig',
'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',

However, the docs (linked above) do not clearly outline how to call the nested applications. I thought they might be forked automatically with their "parents" however, a simple test (code below) proved other-wise:

If I change 'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig', to dashboard_folder.dashboard.reports.apps.ReportsDashboardConfig',

I get the following error:

ModuleNotFoundError: No module named 'dashboard_folder.dashboard.reports'

I figured id try a few 'educated' guesses as to how to call the nested apps to fork them however all of the following unfortunately failed:

manage.py oscar_fork_app offers offers_folder
CommandError: There is no app with the label 'offers'

manage.py oscar_fork_app dashboard.offers offers_folder
CommandError: There is no app with the label 'dashboard.offers'

manage.py oscar_fork_app ReportsDashboard ReportsDashboard_folder
CommandError: There is no app with the label 'ReportsDashboard'

manage.py oscar_fork_app reportsdashboard ReportsDashboard_folder
CommandError: There is no app with the label 'reportsdashboard'

manage.py oscar_fork_app dashboard/reportsdashboard ReportsDashboard_folder
CommandError: There is no app with the label 'dashboard/reportsdashboard'

Any help would be much appreciated, I'm a couple more trys away from just emailing Django-oscar for help but maybe this question will be of help to someone else in the future!

EDIT:

Here is my dashboard app config for reference:

import oscar.apps.dashboard.apps as apps

class DashboardConfig(apps.DashboardConfig):
    name = 'dashboard_folder.dashboard'

the same general pattern is followed for all other Oscar forked applications.


Solution

  • You're right that the documentation on this isn't very clear. The first argument to oscar_fork_app is the app label for the app you want to fork. In the case of top level apps this is something like offer or catalogue, but for nested apps you need to check the apps.py for that app to see the label.

    If you take oscar.apps.dashboard.reports.apps.ReportsDashboardConfig for example, then it's app config looks like this:

    class ReportsDashboardConfig(OscarDashboardConfig):
        label = 'reports_dashboard'    # <--- this is important
    

    The label is what you need to use to fork the app. So something like:

    python manage.py oscar_fork_app reports_dashboard path/to/your_forks_directory
    

    Note also that the second argument needs to be the path to the top level of the directory in which you keep all your forked apps. The children of this directory have to match Oscar's app structure, and nested apps will be forked into the appropriate nested directory inside it.

    If you still get a ModuleNotFoundError after this, then it is most likely because the app name auto-generated by Oscar doesn't quite match your project structure. Check this name to see if it matches a module found within your project, and adjust it if it doesn't.