我正在用Django和PostgreSQL做一个项目。用户必须注册,并且在该登录之后。
问题
当用户是signing up
时,我会问不同的问题like name, email
等,其中一个字段是**Country(home country)**
。一旦数据存储在数据库中。现在,如果用户想要登录,我想要他/她可以see all the data related to home country. e.g UK people can't see data from US or any other country and vise versa
。
我想您可以根据用户国家过滤数据,例如:
user = request.user
data = *DataModle*.objects.filter(country=user.country)