LoginSignup
1
0

More than 3 years have passed since last update.

備忘録 俺得 いつか丁寧に記事にする

Last updated at Posted at 2021-02-17

cloudinary edit処理

1 formにdataのうむの核にン upload(form) delete(oldpublicid) getfile(newpublcid)
apiのcall数が2倍(delete and upload)下は1回(upload)
2 publicid and url are stayのほうが更新は楽だがformを介してpublicidを持ってuploadする方法がわからない

formに入力されたデータの受取

cha_name = form.cleaned_data.get('cha_name')
register_number = form.cleaned_data.get('register_number')
cha_url = form.cleaned_data.get('cha_url')

results['genre'] = request.POST.getlist("genre")
genre = {'genre_id': results}

localhostが勝手にhttpsにリダイレクト

1度setting.pyでhttpsにリダイレクトしてくれるコードを追加したところlocalhostで安全な接続ができないかなんとかが出てサーバーが立てられなかったのでコードを消した。するとそれ以降毎回httpsにredirectされてしまった
->
Chrome 設定 > 詳細設定 > 閲覧履歴データを消去する > 「キャッシュされた画像とファイル」にチェックを入れデータ消去を実行

form.is_validがエラーになる

->引っ張て来ているformのform.pyにおけるfieldがすべて検証されているか

改めてherokuにデプロイしたときにmakemigrations/migrateはうまくいくのにカラムがないと怒られる

$ heroku run python manage.py dbshell
でデータベースの中身を確認したところローカルの奴と違う
↑開発しているときにdb,migrationsを削除したからテーブルの中身が反映されていない
->herokuのアドオンからdbを削除して再びmigrations/migrateをすればうまくテーブルが作られた
dbを消さずにカラムなどを追加する方法を学ばねば運用できないやばい

manytomanyfieldのデータ作成追加削除

参考
https://djangobrothers.com/blogs/many_to_many_objects/

いいね機能の実装

https://h-memo.com/how-to-make-a-like-button-using-django-session/
これを参考に脳死でできた

テーブルをまたいだレコードの取得

genreに繋がったchannelに繋がったfavのuser_idがuser.idに一致するgenreを取得
genres = Genre.objects.filter(channel_fav_user_id = user.id).all()

googleanalyticsapiを使ってユーザーに訪問者数を確認できるようにする

初期設定 https://zerofromlight.com/blogs/detail/36/ 
データ取得 https://zerofromlight.com/blogs/detail/40/

googleサービスアカウントの秘密鍵jsonファイルをherokuで読み込ませる

csvをherokupostgresにリモートから追加する

1
0
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
1
0