Re: Django and asynchronous tasks

2016-11-29 Thread Alain Muls
Hi All I spent several days reading and searching examples of how to implement channels. The current status of my project is as follows: - I have a page which lets the user enter the data used for the offline calculations, a POST request is send - the post request is handled and I can

Re: rewrite PostgreSQL query to Django ORM

2016-11-29 Thread Avraham Serour
I think you would still need some SQL, you could use annotate to add the field with the value of the calculation and then add .order_by() to the queryset https://docs.djangoproject.com/en/1.10/ref/models/expressions/#raw-sql-expressions On Tue, Nov 29, 2016 at 11:07 PM, Artem Bernatskyy < artem.b

rewrite PostgreSQL query to Django ORM

2016-11-29 Thread Artem Bernatskyy
Hello, how to rewrite this PostgreSQL query to Django ORM with no raw SQL ? select * from finance_fund order by((select price from finance_nav where date='2016-11-08' and fund_id=finance_fund.id)/(select price from finance_nav where date='2016-11-07' and fund_id=finance_fund.id)) LIMIT 30; So

Add form fields/values at ModelForm level or at CBV level.

2016-11-29 Thread Paul
I have a model Product which a Foreign Key to a Company model. The Company Model has a OneToOne Relationship to user. When a user submits a form to add product I need to associate the product with the company of the user (the user doesn't need to add manually the company in the form) There ar

How to add AutoField to/switch out primary key for an existing table?

2016-11-29 Thread Hanne Moa
A model was designed with a wrong assumption of uniqueness and given a natural key. We now need to switch to a surrogate primary key. Upgrading Django is currently not an option. The production database may not be dropped/restored for this, it is in use by several unrelated projects (remember the t

How does django pass data through post?

2016-11-29 Thread Daniel Roseman
The problem is in your html. Browsers can only send data for inputs with a `name` attribute, which Django then uses as the key in the querydict, whereas the `value` attribute becomes the value for that key. None of your inputs have names. It also doesn't make sense to add the id to the form or