Question

I saw a couple of ways extending user information of users and decided to adopt the model inheritance method.

for instance, I have :

class Parent(User):
    contact_means = models.IntegerField()
    is_staff = False 
    objects = userManager()

Now it is done, I've downloaded django_registration to help me out with sending emails to new users. The thing is, instead of using registration forms to register new user, I want to to invoke the email sending/acitvation capability of django_registration. So my workflow is:

1. add new Parent object in admin page.
2. send email

My problem is, the django-registration creates a new registration profile together with a new user in the user table. how do I tweak this such that I am able to add the user entry into the custom user table.

I have tried to create a

modelAdmin

and alter the save_model method to launch the create_inactive_user from django_registration, however I do not how to save the user object generated from django_registration into my Parent table when I have using model inheritance and I do not have a Foreign key attribute in my parent model.

Was it helpful?

Solution

It's probably something like:

p = Parent()
p.user_ptr = user
p.contact_means = ...
p.save()

(Django creates the foreign key for you when doing model inheritance, plus the attribute ending in _ptr)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top