Hi I am new learner of Django and would like to figure out how to load some data into the database using a file(.py).
There are three tables in the database.
class region(models.Model):
region_name = models.CharField(primary_key=True,max_length=50, null=False)
class country(models.Model):
country_name = models.CharField(primary_key=True,max_length=40, null=False)
region = models.ForeignKey(region)
class office(models.Model):
office_name = models.CharField(primary_key=True,max_length=50, null=False)
address = models.CharField(max_length=200, null=False)
postal_code = models.IntegerField(null = False)
country = models.ForeignKey(country)
Initially I use the python shell of enter some simple data into the db using
>>> r = region(region_name='asia')
>>> r.save()
Can anyone help to create such a file to load data of region, country, office into the database? as there are sets of region,country,office that really need to be there.
Thank you very much for helping out!