I'm am trying to make a ForeignKey with a default value.
But when I save i get a "invalid literal for int() with base 10: 'Stat
object'" error
Here is my code:
from django.db import models
class Stat(models.Model):
total = models.IntegerField(default=0)
right = models.IntegerField(default=0)
wrong = models.IntegerField(default=0)
def percent_right(self):
return (float(right) / total) * 100
class Noun(models.Model):
word = models.CharField(max_length='50',
unique=True)
definition = models.CharField(max_length='100',
default=Stat())
definition_stats = models.ForeignKey(Stat, default=Stat(),)
GENDER_CHOICES = (
(True, 'Masculine'),
(False,'Feminine'),
(None, 'Neuter'),
)
gender = models.BooleanField(blank=True, null=True,
choices=GENDER_CHOICES)
gender_stats = models.ForeignKey(
Stat,
default=Stat(),
related_name='gender_stats',
)
plurality = models.CharField(max_length='50',)
class Verb(models.Model):
word = models.CharField(max_length='50',
unique=True)
definition = models.CharField(max_length='100',)
definition_stats = models.ForeignKey(Stat, default=Stat(),)
irregular = models.BooleanField()
Thanks,
Luke
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---