Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dropdown(models.Model):
- name = models.CharField(max_length=256, unique=True)
- id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, verbose_name="ID")
- class Meta:
- abstract = True
- class Country(Dropdown):
- pass
- class City(Dropdown):
- country = models.ForeignKey(Country, on_delete=models.CASCADE)
- # you see 2 models and 1 apstract parent class.
- # I need to import into django project 189 Country objects (only by name, I do not have IDs)
- # And then 5000 cities, only by names, I don't have IDs. And I do not want to use IDs of Country objects during import. I need to use also their names
- # So example of my .csv file would be
- # name country
- # Rome Italy
- # Moscow Russia
- # ...
- # ...
- # ...
- # What should be my approach to solve that task?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement