Hi Steve.
The __unicode__ method must be within the model class. I took your code and
applied the fix.
http://pastebin.com/sH2J50jS
2014-03-27 7:06 GMT-03:00 Steve Evans <00sev...@gmail.com>:
> Hi I am having the same issue:
>
> I am using Python 2.7, and Django 1.6.
>
> Here is my code for
Thankyou! so much...!
It was because i had tabs instead of 4 spaces for the indents.
So basically it was an indentation error but it didn't say that in the
console.
I think this will fix a lot of other peoples problems if they are using
tabs instead of spaces for indentations.
Cheers.
On Thur
i wonder if it is just the formatting of the email, but i think you missed
spaces before your def. def are hierarchically under classes, so it should
be:
import datetime
from django.db import models
from django.utils import timezone
# Create your models here.
class Poll(models.Model):
questio
Hi I am having the same issue:
I am using Python 2.7, and Django 1.6.
Here is my code for models.py:
import datetime
from django.db import models
from django.utils import timezone
# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
def __unicode_
trojactory has the right idea.
__unicode__ has two underscores on either side of _ _ unicode _ _
If you don't spell __unicode__ with two underscores on both sides, you are
not overriding the default method __unicode__
You are getting the default output for __unicode__ instead of the expected.
As I mentioned, I tried this but it doesn't work for me. Is this the python
unicode problem? I tried unicode(Poll.objects.all()) and it returns the same
On Saturday, 11 January 2014 12:38:16 UTC-8, Kai Ren wrote:
>
> Just type exit()
> then re-enter the shell, it will work.
>
> On Monday, May 16,
No, just single underscore
On Saturday, 11 January 2014 06:25:20 UTC-8, trojactory wrote:
>
> Juan,
>
> Are you entering double underscores like '__unicode__'?
>
> Cheers,
> Arun
>
> On Saturday, January 11, 2014 5:14:01 AM UTC+5:30, Juan Hu wrote:
>>
>> I have same problem with Django 1.6.1 and P
Just type exit()
then re-enter the shell, it will work.
On Monday, May 16, 2011 7:32:41 AM UTC-5, maaz muqri wrote:
>
> Hi,
>
> class Poll(models.Model):
> # ...
> def __unicode__(self):
> return self.question
>
> class Choice(models.Model
Juan,
Are you entering double underscores like '__unicode__'?
Cheers,
Arun
On Saturday, January 11, 2014 5:14:01 AM UTC+5:30, Juan Hu wrote:
>
> I have same problem with Django 1.6.1 and Python 2.7.5. I tried to restart
> interactive interpreter by exit() but it still doesn't work :(
> Followin
I have same problem with Django 1.6.1 and Python 2.7.5. I tried to restart
interactive interpreter by exit() but it still doesn't work :(
Following the tutorial, for Python3 we use _str_ but I am using Python
2.7.5 so I use _unicode_.
Can anyone help to point out the problem and solution? Thanks!
show us your code, and someone might show you where it is wrong, but the
tutorial is pretty clear on what you have to do.
Cheers, Nigel
07914 740972
On 8 October 2013 22:42, Brachamul wrote:
> Could someone post what the entire "models.py" file should look like at
> this point?
> I don't thin
Could someone post what the entire "models.py" file should look like at
this point?
I don't think I have indendation problems, but I'm new to both Python &
Django, so I can't be sure.
Using Python 2.7.5 and Django 1.4.
--
You received this message because you are subscribed to the Google Groups
I was having the same problem my django version was 1.3.1 and python 2.7.
There was indentation problem with my code after correcting it my problem
was solved.
On Tuesday, June 14, 2011 11:01:54 PM UTC+5, Kyle Latham wrote:
>
> Hello,
>
> I am having the same problem while working through the t
Just restart the python interactive Shell... that should solve your problem
Regards,
Manju
On Monday, May 16, 2011 5:32:41 AM UTC-7, maaz muqri wrote:
>
> Hi,
>
> class Poll(models.Model):
> # ...
> def __unicode__(self):
> return self.que
On Wed, Nov 14, 2012 at 5:13 PM, Daniel Roseman wrote:
> On Tuesday, 13 November 2012 20:10:38 UTC, Colin Keenan wrote:
>
>> By the way, I just checked django.VERSION and it's (1, 6, 0, 'alpha', 0)
>>
>> So, since version 1.6 is supposed to fully support python 3, I should be
>> fine. Obviously, b
On Tuesday, 13 November 2012 20:10:38 UTC, Colin Keenan wrote:
> By the way, I just checked django.VERSION and it's (1, 6, 0, 'alpha', 0)
>
> So, since version 1.6 is supposed to fully support python 3, I should be
> fine. Obviously, being 'alpha' means I'll run into trouble, but I'll keep
> che
By the way, I just checked django.VERSION and it's (1, 6, 0, 'alpha', 0)
So, since version 1.6 is supposed to fully support python 3, I should be
fine. Obviously, being 'alpha' means I'll run into trouble, but I'll keep
checking out new versions as I learn so by the time 1.6 is really out, I'll
Thanks for the advice. It's true that I'm just learning django, and because
I wanted to use python3, I installed via the most up-to-date development
source code. My experience with development versions of stuff has actually
been better than the fully supported versions of the same product for s
On Tue, Nov 13, 2012 at 8:35 AM, Colin Keenan wrote:
> I found out the reason `__str__()` worked for me but `__unicode__()` didn't.
> It's because python3 already uses unicode in the `__str__` method, so if
> using python3, don't use `__unicode__`.
You should be fore-warned that Django does not o
As of the moment I'm writing this post, my first post hasn't shown up yet.
I'm having the same problem. After posting my situation, I decided to also
write a __str__(self) method. That worked! But, the tutorial clearly states
that we should not be doing the usual __str__, and instead doing
__un
I found out the reason `__str__()` worked for me but `__unicode__()`
didn't. It's because python3 already uses unicode in the `__str__` method,
so if using python3, don't use `__unicode__`.
On Monday, May 16, 2011 7:32:41 AM UTC-5, maaz muqri wrote:
>
> Hi,
> ___
I also found this by searching from google. I am also having the exact same
problem. I know python well enough not to make a "spacing" error. The
people that were having this problem over a year ago seem to have never
gotten the solution to their problem.
I installed everything myself from dev
Restart your interactive shell by *exit() *first then *python manage.py
shell*. It's works for me
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/AYBiKDc7a
Hello,
I just started using django two days ago. I tried your method and
>>> p=Poll.objects.all()[0]
>>> p
#results in
>>> type(p)
#results in
>>> dir(p)
#gives an error
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__'
'__dict__', '__doc__', '__eq__', '__format__', '__geta
On Tue, Jun 14, 2011 at 11:01 AM, Kyle Latham wrote:
Poll.objects.all()
> []
What do you get when you try:
>>> p = Poll.objects.all()[0]
>>> p
>>> type(p)
>>> dir(p)
Try this too:
>>> p = Poll.objects.all()
>>> for x in p:
. . .print x (indent this line four spaces, hit return key onc
Hello,
I am having the same problem while working through the tutorial. have
searched these forums and tried everything that was recommended. My
spacing is good also - I checked that. I am still getting the same
output:
>>> Poll.objects.all()
[]
Any ideas on how to fix my issue?
On Jun 5, 11:2
Hi, i found this post when try to solve same problem: my trouble was a
"spaces" in models.py.
in your first message it seems to be ok, but you must really check
spaces in your class describe.
http://mail.python.org/pipermail/tutor/2007-January/051903.html
On May 17, 4:59 pm, maaz muqri wrote:
> i
hmm... strange...
the __unicode__ thing is nothing django-specific. It works in plain
python as well:
It's supposed to work like this:
>>> class TestClass(object):
... def __unicode__(self):
... return "unicode"
... def __repr__(self):
... return "buh"
... def __str__
im just getting "Poll object" as output
On May 17, 1:14 pm, Roman Klesel wrote:
> 2011/5/16 maaz muqri :
>
> > I am getting this
>
> Poll.objects.all()
> > []
>
> What do you get when you do:
>
> print unicode(Poll.objects.all()[0])
>
> ?
>
> Regards
> Roman
--
You received this message be
2011/5/16 maaz muqri :
> I am getting this
>
Poll.objects.all()
> []
What do you get when you do:
print unicode(Poll.objects.all()[0])
?
Regards
Roman
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
but still I am getting same problem
On May 16, 6:58 pm, AJ wrote:
> I think you are getting the poll object back. You need to specify the method
> for your model class(es)
>
> def __unicode__(self):
> return "%s %s %s" % (self.poll_name)
>
>
>
>
>
>
>
>
>
> On Mon, May 16, 2011 at 8:32 AM
Sorry about that. It is indeed not right. I will take care of this from next
time onwards.
On Mon, May 16, 2011 at 11:45 AM, Fabian Ezequiel Gallina <
galli...@gmail.com> wrote:
> 2011/5/16 AJ :
> > I think you are getting the poll object back. You need to specify the
> method
> > for your model
2011/5/16 AJ :
> I think you are getting the poll object back. You need to specify the method
> for your model class(es)
>
> def __unicode__(self):
>
> return "%s %s %s" % (self.poll_name)
>
>
That is wrong, you have a placeholder for three args and just pass one
to the string formatting.
Can it be necessary to recreate a model?
On 16 Maj, 16:32, momo2k wrote:
> Did you restart the interpreter after adding the code?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.co
Did you restart the interpreter after adding the code?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@go
I think you are getting the poll object back. You need to specify the method
for your model class(es)
def __unicode__(self):
return "%s %s %s" % (self.poll_name)
On Mon, May 16, 2011 at 8:32 AM, maaz muqri wrote:
> Hi,
>
> class Poll(models.Model):
36 matches
Mail list logo