2011-09-02 56 views
0

我這樣做是通過django獲取完整的UserProfile配置文件

$ python manage.py shell 
from django.contrib.auth.models import User 
a = User(username='zoro') 
a.get_profile().? 

我在get_profile後輸入的是什麼。獲取完整的個人資料,而不是輸入像 a.get_profile().Location這樣的東西來獲取位置。

回答

1

a.get_profile()是完整的配置文件(它是您的用戶配置文件模型的實例對象)。所以你可以將它保存在一個變量中並使用它。

雖然如果你想得到所有的python字典,你可以嘗試a.get_profile().__dict__

+0

很酷,乾杯! – ragingbull