Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8260585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:07:57+00:00 2026-06-08T03:07:57+00:00

I am following this part of the ‘django by example’ tutorial. Now when I

  • 0

I am following this part of the ‘django by example’ tutorial. Now when I go to /admin/todo/datetime/ and click on Add date time I get this error:

Exception Type: Exception at /admin/todo/datetime/add/
Exception Value: <class 'todo.models.Item'> has no ForeignKey to <class 'todo.models.DateTime'>

My code is pretty much identical(except that I have the import statements included):

from django.db import models
from django.contrib import admin

class DateTime(models.Model):
    datetime = models.DateTimeField(auto_now_add = True)
    def __unicode__(self):
       return unicode(self.datetime)

class Item(models.Model):
    name = models.CharField(max_length = 60)
    created = models.DateTimeField(auto_now_add = True)
    priority = models.IntegerField(default = 0)
    difficulty = models.IntegerField(default = 0)
    done = models.BooleanField(default = False)

class ItemAdmin(admin.ModelAdmin):
    list_display = ["name", "priority", "difficulty", "created", "done"]
    search_fields = ["name"]

class ItemInline(admin.TabularInline):
    model = Item

class DateAdmin(admin.ModelAdmin):
    list_display = ["datetime"]
    inlines = [ItemInline]

admin.site.register(Item, ItemAdmin)
admin.site.register(DateTime, DateAdmin)

I looked at similar S.O. threads but I can’t figure out from there what is going wrong here.
(Btw, I use django 1.3 while django 1.2 is used in the turorial)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:07:58+00:00Added an answer on June 8, 2026 at 3:07 am

    Your models don’t match those in the tutorial. Your Item.created is a DateTimeField while their Item.created is a ForeignKey to the DateTime model.

    # From http://lightbird.net/dbe/todo_list.html#adding-multiple-items
    
    class DateTime(models.Model):
        datetime = models.DateTimeField(auto_now_add=True)
        def __unicode__(self):
            return unicode(self.datetime)
    
    class Item(models.Model):
        name = models.CharField(max_length=60)
        created = models.ForeignKey(DateTime)
        priority = models.IntegerField(default=0)
        difficulty = models.IntegerField(default=0)
        done = models.BooleanField(default=False)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am following this tutorial: http://tutorial.symblog.co.uk/docs/validators-and-forms.html at the swift mailer part i am not
I'm following this tutorial http://blogs.msdn.com/b/astoriateam/archive/2010/07/21/odata-and-authentication-part-6-custom-basic-authentication.aspx . I need to add to the web.config :
I am following this tutorial http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-5-magento-models-and-orm-basics . As per this tutorial,when i pass a
I am following the Getting started with wxPython tutorial, to this part . What
I am following this tutorial http://developers.facebook.com/docs/appsonfacebook/tutorial/ and specifically at this part of code $app_id
I am following this tutorial http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-9 (not exactly same as this) I am trying
I am following this example, http://www.quartz-scheduler.org/documentation/quartz-2.1.x/quick-start At one part of the example, it mentioned
I'm following this tutorial, but I'm faced with a weird problem. There's a part
my problem is the following: This is a part of my HTML-Code: <form method='GET'
For some reasons this part where I fetch JSON data from following url will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.