Saturday, July 31, 2010

Unable to add model in admin (but can list them)

I've been scratching my head over this for awhile now --

I have an app called "main" that has two models defined "entity"
"story" -- I am able to see a list of each via the following urls:

http://127.0.0.1:8000/admin/main/entity/
http://127.0.0.1:8000/admin/main/story/

However, I'm only able to add new entities without issue... but when I
attempt to add a new story I get a 404 error, with no other
information (I have Debug = True) set.

I'm revisiting this project after a few months, so I'm not sure what I
might've done to get my project in this state... wondering if anyone
else has ideas? (I was previously able to add stories, so clearly I
messed something up somewhere.. and didn't realize it).

This is an abridged version of my main/models.py :


class Entity(models.Model):
name = models.CharField(max_length=64)
sketch = models.TextField()

class Meta:
verbose_name_plural = 'entities'

def __unicode__(self):
return self.name

class Story(models.Model):
link = models.URLField(max_length=384)
title = models.CharField(max_length=256)
slug = models.SlugField(max_length=256)
summary = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)
submitter = models.ForeignKey(User)
entity = models.ForeignKey(Entity)

class Meta:
verbose_name_plural = 'stories'

def __unicode__(self):
return self.title

# def save(self, *args, **kwargs):
# if not self.id:
# self.slug = slugify(self.title)
#
# super(Story, self).save(*args, **kwargs)

---

and here is my admin.py


class StoryAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}

admin.site.register(Entity)
admin.site.register(Story, StoryAdmin)


--

Incidentally, I've tried it with and without the overloaded save
method, and with and without the StoryAdmin customization... to no
avail.

Thanks for any help!
Fell


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment