Django does not run my update_workers.py and gives the error ModuleNotFound

Hello, I need to solve this problem
When running python “update.workers.py” the error “ModuleNotFoundError > No module named ‘core’” is displayed
The name of my app is ‘core’
inside update.workers.py there is the following
//code//
from core.models import Workers
##To delete all workers
Workers.objects.all().delete()
##To create a worker
W=Workers.objects.create(code=‘0001’, name=‘Marcelino’)
W.save()
//end of code//
inside my models.py
//code//
from django.db import models
class Workers(models.Model):
code= models.PositiveIntegerField(primary_key=True, serialize=False,verbose_name=‘code’)
name= models.CharField(max_length=252, verbose_name=‘Full Name’)
def str(self):
return self.name
class Meta:
db_table = “workers”
verbose_name = “Worker”
verbose_name_plural = “Workers”
ordering = [“code”]
//end of code//

I have to say that my project runs without problems,
using python manager.py runserver
it opens my website and everything is fine
but when I try to run my update_workers.py it shows me that error

Welcome @tito1977 !

If you’re trying to run Django code directly from Python, it’s generally not going to work - at least not as you may hope or expect. Django needs to go through its initialization process before it can be used.

I believe the easiest way to create a script to run directly from the command line using Django features is to create it as a custom django-admin command. (There are other ways of doing it, but this is how I do it.)

I am solve the problem, in my apps.py i am write “class CoreConfig(AppConfig):” change “AppConfig(AppConfig)” it work thanks for all