Hi,

Using Django svn rev 9111 I ran into an issue using the admin. To  
create a reproducible example I went back to the Django Poll/Choice  
tutorial, part 2.

With below models.py and admin.py, I can create a new Poll, add the  
1st choice and save, add the 2nd and save, but that's it. After that  
it will just show the 'Please correct the errors below' validation  
message.

I can add more (3rd, 4th) choices using the Ipython shell. Database is  
Postgres.

Any hints?  My next step would be to override the models 'save'  
methods to further investigate. Django search does not show any hits  
on this problem.

Thanks,
Rob



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

from d3.polls.models import Poll, Choice
from django.contrib import admin

class ChoiceInline(admin.TabularInline):
	model = Choice
	extra = 1

class PollAdmin(admin.ModelAdmin):
	"""docstring for PollAdmin(admin.ModelAdmin)"""
	fieldsets = [
		(None,					{'fields': ['question']}),
		('Date information',	{'fields': ['pub_date'], 'classes': ['collapse']})
	]
	inlines = [ChoiceInline]
	list_display = ('question', 'pub_date', 'was_published_today')
	list_filter = ['pub_date']
	search_fields = ['question']
	date_hierarchy = 'pub_date'
		
admin.site.register(Poll, PollAdmin)




from django.db import models
import datetime

# Create your models here.


class Poll(models.Model):
	question = models.CharField(max_length=200)
	pub_date = models.DateTimeField('date published', default=datetime.datetime.now)
	
	def __unicode__(self):
		"""docstring for unicode"""
		return self.question
	
	def was_published_today(self):
		"""docstring for was_published_today"""
		return self.pub_date.date() == datetime.date.today()
	was_published_today.short_description = 'Published today?'


class Choice(models.Model):
	"""docstring for Choice"""
	poll = models.ForeignKey(Poll)
	choice = models.CharField(max_length=200)
	votes = models.IntegerField()
	
	def __unicode__(self):
		"""docstring for unicode"""
		return self.choice




Reply via email to