This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
from IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = "all" | |
pd.set_option('display.float_format', lambda x: '%.3f' % x) | |
pd.set_option('max_columns', None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# . | |
# . | |
# ├── myapp | |
# │ ├── __init__.py | |
# │ ├── admin.py | |
# │ ├── migrations | |
# │ ├── models.py | |
# │ ├── tasks | |
# │ │ ├── __init__.py ## ==> code | |
# │ │ └── my_task.py ## ==> code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// my_list.html | |
{% extends "skeleton/base.html" %} | |
{% load el_pagination_tags %} | |
{% block custom_stylesheet %} | |
{% endblock %} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from django.core.files import File | |
p = File(open('/Users/Chois/Desktop/1555555.jpeg', 'rb')) | |
PortfolioImage.objects.create(portfolio=Portfolio.objects.first(), image=p) | |
for i in range(49): | |
a = Portfolio.objects.create( | |
name=str(i) | |
) | |
a.portfolioimage_set.create( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseModel(TimeStampedModel): | |
objects = BaseManager() | |
is_active = models.BooleanField( | |
"활성화", | |
default=True | |
) | |
class Meta: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 이미지 저장 | |
self.item.image1 = tempfile.NamedTemporaryFile(suffix=".jpg").name | |
self.item.save() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 파일업로드 input이 있는지 확인한다 | |
input_element = self.browser.find_element_by_id('id_form-0-image1') | |
self.assertIsNotNone(input_element) | |
# 이미지 파일을 업로드한다. | |
input_element.send_keys(os.path.dirname('/tmp/') + "/test_image.jpg") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def post(self, request, *args, **kwargs): | |
''' | |
ajax -> just orderForm validation check | |
general request -> Create order data after payment | |
''' | |
# OrderForm validation check | |
if request.is_ajax(): | |
form = OrderForm( | |
request.POST, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Mock test | |
# | |
@patch('orders.views.OrderView.generate_merchant_uid') | |
@patch('orders.views.services.register_expected_price') | |
def test_merchant_uid_is_generated_on_GET_request( | |
self, mock_register_expected_price, mock_generate_merchant_uid | |
): | |
""" | |
1. mock arg의 순서가 중요하다! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from django.contrib.auth.decorators import login_required | |
from django.utils.decorators import method_decorator | |
from django.views.generic import DetailView | |
from django.views.generic.edit import FormMixin | |
from django.shortcuts import render, get_object_or_404, redirect | |
from django.core.urlresolvers import reverse | |
from products.models import Product |
NewerOlder