Skip to content Skip to sidebar Skip to footer

Django User With Email As Pk - Hack Possible?

I read a lot about the topic, but didn't find anything that sounded as satisfactory as an idea of mine, and also don't see why it would raise problems. So if you can give it a look

Solution 1:

Firstly, your title doesn't seem to have anything to do with your question; which is a good thing, because using email as a primary key is an incredibly bad idea. People change email addresses all the time, but a PK must stay constant.

Secondly, you should absolutely not copy the contrib.auth code. Apart from anything else, this wouldn't solve your problems with the migrations, it would just make them worse.

A much better solution would be add a pre-save signal on User, which you can do from anywhere in your project (ideally in an AppConfig ready method). And you don't need to change the model in order to make email uneditable; you should do that in the forms that use that model.

Post a Comment for "Django User With Email As Pk - Hack Possible?"