Hey all, I'm trying to do something really simple and I was wondering if it is possible within django.
There is 1 main table lets call it 'Team' - it contains teams all unique there are 2 sub tables that FK to Team, called Bulletin and Wall posts. There is a 3rd subtable called TeamAccess which FK to Team as well. TeamAccess is a special table because users can be associated with different teams and have a different experience with each team etc, so this table holds that information. What I want to try to accomplish is that when a user logs in, it basically informs the user how many new bulletins and wall posts have been made per team since their last visit to that team. So it's a simple date compare between TeamAccess objects and TeamBulletin objects (and then I count them) Is this query too hard to do? Team id TeamAccess id team_id last_bulletin_visit last_wall_visit TeamBulletin id team_id create_date TeamWall id team_id create_date here is my attempt that isn't working, there isn't much syntax information I can compare with, so I'm not even sure if I'm on the right track. For the below, I'm just going to grab the number of bulletins per team - my take on it from the examples that I have read. Here is the sql (which I know works - that I want to build but not using custom sql =P) select *,(select count(0) from team t, teambulletin tb where t.id = tb.team_id and team_id = ta.id group by team_id) as bulletinCount from teamaccess ta where ta.user_id = '1' teams = TeamAccess.objects.extra(select={'bulletinCount':'SELECT COUNT(*) FROM team_teambulletin where team_teambulletin.team_id = team_team.id and team_teamaccess.team_id = team_team.id'}).filter(user = user.id) but when I pump that into my shell the following error always shows up Traceback (most recent call last): File "<console>", line 1, in <module> File "/Library/Python/2.5/site-packages/django/db/models/query.py", line 102, in __repr__ return repr(self._get_data()) File "/Library/Python/2.5/site-packages/django/db/models/query.py", line 470, in _get_data self._result_cache = list(self.iterator()) File "/Library/Python/2.5/site-packages/django/db/models/query.py", line 183, in iterator cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "/Library/Python/2.5/site-packages/django/db/backends/util.py", line 12, in execute return self.cursor.execute(sql, params) ProgrammingError: current transaction is aborted, commands ignored until end of transaction block --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---