django-admin startproject Store
cd Store
python manage.py migrate
python manage.py createsuperuser
TEMPLATES = [
{
'DIRS': [BASE_DIR / 'templates',],
...
},
]
STATIC_ROOT = BASE_DIR / 'staticfiles'
MEDIA_ROOT = BASE_DIR / 'media'
MEDIA_URL = '/media/'
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
pip install django-oscar==3.2.4
pip install pycountry
from oscar.defaults import *
INSTALLED_APPS = [
...
'django.contrib.sites',
'django.contrib.flatpages',
'oscar.config.Shop',
'oscar.apps.analytics.apps.AnalyticsConfig',
'oscar.apps.checkout.apps.CheckoutConfig',
'oscar.apps.address.apps.AddressConfig',
'oscar.apps.shipping.apps.ShippingConfig',
'oscar.apps.catalogue.apps.CatalogueConfig',
'oscar.apps.catalogue.reviews.apps.CatalogueReviewsConfig',
'oscar.apps.communication.apps.CommunicationConfig',
'oscar.apps.partner.apps.PartnerConfig',
'oscar.apps.basket.apps.BasketConfig',
'oscar.apps.payment.apps.PaymentConfig',
'oscar.apps.offer.apps.OfferConfig',
'oscar.apps.order.apps.OrderConfig',
'oscar.apps.customer.apps.CustomerConfig',
'oscar.apps.search.apps.SearchConfig',
'oscar.apps.voucher.apps.VoucherConfig',
'oscar.apps.wishlists.apps.WishlistsConfig',
'oscar.apps.dashboard.apps.DashboardConfig',
'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
'oscar.apps.dashboard.users.apps.UsersDashboardConfig',
'oscar.apps.dashboard.orders.apps.OrdersDashboardConfig',
'oscar.apps.dashboard.catalogue.apps.CatalogueDashboardConfig',
'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',
'oscar.apps.dashboard.partners.apps.PartnersDashboardConfig',
'oscar.apps.dashboard.pages.apps.PagesDashboardConfig',
'oscar.apps.dashboard.ranges.apps.RangesDashboardConfig',
'oscar.apps.dashboard.reviews.apps.ReviewsDashboardConfig',
'oscar.apps.dashboard.vouchers.apps.VouchersDashboardConfig',
'oscar.apps.dashboard.communications.apps.CommunicationsDashboardConfig',
'oscar.apps.dashboard.shipping.apps.ShippingDashboardConfig',
# 3rd-party apps that oscar depends on
'widget_tweaks',
'haystack',
'treebeard',
'sorl.thumbnail', # Default thumbnail backend, can be replaced
'django_tables2',
]
SITE_ID = 1
MIDDLEWARE = (
...
'oscar.apps.basket.middleware.BasketMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)
TEMPLATES = [
{
...
'OPTIONS': {
'context_processors': [
...
'oscar.apps.search.context_processors.search_form',
'oscar.apps.checkout.context_processors.checkout',
'oscar.apps.communication.notifications.context_processors.notifications',
'oscar.core.context_processors.metadata',
],
},
},
]
AUTHENTICATION_BACKENDS = (
'oscar.apps.customer.auth_backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
}
THUMBNAIL_FORMAT = 'PNG'
EMAIL_BACKEND = "django.core.mail.backends.dummy.EmailBackend"
from django.apps import apps
from django.conf import settings
urlpatterns = [
...
path('i18n/', include('django.conf.urls.i18n')),
path('', include(apps.get_app_config('oscar').urls[0])),
]
python manage.py makemigrations
python manage.py migrate
python manage.py oscar_populate_countries
python manage.py runserver
Download Django-Oscar
Move
django-oscar-master\src\oscar\static_src\oscar\img\image_not_found.jpg
to
Store/media/
Move
django-oscar-master\src\oscar\templates\
to
Store/
Replace
{% render_product product.object %}
with
{% render_product product %}
Dashboard
Access through: http://localhost:8000/dashboard/
Login with superuser
Creating a Partner ≡ Dashboard → Fulfilment → Partners
Example: BookRetailer
Creating a Product Type ≡ Dashboard → Catalog → Product Types
Example: Books
Creating a Category ≡ Dashboard → Catalog → Categories
Example: Engineering Books
Creating a Product ≡ Dashboard → Catalog → Products
Example: The C Programming Language
Partners, Product Types and Categories are required fields to create products therefore they must be created before the product is created.
Download the repository:
https://github.com/django-oscar/django-oscar-paypal
There is a folder paypal inside.
Copy folder paypal to our project folder root (Store).
pip install paypalhttp
pip install paypal-checkout-serversdk
pip install django-localflavor
INSTALLED_APPS = [
...
'paypal',
]
PAYPAL_SANDBOX_MODE = True
PAYPAL_CALLBACK_HTTPS = False
PAYPAL_API_VERSION = '119'
PAYPAL_API_USERNAME = 'sdk-three_api1.sdk.com'
PAYPAL_API_PASSWORD = 'QFZCWN5HZM8VBG7Q'
PAYPAL_API_SIGNATURE = 'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU'
PAYPAL_BRAND_NAME = "YAHIBA"
PAYPAL_BUYER_PAYS_ON_PAYPAL=True
urlpatterns = [
...
path('checkout/paypal/', include('paypal.express.urls')),
]
python manage.py makemigrations
python manage.py migrate
...
<li><a href="https://github.com/django-oscar/django-oscar-paypal">
{% if anon_checkout_allowed or request.user.is_authenticated %}
<a href="{% url 'paypal-redirect' %}">
<img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif">
</a>
{% endif %}
</li>
...
OSCAR_SHOP_NAME = "Book Store"
OSCAR_SHOP_TAGLINE = "All kinds of books!"
OSCAR_DEFAULT_CURRENCY = 'EUR'
OSCAR_ALLOW_ANON_CHECKOUT = True
Django 4.2 Django Oscar 3.2.4
20 March 2025
|
Last Updated: 03 Dec. 2025
|
jaimedcsilva Related