开发者

Defining variables to pass to Django models

开发者 https://www.devze.com 2023-03-05 10:56 出处:网络
The following works for me -- email_list = EmailList.objects.get(domain=(开发者_如何学编程cd[\'email\'].split(\'@\')[1]))

The following works for me --

email_list = EmailList.objects.get(domain=(开发者_如何学编程cd['email'].split('@')[1]))

But defining the 'domain' variable before does not --

domain = cd['email'].split('@')[1]
email_list = EmailList.objects.get(domain=domain)

When I do the latter, it raises an "EmailList matching query does not exist". What accounts for this difference??


There is nothing that accounts for this difference; Python variables do not change type when bound to a name.

0

精彩评论

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