您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

为每个用户python创建唯一的配置文件页面

为每个用户python创建唯一的配置文件页面

一种简单的方法是为每个用户分配一个唯一的URL标识符(或使用其键名),这样您就可以通过用户的ID查询用户或基于唯一的URL标识符属性进行查询。如果需要,还可以使用其federated_id。

例:

class User(ndb.Model):
  unique_identifier = ndb.Stringproperty()
  ...

class ProfilePage(webapp2.RequestHandler):
  def get(self, profile_id):
    #profile_id = key name of user
    user = User.get_by_id(profile_id)
    #profile_id = some unique field
    #user = User.query(User.unique_identifier == profile_id).get()
    if user:
       #Get all posts for that user and render....


app = webapp2.WSGIApplication([('/', MainPage),
                               ('/profile/<profile_id>', ProfilePage),])
python 2022/1/1 18:51:19 有403人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶