So führen Sie eine Django Python -Datei aus der Befehlszeile ausPython

Python-Programme
Guest
 So führen Sie eine Django Python -Datei aus der Befehlszeile aus

Post by Guest »

Ich habe eine einfache Python -Datei, die ich irgendwann von Chron ausführen möchte.from customers.models import Customer, NotificationLogEntry

def hello():
customers = Customer.objects.all()
for c in customers:
log_entry = NotificationLogEntry(
customer=c,
sent=True,
notification_type=0,
notification_media_type=0,
)
log_entry.save()

if __name__ == '__main__':
hello()
< /code>

Wenn ich dies mit: < /p>

ausführepython notifications.py
< /code>

Ich erhalte einen Importfehler: < /p>

Traceback (most recent call last):
File "notifications.py", line 1, in
from customers.models import Customer, NotificationLogEntry
ImportError: No module named customers.models
< /code>

Dieses Modul existiert und ich nenne es ohne Probleme in meiner Django -App. Warum bekomme ich diesen Fehler außerhalb meiner App?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post