简体   繁体   English

更新Django contrib的最佳做法

[英]Best practice to update Django contrib

I'd like to make some changes to def login and def logout in django.contrib.auth __init.py__ . 我想在django.contrib.auth __init.py__def logindef logout进行一些更改。 Specifically I want to add a mixpanel event to user login and logout. 具体来说,我想向用户登录和注销添加一个mixpanel事件。

I know I can do this by editing the file directly, although I assume this is not recommended due to version control / etc. 我知道我可以通过直接编辑文件来做到这一点,尽管我认为由于版本控制/等原因不建议这样做。

What's the best / easiest way to override these functions cleanly? 彻底重写这些功能的最佳/最简单方法是什么?

There's no reason to change the code at all. 完全没有理由更改代码。 Both login and logout send signals ; 登录和注销都发送信号 ; you can write code that listens to those signals and create your mixpanel events. 您可以编写侦听这些信号的代码并创建您的混合面板事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM