Why do I get such an error only for PermiLayer model , when the same code/logic works perfectly fine for other models .
My code is this
uperm = PermiLayer()
perml=uperm.objects.get(pk = num)
Ps: I have already tried Manager isn't accessible via `Model` instances solutions there . But didn;'t work out
Edit:
This is my models
from django.contrib.gis.db import models
from django.contrib.auth.models import Us开发者_如何学Goer
from django.contrib.contenttypes.models import ContentType
from maps.models import Sdr_Layer
from OsmMap.models import OsmLayers
class PermiLayer(models.Model):
user = models.ForeignKey(User)
table = models.IntegerField()
permi = models.IntegerField()
Managers are accessible only via Model Classes, rather than from model instances https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-objects
why don't you just get it like
perml=PermiLayer.objects.get(pk = num)
精彩评论