Search code examples
pythondjangodjango-oscar

How to properly fork an app in Django Oscar 2.0


I am attempting to make a minor modification to the mixin.py file in the checkout app (specifically, attempting to comment out the line within OrderPlacementMixin that automatically sends an email after a successful order as described in this stackoverflow post). However, I can't seem to get oscar to recognize my fork. I have already followed the steps as enumerated here, with no luck.

Here are the steps I've done

1) Create a custom_apps directory in the project root, and an empty __init__.py file inside it

2) Run manage.py oscar_fork_app checkout custom_apps - this command generates the checkout directory as well as multiple files. Here's the terminal output. I've also attached a photo of the directory structure

(venv) work@pc:~/MyProjects/oscar2_project/frobshop$ ./manage.py oscar_fork_app checkout custom_apps
Creating package custom_apps/checkout
Creating app config
Creating models.py
Replace the entry 'oscar.apps.checkout.apps.CheckoutConfig' with 'custom_apps.checkout.apps.CheckoutConfig' in INSTALLED_APPS

enter image description here

3) I commented out 'oscar.apps.checkout' in my INSTALLED_APPS in my settings.py, and I inserted 'custom_apps.checkout' at the end of the INSTALLED_APPS` list

4) I run python manage.py runserver, to which I get the exception oscar.core.exceptions.AppNotFoundError: Couldn't find an Oscar app to import checkout.calculators from. At this point, I haven't even tried to modify any code yet, however, my fork already refuses to run.

I would appreciate it if anyone can point out any steps I'm missing. I understand that its possible to copy all the contents of oscar.apps.checkout, however I would like to avoid doing so.


Solution

  • Oscar 2.0 app configs are extended Django apps configs.

    It looks like your forked app module does not have a default_app_config specified, so you should either add one, or in INSTALLED_APPS use the dotted path to its app config class: custom_apps.checkout.apps.CheckoutConfig instead of custom_apps.checkout.