Building a full ecommerce site part 3: overriding Oscar checkout views

I thought I'd need to override Oscar's checkout views to integrate Paypal. As it turns out, I don't have to. But, since I've already done it and figured out that it has a particular naughty quirk, I might as well publish this.

I didn't know how to override Oscar's views. So I googled, as is my wont. Turned out, I should start with its documentation on Customising Oscar.

Step 1: fork the Oscar app

In summary: Oscar is a bunch of apps, fork the app whose view you need to override, and override the view. Refer to the documentation for the full instructions before coming back here for the little surprise below.

Step 2: ModuleNotFoundError!

When I run the server, it breaks with a ModuleNotFoundError. I'd followed the documentation perfectly. I'd created a folder for the app I wanted to fork, at mezzanine_plus_oscar/oscar_forked_apps. I'd successfully run the command python manage.py oscar_fork_app checkout oscar_forked_apps. I'd edited oscar_forked_apps.checkout into the get_core_apps() function in settings.py as a list.

After a modicum of gnashing of teeth, I figured it out. When you fork an Oscar app, it creates the module in your app folder, and in that module are two files in particular: __init__.py and config.py. Their contents:

# __init__.py
default_app_config = 'oscar_forked_apps\checkout.config.CheckoutConfig'

and

# config.py
class
CheckoutConfig(config.CheckoutConfig):
name = 'oscar_forked_apps\checkout'

Notice anything funny? That's right, they use backslashes instead of dot notation. I don't know why Oscar does this. Maybe it's because I'm on Windows. I found an email thread online where another user had the same issue and he/she used Windows too. Maybe Oscar produces dot notation if you're on Linux. Idk.

Anyway, the solution is to simply replace the backslashes with dots.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required