1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
from django.db import models
from django.utils import timezone
from django.template.defaultfilters import slugify
import datetime
CATS = (
('1', "Travco"),
('2', "Groceries"),
('3', "Lodging"),
('4', "Camping"),
('5', "Restaurants"),
('6', "Petrol"),
('7', "Misc"),
)
class Expense(models.Model):
name = models.CharField(max_length=200)
amount = models.DecimalField(max_digits=8, decimal_places=2)
date = models.DateTimeField(default=timezone.now)
notes = models.TextField(null=True, blank=True)
category = models.CharField(max_length=2, choices=CATS, default=1)
class Meta:
ordering = ('-date',)
def __str__(self):
return self.name
def date_month(self):
return self.date.strftime("%b %Y")
|