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
from django.core.management import BaseCommand | |
from faker import Factory, Faker | |
from random import randint | |
from posts.models import Post, Comment | |
from users.models import User | |
class Command(BaseCommand): |
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
from django.db import models | |
from django.conf import settings | |
from django.core.urlresolvers import reverse | |
from users.models import User | |
from tags.models import Tag | |
class Post(models.Model): |
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
from django.db import models | |
from django.contrib.auth.models import AbstractUser | |
class User(AbstractUser): | |
phone_number = models.CharField( | |
max_length=20, | |
) |
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
from django.db import models | |
from users.models import User | |
class Like(models.Model): | |
post = models.ForeignKey( | |
"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
import os | |
from .base_setting import PROJECT_DIR | |
STATIC_URL = '/static/' | |
MEDIA_URL = '/media/' | |
STATIC_ROOT = os.path.join(PROJECT_DIR, "dist", "static") | |
MEDIA_ROOT = os.path.join(PROJECT_DIR, "dist", "media") |
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
from rest_framework import serializers | |
from trades.models import Sell | |
from trades.serializers import CommentModelSerializer | |
from .api_sell_list import SellBaseModelSerializer | |
class SellDetailModelSerializer(SellBaseModelSerializer): | |
comment = CommentModelSerializer( |
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
from rest_framework.generics import RetrieveAPIView | |
from trades.serializers import SellDetailModelSerializer | |
from trades.models import Sell | |
class SellDetailAPIView(RetrieveAPIView): | |
serializer_class = SellDetailModelSerializer | |
lookup_field = "hash_id" |
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
from rest_framework.views import APIView | |
from rest_framework.response import Response | |
from users.models import User | |
class UserCheckAPIView(APIView): | |
def post(self, request): |
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 time | |
class Timer(): | |
def __init__(self, function): | |
self.function = function | |
def __call__(self, *args, **kwargs): | |
# wrapper 역할을 수행함 |
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 make_number_comma(number): | |
number_to_str = str(number) | |
len_number = len(number_to_str) | |
if len_number > 3: | |
result = "" | |
for idx, num in enumerate(number_to_str[::-1]): | |
result += num | |
if idx % 3 == 2 and idx < len_number-1: | |
result += "," |