0π
β
Ok, the info found here:
http://bitkickers.blogspot.dk/2010/04/django-manytomany-error-cannot-resolve.html
indicated that load order of the model could yield this kind og error, so i changed the models.py file from this order:
class Image(models.Model):
folders = models.ManyToManyField('Folder')
title = models.CharField()
class Folder(models.Model):
user = models.ForeignKey(User)
name = models.CharField()
class CanAccess(models.Model):
folder = models.ForeignKey(Folder)
user = models.ForeignKey(User)
to this order:
class CanAccess(models.Model):
folder = models.ForeignKey("Folder")
user = models.ForeignKey(User)
class Image(models.Model):
folders = models.ManyToManyField('Folder')
title = models.CharField()
class Folder(models.Model):
user = models.ForeignKey(User)
name = models.CharField()
And that actually seems to fix the problem.
π€Drewes
2π
You donβt need the _set
when doing a lookup:
Image.objects.filter(folders__canaccess__user=current_user)
π€Daniel Roseman
- [Answered ]-Request.user is a SimpleLazyObject after authenticating
- [Answered ]-GeoDjango β LineStringField β how to use it? Where do I find documentation?
- [Answered ]-Latest django-mongodb-engine
- [Answered ]-Django: send_mail not working [only for production]
- [Answered ]-Django Admin β customize use jquery inside and custom fields
Source:stackexchange.com