Have been at this now for some hours and still can't see the wood for
the trees.  Failed to get two signals working - one called on pre_save
to keep an audit trail of one field on a model (didn't implemenet the
Audit.py version in the wiki as more complex than I needed).  The
other to create some default records in a related table.  Both are
failing with the same error and I suspect I am going to kick myself
when someone points out the obvious, but here goes.

Model.py

(simplified)

class Version(models.Model):

        version_no = models.CharField(_('ver'), max_length=10, unique=True)
        name = models.CharField(_('name'), max_length=50, unique=True)

class VersionDocs(models.Model):

        version = models.ForeignKey('Version')
        doc_content = models.TextField(_('content'))


class VersionDocsVer(models.Model):

        doc = models.ForeignKey('VersionDocs')
        doc_content = models.TextField(_('content'))


pre_save.connect(keep_version, sender=VersionDocs)
post_save.connect(default_docs, sender=Version)



signals.py

(simplified)

from devcycle.models import *

def default_docs(instance, **kwards):

        try:
                doc = VersionDocs.objects.filter(version=instance.id)

        except:

            ....

def keep_version(instance, **kwargs):

        print 'version instance =',instance.id
        original = VersionDocs.objects.get(id=instance.id)

        ....



Using Django version 1.1 beta 1,





--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to