파이썬/Django(108)
-
admin list에서 함수의 결과를 나오게 하는 방법
list_display = ['sentence_html','meaning_html', 'google_html'] search_fields = ['sentence','meaning'] def sentence_html(self,obj) : return format_html(obj.sentence.replace('\n',' ')) def meaning_html(self,obj) : return format_html(obj.meaning.replace('\n',' ')) def google_html(self,obj) : if obj.google == None : return obj.google else : return format_html(obj.google.replace('\n',' ')) 함수 라벨(labe..
2021.01.14 -
admin에서 Form 없이 수정화면의 label 변경
def get_form(self, request, obj=None, **kwargs) : form =super().get_form(request, obj, **kwargs) form.base_fields['desc'].label = 'afafas' return form
2021.01.14 -
admin 계정 생성
python manage.py createsuperuser
2021.01.14 -
django에서 shell 수행
python manage.py shell
2021.01.14 -
DB에 적용할 DML문 확인
Migrations for 'polls': polls/migrations/0001_initial.py - Create model Question - Create model Choice python manage.py sqlmigrate polls 000
2021.01.14 -
서버 실행
python manage.py runserver python manage.py runserver 8080 python manage.py runserver IP:8080
2021.01.14