2016-10-01から1ヶ月間の記事一覧
概要 とにかくdockerを使ってみる。今回は、dockerfile編。herokuで使うときも重要になってくる。 参考書籍 プログラマのためのDocker教科書 インフラの基礎知識&コードによる環境構築の自動化作者: 阿佐志保,山田祥寛出版社/メーカー: 翔泳社発売日: 2015/1…
概要 Dockerを使ってみる。 参考書籍 https://www.amazon.co.jp/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9E%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AEDocker%E6%95%99%E7%A7%91%E6%9B%B8-%E3%82%A4%E3%83%B3%E3%83%95%E3%83%A9%E3%81%AE%E5%9F%BA%E7%A4%8E%…
とりあえず、先の記事で、dockerfileから作ったheroku appに、いつもの手順でgit push heroku masterしてみる。以下のようなerrorが出てきた。 boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacA…
概要 dockerfileの読解はなんとなくわかったので、実際に公式イメージをダウンロードして使ってみる。 参考サイト qiita.com https://hub.docker.com/u/heroku/ 手順 まず公式サイトからimageのdockerをダウンロードしてみる。 今回はこちらを使ってみました…
概要 dockerfileの書き方をいまいち理解してないので、読解してみる。最終的にdjangoでdeploy予定なので、それに近いflaskでやっている方の記事を参考にしてみました。 参照サイト qiita.com qiita.com 読解 記事からそのまま転用しています。 image_clock/ …
概要 Dockerfileからdocker imageをbuildして、herokuにdeployできる、Container Registry and Runtimeを使ってみる。 当方、dockerについては、ほとんど何も知らない素人なので、dockerについても色々推察しながら進めて見ます。 参照 qiita.com devcenter.…
container registry and runtime についての公式ページのブログ。 blog.heroku.com もしかすると、container registry and runtime は、Dockerfileがあれば build imageと、pushをやってくれるというすごいやつかもしれない。
概要 docker for macを導入してみる。あと、heroku dockerチュートリアルもやってみる。 参照サイト docs.docker.com devcenter.heroku.com 手順 docker for macをinstallする docs.docker.com kitematic (docker for mac)をinstallする。 kitematicは、dock…
概要 Django, herokuのアプリ上で、matplotlibのグラフデータをs3に保存する。 参照サイト sites.google.com Python 3.5 対応画像処理ライブラリ Pillow (PIL) の使い方 - Librabuch 手順 とりあえずlocalに保存してみる。 def matplotlib_image(media_path,…
概要 Djangoで、画像処理をするときに、backendではなく、frontendで直感的に、操作できるようなものを作りたかったので、Adobe Creative SDKを導入してみた。 参照サイト ほぼ以下のサイトの手順通りになっています。 plus.appgiga.jp 手順 必要なファイル…
概要 画像処理関連のライブラリ、scikit-imageをdjango+heroku+s3の環境で試してみた。 opencvを導入しようとするも、挫折orz 参照サイト 公式サイト: scikit-image: Image processing in Python — scikit-image 日本語での解説サイト<-めちゃめちゃわかり…
概要 image.save(image.url, "フォーマット") の時のフォーマットをファイルの拡張子によって、自動で指定する関数を作りたい。 コード def get_file_extension(file_extension): if file_extension == "jpg": upper_file_extension = "JPEG" else: upper_fi…
概要 django で、漢字・ひらがな・カタカナをローマ字に変換して、slugなどに利用したい! 参照サイト qiita.com pypi.python.org 利用方法 pip install する pip install pykakasiだと失敗するので、githubのソースコードを直接installする。 requirements…
参照サイト File storage API | Django documentation | Django django+heroku+s3で本番環境を整えていたところ、ファイルアップ関連で以下のエラーが出てしまった。 raise NotImplementedError("This backend doesn't support absolute paths.") NotImpleme…
コードの概要 settings/local.py ... STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static_in_pro", "our_static"), ) STATICFILES_STORAGE = 'appname.custom_storages.StaticRootS3BotoStorage' STATIC_URL = "https://%s/%s/" % ("bucketname.s3-websit…
参照サイト send_gridで設定してみる。 Send SMTP Email with Django - SendGrid Documentation | SendGrid まずは、settings/local.py で試してみる。 EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_HOST_USER = '***********' EMAIL_HOST_PASSWORD = '*********…
DjangoでHerokuにdeployするときに、環境変数をセットする方法 公式ドキュメントの通り Configuration and Config Vars | Heroku Dev Center heroku config:set GITHUB_USERNAME=joesmith Adding config vars and restarting myapp... done, v12 GITHUB_USER…
静的ファイル公開の場合の設定をしてみる 静的ファイルの公開方法 — Django 1.4 documentation S3などを利用する場合はこちら 静的ファイルの公開方法 — Django 1.4 documentation ちなみに、カスタムストレージの設定方法はこちら カスタムのストレージシス…
mediaと、staticを分ける方法の1つが判明 概ね、後編でやった、custom_storages.pyを使う方向で間違っていなかった。 こちらの回答が参考になりました! How to set-up a Django project with django-storages and Amazon S3, but with different folders f…
後編 後編では、media_url, static_url などを再設定していく 参照サイト 以下の2つを中心に進めていきます。 Using Amazon S3 to Store your Django Site's Static and Media Files | Caktus Group Heroku上のDjangoアプリで静的ファイルをS3から配信する…
参照サイト 全て以下のリンクのおかげです。 orangain.hatenablog.com めちゃめちゃわかりやすいです! 上記を元に進めて、こちらで設定に困った箇所を中心に編集していきます。 前編 S3の設定について 名前をdesigntoollab と設定した場合のポリシーの追加…
django projectをherokuにあげる Deploying Python and Django Apps on Heroku | Heroku Dev Center Procfileを、ルートディレクトリに配置する(manage.pyと同じ場所) Procfile web: gunicorn ecommerce2.wsgi --log-file - pip freeze > requirements.txt …
django-filterを使ってみる 公式ドキュメント: django-filter — django-filter 0.15.2 documentation まずはpip install pip install django-filter settings/local.pyに設定をかきこむ INSTALLED_APPS = ( ... #third party apps 'django_filters', ... dj…
UIを少し修正 修正に役に立った・知らなかったtips的なもの {% if object_list|length <= 0 %} でobjectの長さを確認できる。
DjangoClass Based ViewのCreateView,UpdateViewとModelFormの組み合わせて使う UpdateViewのform_classに、ModelFormを代入する class ImageUploadForm(forms.ModelForm): class Meta: model = Image fields = ['image'] widgets = { 'image': forms.FileIn…
django registration redux 簡単にいうと、django-registrationに、メール認証機能をつけたモジュール。導入もお手軽。 参照にしたサイト 公式サイト: django-registration-redux 1.4 documentation — django-registration-redux 1.4 documentation CodingE…
Django thumbnail imageを作成する。 def original_post_save_receiver(sender, instance, *args, **kwargs): if instance.image: processed_obj = OriginalImageProcessed.objects.create(original=instance) owner_slug = instance.slug media_path = inst…
<a class="btn btn-primary" href='{{ obj.image.url }}' download>ダウンロード</a> hrefに、downloadをつけるだけでとりあえずダウンロードリンクだけはできる。ただ、これだとセキュリティ上、イマイチぽいので、別のやり方としては、以下のような方法があるらしい! def safe_name(file_name): """ Generates a safe file nam…
Bratintreeのtransactionを試してみる。 Braintreeのtokenを処理するClient を自分たちのサイトに設定する。 公式ドキュメント参照: Set Up Your Client | JS - Braintree Developer Documentation templates/javascript.html に追記する。 ちょっとjsv3は…
Braintree Instance Methods orders/models.py get_braintree_id メソッドを設定する。 class UserCheckout(models.Model): ... @property def get_braintree_id(self,): self = instance if not instance.braintree_id: result = braintree.Customer.create…