How to change default django User model to fit my needs?

前端 未结 5 1733
孤独总比滥情好
孤独总比滥情好 2021-01-01 23:25

The default Django\'s User model has some fields, and validation rules, that I don\'t really need. I want to make registration as simple as possible, i.e. requi

5条回答
  •  粉色の甜心
    2021-01-02 00:03

    You face a bit of a dilemma which really has two solutions if you're committed to avoiding the profile-based customization already pointed out.

    1. Change the User model itself, per Daniel's suggestions
    2. Write a CustomUser class, subclassing User or copying its functionality.

    The latter suggestion means that you would have to implement some things that User does automatically manually, but I wonder whether that's as bad as it sounds, especially if you're at the beginning of your project. All you'd have to do is rewrite a middle-ware class and some decorators.

    Of course, I don't think this buys you anything that 1 won't get you, except that your project shouldn't break if you svn update your django. It may avoid some of the compatibility problems with other apps, but my guess is most problems will exist either way.

提交回复
热议问题