Reputation: 6555
This is driving me insane!!!!
I have a model and trying to simply call a method. There is 'nothing' wrong with code below, nothing. however I keep getting...
global name 'has_auto' is not defined
It it defined, indentation is correct and same code works in any other file. Here the code:
class Reply(models.Model):
message = models.TextField(help_text="Message from number")
#FK
keyword = models.ForeignKey(Keyword, related_name="Inbox")
class Meta:
app_label = 'sms'
verbose_name_plural = u'Message Replies'
def __unicode__(self):
return self.message
def has_auto(self):
pass
def save(self, *args, **kwargs):
has_auto()
super(Reply, self).save()
the model is called reply.py and in the models folder I have ntoced that the init__.py has:
"""
.. autoclass:: Gateway
:members:
.. autoclass:: Message
:members:
.. autoclass:: Originator
:members:
.. autoclass:: Reply
:members:
.. autoclass:: Keyword
:members:
.. autoclass:: Template
:members:
"""
from gateway import Gateway
from message import Message
from originator import Originator
from reply import Reply
from batch import Batch
from keyword import Keyword
from template import Template
Gatewat and all the other models work with the same test, the issues is only in Reply.py! Anyone know whats going on here, it's driving me mad!
Upvotes: 0
Views: 165
Reputation: 29804
Your save
method:
def save(self, *args, **kwargs):
has_auto() #error
super(Reply, self).save()
You need to call: self.has_auto()
def save(self, *args, **kwargs):
self.has_auto()
super(Reply, self).save()
Hope this helps!
Upvotes: 3