0

I have the following model:

class my_model(models.Model):
    item_id = models.IntegerField(max_length=100)
    item_array = ArrayField(models.FloatField())

When I try:

df = pd.read_pickle('df.pkl')

db = my_model()

for item in df.columns:
    db.item_id = item
    db.item_array = df[item]

db.save()

I get the following error:

ImproperlyConfigured: Requested setting INSTALLED_APPS, 
but settings are not configured. You must either define the 
environment variable DJANGO_SETTINGS_MODULE or call 
settings.configure() before accessing settings.

What could I do to fix this?

Filipe
  • 199
  • 1
  • 14
  • Django models can't access via normal scripts, if you wanted to, you need to follow certain procedures – JPG Nov 23 '20 at 03:10
  • Does this answer your question? [Django Standalone Script](https://stackoverflow.com/questions/39723310/django-standalone-script) – JPG Nov 23 '20 at 03:10
  • @Arakkal I'll try the suggestion.. in the meantime, what is the correct way to upload data into the database? – Filipe Nov 23 '20 at 03:18
  • 1
    Use django-orm for that – Alvi15 Nov 23 '20 at 03:31

0 Answers0