Twelve-Factor App に準拠した Web アプリケーション開発について

I’ve been working on a Django project that required a file upload. I like to practice what is these days called an API first approach to app design, but has been a pretty good practice well before the term was coined. So, my projects generally start with a REST framework. In the Python/Django ecosystem, I default to the exceptionally well designed django-rest-framework. I had to do quite a bit of
Djangoの管理画面の一覧表示でページング(ページネーション)表示がありますが、あれを通常のページで使う方法です。 django.contrib.admin.views.main.ChangeListオブジェクトを管理画面で使っているのですが、これのモックを作って使ってみました。 Djangoのバージョンは1.1.2と1.2.1で確認しました。 urls.py from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'^$', 'myapp.views.index'), ) myapp/views.py #coding:utf-8 from django.utils.http import urlencode from django.core.paginator import Paginator, I
Complete beginners start here!Getting started with the webGetting started with the webInstalling basic softwareWhat will your website look like?Dealing with filesHTML basicsCSS basicsJavaScript basicsPublishing your websiteHow the web worksHTML — Structuring the webIntroduction to HTMLIntroduction to HTMLGetting started with HTMLWhat's in the head? Metadata in HTMLHTML text fundamentalsCreating hy
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? ※追記:パフォーマンス比較ですが、「インデックスちゃんとはったら良くね?」との指摘がありました。その通りです。申し訳ありません。 RESTful な API を作る時のページネーションのプラクティスが Django RESTful Framework の Pagination に良くまとまっているので、 Django 以外の別の実装のためにも汎用化したい。 レスポンスの表現方法 レスポンスで次のページを示す方法には以下の方法がある。 JSON や XML のレスポンスに含める Link ヘッダに URL で指定する RFC 8288 G
Djnagoで、1ページあたりの件数が多くなった時にページングする方法を調べた時のメモです。 なお、ページングという用語については、 ページング(Paging) ページネーション(Pagination) ページャー(Pager) などの呼び方があるものの、今回は以下に従いページングと呼ぶことにします。 一覧リストにおけるページングについて : circumstance evidence 環境 Windows10 Python 3.5.1 Django 1.9.2 django-pure-pagination 0.3.0 2018/8/26 追記 この記事で取り上げた django-pure-pagination ですが、 現在メンテナンスされていない Django2.1以降に対応していない の問題があるようです。 そのため、新規に導入する場合には、別のライブラリを使ったほうが良いです。 2
from django import forms class AuthenticationForm(forms.Form): username = forms.CharField( max_length=254, widget=forms.TextInput(attrs={'class': "input-lg"}), ) password = forms.CharField(widget=forms.PasswordInput) I dislike this approach because it requires including presentation rules in our back-end code. This class attribute is used exclusively by our CSS and/or JavaScript and should therefo
tutorial How to Create Django Signals Jul 28, 2016 7 minutes read comments views The Django Signals is a strategy to allow decoupled applications to get notified when certain events occur. Let’s say you want to invalidate a cached page everytime a given model instance is updated, but there are several places in your code base that this model can be updated. You can do that using signals, hooking s
2017年4月4日、Django 1.11 LTSがリリースされました! 今回のバージョンはLTS(Long Term Support=長期サポート)なので、非LTSバージョンよりサポート期間が長めになっています。サポート期間についての詳細は以下URL「Supported Versions」を確認してください。 https://www.djangoproject.com/download/ それでは、release notesに載っている主な変更点について解説します。 Python2サポートは1.11で最後 1.11はPython2をサポートする最後のバージョンです。次の2.0からはPython3のみサポートになります。 1.11のサポート期限は2020年4月までなので、それまでにはPython3への移行を終える必要があります。1 Deprecating warningsがデフォルトで無効
HyperKitty, the next-generation mailing-list archiver View page source HyperKitty, the next-generation mailing-list archiver HyperKitty is a Django-based application providing a web interface to access GNU Mailman v3 archives, and interact with the lists. The project page is https://gitlab.com/mailman/hyperkitty. There is a demo server available, but it’s also a development server, so it may be b
この記事には以下の追記がありますので、あわせてお読みください。 koty.hatenablog.com modelが大きくなってきたり、migration ファイルが増えると、unit testの最初に流れるmigrationのせいでテストの実行に時間がかかるようになる。そこで高速化を試みた。 作戦としては、 migrate済みのsqliteファイルを用意しておく テスト実行時にsqliteファイルをコピーする migrationをスキップしつつ、コピーしたファイルに対しテストを実行する ということを考えた。 migrationのスキップ方法はここに書いてある通り。 simpleisbetterthancomplex.com というわけで、以下のような設定を追記するとうまくいく。これで実行時間が半分になった。*1 import shutil # あらかじめmigrate済みの空のファイルd
This repository includes a boilerplate project used for all Seedstars Labs applications. It uses Django as backend and React as frontend. We build on the shoulders of giants with the following technologies: Frontend React React Router Declarative routing for React Babel for ES6 and ES7 magic Webpack for bundling Webpack Dev Middleware Clean Webpack Plugin Redux Predictable state container for Java
djangoのモデルデータはマネージャというオブジェクトを介して取得します。 独自定義のマネージャを使うことでデフォルトとは違う挙動をさせることができて便利ですが、地雷もありますよという話。 http://docs.djangoproject.com/en/1.2/topics/db/managers/#custom-managers マネージャのカスタマイズ class MyManager(models.Manager): def get_query_set(self): return super(MyManager, self).get_query_set().filter(is_deleted=False) def with_user(self, user): return self.filter(user=user) class MyModel(models.Model): is_
Djangoで、CreateView + ModelForm + Modelを使った時に、 バリデーションを書く場所 バリデーションの実行順序 が気になりました。 後述の通り日本語の分かりやすい記事があったものの、実際に手を動かさないと理解できない部分もあったため、その時のメモを残します。 目次 環境 バリデーションを書く場所について ModelForm 各フィールドごとのバリデーション 複数フィールドを組み合わせるバリデーション Model 各フィールドごとのバリデーション 複数フィールドを組み合わせるバリデーション バリデーションの呼び出し順について 実装 myapp/utils.py ModelForm Model バリデーションエラーなしの場合の動作確認 バリデーションエラーありの場合の動作確認 最初のForm.clean_<filed_name>でエラー Form.CustomF
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く