1

django アプリケーションをまとめる (私の最初の django/python 何でも)。application/urls.py の別のファイルにいくつかの URL パターンがあります。しかし、起動して何かに移動しようとすると、The included urlconf module 'finances.urls' from '~/Development/PFM/finances/urls.py' does not have any pattern in it が表示されます

私は別の投稿で読んだ、ここ

ビューでの逆引き参照に潜在的な問題があることを確認してください。私は一般的なクラス ベースのビューと 1 つのカスタム ビューを使用しているだけなので、どこから始めればよいかわかりません。コードは次のとおりです。

PFM/urls.py:

from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
                       url(r'^finances/', include('finances.urls')),
                       # Examples:
                       # url(r'^$', 'PFM.views.home', name='home'),
                       # url(r'^PFM/', include('PFM.foo.urls')),

                       # Uncomment the admin/doc line below to enable admin documentation:
                       # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

                       # Uncomment the next line to enable the admin:
                       url(r'^admin/', include(admin.site.urls)),
)

PFM/finances/urls.py:

from django.conf.urls import patterns, url
from finances import views

urlpatterns = patterns
('',
    url(r'^$', views.ListView.as_view(), name='index'),
    url(r'^(P<pk>\d+/$)', views.TransactionList, name='detail'),  # transaction list
    url(r'^/account/(P<pk>\d+)/$', views.AccountList.as_view(), name='detail'),  # account detail
    url('/account/create/', views.account, name='create'),  # account create
    url(r'^/account/update/(P<pk>\d+)/$', views.AccountUpdate.as_view(), name='update'),  # account update
    url(r'^/account/delete/(P<pk>\d+)/$', views.AccountDelete.as_view(), name='delete'),  # account delete
 )

Finances/models.py (必要な場合)

#views for Account
class AccountList(DetailView):
    model = Account
    object_id = Account.pk


class AccountUpdate(UpdateView):
    model = Account
    object_id = Account.pk


class AccountDelete(DeleteView):
    model = Account
    object_id = Account.pk
    post_delete_redirect = "finances/"


#create form/view for Account
def account(request):
    if request.method == 'POST':
        form = AccountForm(request.POST)
        if form.is_valid():
            #save the data?
            Account.save()
            return HttpResponseRedirect('/index.html')
        else:
            form = AccountForm()

        return render(request, 'account_create.html', {
            'form': form,
        })


#views for Transactions
class TransactionList(ListView):
    template_name = "finances/index.html"

    def get_queryset(self):
        return Transaction.objects.order_by('-due_date')

どんな助けでも大歓迎です。どうも

4

2 に答える 2