#Dynamic settings

17 messages · Page 1 of 1 (latest)

jolly kettle
#

I'm trying to work with dynamic settings from outside apps in django.

So in my settings.py I use core_config = CoreConfig()

Then what that does is runs django.conf.settings.AUTH_USER_MODEL = self.AUTH_USER_MODEL which defaults to core.User.
I can confirm this works by printing just under.

core_config = CoreConfig()
print(settings.AUTH_USER_MODEL)

> core.User

But the issue is when I do it with this method, I get errors to do with auth.User, implying that django ISNT reading this value. This doesn't happen if i manually set AUTH_USER_MODEL = "core.User" underneath.

auth.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'auth.User.groups' clashes with reverse accessor for 'core.User.groups'.
    HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'core.User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'auth.User.user_permissions' clashes with reverse accessor for 'core.User.user_permissions'.
    HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'core.User.user_permissions'.
core.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'core.User.groups' clashes with reverse accessor for 'auth.User.groups'.
    HINT: Add or change a related_name argument to the definition for 'core.User.groups' or 'auth.User.groups'.
core.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'core.User.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'.
    HINT: Add or change a related_name argument to the definition for 'core.User.user_permissions' or 'auth.User.user_permissions'.

Any ideas how I can change django settings dynamically, and make django actually read the updated ones? Thanks :)

#

Nvm i think i'm just having a bit of a brain fart. No idea why i'm implementing this in the first place, there's not enough benefits for it to be worth implementing.

I'll just copy the values over manually and stop being lazy mona

Though if you know a solution would still like to hear, incase I come back to this in the future :)

granite veldt
#

? Are you trying to migrate to your own custom User model

jolly kettle
granite veldt
#

what setting, can you explain more

jolly kettle
#

It’s in my original message, multiple. E.g the one that made me realise it wasn’t working “AUTH_USER_MODEL”

granite veldt
#

ok, what is the error message,

jolly kettle
#

Big block on the first message, starts with auth.user.groups: (fields…

#

The issue isn’t the error displayed tho, it’s the fact Django isn’t reading the updated settings, it’s assuming we haven’t set the variables at all

granite veldt
granite veldt
jolly kettle
#

Yeah that’s it, I almost need to refresh or reinitialise it

jolly kettle
granite veldt
#

Try removing dynamic assignments of the AUTH_USER_MODEL and it should work and ensure AUTH_USER_MODEL = 'core.User'

jolly kettle
#

Just not using dynamic defaults. Just adding the settings manually in each project. And still use dynamic settings for the rest of the app that doesn’t rely on djangos inbuilt settings

limber bloom