DjangoでORMは内容が空ではないデータの例を探します。


djangoでデータベースを操作する時、どのように内容が空でないデータを探し出しますか?

from django.db.models import Q
 
class Index(VIew):
 def get(self, request):
 userObj = models.Asset.objects.filter(~Q(asset_id = '')
 return HttpResponse('yes')
上のコードの中のmodels.Assset.objects.filter(~Q(nick=')はQ関数を使ってニックが空ではないデータを探して、主に~Qを使います。
補足知識:DjangoエラーHINT:Add or change a related_name argment to the definition for'GodownentryReturn.suppl
Unhanded exception in thread started by
Traceback(most recent call last):
File「G:\workspace\pycharm\carwin\carwin_env\lib\site-packages\django\utils\autreload.py、line 226、in wrapper
fn(*args、**kwargs)
File「G:\workspace\pycharm\carwin\carwin_env\lib\site-packages\django\core\management\commends\runserver.py、line 116、inner_run
self.check(display_)numerrors=True)
File「G:\workspace\pycharm\carwin\carwin_env\lib\site-packages\django\core\manage\base.py、line 472、in check
ライセSystem CheckError(msg)
django.co re.managerment.basee.System CheckErr:System CheckError:System check dentified some ises:
ERRORS:
article.Godownentry Return.supplier:(fields.E 304)Reverse accessor for'Godownentry Return.supplier'clases with reverse accessor for'GodownentryReturn.supplier'
HINT:Add or change a related uname argment to the definition for'GodownentryReturn.supplier'or'GodownentryReturn.supplier'
part.GodownentryReturn.supplier:(fields.E 304)Reverse accessor for'Godownentry Return.supplier'clases with reverse accessor for'GodownentryReturn.supplier'
HINT:Add or change a related uname argment to the definition for'GodownentryReturn.supplier'or'GodownentryReturn.supplier'
理由:
一つの表の中で何度も外部キーテーブルを引用しています。しかも唯一のreleatedを指定していません。nameが招いたのです。
ソリューション:
同じ表の外ボタンを別のreleated_に追加します。name
以上のDjangoの中でORMは内容が空っぽではないデータの実例を探し出します。つまり、小編集が皆さんに提供した内容は全部です。