跳转到主要内容

为Oscar添加商店功能的扩展

项目描述

https://github.com/django-oscar/django-oscar-stores/workflows/Tests/badge.svg Coverage

这是一个为django-oscar添加商店支持的扩展。它提供

  • 使用谷歌地图进行地理编码的商店定位页面。它还支持使用浏览器的位置显示最近的商店。

  • 存储详情页面,包括营业时间

  • 店铺分组

  • 管理店铺的仪表板

它具有高度的扩展性,可以作为在Oscar网站上构建复杂店铺功能的基础。

屏幕截图

面向客户的页面

https://github.com/django-oscar/django-oscar-stores/raw/master/docs/images/locator.thumb.png https://github.com/django-oscar/django-oscar-stores/raw/master/docs/images/detail.thumb.png

仪表板页面

https://github.com/django-oscar/django-oscar-stores/raw/master/docs/images/dashboard-list.thumb.png https://github.com/django-oscar/django-oscar-stores/raw/master/docs/images/dashboard-detail.thumb.png

依赖项

GeoDjango 被使用,因此需要一个空间数据库。我们推荐使用PostGIS。Django的文档中包含了一些安装说明,尽管它以其复杂性而闻名。

Spatialite是另一种选择,尽管设置起来可能会有点复杂。在Ubuntu上,你可以这样做

$ sudo apt-get install spatialite-bin libspatialite3 libgeos++-dev libgdal-dev libproj0

还需要Python包 pysqlite,尽管它默认不支持C扩展。为了解决这个问题,有两种选择

  1. 下载该包,编辑 setup.cfg 以启用C扩展并安装

$ pip install pysqlite --no-install
$ vim $VIRTUAL_ENV/build/pysqlite/setup.cfg
$ pip install pysqlite
  1. 使用自定义分支

$ pip install git+git://github.com/tinio/pysqlite.git@extension-enabled#egg=pysqlite

安装

首先,确保你正在使用空间数据库并且已安装django-oscar。

安装包

$ pip install django-oscar-stores

然后将 storesstores.dashboard 添加到 INSTALLED_APPS

现在更新你的根 urls.py

from django.views.i18n import JavaScriptCatalog

urls = [
    # basic configuration for Oscar
    path('', include(apps.get_app_config('oscar').urls[0])),

    # adds URLs for the dashboard store manager
    path('dashboard/stores/', apps.get_app_config('stores_dashboard').urls),

    # adds URLs for overview and detail pages
    path('stores/', apps.get_app_config('stores').urls),

    # adds internationalization URLs
    path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
]

设置

  • GOOGLE_MAPS_API_KEY (默认:未设置)。用于与地图和地理编码API一起使用的地图API密钥。你必须提供此密钥。

  • STORES_GEOGRAPHIC_SRID (默认: 3577)。这用于距离计算。有关更多详细信息,请参阅http://spatialreference.org

  • STORES_GEODETIC_SRID (默认: 4326)。

  • STORES_MAX_SEARCH_DISTANCE (默认:无)。这通过距离过滤查询中的店铺。可以使用距离对象设置单位

from django.contrib.gis.measure import D
# Maximal distance of 150 miles
STORES_MAX_SEARCH_DISTANCE = D(mi=150)
# Maximal distance of 150 kilometers
STORES_MAX_SEARCH_DISTANCE = D(km=150)

贡献

在存储库中有一个沙盒网站,这是一个使用stores扩展的示例Oscar项目。你可以使用以下方法设置此项目

$ make sandbox

这将加载一个固定文件,该文件提供了一个超级用户来测试仪表板

email: superuser@example.com
username: superuser
password: testing

使用以下命令运行测试

$ pytest

许可证

django-oscar-stores 在许可的 新BSD许可证 下发布。

项目详情


下载文件

下载适合您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分发

django-oscar-stores-3.0.2.tar.gz (24.1 kB 查看哈希值)

上传时间

构建分发

django_oscar_stores-3.0.2-py3-none-any.whl (37.1 kB 查看哈希值)

上传时间: Python 3

支持者