[정리중] Django ISSUE 본문

[PL]/Python

[정리중] Django ISSUE

객과 함께. 2021. 7. 17. 20:00

Configure the DEFAULT_AUTO_FIELD setting or the BlogConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
=> models.py에 id 명시적으로 기록해서 수정하였다. (id = models.BigAutoField(primary_key=True) 추가함.)
    이러한 오류는 장고 3.1 버전에서 3.2 버전으로 업데이트하면서 생긴 메시지 인듯함.

---------------------------------------------------------------------------------------------------------

You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): users.
Run 'python manage.py migrate' to apply them.
=> 데이터베이스 users 에 마이그레이션을 적용 해주면 없어짐.

---------------------------------------------------------------------------------------------------------

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
=> 장고의 환경이 아니거나 잘못된 경로에서 실행할때 생김.

----------------------------------------------------------------------------------------------------------

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
=> 장고의 실행 할 수 있는 조건과 환경이 없어서 생기는 오류임. 
     가상 환경이 만들어져 있다면 가상환경이 아닌 일반 환경에서 실행해서 생기는 오류임.

-----------------------------------------------------------------------------------------------------------

AssertionError: You need to pass a valid Django Model in BooksType.Meta, received "None".
=> 이것의 원인을 찾았다. 원인은 graphqlExam App의 schema.py에 class BooksType.Meta 구성을 하면서  model -> models 작성.
이것을 정상적으로 model로 바꾸었음.(오타로 인한 버그.)

-----------------------------------------------------------------------------------------------------------

django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: staticfiles
=> settings.py의 내용중에서 INSTALLED_APPS에 같은 이름의 프로그램이 중복되어서 나는 오류임.

-----------------------------------------------------------------------------------------------------------

WARNINGS:
?: (urls.W005) URL namespace 'rest_framework' isn't unique. You may not be able to reverse all URLs in this namespace
=> 프로젝트 urls.py 에서   path('', include('todos.urls')), 나  path('todo/', include('todos.urls')), 중 하나로 정의 하면 경고 메세지는 없어진다. 

-----------------------------------------------------------------------------------------------------------

RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': (2002, "Can't connect to MySQL server on 'localhost' (10061)")
  warnings.warn(
No changes detected
=> 윈도우즈 '서비스' 에서 해당 데이터베이스 서비스가 켜줘 있지 않아서 생기는 버그.
   윈도우즈 서비스 항목을 체크 바람.

-----------------------------------------------------------------------------------------------------------

TypeError: _path() missing 2 required positional arguments: 'route' and 'view'
=> 일치하는 패턴이 'urls.py'에서 찾지 못해서 생기는 버그임.

-----------------------------------------------------------------------------------------------------------

ypeError: __init__() got an unexpected keyword argument 'related_name'
=> Django models 작성시에  (CharField, ForeignKey, DateField, IntegerField) 필드에서 제공하는 옵션중에  "related_name"은 지원하지 않아서 생기는 버그임.

-----------------------------------------------------------------------------------------------------------

ERRORS:
doro.tb1doroaddress.tb1_dc: (fields.E304) Reverse accessor for 'doro.tb1doroaddress.tb1_dc' clashes with reverse accessor for 'doro.tb1doroaddress.tb1_tsdo'.
        HINT: Add or change a related_name argument to the definition for 'doro.tb1doroaddress.tb1_dc' or 'doro.tb1doroaddress.tb1_tsdo'.
doro.tb1doroaddress.tb1_tsdo: (fields.E304) Reverse accessor for 'doro.tb1doroaddress.tb1_tsdo' clashes with reverse accessor for 'doro.tb1doroaddress.tb1_dc'.
        HINT: Add or change a related_name argument to the definition for 'doro.tb1doroaddress.tb1_tsdo' or 'doro.tb1doroaddress.tb1_dc'.

=> https://stackoverflow.com/questions/58788480/python-error-fields-e304-reverse-accessor-for-field-clashes-with-reverse-acc

 

Python Error : (fields.E304) Reverse accessor for field clashes with reverse accessor for another field

Below is my models.py file in a Django project. Whenever I try to run the project I get the following error. Please assist as I have just started picking up django I tried changing the names of the

stackoverflow.com

-----------------------------------------------------------------------------------------------------------

django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
positioninfo.tb5posiinfo: (models.E012) 'unique_together' refers to the nonexistent field 'tb5_sgn'.
positioninfo.tb5posiinfo: (models.E012) 'unique_together' refers to the nonexistent field 'tb5_tsn'.

=> models에서 작성한 것과 DB 테이블에서 작성한 필드명이 틀렷을 경우 나타남.

-----------------------------------------------------------------------------------------------------------

django.db.utils.OperationalError: (1045, "Access denied for user 'DB User_ID' )
=> vscode, PyCharm 등에서 DB에 접근후 로그인 할때 해당 유저의 정보가 맞지 않아서 생기는 오류임.

-----------------------------------------------------------------------------------------------------------

django.db.utils.OperationalError: (1050, "Table 'tb5posiinfo' already exists")

django.db.utils.OperationalError: no such table: posts_post
=> Django에서 makemigrations 실행 한 후  migrate시에 나타나는 오류임. 이것은 DB테이블에 이미 테이블이 존재하는데 해서 생기는 WARNINGS임.

-----------------------------------------------------------------------------------------------------------

django.template.exceptions.TemplateDoesNotExist: graphene/graphiql.html
=> 이 버그는 Graphql 라이브러시 사용시에 나타난 오류임. 
   schema, models, urls등에 작성한 후 setting에서 "INSTALLED_APPS , GRAPHENE" 이부분 때문에 
   생겼던 오류


INSTALLED_APPS = [
    'graphene_django',
]

GRAPHENE = {
    "SCHEMA": "doroAddress.schema.schema"
}

-----------------------------------------------------------------------------------------------------------

graphql.error.located_error.GraphQLLocatedError: tb5posiinfo matching query does not exist.
=> 이 오류는 기본 sql언어에서 대략적인것을 검색 할때 LIKE명령을 사용하여 검색을 하는데 Graphql에서는 이것과 맞지 않아서 생기는 오류임.

-----------------------------------------------------------------------------------------------------------

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

=> Graphene-Django 기반의  Todo프로그램을 만들면서 생겼던 오류로써 작성된 그를 취소 하거나 삭제처리 할때 

발생 하였다.  json.loads()에서

json_data = json.loads(result.text.__str__())

에서 

json_data = json.loads(result.text.__str__().strip("'<>() ").replace('\'', '\"'))

변경 하였다. 

-----------------------------------------------------------------------------------------------------------

ImportError: cannot import name 'url' from 'django.conf.urls' (urls.py 경로명)

=> django 4버전 부터는 "from django.conf.urls import url"를 지원하지 않는다. 
   django 4 버전에서는 "form django.urls import path, re_path"만을 허용함.

-----------------------------------------------------------------------------------------------------------

django.db.utils.IntegrityError: (1048, "Column 't_name' cannot be null")

=> templlate html단 에서 id값을 잘못 입력해서 컨트롤에서 값을 받아오지 못해서 발생 된것이며

또한 모델 단에서 작성된 필드명과도 맞지 않아서 발생된 오류이다. 

해결 방법은 html단에서 id의 속성값을 재확인 해서 수정 하면 잘 동작함.

-----------------------------------------------------------------------------------------------------------

django.core.exceptions.ImproperlyConfigured: Field name `DepartmentId` is not valid for model `Departments`.
-> serializer에서 발생된 오류임. 역시 오타로 인해 발생된 오류임.(DepartmentId -> DepartmentsId 수정)

-----------------------------------------------------------------------------------------------------------

AttributeError: 'DepartmentSerializer' object has no attribute 'is_value'
=> 오타로 인해서 발생된 오류임.(is_value -> is_valid 수정)

-----------------------------------------------------------------------------------------------------------

rest_framework.exceptions.ParseError: JSON parse error - Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
=> 습관에 의해서 발생된 오류임. 주로 single quotes-> double quotes로 수정 하엿음.

-----------------------------------------------------------------------------------------------------------

RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 127.0.0.1:8000/departments/4/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
-> urls.py에서 url에서 자동으로 '/'를 붙여준다. 그런데 이것이 문제가 된것 같음. 해결법은 url에서 '/'를 제거 하는 정상 동작을 할 수 있음.

-----------------------------------------------------------------------------------------------------------

api.models.Departments.DoesNotExist: Departments matching query does not exist.
=> 이는 원래 지우것이 목적이였으나 POST형식으로 해서 인덱스 번호를 넘겨 줄려고 하였으나 오류가 나서 URL로해서 인덱스 값을 넘겨 주었더니 정상 동작하였음.

'[PL] > Python' 카테고리의 다른 글

Graphql기반한 CRUD중 - Select  (0) 2021.09.13
[Django] Django ORM  (0) 2021.09.13
DJANGO settings.py 의 db(Postgresql, cubrid, sqlite3, mariadb)설정  (0) 2013.12.05
Django 관련  (0) 2013.12.02
[wxPython] static box & radio button  (0) 2007.11.09