Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#94 closed defect (fixed)

Mysterious error

Reported by: Joey Marshall Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I am trying to create a module for news, but with the code below, it reports a mysterious error.
When trying to add a news item, it says "Please correct the errors below.", but it doesn't show any like it normally does. :/ I'm thinking it's just a stupid mistake on my part as I'm new to this (oh, I guess pretty much every one is right now ;) ) and rather new to python programming (and I've done little with object oriented coding).

So if someone could help me out, that would be great!

# 'news' module code:

from django.core import meta
from django.models import auth, core

# Create your models here.

class News(meta.Model):
    fields = (
        meta.ForeignKey(auth.User, raw_id_admin=True),
        meta.CharField('title', maxlength=200),
        meta.DateTimeField('pub_date', 'date published'),
 meta.ManyToManyField(auth.Group, blank=True, help_text="Select which user groups will see this news article."),
    admin = meta.Admin(
        fields = (
            (None, {'fields': ('title','body')}),
            ('Date information', {'fields': ('pub_date',)}),
     ('Groups', {'fields': ('groups',)}),
        list_display = ('title', 'pub_date', 'groups', 'was_published_today'),
        list_filter = ('pub_date', ),
        search_fields = ('title', ),
        date_hierarchy = 'pub_date',
    def __repr__(self):
        return self.title
    def was_published_today(self):
        if ==
            return "Yes"
            return "No"
    was_published_today.short_description = 'Was published today'

Change History (2)

comment:1 Changed 14 years ago by Joey Marshall

oops, In that code there are some tabs insted of 4 spaces.

comment:2 Changed 14 years ago by anonymous

Resolution: fixed
Status: newclosed

ok, I found out what was wrong. It wanted a user id.

Note: See TracTickets for help on using tickets.
Back to Top