Re: TransactionManagementError from inside atomic block

2017-03-29 Thread Ketan Bhatt
eads/writes to another db? > > Cheers, > Simon > > Le samedi 25 mars 2017 15:08:19 UTC-4, Ketan Bhatt a écrit : > > I have a method that updates a row in the table. > To avoid race condition, I locked the row using `select_for_update` inside > an `atomic` block and doing t

TransactionManagementError from inside atomic block

2017-03-25 Thread Ketan Bhatt
I have a method that updates a row in the table. To avoid race condition, I locked the row using `select_for_update` inside an `atomic` block and doing the update. This method is called from a celery task. This works well on my local machine. But when this gets called on my production server (two

Re: How to resize and store pics with Django

2016-06-03 Thread Ketan Bhatt
I am storing links of these images as I need to show them on the frontend, not connected to any user. But I have done what you are talking about too. So Django gives you a Model File Field. Add that to your Model. That will allow you to save and store files. While saving a model object, just use t

Re: How to resize and store pics with Django

2016-06-03 Thread Ketan Bhatt
This is how you can compress the images while saving: ```python import urllib2 import cStringIO from boto3.session import Session from PIL import Image aws_session = Session( aws_access_key_id=settings.AWS_ACCESS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY, region

Re: How to select undetermined field(s) in django model?

2016-05-26 Thread Ketan Bhatt
It just means the "field_name" you are using in the filter query doesn't exist. Multiple reasons: 1. The model doesn't really have that field in its definition. 2. You forgot migrating your database. 3. The field name being sent from your form is not right. To get a clearer picture, try the same

Re: Django Beginner

2016-05-26 Thread Ketan Bhatt
The official tutorial is difficult for a beginner, it was for me. I would suggest you start with Django girls, or "Tango with Django" On Thu, May 26, 2016, 5:52 PM Jani Tiainen wrote: > And after that official tutorial there exists Django Girls and Django > Taskbuster which are much more verbos

Re: How to aggregate on insert?

2016-05-23 Thread Ketan Bhatt
Hey Erik, What Django version are you on? On Tuesday, May 24, 2016 at 1:28:57 AM UTC+5:30, Erik Cederstrand wrote: > > Hi, > > I have inherited a legacy Item model that has a composite unique key > consisting of a Customer ID and a per-customer, incrementing Item ID. > Assume I can't change th

Re: get all columns as a list

2016-05-23 Thread Ketan Bhatt
Can you not do something like `qs.filter(...info that is coming in...).exists()` If ^ is True, then update it, otherwise create a new object? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving em

Query and order by time difference of a specified time.

2016-05-23 Thread Ketan Bhatt
Take a look at the `extra` method of the queryset in Django. It allows you to do what you are trying to do by raw SQL. https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.extra Check the above link, the example with `annotate` will be interesting for you.

Problem with submitting form in my django project! Urgent help required

2015-02-17 Thread Ketan Bhatt
I am facing a problem with my project, I posted about it on Stack Overflow, here is the link: http://stackoverflow.com/questions/28539441/reference-objects-using-foreign-keys-in-django-forms Here is m code on github, I am currently working on the feature_forms branch: https://github.com/keta