django admin 中的所有内容在哪里?
我想弄清楚 django admin 中的所有内容都在哪里。由于我目前正在尝试大力修改行为,因此也许参考会有所帮助。例如,ModelAdmin 位于哪里,我在 C:\Python26\Lib\site-packages\django\contrib\admin 中找不到它。我需要它,因为我想看看它是如何实现的,以便我可以自信地覆盖。我需要这样做的部分原因是这个页面: http ://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-methods,例如,我想覆盖 ModelAdmin.add_view,但我找不到原始来源那。我还想查看管理员的 url 路由文件,这样我就可以轻松找出哪个 url 对应于哪个模板等。
非常感谢您的指点!
I would like to figure out where everything is in django admin. Since i am currently trying to modify the behavior rather heavily right now, so perhaps a reference would be helpful. For example, where is ModelAdmin located, i cannot find it anywhere in C:\Python26\Lib\site-packages\django\contrib\admin. I need that because i would like to look at how it is implemented so that i can override with confidence. I need to do that in part because of this page: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-methods, for example, i would like to override ModelAdmin.add_view, but i can't find the original source for that. As well as i would like to see the url routing file for admin, so i can easily figure out which url corresponding to which template etc.
Thanks a lot for any pointers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的跨文件文本搜索应该足以向您显示所有内容的位置。
如果你不能做到这一点,你应该能够遵循导入 - 你从 django.contrib.admin 导入 ModelAdmin,所以打开该目录中的 __init__.py 文件,并看到那里ModelAdmin 本身是从 django.contrib.admin.options 导入的。打开该文件,您将看到代码。
A simple cross-file text search should be enough to show you where everything is.
If you can't make that work, you should be able to follow the imports - you import ModelAdmin from django.contrib.admin, so open the
__init__.py
file inside that directory, and see that there ModelAdmin is itself imported fromdjango.contrib.admin.options
. Open that file, and you'll see the code.