Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

Still working through this tutorial.

I have got the problem:

TemplateDoesNotExist at /polls/

polls/index.html


Traceback:
Environment:

Request Method: GET
Request URL: http://localhost:8060/polls/
Django Version: 1.0.2 final
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'mysite.polls']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')

Template Loader Error:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.load_template_source:
/home/csunix/scs5tdp/Desktop/mysite/templates/admin/base_site.html/
home/csunix/scs5tdp/Desktop/mysite/templates/polls/index.html/home/
csunix/scs5tdp/Desktop/mysite/mysite/polls/index.html/polls/index.html
(File does not exist)
Using loader
django.template.loaders.app_directories.load_template_source:
/home/csunix/scs5tdp/python/lib/python2.5/site-packages/django/contrib/
admin/templates/polls/index.html (File does not exist)



Traceback:
File "/home/csunix/scs5tdp/python/lib/python2.5/site-packages/django/
core/handlers/base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/cserv2_a/ug/scs5tdp/Desktop/mysite/mysite/../mysite/polls/
views.py" in index
  7. t = loader.get_template('polls/index.html')
File "/home/csunix/scs5tdp/python/lib/python2.5/site-packages/django/
template/loader.py" in get_template
  80. source, origin = find_template_source(template_name)
File "/home/csunix/scs5tdp/python/lib/python2.5/site-packages/django/
template/loader.py" in find_template_source
  73. raise TemplateDoesNotExist, name

Exception Type: TemplateDoesNotExist at /polls/
Exception Value: polls/index.html


The File exists in that Dir that is listed in the TEMPLATE_DIR so Im
confused why I get that error
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

Help was much appreciated, thanks ;)

On Mar 17, 1:26 pm, Oliver Beattie  wrote:
> You're probably using the tutorial for the development (trunk) version
> of Django, but you're running 1.0.x — you should be following this
> tutorial:http://docs.djangoproject.com/en/1.0//intro/tutorial02/#activate-the-...
>
> On Mar 17, 1:21 pm, TP  wrote:
>
> > I have fixed this error:
>
> > now when I comes to view the admin site I get the error:
>
> > AttributeError at /admin/
>
> > 'AdminSite' object has no attribute 'urls'
>
> > On the webpage.
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread Oliver Beattie

You're probably using the tutorial for the development (trunk) version
of Django, but you're running 1.0.x — you should be following this
tutorial: 
http://docs.djangoproject.com/en/1.0//intro/tutorial02/#activate-the-admin-site

On Mar 17, 1:21 pm, TP  wrote:
> I have fixed this error:
>
> now when I comes to view the admin site I get the error:
>
> AttributeError at /admin/
>
> 'AdminSite' object has no attribute 'urls'
>
> On the webpage.
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

I have fixed this error:

now when I comes to view the admin site I get the error:

AttributeError at /admin/

'AdminSite' object has no attribute 'urls'


On the webpage.
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread Oliver Beattie

Below that there will be an error. I'm guessing it may be a
SyntaxError or NameError, since it looks like you have python after
'mysite.polls' (probably by accident) — that is if that traceback is
right.

On Mar 17, 12:36 pm, TP  wrote:
> This relates to the first tutorial on django project.
> My models.py file:
>
> 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.choice
>
> When trying to access the Python shell:
>
> [scs5...@cslin029 mysite]$ python manage.py shell
> Traceback (most recent call last):
>   File "manage.py", line 4, in 
>     import settings # Assumed to be in the same directory.
>   File "/home/cserv2_a/ug/scs5tdp/Desktop/mysite/mysite/settings.py",
> line 79
>     'mysite.polls'python
>
> That is all the traceback I get! :(
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

This relates to the first tutorial on django project.
My models.py file:

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.choice


When trying to access the Python shell:

[scs5...@cslin029 mysite]$ python manage.py shell
Traceback (most recent call last):
  File "manage.py", line 4, in 
import settings # Assumed to be in the same directory.
  File "/home/cserv2_a/ug/scs5tdp/Desktop/mysite/mysite/settings.py",
line 79
'mysite.polls'python


That is all the traceback I get! :(


--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread Alex Gaynor
On Tue, Mar 17, 2009 at 8:29 AM, TP  wrote:

>
> When I try to run the Python shell again I get this:
>
>  python manage.py shell
> Traceback (most recent call last):
>  File "manage.py", line 4, in 
>import settings # Assumed to be in the same directory.
>  File "/home/cserv2_a/ug/scs5tdp/Desktop/mysite/mysite/settings.py",
> line 79
>'mysite.polls'python
>
>
>
> Does this mean there is something wrong where I have added 'import
> datetime' to my code?
> >
>
Part of your traceback got cut off, which makes it impossible for us to say
what it is.  Can you paste the full thing.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

When I try to run the Python shell again I get this:

 python manage.py shell
Traceback (most recent call last):
  File "manage.py", line 4, in 
import settings # Assumed to be in the same directory.
  File "/home/cserv2_a/ug/scs5tdp/Desktop/mysite/mysite/settings.py",
line 79
'mysite.polls'python



Does this mean there is something wrong where I have added 'import
datetime' to my 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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread Ramiro Morales

On Tue, Mar 17, 2009 at 9:20 AM, TP  wrote:
>
> Right I have now changed to use __unicode__
>
> This looks like:
>
>
> from django.db import models
>
> 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.choice
>
> This still does not work, any advice?

What exactly do you mean when you say "does not work"?.

Remember that if you are testing this with the interactive shell
(manage.py shell) you need to restart it to see the efefct of the
changes you perform in model.py.

HTH

-- 
Ramiro Morales
http://rmorales.net

--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

>>> from mysite.polls.models import Poll, Choice
>>> Poll.objects.all()
[]

Is my output.

The desired output is:

>>> Poll.objects.all()
[]

--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

Right I have now changed to use __unicode__

This looks like:


from django.db import models

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.choice

This still does not work, any advice?
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Poll Tutorial regarding __unicode__

2009-03-17 Thread Oliver Beattie

__unicode__ is called when unicode(ModelInstance) is called. __str__
is called when str(ModelInstance) is called.

Internally, if you only define __unicode__, then Django will provide
__str__ for you (see 
http://code.djangoproject.com/browser/django/trunk/django/db/models/base.py#L277
for the nitty-gritty)

Basically, it's good practice to only provide a __unicode__ method and
leave __str__ well alone, since you really should always be dealing
with unicode strings when interacting with (potentially non-ASCII)
data. Thus, you shouldn't type cast any data directly to str() without
first knowing exactly what you're doing in the process.

On Mar 17, 11:42 am, TP  wrote:
> I am currently running through the first tutorial on the django
> projects site.
>
> When I have added the __unicode__() method to my models I don't see
> any change in how they're represented.
>
> I am using Django 1.0.2 So an old version is not the problem.
>
> My models.py looks like this:
>
> from django.db import models
> import datetime
>
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
>     def __str__(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 __str__(self):
>         return self.choice
>
> Is this correct?
>
> Any help would be gladly received.
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Poll Tutorial regarding __unicode__

2009-03-17 Thread TP

I am currently running through the first tutorial on the django
projects site.

When I have added the __unicode__() method to my models I don't see
any change in how they're represented.

I am using Django 1.0.2 So an old version is not the problem.

My models.py looks like this:

from django.db import models
import datetime


class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __str__(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 __str__(self):
return self.choice


Is this correct?

Any help would be gladly received.
--~--~-~--~~~---~--~~
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...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---