Django South - SyntaxError: invalid syntax (<string>, line 1)

304 views
Skip to first unread message

Ivan Goncalves

unread,
Sep 30, 2013, 10:52:09 AM9/30/13
to django...@googlegroups.com
Hi.... 

I'm having trouble with the South.

In the model below:

class Carrier (models.Model):
     name = models.CharField (max_length = 40, blank = False, null = False, verbose_name = 'Name')
     user = models.ForeignKey (User, blank = True, null = True)
    
     def save (self, force_insert = False, force_update = False):
         self.nome self.nome.upper = ()
         super (Carrier, self). save (force_insert, force_update)
        
     def __ unicode__ (self):
         return u '% s'% (self.nome)

the error occurs when i run the migrate after South on the app.
SyntaxError: invalid syntax (<string>, line 1)

But if my model does not have the user field, then the error message does not occur, as shown below:

class Carrier (models.Model):
     name = models.CharField (max_length = 40, blank = False, null = False, verbose_name = 'Name')
    
     def save (self, force_insert = False, force_update = False):
         self.nome self.nome.upper = ()
         super (Carrier, self). save (force_insert, force_update)
        
     def __ unicode__ (self):
         return u '% s'% (self.nome)


I need the field User. What I have to do ?

Thanks a lot.

Ivan 

Leonardo Giordani

unread,
Oct 1, 2013, 6:47:07 AM10/1/13
to django...@googlegroups.com
Can you use the models.py file with the user field on a bare DB?
I mean: if you start from scratch with an empty DB everything works correctly? You can create Carriers from the Django shell?


Leonardo Giordani
Author of The Digital Cat
My profile on About.me - My GitHub page - My Coderwall profile


2013/9/30 Ivan Goncalves <iv...@singular.inf.br>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/45f2764c-c903-41c2-b692-2afb9f9332ea%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Chris

unread,
Oct 1, 2013, 9:23:38 AM10/1/13
to django...@googlegroups.com
Ivan,

Did this code paste correctly? There is a syntax error in the save method:

 def save (self, force_insert = False, force_update = False):
         self.nome self.nome.upper = () <--- SYNTAX ERROR
         super (Carrier, self). save (force_insert, force_update)

Is that supposed to be:
self.name = self.name.upper()

?
Reply all
Reply to author
Forward
0 new messages