diadia

興味があることをやってみる。自分のメモを残しておきます。

エラー対処

nginxで403が返されるときに対応したこと

サーバー上に新しくディレクトリを作成し、そこを起点にgithubからpullを行いデプロイした際にうまく作動しなかった。 環境 centos7 nginx porstgresql django 症状: home画面のhtmlはサーバーから配信される。 home画面の静的ファイルの配信がうまく行って…

エラー:form.is_valid()の結果が常にFalseになる場合

エラー原因に対する基本的な探索方法 form.is_valid()を実行したあとには、errorsアトリビュートを実行するか、formをfor構文で各要素をprintするとエラー原因を探る事ができる。 if form.is_valid() == False: for ele in form : print(ele) 今回のエラー内…

UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list

以下の注意メッセージが表示される UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list:****** 解消方法 参考にしたところ:https://stackoverflow.com/questions/44033670/python-django-rest-framewor…

postgresのパスワードが分からない場合

postgresのパスワードが分からない場合 いろんな方のブログを見ていると、postgresqlをインストールすると同時にpostgresユーザーが作成される。そしてpostgresのパスワードも設定することになる、と書いてあるが、自分の場合postgresのパスワードを定める機…

django:sendgridでメール本文において&が&に変換されてしまう件について

状況 Checkクラスにはurlを格納する属性があり、一定時間ごとに各インスタンスurlを利用し、ウェブサイトにアクセスする。そして特定の情報が存在した場合にsendgridを使って自分のメールに送信する仕組みを設けた。メール本文にはアクセスしたurlを載せる。…

エラー:django.core.exceptions.ImproperlyConfigured: The included URLconf '***.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

django.core.exceptions.ImproperlyConfigured: The included URLconf '***.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import. djangoのエラーでa circul…

DRF JSONデータの成形

成形する必要性 django rest framework の場合request.POSTには注意事項がある。 それはキーに対する値が空(ブランク?null?)の項目はDRFはエラーを吐き出す。辞書型データに例えて説明すると、ex_dict["key1"]=""の要素を含むデータをrequests.POSTするとエ…

エラー:AssertionError: You cannot call `.save()` on a serializer with invalid data.

AssertionError: You cannot call `.save()` on a serializer with invalid data. 上記のエラーが表示された。 エラーが出た状況: インスタンスを生成することを目的にdjango rest apiでrequests.post()をする。するとdjango アプリケーションで上記のエラ…

エラー:json.decoder.JSONDecodeError: Extra data

エラー内容とエラーが出た経緯 Traceback (most recent call last): File "execute.py", line 38, in <module> json.load(f) File "/anaconda3/lib/python3.6/json/__init__.py", line 299, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_</module>…

centos7 psycopg2のインストールエラー

sudo pip3.6 install psycopg2のエラー Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-70sqru_l/psycopg2/ 以上のようなエラーが出た。この問題には以下のように解決する。 https://ja.stackoverflow.com/questions/469…

初期化したサーバにssh接続できない件

エラー原因のコマンド ssh root@***.***.***.*** エラーメッセージの一部 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@…

sqlite3:エラー対処:sqlite3.OperationalError: near ")": syntax error

sqlite3.OperationalError: near ")": syntax error このエラーがたまに出て、足止めをくらうのでメモにしておく。 コード cur.execute("INSERT INTO mydb VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,)", (url,title,description,price,None,None,None,None,None,…

SQLAlchemy:エラー対処:sqlalchemy.exc.ArgumentError: Unknown arguments passed to Column: ['precision', 'asdecimal']

エラーコード sqlalchemy.exc.ArgumentError: Unknown arguments passed to Column: ['precision', 'asdecimal'] コード class Product(Base): __tablename__ = 'mydb_jp' description = Column(Text) price = Column(Float, precision=(10,0), asdecimal=Tr…

SQLAlchemy:エラー対処:sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None

エラーメッセージ: sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None エラーが出た背景 sqlite3のデータベースを読み込みいろいろ変更しようとする際に起きた。 エラー部分 engine = create_engine('sqlite://…

django エラー:AttributeError: 'ManyToManyField' object has no attribute 'm2m_reverse_field_name'が出る

python manage.py makemigrations をしたら以下のようなエラーが出た。 AttributeError: 'ManyToManyField' object has no attribute 'm2m_reverse_field_name' エラーが出るまでの過程 models.pyをいじり、makemigrationsを終わったあとにmigrateした。 問…

TypeError: unhashable type: 'set' エラー対処

エラー内容 TypeError: unhashable type: 'set' 上記のエラーが出てきた。unhashable typeって出てきた。 エラー発生箇所 以下のコードがエラーの発生源だった。 print(type({{ cart_obj.subtotal }})) 他にもこのコードも同様なエラーが出た。 charge = str…

IntegrityErrorが発生してしまう。。。

エラー対処中 解決次第更新する django.db.utils.IntegrityError: NOT NULL constraint failed: appname_model.anoteher_model_id 同じエラーが出ている人の記事: http://nihaoshijie.hatenadiary.jp/entry/2014/06/12/090008 ドキュメントのフィールドオプ…

If you see valid patterns in the file then the issue is probably caused by a circular import.

エラー内容 The included URLconf '<module 'apps.urls' from 'hoge/apps/urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import. 文章の意味は、apps/urls.pyにurlのパターンが存在しないからエラーが</module>…

Exception Type : MultipleObjectsReturnedが出るとき

エラー内容 djangoを使っていて以下のエラーが出た。このエラーに対してなんのことか分からなかったのでメモしておく。 Exception Type: MultipleObjectsReturned Exception Value: get() returned more than one Post -- it returned 4! エラー箇所のコード…

opencvのエラー

エラー内容1 Traceback (most recent call last): File "opencv_practice.py", line 10, in cv2.imshow("resized",image1) cv2.error: OpenCV(4.0.0) d:\build\opencv\opencv-4.0.0\modules\highgui\src\window .cpp:358: error: (-215:Assertion failed) si…

git エラー集

リモートリポジトリに上げたコードをpullしようとしたところ、下記のエラーが出てしまった。 error: Your local changes to the following files would be overwritten by merge: ****/****/__pycache__/models.cpython-36.pyc ****/****/__pycache__/settin…

UnicodeEncodeError:が表示されるとき

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)がdjangoで表示された。 環境、状況 環境 centos7 django2.1 python3.6 状況 python36 manage.py createsuperuser と叩き、ユーザ名を入力すると上の…

makemigrationsでNo changes detectedが返される場合

参考URL https://www.monotalk.xyz/blog/django-model-%E3%82%92%E4%BD%9C%E6%88%90%E3%81%97%E3%81%9F%E3%81%8Cmakemigrations-%E3%81%A7-no-changes-detected-%E3%81%AB%E3%81%AA%E3%82%8B/ python manage.py makemigrations参考先によると上記のコマンド…