Skip to content

Instantly share code, notes, and snippets.

@Gasoid
Last active May 23, 2017 12:42
Show Gist options
  • Save Gasoid/3533212fe82fd4ef0fc636bd1ad27fce to your computer and use it in GitHub Desktop.
Save Gasoid/3533212fe82fd4ef0fc636bd1ad27fce to your computer and use it in GitHub Desktop.
class City(models.Model):
name = models.CharField(max_length=255)
class Person(models.Model):
city = models.ForeighKey(City)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
for city_name in ('Saratov', 'NN', 'Moscow'):
city = City(name=city_name)
city.save()
if person_saratov_queryset:
print('Saratov')
if person_nn_queryset:
print('NN')
if person_moscow_queryset:
print('Moscow')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment