# Returning value rather than object pointer in Tutorial

**URL:** <https://forum.djangoproject.com/t/returning-value-rather-than-object-pointer-in-tutorial/32246>\
**Category:** Getting Started\
**Created:** [June 19, 2024, 4:30pm UTC](https://forum.djangoproject.com/t/returning-value-rather-than-object-pointer-in-tutorial/32246 "2024-06-19T16:30:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimGilchristCA](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/timgilchristca/32/22053_2.png) [@TimGilchristCA](https://forum.djangoproject.com/u/TimGilchristCA)\
**Post date:** [June 19, 2024, 4:30pm UTC](https://forum.djangoproject.com/t/returning-value-rather-than-object-pointer-in-tutorial/32246/1 "2024-06-19T16:30:01Z")

</div>

So have progressed to part 2 of the tutorial on models. Everything works except for adding the _str_() methods.  
I’ve modified polls/model.py as directed so it now looks like this:

```auto
from django.db import models
from django.utils import timezone
import datetime

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField("date published")
    def __str__ (self): #Note that when this published the underscores disappear
        return self.question_text
    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
    def __str__ (self):
        return self.choice_text

```

However when I run

```auto
>>> Question.objects.all() I get
<QuerySet [<Question: Question object (1)>, <Question: Question object (2)>]>

```

(I’d added two questions to the data base earlier). I can see using Admin that they have the values I set.  
Can you explain how the method is meant to work?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 19, 2024, 5:02pm UTC](https://forum.djangoproject.com/t/returning-value-rather-than-object-pointer-in-tutorial/32246/2 "2024-06-19T17:02:08Z")

</div>

Note: When posting code here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve fixed your post for you.)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 19, 2024, 5:03pm UTC](https://forum.djangoproject.com/t/returning-value-rather-than-object-pointer-in-tutorial/32246/3 "2024-06-19T17:03:14Z")

</div>

After making this code change, did you exit and restart the shell? (Changes to the source code are not picked up by the shell while it is running.)

---

<div class="post-metadata">

**Author:** ![TimGilchristCA](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/timgilchristca/32/22053_2.png) [@TimGilchristCA](https://forum.djangoproject.com/u/TimGilchristCA)\
**Post date:** [June 20, 2024, 7:58am UTC](https://forum.djangoproject.com/t/returning-value-rather-than-object-pointer-in-tutorial/32246/4 "2024-06-20T07:58:39Z")

</div>

I did exit the shell Ctrl - D and got back to the normal terminal prompt. However having just done it today on a different computer (I’m using Replit so I just need a browser) it worked fine!  
My problem is I’m learning multiple things at a time as I’ve not used the Replit environment before so I may have missed something or it left something running in the background that I was not aware of. Going forward if I have an issue I’ll log in and out to see if its the environment (or my lack of understanding of it).  
Thanks so much for your help and sorry I wasted your time.
