I just made a post about this on django-developers. The problem is in
psycopg2 creating the query's SQL before it knows the postgresql
version. So, the query is executed without "returning id", but
psycopg2 expects the returning id to be there when in gets the
results... -> problem.

Anssi Kääriäinen

On 9 heinä, 15:04, Szymon <szy...@mwg.pl> wrote:
> Hi again,
>
> I think I got it... I had "TransactionMiddleware" enabled and
> 'autocommit' set to True... When I deleted 'autocommit' exception is
> gone.
>
> Regards,
> Szymon
>
> On 9 Lip, 13:35, Szymon <szy...@mwg.pl> wrote:
>
> > Hi,
>
> > I'm lost. Maybe someone here will help me:
>
> > Model:
>
> > class obrazki(models.Model):
>
> >     obrazek = models.ImageField(upload_to="upload/%y/%m/%d/")
> >     slug = models.SlugField(max_length=200)
> >     tytul = models.CharField(max_length=100)
> >     tagi = TagField(null=True)
> >     data = models.DateTimeField()
>
> > Source:
>
> > [...]
>
> > formularz = fzdjecie(request.POST, request.FILES)
>
> >         if formularz.is_valid():
>
> >             o = obrazki(tytul=formularz.cleaned_data['tytul'],
> > slug=slug(formularz.cleaned_data['tytul']), data=datetime.now(),
> > tagi=formularz.cleaned_data['tagi'])
>
> >             o.save()
>
> > [...]
>
> > Exception:
>
> > Traceback (most recent call last):
>
> >  File "/usr/local/lib/python2.6/site-packages/django/core/handlers/
> > base.py", line 92, in get_response
> >    response = callback(request, *callback_args, **callback_kwargs)
>
> >  File "/home/pikczur/app/root/glowna.py", line 35, in index
> >    o.save()
>
> >  File "/usr/local/lib/python2.6/site-packages/django/db/models/
> > base.py", line 410, in save
> >    self.save_base(force_insert=force_insert,
> > force_update=force_update)
>
> >  File "/usr/local/lib/python2.6/site-packages/django/db/models/
> > base.py", line 495, in save_base
> >    result = manager._insert(values, return_id=update_pk)
>
> >  File "/usr/local/lib/python2.6/site-packages/django/db/models/
> > manager.py", line 177, in _insert
> >    return insert_query(self.model, values, **kwargs)
>
> >  File "/usr/local/lib/python2.6/site-packages/django/db/models/
> > query.py", line 1087, in insert_query
> >    return query.execute_sql(return_id)
>
> >  File "/usr/local/lib/python2.6/site-packages/django/db/models/sql/
> > subqueries.py", line 324, in execute_sql
> >    return self.connection.ops.fetch_returned_insert_id(cursor)
>
> >  File "/usr/local/lib/python2.6/site-packages/django/db/backends/
> > __init__.py", line 171, in fetch_returned_insert_id
> >    return cursor.fetchone()[0]
>
> > ProgrammingError: no results to fetch
>
> > Latest Django trunk, Postgres 8.4.
>
> > Best regards,
> > Szymon
--~--~---------~--~----~------------~-------~--~----~
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