#3519: IndexError when creating related objects in admin
---------------------------+------------------------------------------------
Reporter: dp_wiz | Owner: adrian
Status: reopened | Component: Admin interface
Version: SVN | Resolution:
Keywords: edit_inline | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 1 | Needs_better_patch: 1
---------------------------+------------------------------------------------
Changes (by Gary Wilson <[EMAIL PROTECTED]>):
* stage: Design decision needed => Accepted
Comment:
Posting model code here for convenience...
{{{
#!python
from django.db import models
from django.contrib.auth.models import User
class Entry(models.Model):
title = models.CharField(maxlength=255)
slug = models.CharField(maxlength=40, prepopulate_from=("title",))
published = models.DateTimeField(blank=True, null=True)
author = models.ForeignKey(User)
def get_uncut(self):
return self.part_set.filter(cut=False)
def __str__(self):
return self.title
def get_absolute_url(self):
return '/blog/%d.%02d.%02d/%s/' % (self.published.year,
self.published.month, self.published.day, self.slug)
class Admin:
pass
class Meta:
ordering = ['-published']
class Part(models.Model):
entry = models.ForeignKey(Entry, edit_inline=models.TABULAR,
num_in_admin=5)
header = models.CharField(maxlength=255)
order = models.SmallIntegerField(default=0)
text = models.TextField(core=True)
cut = models.BooleanField(default=False)
def __str__(self):
return self.header
class Meta:
ordering = ['order', 'id']
class Reply(models.Model):
object = models.ForeignKey(Entry)
author = models.ForeignKey(User)
text = models.TextField()
posted = models.DateTimeField(auto_now_add=True)
def __str__(self):
return '%s @ %s on "%s"' % (self.author.first_name,
self.posted.strftime("%H:%M, %d %b %y"), self.object.title)
class Admin:
pass
class Meta:
ordering = ['posted']
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/3519#comment:8>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---