0

アプリにいくつかの URL/ビューを追加したいと考えていますdashboard。そこで、 を使用してアプリをフォークしましたoscar_fork_app。フォークされたapp フォルダーapp.pyにファイルを作成しました。dashboardまた、アプリ内にapp.pyサブアプリを追加しました。これに続い。 じぶんのcataloguedashboard
#dashboard/app.py

from oscar.apps.dashboard.app import DashboardApplication as CoreDashboardApplication


class DashboardApplication(CoreDashboardApplication):
    name = 'dashboard'
    permissions_map = {
        'index': (['is_staff'], ['partner.dashboard_access']),
    }

    index_view = get_class('dashboard.views', 'IndexView')
    catalogue_app = get_class('dashboard.catalogue.app', 'application')


    def get_urls(self):
        urls = [
            url(r'^catalogue/', include(self.catalogue_app.urls)),
        ]
        return self.post_process_urls(urls)


application = DashboardApplication()

じぶんの#dashboard/catalogue/app.py

from oscar.apps.dashboard.catalogue.app import CatalogueApplication as CoreCatalogueApplication


class CatalogueApplication(CoreCatalogueApplication):
    name = None
    csv_upload_view = get_class('dashboard.catalogue.views',
                                 'CSVUpload')

    def get_urls(self):
        urls = [
            url(r'^csvupload/$',
                self.csv_upload_view.as_view(),
                name='csvupload'),
        ]
        return self.post_process_urls(urls)


application = CatalogueApplication()

私がヒットしたとき、/dashboardそれは言います

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/dashboard/
Using the URLconf defined in teashop.urls, Django tried these URL patterns, in this order:
^i18n/
^admin/
^accounts/reviews/$ [name='review-list']
^accounts/subscriptions/$ [name='subscriptions']
^accounts/storecredit/$ [name='storecredit']
^catalogue/
^basket/
^checkout/
^accounts/
^search/
^dashboard/ ^catalogue/
^offers/
The current URL, dashboard/, didn't match any of these.

oscar.apps.dashboard.app のすべての URL を forked_app にコピー アンド ペーストする必要がありますか? 正しい方法で拡張する方法は何ですか?

4

1 に答える 1

1

親クラスのすべての URL を追加する必要がありました。

class DashboardApplication(CoreDashboardApplication):
    ...
    catalogue_app = get_class('dashboard.catalogue.app', 'application')


    def get_urls(self):
        urls = super(DashboardApplication, self).get_urls()  
        urls += [
            url(r'^catalogue/', include(self.catalogue_app.urls)),
        ]
        return self.post_process_urls(urls)

他の app.py についても同様

class CatalogueApplication(CoreCatalogueApplication):
    name = None
    csv_upload_view = get_class('dashboard.catalogue.views',
                                 'CSVUpload')

    def get_urls(self):
        urls = super(CatalogueApplication, self).get_urls()
        urls += [
            url(r'^csvupload/$',
                self.csv_upload_view.as_view(),
                name='csvupload'),
        ]
        return self.post_process_urls(urls)


application = CatalogueApplication()
于 2015-09-18T05:07:09.260 に答える