Ticket #5680: models-mysql-duplicated-index-and-foreign-constraints.py

File models-mysql-duplicated-index-and-foreign-constraints.py, 434 bytes (added by Peter Melvyn <peter.melvyn@…>, 16 years ago)

example demonstrating duplicated index and foreign key constraints on MySQL

Line 
1from django.db import models
2
3class Poll(models.Model):
4 question = models.CharField(max_length=200)
5 pub_date = models.DateTimeField('date published')
6 def __unicode__(self):
7 return self.question
8
9class Choice(models.Model):
10 poll = models.ForeignKey(Poll)
11 choice = models.CharField(max_length=200)
12 votes = models.IntegerField()
13 def __unicode__(self):
14 return self.choice
Back to Top