I'm trying to make a poll with Django but I'm very new to it and when I go to the admin thing it gives this error:
ImproperlyConfigured at /admin/polls/poll/1/
'PollAdmin.fields' refers to field 'None' that is missing from the form.
I'm not very sure what that means but this is my admin.py file which I think is causing the error:
from django.contrib import admin
from polls.models import Poll
class PollAdmin(admin.ModelAdmin):
fields = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub date']}),
admin.site.register(Poll, PollAdmin)
Edit:
Here's my models file if that matters:
from django.db import models
import datetime
from django.utils import timezone
class Poll(models.Model):
question = models.CharField(max_length = 200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days = 1)
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length = 200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice_text
Edit (again)
Now I fixed my PollAdmin class to this:
class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub_date']}),
]
But it's saying:
DoesNotExist at /admin/polls/poll/1/
Site matching query does not exist.