Hi Everyone, 

I am having Field Error while trying to have date field in my admin.py. 
There is some problem with Date Filed and I am unable to figure out what 
wrong I am doing. here is my code:

*MODEL.PY*


from django.db import models


import datetime
from django.utils import timezone


class Movie(models.Model):
    movie_title = models.CharField(max_length=200)
    movie_director = models.CharField(max_length=200)
    movie_writer = models.CharField(max_length=200)
    movie_musician = models.CharField(max_length=200)
    movie_intro = models.TextField()
    posted = models.DateField(db_index=True, auto_now_add=True)


    def __str__(self):
        return self.cd_movie


    def is_latest(self):
        return self.posted >= timezone.now() - datetime.timedelta(days=1)


    is_latest.admin_order_field = 'posted'
    is_latest.boolean = True
    is_latest.short_description = 'Latest?'







################



*ADMIN.PY *



from django.contrib import admin
from movie.models import Movie




############
##    movie_title = models.CharField(max_length=200)
##    movie_director = models.CharField(max_length=200)
##    movie_writer = models.CharField(max_lenth=200)
##    movie_musician = models.CharField(max_length=200)
##    movie_intro = models.TextField()
##    posted = models.DateField(db_index=True, auto_now_add=True)
#############


class MovieAdmin(admin.ModelAdmin):
    fieldsets = [
        ('Movie Info',               {'fields': ['movie_title',
'movie_director','movie_musician','movie_writer']}),
        ('Movie Intro',               {'fields': ['movie_intro']}),
        ('Date information', {'fields': ['posted']}),
    ]




    list_display = ('movie_title', 'posted', 'is_latest')
    list_filter = ['posted']
    search_fields = ['movie_title']


admin.site.register(Movie, MovieAdmin)




--------------------

I am having the following error:

FieldError at /admin/movie/movie/add/

Unknown field(s) (posted) specified for Movie. Check fields/fieldsets/exclude 
attributes of class MovieAdmin.

Request Method:GETRequest 
URL:http://localhost:8000/admin/movie/movie/add/Django 
Version:1.7Exception Type:FieldErrorException Value:

Unknown field(s) (posted) specified for Movie. Check fields/fieldsets/exclude 
attributes of class MovieAdmin.

Exception 
Location:C:\Python34\lib\site-packages\django\contrib\admin\options.py 
in get_form, line 654Python Executable:C:\Python34\python.EXEPython Version:
3.4.1Python Path:

['D:\\dp\\cricket',
 'C:\\Windows\\system32\\python34.zip',
 'C:\\Python34\\DLLs',
 'C:\\Python34\\lib',
 'C:\\Python34',
 'C:\\Python34\\lib\\site-packages']

Server time:

-------------


Thanks in AdvanceMon, 15 Dec 2014 11:57:49 +0500

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fdaee0d3-edb0-43e7-8d92-e3218e7b9da0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to