這是我打的心情。對於我所有的foreignKeys,我應該在Django中使用User還是UserProfile?
我有User和ProfileUser。我想向模型添加額外的邏輯,因爲我不能將它添加到Django User模型中,所以我必須將其添加到ProfileUser。目前我所有的模型都有ForeignKey(用戶)。我應該保留它們還是應該在其他模型上使用ForeignKey(UserProfile)?
舉例我的看法,如果我保持ForeignKey的(用戶):
class myview(request):
user = request.user
userProfile = user.get_profile()
neededStuff = userProfile.get_needed_stuff()
,然後在用戶配置模式:
def get_needed_stuff(self):
user= self.user # Or actually, is this right
goals = Goal.objects.get(<conditions that i wont bother writing here>)
return goals
因此,對於這種情況,並且爲網站的進一步發展,我應該使用哪個外鍵?
首先,弄清楚''應該是什麼。 –
2011-05-05 18:38:21
我知道我的條件,但他們很複雜,所以我沒有打擾他們寫作。它與註冊日期,投票,聲譽等有關 – mgPePe 2011-05-05 18:39:37