"django.core.exceptions.appregistrynotready: Apps Aren't Loaded Yet" When Trying To Load Data Into My Model
I am developing an app in Django. I want to load data inside my model, that is glossary_entry, but the data is stored inside an xlsx file, that is dati_prova.xlsx. In order to achi
Solution 1:
I solved the problem by substituting this:
import pandas as pd
from django.conf import settings
settings.configure()
from myapp.models import glossary_entry #this is line 7
path=r"mypath\dati_prova.xlsx"withopen(path) as f:
reader = pd.read_excel(f)
next(reader, None) # skip the headersfor row in reader:
_, created = glossary_entry.objects.get_or_create(
Lemma = row[0],
Acronym = row[1],
Definizione = row[2],
)
# creates a tuple of the new object or# current object and a boolean of if it was created
with this:
import pandas as pd
from myapp.models import glossary_entry
defpour_entire_entry_model():
elements = glossary_entry.objects.all()
for element in elements:
entry = acquired_terminology.objects.create()
entry.Lemma = element.Lemma
entry.Acronym = element.Acronym
entry.Definizione = element.Definizione
# creates a tuple of the new object or# current object and a boolean of if it was created
Post a Comment for ""django.core.exceptions.appregistrynotready: Apps Aren't Loaded Yet" When Trying To Load Data Into My Model"