开发者

Manager isn't accessible via PermiLayer instances error in django

开发者 https://www.devze.com 2023-03-16 01:08 出处:网络
Why do I get such an error only for PermiLayer model , when the same code/logic works perfectly fine for other models .

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消