我有一個基於函數的代碼看起來像這樣:類視圖和「加薪NotImplementedError」
def foo(request):
raise NotImplementedError()
這是怎麼認爲的基於類的視圖使用?
class FooView(View):
def get(self, request, *args, **kwargs):
raise NotImplementedError()
編輯>問:問題是關於語法。 FooView不是一個抽象類,它是實現類。當我嘗試使用return raise NotImplementedError()
時 - 它給了我一個錯誤。我應該把NotImplementedError
放在get()
還是其他一些功能?
我不太確定你要在這裏做什麼。也許如果你能描述你正在尋找的_behavior_,我們可以更好地理解這個問題...... – mgilson
這個想法是,FooView還沒有實現,但它必須被定義爲未來的發展。所以FooView必須是引發NotImplementedError()的空類,只是爲了方便。 – Oleg
所以它應該是一個抽象的基類? – mgilson