from django.db import models
# Create your models here.
class Artist(models.Model):
name=models.CharField('artist',max_length=50,primary_key=True)
year_formed=models.PositiveIntegerField()
class Album(models.Model):
name=models.CharField('album',max_length=50)
artist=models.ForeignKey(Artist,on_delete=models.PROTECT)
from polls.models import Artist
newartist=Artist(name='Vikrant',year_formed=1985)
newartist.save()
artist=Artist.objects.all()
for i in artist:
print(i.name)
print(i.year_formed)
ind=Artist.objects.get(id=1)
print(ind.name)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/65548402-a106-46a1-a40d-ab8bd91348a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/65548402-a106-46a1-a40d-ab8bd91348a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b4837329-8c85-4b43-ae11-d8d3fa766dea%40googlegroups.com.