Skip to content

Instantly share code, notes, and snippets.

View jjangdm's full-sized avatar

JANGDONGMIN jjangdm

  • I'm free.
  • Suwon-city
View GitHub Profile
class Item(models.Model):
item_number = models.CharField(u"항목번호", max_length=3)
category = models.ForeignKey(Category, verbose_name=u"범주")
title = models.CharField(max_length=50, verbose_name=u"항목명")
slug = models.SlugField(blank=True)
description = models.TextField(blank=True, verbose_name=u'메모')
class Meta:
ordering = ["item_number"]
verbose_name = u'항목'
@jjangdm
jjangdm / gist:5049275
Created February 27, 2013 16:30
class_example.py
class Accounts(object):
accountNumber = 0
def __int__(self, name, balance):
self.name = name
self.balance = balance
Accounts.accountNumber += 1
def withdraw(self, atm):
self.balance = self.balance - atm
return self.balance
def deposit(self, atm):
today = datetime.datetime.now()
categoryNumber_list = Category.objects.all().values_list("categoryNumber",flat=True)
category_list = Category.objects.all()
income_list = Income.objects.filter(date__year=today.year)
monthly_list = []
for i in categoryNumber_list:
if int(i)<100:
for j in range(1,13):
temp_money = sum(Income.objects.filter(category__categoryNumber="%s" %i, date__year=today.year, date__month="%s" %j).values_list("money",flat=True))
import datetime
today = datetime.datetime.now()
income_list = []
outcome_list = []
item_number_list = Item.objects.all().values_list("item_number", flat=True)
for month in range(1,13):
for n in item_number_list:
@jjangdm
jjangdm / gist:5023264
Created February 24, 2013 09:47
제가 만든 방법
income_list = []
for n in range(1,13):
temp = sum(Income.objects.filter(date__month="%s" %n).values_list("money", flat=True))
income_list.append(temp)
#EXPECTED RESULT
[100000, 0, 250000, ......, 0] 의 원소 12개
@jjangdm
jjangdm / gist:5012178
Created February 22, 2013 09:50
109번째줄은 맨 밑에서 위로 두번째입니다
class Income(models.Model):
date = models.DateField(verbose_name=u"날짜", auto_now_add=True)
item = models.ForeignKey(Item, verbose_name=u"항목")
member = models.ForeignKey(Member, verbose_name=u"이름", blank=True, null=True)
money = models.IntegerField(verbose_name=u"금액")
comment = models.TextField(blank=True, verbose_name=u"비고")
week = models.IntegerField(blank=True, verbose_name=u"주차", editable=False)
class Meta:
ordering = ["-date", "item"]
@jjangdm
jjangdm / gist:4959173
Created February 15, 2013 08:40
model에 실제 입력한 예
*Category
categoryNumber item description
000 전년도이월
001 급여
002 상여금
003 은행이자
004 기타수입
111 임대료(관리비)
112 전기요금(관리비)
<table id="contents" align="center" border="1px" cellspacing="0">
<tr bgcolor="#efffff">
<td align="center" width="15%">항목</td>
{% for p in month_list %}
<td width="5%" align="center">{{ p }}월</td>
{% endfor %}
<td width="6%" align="center">합계</td>
<td width="6%" align="center">예산</td>
<td width="6%" align="center">항목예산대비</td>
<td width="6%" align="center">예산총액대비</td>
@jjangdm
jjangdm / gist:4944655
Created February 13, 2013 13:37
model.py
# -*- coding:utf-8 -*-
from django.db import models
import datetime
today = datetime.datetime.now()
class Category(models.Model):
categoryNumber = models.CharField(max_length=3, verbose_name="항목번호")
item = models.CharField(max_length=40, verbose_name="항목")
description = models.TextField(blank=True, verbose_name="메모")
def report_total(request):
today = datetime.datetime.now()
categoryNumber_list = Category.objects.all().values_list("categoryNumber",flat=True)
category_list = Category.objects.all().values_list("item",flat=True)
monthly_list = []
for i in categoryNumber_list:
if int(i)<100:
for j in range(1,13):
temp_money = sum(Income.objects.filter(category__categoryNumber="%s" %i, date__year=today.year, date__month="%s" %j).values_list("money",flat=True))
monthly_list.append((int(i),temp_money),)