2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

(Djangoメモ)ImageFieldを使う

2
Posted at

PIL(PythonImagingLibrary)が必要。
インストールはeasy_installで出来る。
参考:http://memo.yomukaku.net/entries/BWTTNPl

インストールできたらまずは画像のアップロード先になるディレクトリ MEDIA_ROOT を設定。

settings.py
# ...
MEDIA_ROOT = os.path.join(BASE_DIR,'media')  # デフォルトでは定義されていないので手書き追加
# ...

あとは好きなように作って・・・

models.py
class Face(models.Model):
	image = models.ImageField(upload_to='images/')  # upload_toは指定必須で、MEDIA_ROOT以下の同名ディレクトリにファイルがアップロードされる
	is_ok = models.BooleanField()

アップロード先のパーミッションをいじればOK。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?