Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. models.py:
  2.  
  3. class Key(models.Model):
  4. """Authentication key"""
  5. user = models.ForeignKey(User, editable=False, db_index=True, blank=False,
  6. null=False)
  7. key = models.CharField(_("Lookup key"), max_length=64,
  8. editable=False, db_index=True)
  9. hashed_secret = models.CharField(_("Hashed secret"), max_length=128,
  10. editable=False, db_index=False)
  11. description = models.TextField(_("Description of intended use"),
  12. blank=False)
  13. created = models.DateTimeField(auto_now_add=True)
  14.  
  15. class KeyAction(models.Model):
  16. """Record of an action taken while using a key"""
  17. key = models.ForeignKey(Key, related_name='history', db_index=True)
  18. action = models.CharField(max_length=128, blank=False)
  19. notes = models.TextField(null=True)
  20. content_type = models.ForeignKey(ContentType)
  21. object_id = models.PositiveIntegerField()
  22. content_object = generic.GenericForeignKey('content_type', 'object_id')
  23. created = models.DateTimeField(auto_now_add=True)
  24.  
  25. 0003_remove_authkeys.py:
  26.  
  27. def forwards(self, orm):
  28. "Write your forwards methods here."
  29. (orm.Key.objects.all().exclude(
  30. id__in=orm.KeyAction.objects.values_list('id', flat=True)
  31. .delete()))
  32.  
  33. Traceback:
  34. File "/home/vagrant/src/kuma/authkeys/migrations/0003_remove_authkeys.py", line 15, in forwards
  35. id__in=KeyAction.objects.values_list('id', flat=True)
  36. File "/home/vagrant/src/vendor/src/django/django/db/models/query.py", line 513, in delete
  37. collector.collect(del_query)
  38. File "/home/vagrant/src/vendor/src/django/django/db/models/deletion.py", line 159, in collect
  39. for parent_model, ptr in model._meta.parents.iteritems():
  40. AttributeError: type object 'long' has no attribute '_meta'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement