참조 속성을 사용하도록 테이블 정의를 변경했습니다. 이제 삽입을 시도 할 때 값이 None이 아니고 value가 아니라면 얻는다 .has_key () : AttributeError : 'Query'object has no attribute 'has_key'
subject = self.request.get('subject')
content = self.request.get('content')
user = self.request.get('name')
name = User.all().filter('name =', user)
if subject and content:
p = Post(parent = blog_key(), subject = subject, content = content, user = name)
p.put()
이것은 내 Post 수업입니다.
class Post(db.Model):
subject = db.StringProperty(required = True)
content = db.TextProperty(required = True)
created = db.DateTimeProperty(auto_now_add = True)
last_modified = db.DateTimeProperty(auto_now = True)
user = db.ReferenceProperty(User)
Python 2.7을 사용하고 있습니다. 값이 None이 아니고 value.has_key ()가 아닌지에 관한 다른 게시물의 지침을 따르려고 시도했지만 그 제안은 저에게 효과적이지 않았습니다.
여러분의 도움에 감사드립니다.
추가 한 다음 이름을 p로 설정했습니다.
for p in q.run():
print "name ", p.name
if subject and content:
p = Post(parent = blog_key(), subject = subject, content = content, name = p)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다