1

I am very new to Django so this might be a basic question but I am not able to find how to implement it.

So I have an app in my Django project, lets call it player. In the apps.py I want to add some settings that are specific to this app. So the code is like:

from django.apps import AppConfig

class PlayerConfig(AppConfig):
    name = 'player'
    player_key = 'GJHGJGJJKJK'

Now I have another app named engine. This has a serializer.py in which I want to create to create a player_engine and pass the player.player_key to it.

so my serializer has a piece of code that looks like this:

from engines import player_engine

class EngineSerializer(serializers.ModelSerializer):
   class Meta:
   # some meta configuration values here
   ...

   def validate(self, data)
       player_engine = PlayerEngine(player.player_key)
       #in above method, I want to know to pass player.player_key
       ...

I know there might be better way to structure this etc, however this is a legacy Django implementation and I cannot restructure things, so I would really appreciate if anyone can point me to a solution keeping this structure intact.

Ideally I want to know if there is way app level settings can somehow be clubbed into the settings available in django's settings.py

Undefined Variable
  • 4,196
  • 10
  • 40
  • 69

1 Answers1

0

you can use django-zero-settings, which may help you in some cases. checkout this answer https://stackoverflow.com/a/68916822/6484831

aasmpro
  • 554
  • 9
  • 21