On Mon, Sep 14, 2009 at 1:27 PM, about2flip <[email protected]> wrote:
>
> Hi:
>
> I am using learn django in 24 hours and I am following this example on
> models.
>
> from django.db import models
>
> class Person(models.Model):
> name = models.CharField('name', maxlength=200)
> email = models.EmailField('Email', blank=True)
> headshots = models.ImageField(upload_to='img', blank=True)
> text = models.TextField('Desc', maxlength=500, blank=True)
> def_str_(self):
> return '%s' % (self.name)
>
> I keep getting an error when I use the command>>>python manage.py
> syncdb (see below)
>
>
> E:\djproj\ifriends>python manage.py syncdb
> C:\Python26\lib\site-packages\MySQLdb\__init__.py:34:
> DeprecationWarning: the se
> ts module is deprecated
> from sets import ImmutableSet
> Traceback (most recent call last):
> File "manage.py", line 11, in <module>
> execute_manager(settings)
> File "C:\Python26\lib\site-packages\django\core\management
> \__init__.py", line
> 362, in execute_manager
> utility.execute()
> File "C:\Python26\lib\site-packages\django\core\management
> \__init__.py", line
> 303, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 195,
> in run_from_argv
> self.execute(*args, **options.__dict__)
> File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 221,
> in execute
> self.validate()
> File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 249,
> in validate
> num_errors = get_validation_errors(s, app)
> File "C:\Python26\lib\site-packages\django\core\management
> \validation.py", lin
> e 28, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
> File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 131, in
> get_app_errors
> self._populate()
> File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 58, in
> _populate
> self.load_app(app_name, True)
> File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 74, in
> load_app
> models = import_module('.models', app_name)
> File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
> __import__(name)
> File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
> def_str_(self):
> ^
> SyntaxError: invalid syntax
>
> E:\djproj\ifriends>
>
> Its telling me it is line 8, but I double check 5x already and it is
> the same as the book. The book does not have an errata, so I am not
> sure if the syntaxt is correct because I am a Freshman learning
> django.
>
> thanks too all that reply with help.
Put a space between 'def' and '_str_' and it should work. Tho you want to
use _unicode_ instead of _str_ in django. All string output is handled as
unicode.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---