Programing
-
[django] admin page를 통해 DB data 생성Programing/Python 2019. 4. 9. 07:42
이번에는 model에 생성한 DB를 admin page를 통해서 데이터를 생성해 보겠습니다. 1. admin 페이지 생성 $> python manage.py createsuperuser Username: admin Email address: admin@sample.com Password: Password (again): Superuser created successfully. 2. elections/admin.py 에 Candidate 추가 1 2 3 4 5 from django.contrib import admin from .models import Candidate # Register your models here. admin.site.register(Candidate) 3. admin page 접속..
-
[django] DB 생성과 마이그레이션Programing/Python 2019. 4. 9. 07:27
장고 앱에서는 MVT(Model/View/Template) 구조를 가지고 있는데요. 데이터 생성 및 관리를 Model 에서는 database를 사용하고 있습니다. sqlite를 default database로 사용하고 있는데 확장성을 위해서 다른 데이터베이스도 사용이 가능합니다. 이 글에서는 프로젝트 내에 앱과 DB 생성 과정을 정리해 보았습니다. 1. app 생성 $> python manage.py startapp elections 2. app 생성 확인 $> tree ├── elections │ ├── admin.py │ ├── apps.py │ ├── __init__.py │ ├── migrations │ │ ├── __init__.py │ │ └── __pycache__ │ │ └── __init..
-
[tistory] color scripterPrograming/Tips 2019. 4. 8. 16:17
https://colorscripter.com/ Color Scripter Simple & Flexible Syntax HighLighter colorscripter.com 티스토리 사용중에 소스 코드를 추가해야 하는 경우가 많은데요. 기존에 사용하던 syntaxhighliter 보다 보다 간편하게 copy&paste로 작성이 가능한 color scripter를 사용하게 되었습니다. 위 링크된 사이트에 가서 소스코드를 추가하고 원하는 스타일로 설정한 다음 html 코드를 복사하여 붙이기를 수행하면 됩니다. Java, JavaScript, JSP, Python, Ruby, SQL, Swift, Visual Basic, Action Script, ASP, C, C#, CSS, HaXe, HTML, Objec..
-
[python] string formaterPrograming/Python 2019. 4. 8. 15:46
https://pyformat.info/ PyFormat: Using % and .format() for great good! Python has had awesome string formatters for many years but the documentation on them is far too theoretic and technical. With this site we try to show you the most common use-cases covered by the old and new style string formatting API with practical exam pyformat.info input 2 output 1 1 1 1 2 2 2 10 1 2 3 4 5 6 7 8 9 def pr..
-
[Django] 서버주소 0.0.0.0Programing/Python 2019. 4. 8. 10:29
https://en.wikipedia.org/wiki/0.0.0.0 0.0.0.0 - Wikipedia In the Internet Protocol Version 4, the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non-applicable target. This address is assigned specific meanings in a number of contexts, such as on clients or on servers.[1] en.wikipedia.org 별도의 설정 없이 서버 외부에서 접근하려면 장고 서버 실행 시 127.0.0.1 대신 0.0.0.0 주소 또는 서버의 실..
-
-
[C] Key PressPrograming/C and CPlusPlus 2019. 3. 4. 14:45
void set_mode(int want_key) { static struct termios old, newk; if (!want_key) { tcsetattr(STDIN_FILENO, TCSANOW, &old); return; } tcgetattr(STDIN_FILENO, &old); newk = old; newk.c_lflag &= ~(ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newk); } int get_key() { int c = 0; struct timeval tv; fd_set fs; tv.tv_usec = tv.tv_sec = 0; FD_ZERO(&fs); FD_SET(STDIN_FILENO, &fs); select(STDIN_FILENO + ..