I have a very simple case in which I want to run a script with python
myscript.py
:
from models import Company
c = Company(number="1234567890", name="Company name")
models.py
:
from django.db import models
class Company(models.Model):
number = models.CharField("company number", max_length=20, unique=True)
name = models.CharField("company name", max_length=30, unique=True)
class Meta:
verbose_name = "Company"
verbose_name_plural = "Companies"
I want to run python myscript.py
or something like python manage.py execute_file myscript.py
I know my question is trivial and I can import a python manage.py shell
environment, but that's not the point. Can I run it in a much simple manner?