Quantcast
Viewing all articles
Browse latest Browse all 44

Delete field from standard Django model

NOTE: this was asked before AbstractUser existed, which is probably what you'd want to use these days.

Basically I would like to delete the default email field from the default Django User class...

class MyUser(User):    field = models.CharField(max_length = 10)    a = 'hello'    def b(self):        print 'world'del User.emaildel MyUser.emaildel Myuser.field

All these give AttributeError. Deleting methods or attributes in the following way though works fine:

del MyUser.adel MyUser.b

So I'm curious why this doesn't work; what type of things are these model fields?

Another thing I tried was overwriting email by creating an email = None in MyUser but that didn't work either (and would be slightly more ugly).

Thanks in advance!

P.s. If you are wondering why; it's more for curiousity than that it is really necessary for the application... But I think it's good not to have unused columns in database.P.p.s. I don't want to change the Django files to manually remove 'email' from user.

EDIT: Follow-up question here (for those who want to do the same thing) Before syncdb, delete field from standard Django model


Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>