Small change to User Model (not subclassing)...Bad Idea?
I know that it's a bad idea to touch the User Model directly. You should instead extend it. My issue is that I've already extended to a ce开发者_如何学编程rtain extent. I wanted users to register/authenticate with their email address rather than a username. To do so, I turned username into a hash value of their email address.
That worked out just fine. My problem now is that my admin is a mess whenever I have a User ForeignKey. The unicode method of a User model presents the username. In my case, that's not ideal. I'd much rather be able to see a first name or email so that I can manually look things up at times.
My question is, can I just change the unicode method in the User model without getting in trouble? Is this trivial enough that it won't lead to future/current breakages?
Thanks
Now that I'm rereading your question... Why not simply turn username into the email itself instead of hashing it?
精彩评论