I don't wont to bother you with a long text and will first show you the 
code. I think this should be self explanatory. If not, let me know :)

#####################

from typing import Any, Dict

from django.apps import AppConfig
from django.db.models.signals import post_save

from django.contrib.auth.models import User
from .models import Employer


class EmployerConfig(AppConfig):
    name = "employer"
    verbose_name = "Employer"

    def ready(self) -> None:
        def post_save_user(**kwargs: Dict[str, Any]) -> None:
            if kwargs['created']:
                return None

            user: User = kwargs['instance']

            if user.employer:
                return None

            employer = Employer(user=user)
            employer.save()

        post_save.connect(post_save_user, User)#####################


As you can see I want to create an employer and link them with the new created 
user. 

Running the command 

./manager.py createsuperuser --username username --email u...@user.com 
***********

shows me that I'm wrong. There is no entry in the myapp_employer table. What 
did I missend?


* Django: 2.0.X 
* app is installed 

* python: 3.6


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d0c4241-3d1a-46c9-9e52-6cc4f46a3906%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to