per page, with , order by , clip by
Results of 1 - 10 of about 54 for else (0.008 sec.)
条件式 14299
条件式 Conditional expressions let you use if ... elif ... else logic within filters, annotations, aggregations, and updates. A conditional expression evaluates a series of conditions for each row of a table and returns the matching result ... >> When ( Q ( then = 0 ), then = 1 ) Case class Case ( * cases , ** extra ) [ソース] Case() 式は Python の if ... elif ... else 文のようなものです。指定された When() オブジェクトの各 condition は 1 つが True と評価されるまで順番に評価されます。一致し ... 件がJane DoeとJack Blackの両方にマッチしても正しい結果が得られることを覚えておいてください。これは Python の if ... elif ... else 文と同じように動作します。 case() は filter() 句でも使えます。たとえば、1ヶ月以上前に登録されたゴールドクライアントと1年以 ... データベースでは、これは CASE ステートメントを使ってエミュレートされます: SELECT count ( CASE WHEN account_type = 1 THEN id ELSE null ) as regular , count ( CASE WHEN account_type = 2 THEN id ELSE null ) as gold , count ( CASE WHEN account_type = 3 TH ...
https://man.mtool.work/django/6.1/ref/models/conditional-expressions.html
"sites" フレームワーク 11481
"sites" フレームワーク Django にはオプションで "sites" フレームワークが付属しています。これは、オブジェクトや機能を特定の Web サイトに関連付けるためのフックで、 Django で動くサイトのドメイン名や "冗長な" 名前を保持する場所です。 1 つの Djan ... ます。たとえば: from django.conf import settings def my_view ( request ): if settings . SITE_ID == 3 : # Do something. pass else : # Do something else. pass It's fragile to hardcode the site IDs like that, in case they change. The cleaner way of accom ... _view ( request ): current_site = get_current_site ( request ) if current_site . domain == "foo.com" : # Do something pass else : # Do something else. pass これには、サイトフレームワークがインストールされているかどうかを確認するという利点もあります。 ... out_request (): current_site = Site . objects . get_current () if current_site . domain == "foo.com" : # Do something pass else : # Do something else. pass 表示用の現在のドメインを取得する LJWorld.com と Lawrence.com はどちらも、ニュースが発生したとき ...
https://man.mtool.work/django/6.1/ref/contrib/sites.html
ファイルのアップロード 10220
ファイルのアップロード Django がファイルアップロードを扱うとき、ファイルデータは request.FILES に格納されます ( request についての詳細は リクエスト/レスポンス オブジェクト を参照してください)。ここでは、ファイルがどのようにディスクとメモリに ... if form . is_valid (): handle_uploaded_file ( request . FILES [ "file" ]) return HttpResponseRedirect ( "/success/url/" ) else : form = UploadFileForm () return render ( request , "upload.html" , { "form" : form }) ここで、 request.FILES をフォームの ... , request . FILES ) if form . is_valid (): # file is saved form . save () return HttpResponseRedirect ( "/success/url/" ) else : form = ModelFormWithFileField () return render ( request , "upload.html" , { "form" : form }) 手動でオブジェクトを作成す ... ithFileField ( file_field = request . FILES [ "file" ]) instance . save () return HttpResponseRedirect ( "/success/url/" ) else : form = UploadFileForm () return render ( request , "upload.html" , { "form" : form }) リクエストの外で手動でオブジェクト ...
https://man.mtool.work/django/6.1/topics/http/file-uploads.html
Djangoの認証システムを使用する 9908
Djangoの認証システムを使用する このドキュメントでは、デフォルト設定でのDjangoの認証システムの使用方法を説明します。この設定は、タスクの適切な範囲を管理することで、最も一般的なプロジェクトのニーズにかなうよう徐々に発展してきました。そして、パ ... thenticate ( username = "john" , password = "secret" ) if user is not None : # A backend authenticated the credentials ... else : # No backend authenticated the credentials ... request はオプションで、 HttpRequest のインスタンスを取ります。このインス ... icated を用いて次のように識別できます。 if request . user . is_authenticated : # Do something for authenticated users. ... else : # Do something for anonymous users. ... 非同期ビューでは次のようになります。 user = await request . auser () if user . i ... s_authenticated : # Do something for authenticated users. ... else : # Do something for anonymous users. ... ユーザーをログインさせる方法 現在のセッションに接続したい認証ユーザーがいる場合、 ...
https://man.mtool.work/django/6.1/topics/auth/default.html
Sprint quickstart guide 9597
Sprint quickstart guide This document explains how to prepare to contribute to Django. It is intended for use during sprints, or by people who are already familiar with contributing to Python open source projects. This guide assumes you're ... ush the branch to your fork and open a pull request. See Submitting contributions for the full process. Continuing someone else's work If you're continuing the work from someone else's pull request on GitHub, things can be tricky. You need to pull th ...
https://man.mtool.work/django/6.1/internals/contributing/sprint-quickstart.html
Submitting contributions 9285
Submitting contributions We're always grateful for contributions to Django's code. Indeed, bug reports with associated contributions will get fixed far more quickly than those without a solution. Typo fixes and trivial documentation changes ... he process for suggesting new features . If a ticket for this issue already exists and has been accepted, make sure nobody else has claimed it. To do this, look at the "Owned by" section of the ticket. If it's assigned to "nobody," then it's availabl ... e to be claimed. Otherwise, somebody else may be working on this ticket. Either find another bug/feature to work on, or contact the developer working on the ticket ... week or two, another developer may ask you to relinquish the ticket claim so that it's no longer monopolized and somebody else can claim it. If you've claimed a ticket and it's taking a long time (days or weeks) to code, keep everybody updated by po ...
https://man.mtool.work/django/6.1/internals/contributing/writing-code/submitting...
組み込みテンプレートタグとフィルタ 8336
組み込みテンプレートタグとフィルタ このドキュメントでは、 Django の組み込みテンプレートタグとフィルタについて述べます。 また 自動ドキュメンテーション を使えばインストールされている組み込みタグとカスタムタグのドキュメントを読めるのでお勧めで ... あります。: < ul > {% if athlete_list %} {% for athlete in athlete_list %} < li > {{ athlete.name }} </ li > {% endfor %} {% else %} < li > Sorry, no athletes in this list. </ li > {% endif %} </ ul > if {% if %} タグは変数を評価し、その変数が "true" で ... tes: {{ athlete_list | length }} {% elif athlete_in_locker_room_list %} Athletes should be out of the locker room soon! {% else %} No athletes. {% endif %} 上の例では、 athlete_list が空でなければ、アスリートの人数を {{ athlete_list|length }} 変数で表 ... 示します。 例にもあるように if タグはオプションで 1 個以上の {% elif %} 節、および 1 個の {% else %} 節をつけることができます。 {% else %} はそれまでの評価結果がすべて True でなかった場合に表示されるコンテンツを定義します ...
https://man.mtool.work/django/6.1/ref/templates/builtins.html
Django テンプレート言語 8336
Django テンプレート言語 このドキュメントはDjangoテンプレートシステムの文法を説明しています。もしあなたがもっと技術者的な観点でどう動かすかやどう拡張するかを知りたい場合は、 Python プログラマーのための Django テンプレート言語 を参照してくださ ... athlete_list : < ul > {% for athlete in athlete_list %} < li > {{ athlete.name }} </ li > {% endfor %} </ ul > if , elif , else 変数を評価し、その変数が "true "の場合、ブロックの内容が表示されます: {% if athlete_list %} Number of athletes: {{ athlete ... _list | length }} {% elif athlete_in_locker_room_list %} Athletes should be out of the locker room soon! {% else %} No athletes. {% endif %} 上記の場合、 athlete_list が空でなければ、 {{ athlete_list|length }} 変数によって選手の数が表示 ... な演算子を使うこともできます: {% if athlete_list | length > 1 %} Team: {% for athlete in athlete_list %} ... {% endfor %} {% else %} Athlete: {{ athlete_list.0.name }} {% endif %} 上の例はうまくいきますが、ほとんどのテンプレートフィルタは文字列を返すの ...
https://man.mtool.work/django/6.1/ref/templates/language.html
クラスベースのビューでフォームを扱う 8336
クラスベースのビューでフォームを扱う フォームの処理には、一般に3つの場合分けが存在します。 最初の GET リクエスト (空白またはデフォルト値が埋め込まれたフォームを返す) 無効なデータの POST リクエスト (よくあるパターンは、エラー表示を追加したフ ... ( self , form ): response = super () . form_invalid ( form ) if self . request . accepts ( "text/html" ): return response else : return JsonResponse ( form . errors , status = 400 ) def form_valid ( self , form ): # We make sure to call the parent's ... ave() for example). response = super () . form_valid ( form ) if self . request . accepts ( "text/html" ): return response else : data = { "pk" : self . object . pk , } return JsonResponse ( data ) class AuthorCreateView ( JsonableResponseMixin , Cre ...
https://man.mtool.work/django/6.1/topics/class-based-views/generic-editing.html
フォームを使う 8336
フォームを使う このドキュメントについて このドキュメントでは、Web フォームの基本と、それらを Django で扱う方法を紹介しています。より詳しく知りたいときは、フォーム API の特定の領域、 フォーム API 、 フォーム フィールド または フォームとフィー ... direct to a new URL: return HttpResponseRedirect ( "/thanks/" ) # if a GET (or any other method) we'll create a blank form else : form = NameForm () return render ( request , "name.html" , { "form" : form }) もし GET とともにビューにたどり着いた場合は ... d through the contact form. \n " f "Contact email (unverified): { contact_email } \n " f "Marked urgent: { 'yes' if urgent else 'no' } \n " f "Message: \n { message } " ) # Send the message, directing replies to the contact_email. EmailMessage ( subj ... ody , from_email = "contact-form@example.com" , to = [ "info@example.com" ], headers = { "Importance" : "high" } if urgent else None , reply_to = [ contact_email ], ) . send () return HttpResponseRedirect ( "/thanks/" ) Tip Django からメールを送信する ...
https://man.mtool.work/django/6.1/topics/forms/
PREV 1 2 3 4 5 6 NEXT