I'm building a web app with django. It uses postgresql. The app code
is getting really messy and I'd like to improve it(my begginer skills
being a big factor too).

This is an excerpt of my models.py file:

REPEATS_CHOICES = (
    (NEVER, 'Never'),
    (DAILY, 'Daily'),
    (WEEKLY, 'Weekly'),
    (MONTHLY, 'Monthly'),
    ...some more...
)

class Transaction(models.Model):
    name = models.CharField(max_length=30)
    type = models.IntegerField(max_length=1, choices=TYPE_CHOICES) # 0
= 'Income' , 1 = 'Expense'
    amount = models.DecimalField(max_digits=12, decimal_places=2)
    date = models.DateField(default=date.today)
    frequency = models.IntegerField(max_length=2,
choices=REPEATS_CHOICES)
    ends = models.DateField(blank=True, null=True)
    active = models.BooleanField(default=True)
    category = models.ForeignKey(Category,
related_name='transactions', blank=True, null=True)
    account = models.ForeignKey(Account, related_name='transactions')

The problem is with date, frequency and ends. With this info I can
know all the dates in which transactions occurs and use it to fill a
cashflow table. Doing things this way involves creating a lot of
structures(dictionaries, lists and tuples) and iterating them a lot.
Maybe there is a very simple way of solving this with the actual
schema, but I couldn't realize how.

I think that the app would be easier to code if, at the creation of a
transaction, I could save all the dates in the db. I don't know if
it's possible or if it's a good idea.

Possible solutions:

-I'm reading a book about google app engine and the datastore's
multivalued properties. What do you think about this for solving my
problem?.

-I didn't know about the PickleField. I'm now reading about it, maybe
I could use it to store all the transaction's datetime objects.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to