very interesting query... i need some help

2009-08-07 Thread talpay...@gmail.com

i have come up with one of the most interesting query i have ever
seen.

I want to do this :

products = products.filter(productdetail__detail_value__gte =
first_value)
products = products.filter(productdetail__detail_value__lte =
second_value)

where first_value and second_value are integers and
"productdetail__detail_value" are stored as a char.

it is a very simple sql query but how can i do this using django
queryset. the problem is that i need the products to stay as a
queryset... because i need to filter it again if that is the case.

taking the easy way out and changing the way the table is constructed
is not an option. i have to store any kind of data in "detail_value"
and filter the information. it's a generic filter and this is the only
problem i don't have a solution to. please help.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



what is up with InternalError current transaction is aborted, commands ignored until end of transaction block

2010-02-22 Thread talpay...@gmail.com
I have search far and wide for some help regarding the Internal Error
and i can't find any help. I have absolutely no idea why this is
showing it doesn't make any sens. I just want a way to catch it but
that is impossible. I would appreciate any help.


Traceback:
File "C:\Python26\Lib\site-packages\django\core\handlers\base.py" in
get_response
  99. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\Lib\site-packages\iitcms\auth\decorators.py" in
_checklogin
  18. return view_func(request, *args, **kwargs)
File "C:\Python26\Lib\site-packages\iitcms\products\my_admin\views.py"
in import_excel
  1312. msg = prepare_products(request)
File "C:\Python26\Lib\site-packages\iitcms\products\utils.py" in
prepare_products
  115. error_list, ignored_list_number, new_list_number,
edited_list_number = create_products(products, category)
File "C:\Python26\Lib\site-packages\iitcms\products\utils.py" in
create_products
  164. rezult = create_product(category, product, cat_poz,
name_poz, description_poz, price_poz, codes_poz, stoc_poz, um_poz)
File "C:\Python26\Lib\site-packages\iitcms\products\utils.py" in
create_product
  305. new_product =
Product.objects.get(product_name__iexact = product_name)
File "C:\Python26\Lib\site-packages\django\db\models\manager.py" in
get
  119. return self.get_query_set().get(*args, **kwargs)
File "C:\Python26\Lib\site-packages\django\db\models\query.py" in get
  293. num = len(clone)
File "C:\Python26\Lib\site-packages\django\db\models\query.py" in
__len__
  74. self._result_cache = list(self.iterator())
File "C:\Python26\Lib\site-packages\django\db\models\query.py" in
iterator
  231. for row in self.query.results_iter():
File "C:\Python26\Lib\site-packages\django\db\models\sql\query.py" in
results_iter
  281. for rows in self.execute_sql(MULTI):
File "C:\Python26\Lib\site-packages\django\db\models\sql\query.py" in
execute_sql
  2373. cursor.execute(sql, params)
File "C:\Python26\Lib\site-packages\django\db\backends\util.py" in
execute
  19. return self.cursor.execute(sql, params)

Exception Type: InternalError at /products/admin/import/
Exception Value: 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-us...@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.



Re: what is up with InternalError current transaction is aborted, commands ignored until end of transaction block

2010-02-22 Thread talpay...@gmail.com
i actually found a solution. i don't know what the problem is... and
it wouldn't mater anyway. I just wanted to catch and show a message
about it. You should you something like this:

from django.db import transaction

@transaction.commit_manually
def view(request):
try:
#do something with database
transaction.commit()
except:
transaction.rollback()
#return error message.


Thank you for the help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.