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

  • Home
  • SEARCH
  • 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 6863581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:48:02+00:00 2026-05-27T02:48:02+00:00

I’m doing this Django tutorial https://docs.djangoproject.com/en/dev/intro/tutorial01/ and was_ published _today isn’t working. Thanks for

  • 0

I’m doing this Django tutorial https://docs.djangoproject.com/en/dev/intro/tutorial01/ and was_published_today isn’t working. Thanks for your time.

Here’s the command line:

    Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> from polls.models import Poll, Choice
    >>> Poll.objects.all()
    [<Poll: What's up?>]
    >>> Poll.objects.get(pk=1)
    <Poll: What's up?>
    >>> p = Poll.objects.get(pk=1)
    >>> p.was_published_today()
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    AttributeError: 'Poll' object has no attribute 'was_published_today'

Here’s models.py

    # Create your models here.
    from django.db import models

    import datetime

    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_today(self):
            return self.pub_date.date() == datetime.date.today()


    class Choice(models.Model):
        poll = models.ForeignKey(Poll)
        choice = models.CharField(max_length=200)
        votes = models.IntegerField()
        # ...
        def __unicode__(self):
            return self.question

    >>> dir (p)
    ['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict_
    _', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__
    ', '__metaclass__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_e
    x__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_
    _unicode__', '__weakref__', '_base_manager', '_collect_sub_objects', '_default_m
    anager', '_deferred', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_
    get_next_or_previous_in_order', '_get_pk_val', '_get_unique_checks', '_meta', '_
    perform_date_checks', '_perform_unique_checks', '_set_pk_val', '_state', 'choice
    _set', 'clean', 'clean_fields', 'date_error_message', 'delete', 'full_clean', 'g
    et_next_by_pub_date', 'get_previous_by_pub_date', 'id', 'objects', 'pk', 'prepar
    e_database_save', 'pub_date', 'question', 'save', 'save_base', 'serializable_val
    ue', 'unique_error_message', 'validate_unique']

Note: I am also using instantdjango.com ‘s Instant Django.

  • 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-05-27T02:48:02+00:00Added an answer on May 27, 2026 at 2:48 am

    I had a similar problem as I was working through the Django tutorial. I found that, in order to pick up custom methods, I had to exit from the Python shell and restart it (and re-import the Poll class).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is

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.