This is my second time going through the <a
href="http://www.djangoproject.com/documentation/tutorial1/";>Django
tutorials</a>. The first time I ran through the whole process on my
dreamhost server without any errors. This time I'm using the local
development server on my computer (Mac OS X v10.4.6 / Python 2.4)

In <a
href="http://www.djangoproject.com/documentation/tutorial1/";>tutorial
one</a>, you are to define a simple Poll model as well as a Choice
model. Everything works fine (able to access and save records via the
API) until I try to add a __str__() method to represent the model.

<code><pre>
from django.db import models

class Poll(models.Model):
    question = models.CharField(maxlength=200)
    pub_date = models.DateTimeField('Date Published')

        def __str__(self):
                return self.question
</pre></code>

Once I add this simple representation and start the Python Interactive
Prompt I get syntax errors (prooject name is webmules):

<code><pre>
>>> from webmules.polls.models import Poll, Choice
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/Users/swm/Sites/webmules/../webmules/polls/models.py", line 8
    def __str__(self):
    ^
SyntaxError: invalid syntax
>>>
</pre></code>

What's odd is if I remove the method and add an inner Admin() class,
like:

<code><pre>
from django.db import models

class Poll(models.Model):
    question = models.CharField(maxlength=200)
    pub_date = models.DateTimeField('Date Published')

    class Admin:
        pass
</pre></code>

I get syntax errors when I start the development server:

<code><pre>
Django version 0.95 (post-magic-removal), using settings
'webmules.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[24/Jun/2006 13:21:02] "GET /admin/ HTTP/1.1" 200 2753
Validating models...
Unhandled exception in thread started by <function inner_run at
0x2c82b0>
Traceback (most recent call last):
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/management.py",
line 992, in inner_run
    validate()
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/management.py",
line 959, in validate
    num_errors = get_validation_errors(outfile)
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/core/management.py",
line 816, in get_validation_errors
    for cls in models.get_models(app):
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/loading.py",
line 43, in get_models
    app_list = get_apps() # Run get_apps() to populate the _app_list
cache. Slightly hackish.
  File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/loading.py",
line 20, in get_apps
    mod = __import__(app_name, '', '', ['models'])
  File "/Users/swm/Sites/webmules/../webmules/polls/models.py", line 8
    class Admin:
    ^
</pre></code>

If I don't have the  __str__() method the API works great, if I don't
define the inner Admin class my development server starts without any
problems. It seems like anything I add to my models breaks everything
else. Has anyone ever seen anything like that?

Apologies for the long message, just wanted to be thorough. Thanks in
advance.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to