라벨이 Django APP인 게시물 표시

[Django APP] Django-import-export

 [install] pip install Django-import-export INSTALL_APP = [     ...     'import_export',     ... ] admin.py from import_export.admin import ImportExportModelAdmin from . import models class LottoAdmin(ImportExportModelAdmin):     list_display = ('id', 'round', 'date', 'lotto1', 'lotto2', 'lotto3', 'lotto4', 'lotto5', 'lotto6', 'lotto7')     list_display_links = ['round']     list_per_page = 10

[Django APP] django-chartjs

[설치] pip install django-chartjs [설정] INSTALLED_APPS = (     '...',     'chartjs', ) [활용] 1. Create the HTML file {% load staticfiles %} <html>     <head>         <title>django-chartjs line chart demo</title>         <!--[if lte IE 8]>             <script src="{% static 'js/excanvas.js' %}"></script>         <![endif]-->     </head>     <body>         <h1>Some Line Charts loaded in Ajax!</h1>         <canvas id="myChart" width="500" height="400"></canvas>         <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>         <script type="text/javascript" src="{% static 'js/Cha...

[Django APP] django-bootstrap-datepicker-plus

[설치] pip install django-bootstrap-datepicker-plus [설정] INSTALLED_APPS = [     # Add the following     'bootstrap_datepicker_plus', ] [활용] # Use BOOTSTRAP3 if you are using Bootstrap 3 BOOTSTRAP4 = {     'include_jquery': True, } {% load bootstrap4 %}       {# import bootstrap4/bootstrap3 #} {% bootstrap_css %}         {# Embed Bootstrap CSS #} {% bootstrap_javascript jquery='full' %}  {# Embed Bootstrap JS+jQuery #} {{ form.media }}            {# Adds date-picker required JS and CSS #} # File: views.py from django.shortcuts import render from .forms import UserForm def create_user(request):     user_form = UserForm()     return render(request, 'my_template.html', {'my_form': user_form}) [사례] Custom Form usage # File: forms.py from bootstrap_datepicker_plus import DatePickerInput from d...

[Django APP] django_bootstrap4

[설치] pip install django-bootstrap4 [설정] INSTALLED_APPS = [      ...      'bootstrap4',      ... ] [활용] {% load bootstrap4 %} {# Display a form #} <form action="/url/to/submit/" method="post" class="form">     {% csrf_token %}     {% bootstrap_form form %}     {% buttons %}         <button type="submit" class="btn btn-primary">Submit</button>     {% endbuttons %} </form>

[Django APP] django-widget-tweaks

[설치] pip install django-widget-tweaks [설정] INSTALLED_APPS = [      ...      'widget_tweaks',      ... ] [사용법] In template {% load widget_tweaks %} <!-- change input type (e.g. to HTML5) --> {% render_field form.search_query type="search" %} <!-- add/change several attributes --> {% render_field form.text rows="20" cols="20" title="Hello, world!" %} <!-- append to an attribute --> {% render_field form.title class+="css_class_1 css_class_2" %} <!-- template variables can be used as attribute values --> {% render_field form.text placeholder=form.text.label %} {% render_field %} 태그로 렌더링 된 필드의 경우 WIDGET_ERROR_CLASS 및 WIDGET_REQUIRED_CLASS 템플릿 변수를 사용하여 오류 클래스 및 필수 필드 클래스를 설정할 수 있습니다. {% with WIDGET_ERROR_CLASS = 'my_error'WIDGET_REQUIRED_CLASS = 'my_required'%}     {% render_field form.field1 %}     {% render_field form.field2 %}...

[Django APP] django-next-prev

[소스] source [설치] pip install django-next-prev [사용법] models.py  from django.db import models class Category(models.Model):     title = models.CharField(max_length=100) class Post(models.Model):     title = models.CharField(max_length=100)     category = models.ForeignKey(Category, on_delete=models.CASCADE)     created = models.DateField()     text = models.TextField()     class Meta:         ordering = ('created', 'title') views.py from next_prev import next_in_order, prev_in_order from .models import Post # default ordering first = Post.objects.first() second = next_in_order(first) prev_in_order(second) == first # True last = prev_in_order(first, loop=True) # custom ordering qs = Post.objects.all().order_by('-created') newest = qs.first() second_newest = next_in_order(newest, qs=qs) oldest = prev_in_order(newest, qs=qs, loop=True) ...

[Django APP] django-sass-processor

[SCSS Install] pip install libsass django-compressor django-sass-processor (scss파일을 css로 변환하는 변환기 앱) add to settings.py INSTALLED_APPS = [     'sass_processor', ] #  django-sass-processor Settings SASS_PROCESSOR_ENABLED = True SASS_PROCESSOR_ROOT = os.path.join(BASE_DIR, ' appname /static') SASS_OUTPUT_STYLE = 'compact' SASS_PRECISION = 8

[Django APP] django-ckeditor

[ckeditor Install] pip install django-ckeditor (리치에디터 앱) add to settings.py INSTALLED_APPS = [     'ckeditor',     'ckeditor_uploader', ] #  django-ckeditor Settings CKEDITOR_UPLOAD_PATH = "uploads/" CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/" CKEDITOR_CONFIGS = {     'default': {         'toolbar': 'full',     }, } add to  projectname/projectname/ urls.py from django.urls import include urlpatterns = [     path('ckeditor/', include('ckeditor_uploader.urls')), ]

[Django APP] django-filer

[Filer Install] pip install django-filer  (파일/이미지 관리 앱 설치) add to projectname/projectname/settings.py INSTALLED_APPS = [     'easy_thumbnails',     'filer',     'mptt', ] #  django-filer Settings THUMBNAIL_HIGH_RESOLUTION = True THUMBNAIL_PROCESSORS = (     'easy_thumbnails.processors.colorspace',     'easy_thumbnails.processors.autocrop',     'filer.thumbnail_processors.scale_and_crop_with_subject_location',     'easy_thumbnails.processors.filters', ) FILER_CANONICAL_URL = 'canonical/' FILER_DEBUG = True FILER_ENABLE_LOGGING = True add to  projectname/projectname/ urls.py from django.urls import include urlpatterns = [     path('filer/', include('filer.urls')), ] python manage.py migrate  ( filer 스키마 생성) dmain/admin으로 접속하여 Filer 스키마 및 어드민 설치 확인

[Django App] django-user-agents

[설치] pip install pyyaml ua-parser user-agents pip install django-user-agents [설정] settings.py 수정 INSTALLED_APPS = (     # Other apps...     'django_user_agents', ) MIDDLEWARE = (     # other middlewares...     'django_user_agents.middleware.UserAgentMiddleware', ) #  django-user-agents Settings # Cache backend is optional, but recommended to speed up user agent parsing # CACHES = { #    'default': { #        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', #        'LOCATION': '127.0.0.1:11211', #    } # } # Name of cache backend to cache user agents. If it not specified default # cache alias will be used. Set to `None` to disable caching. USER_AGENTS_CACHE = 'default' [소스 활용] def my_view(request):     # Let's assume that the visitor uses an iPhone...     request.user_...

[Django App] django-bootstrap-modal-forms

[설치] pip install django-bootstrap-modal-forms [설정] settings.py에 추가 INSTALLED_APPS = [     ...     'bootstrap_modal_forms',     ... ] [js파일 설정] js 파일 복사 (빨간색은 맞게 변경) cp /home/ubuntu/.virtualenvs/ project /lib/python3.6/site-packages/bootstrap_modal_forms/static/js/jquery.bootstrap.modal.forms.min.js /home/ubuntu/ project / app /static/ app /js  base.html에 추가 <!-- Add on script -->     <script src="{% static ‘app/js/jquery.bootstrap.modal.forms.min.js' %}"></script>      </body> </html> [사용법]

[Django App] django-crum

[설치] pip install django-crum [설정] settings.py 수정 MIDDLEWARE += ('crum.CurrentRequestUserMiddleware',) [사용] get_current_request() get_current_user()

[Django App] celery

[순서] - message queue 설치 - python celery 설치 - django-celery-result 설치 - django-celery-beat 설치 [message queue 설치 - linux-ubuntu] 서버 설치 (설치 후 자동 서버 시작됨) $  sudo apt-get install rabbitmq-server 서버 시작 $ sudo rabbitmq-server 서버 시작 (백그라운드) $ sudo rabbitmq-server -detached 서버 종료 (kill 사용금지) $ sudo rabbitmqctl stop 서버 상태 $  sudo rabbitmqctl status [message queue 설치 - linux-amazon linux2] 서버설치 전 rabbitmq-server yum 레포지토리 설치 curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash 서버 설치 $  sudo yum install rabbitmq-server 서버 enable $  sudo systemctl enable rabbitmq-server 서버 시작 $   sudo systemctl start rabbitmq-server 서버 종료 $   sudo systemctl stop rabbitmq-server 서버 상태 $   sudo systemctl status rabbitmq-server [message queue 설치 - Mac] 설치준비 $  brew update 설치 $   brew install rabiitmq 서버 시작 (포그라운드) $   rabbitmq-server 서버 시작 (서비스) $   brew services start r...