Django用L返回用户模型ID [英] Django return user model id with L

查看:179
本文介绍了Django用L返回用户模型ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题直到现在还没有出现 - 这是:当我尝试从User模型获取用户ID时,它将返回用户ID和字母L。

This problem did not appear until now - Here it is: When I try to get the user id from the User model it returns the user ID and the letter L.

>>> from django.contrib.auth.models import User

>>> u = User.objects.get(username='testuser')

>>> u.id

1L

我相信这是我遇到的问题尝试在另一个表中使用用户ID作为外键。感谢您的帮助。

I believe that this is the problem when I try to use the user id as a foreign key in another table. Thanks for your help.

推荐答案

L后缀只是python告诉你,它使用一个大的整数表示ID。它只会影响您在控制台上看到的内容,也不应该干扰python将其用于其他目的的方式。

The "L" suffix is just python telling you that it is using a large integer to represent the ID. It only affects what you see on the console, and shouldn't interfere at all with the way that python is using that number for other purposes.

这篇关于Django用L返回用户模型ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆