Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class Dropdown(models.Model):
  2. name = models.CharField(max_length=256, unique=True)
  3. id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, verbose_name="ID")
  4.  
  5. class Meta:
  6. abstract = True
  7.  
  8. class Country(Dropdown):
  9. pass
  10.  
  11. class City(Dropdown):
  12. country = models.ForeignKey(Country, on_delete=models.CASCADE)
  13.  
  14. # you see 2 models and 1 apstract parent class.
  15. # I need to import into django project 189 Country objects (only by name, I do not have IDs)
  16.  
  17. # 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
  18. # So example of my .csv file would be
  19. # name country
  20. # Rome Italy
  21. # Moscow Russia
  22. # ...
  23. # ...
  24. # ...
  25.  
  26. # What should be my approach to solve that task?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement