V
V
Vladimir Kuts2022-04-18 14:26:38
Django
Vladimir Kuts, 2022-04-18 14:26:38

Registering label from code in model?

Let's say I have a django project

I'm creating a model

class CodeContext(models.Model):
     label = models.CharField('метка в коде', ...)
     ...

create a decorator
def register_code_label(label, ...):
    CodeContext.objects.get_or_create(label=label)
    ...


which I hang on some functions or methods
@register_code_label('method1', ... )
def method1():
     ...


As planned, at the start of the project, records should be created in the database with label codes, but the application crashes with AppRegistryNotReady.
What is the best way to register such labels?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question