[Answer]-CRUD users in django , outside of django Admin

1πŸ‘

βœ…

It looks normal that I’m deleting UserProfile rather than User. But I intended it to a proxy to actual User

Why not delete the User directly? By default, Django will CASCADE DELETE to get rid of the UserProfile as well.

Generally speaking, should I reference each models to User or UserProfile

I think this is more a question of personal preference, but I usually tie to User directly as it saves a step when getting to the object you want (you don’t need to do user.get_profile().student and can call user.student instead). It also makes more sense to me anyway: the student is a property of the user, not the user’s profile.

πŸ‘€Tom

Leave a comment