python - Django Admin創(chuàng)建不關(guān)聯(lián)任何model的自定義頁面
問題描述
由于Django Admin的頁面都是關(guān)聯(lián)model的,如何在Admin后臺創(chuàng)建一個頁面,不關(guān)聯(lián)任何model?
問題解答
回答1:參考文章:Django Admin創(chuàng)建不關(guān)聯(lián)任何model的自定義頁面
templatescustom_view.htmlviews.py
@staff_member_requireddef custom_view(request): #. . . create objects of MyModel . . . #. . . call their processing methods . . . #. . . store in context variable . . . r = render_to_response(’admin/myapp/custom_view.html’, context, RequestContext(request)) return HttpResponse(r)urls.py
from myapp.views import custom_viewurlpatterns = [ url(r’^admin/custom_link/$’, custom_view, name=’custom_name’), url(r’^$’, RedirectView.as_view(url=’/admin/’)), url(r’^admin/’, admin.site.urls),]
相關(guān)文章:
1. javascript - 手機點擊input時,button會被頂上去?求解決!!!2. 百度地圖api - Android 百度地圖 集成了定位,導(dǎo)航 相互的jar包有沖突?3. python - django 按日歸檔統(tǒng)計訂單求解4. 網(wǎng)頁爬蟲 - python爬蟲用BeautifulSoup爬取<s>元素并寫入字典,但某些div下沒有這一元素,導(dǎo)致自動寫入下一條,如何解決?5. javascript - vue-mint UI - icon在哪里有文檔?6. HTML5禁止img預(yù)覽該怎么解決?7. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風(fēng)格檢查怎么辦。。。8. html5 - 表單無法屏蔽自動填充 autocomplete=off9. html - 請教一個前端css問題。10. 請教一個python字符串處理的問題?
