Help Requried : FieldError at /admin/movie/movie/add/

56 views
Skip to first unread message

Muhammad Ahmed

unread,
Dec 15, 2014, 7:24:09 AM12/15/14
to django...@googlegroups.com
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:GET
Request URL:http://localhost:8000/admin/movie/movie/add/
Django Version:1.7
Exception Type:FieldError
Exception 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 654
Python Executable:C:\Python34\python.EXE
Python Version:3.4.1
Python 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 Advance
Mon, 15 Dec 2014 11:57:49 +0500

Muhammad Ahmed

unread,
Dec 15, 2014, 11:23:08 AM12/15/14
to django...@googlegroups.com
Somehow I have managed the problem. 

Thanks to those who took their time to read this post.  
Reply all
Reply to author
Forward
0 new messages