I need some clear thinking on how to handle a save function on a django model. As you'll see below I am at a loss on how to do this elegantly. I'd like to pass the entire object to another module and analyze it there. My motivation for having the analysis broken out and not in models.py is that I will be frequently refining the analysis bit. Thanks.
models.py
from test_app.spam_analyzer import spam_checker
class SharedLink(models.Model):
link = models.URLField()
submitters_ip = models.IPAddressField()
flag = models.CharField()
def save(self, *args, **kwargs):
self.flag = spam_checker(self)
super(SharedLink, self).save(*args, **kwargs)
spam_analyzer.py
from test_app.models import SharedLink #this causes a "field not found" error
def spam_checker(SharedLink)
submitters_ip = SharedLink.submitters_ip
# see if this user's ip appears on a spam list
# if it does flag it 'spam'
return flag