Hi all,

I have an application with Django with database routers. Basically I got 
the request path, split it to get subdomain name and set the database by 
this way.

I do not use default database, so I do not migrate it.

This route action It's working very well but I am still facing trouble when 
I am using post_migration signals with post_migrate signal callbacks. 

My custom command to something like above:

def define_groups_auth(sender, **kwargs):
    admin = Group()
    admin.name = "Administrator"
    admin.save(using=kwargs['using'])
    
    perm = 
Permission.objects.using(kwargs['using']).get(codename='my_permission')
    admin.permissions.add(perm)

post_migrate.connect(define_groups_auth,
                     sender=apps.get_app_config('my_application'))

When I execute ./manage.py --database=db1 for example a strange behavior 
occurs.

The Group Administrator is created but the permission tries to be added on 
default database instead db1 database.

hacking the "add" method i discover that it do not contains a "using" 
parameter. 

Does someone knows a work around to save this ManyToMany relation correctly 
on post_migrate signals?


-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/88c0f059-421f-4815-8f99-c58ced27a064%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to