Re: Raw SQL - How to approach paging and lazy fetching

2017-06-15 Thread Jani Tiainen
Hi, Even you do have legacy database, you can use unmanaged models and then leverage full power of ORM [1]. Just create models and in their Meta set managed = False and there you go. And what comes to paging - you need to somehow pass offset and limit to your query. [1] https://docs.djang

Re: passing data to template

2017-06-15 Thread Mike Dewhirst
On 16/06/2017 12:12 PM, sum abiut wrote: Is it possible to pass data from two different django functions to a one template in a single for loop? Yes. The general way to do that (and pretty much all Django things) is to write a "view" which can contain as many functions as desired and fetch as

Re: display a field from last updated row

2017-06-15 Thread Mike Dewhirst
On 16/06/2017 12:01 PM, sum abiut wrote: Hi, i am having trouble trying to figure this out. I have a table something as below. i want to write an sqlalchemy that query the table and then display the email address from the row that was last updated. Please point me to the right direction to

Internet Explorer question

2017-06-15 Thread Mike Dewhirst
I have just spent the most frustrating 90 minutes in living memory walking a potential user through our application via IE. Does anyone know if we need to make special provision for IE in Django Admin (1.10) ? The UI seems very slow and quirky. I suspected Javascript was disabled but the Sho

Re: Send message to group from server on production by channels.

2017-06-15 Thread Andrew Godwin
What is your CHANNEL_LAYERS configuration? It sounds like the thing running the cron is not on the same layer as everything else. Andrew On Thu, Jun 15, 2017 at 11:27 AM, Петр Гордеев wrote: > Hi, > I have a problem with send message from backend on production. > If I want to send message to gr

passing data to template

2017-06-15 Thread sum abiut
Is it possible to pass data from two different django functions to a one template in a single for loop? Cheers, -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

display a field from last updated row

2017-06-15 Thread sum abiut
Hi, i am having trouble trying to figure this out. I have a table something as below. i want to write an sqlalchemy that query the table and then display the email address from the row that was last updated. Please point me to the right direction to help me accomplished that. fname lname email

how to combine views in one template

2017-06-15 Thread Mark Alan Jones
Hello Django Community, I am new to Django and tackling my first app outside of the tutorial. The app I'm working on is a simple ticket system for build requests at my IT Company. I only have one model 'Build', and I have checkboxes that denote how far the build has been done. I have a page t

Raw SQL - How to approach paging and lazy fetching

2017-06-15 Thread Kevin Yu
Hi All, I am using raw sql to connect to database. The reason we used raw sql instead of the Django model is because the database is legacy and is being shared by multiple applications... I have one use case that I'm struggling right now. Basically I have a page that fetch more than 1000 resul

Re: Integration of Django with other python codes

2017-06-15 Thread yingi keme
You have to study django tutorials. Ok for a simple task like this. After you have successfully created your app in your project, all you need is to configure your url so it can point the views.py. The views.py file will have a function like this def myInput(request, input): return rende

Re: How to get a list of queryset selected fields

2017-06-15 Thread Todor Velichkov
query.get_meta().fields == query.model._meta.fields, i.e. all the model fields As far as I understand from reading, deferred_loading is populated only when the queryset is deferred itself, but at the same time if I use .values(*some_fields) instead of .only(*some_fields), its empty again (i.e.

RE: How to get a list of queryset selected fields

2017-06-15 Thread Matthew Pava
I have done some digging into the QuerySet API, and I think I may have found what you are looking for: MyModel.objects.all().query.get_meta().fields You can access the fields that are deferred by using MyModel.objects.all().query.deferred_loading. Note that the deferred columns will still be r

Re: Django Channels : High CPU usage by workers and 503 responses.

2017-06-15 Thread RAUSHAN RAJ
I just installed channels==1.1.4, it's working like a charm.The issue is gone.Thanks Andrew. On Thursday, June 15, 2017 at 7:06:01 PM UTC+5:30, Andrew Godwin wrote: > > The error you have looks like > https://github.com/django/channels/issues/643, which was fixed in the > master branch but not

Re: How to get a list of queryset selected fields

2017-06-15 Thread Todor Velichkov
Hi, Bruno Soares, well values_list is not what I'm looking for, I'm searching for a list of field names, not field values. Imagine you have a queryset you know nothing about it (how it gets generated) and you want to build a representation (table) of it. The first thing would be to render the

Re: Error even after following the django documentation

2017-06-15 Thread Oladipupo Elegbede
TypeError: 'choice_text' is an invalid keyword argument for this function That above, is where the problem is where the problem is so I am going to guess you need to check your model if you wrote everything correctly. If I can see what your model looks like, I can probe in. On Thu, Jun 15, 2017 at

RE: How to get a list of queryset selected fields

2017-06-15 Thread Todor Velichkov
Hello, Matthew Pava, thank you for your answer. This is probably the solution which I'm going to use if there isn't anything better, but overall I don't like this approach for a few reasons: 1) Dict keys are unordered, I would prefer to be ordered as requested (or as defined in the Model) I gu

Error even after following the django documentation

2017-06-15 Thread danbmathew
Well I'm new to django and my code is just as in the documentation.But got an error while trying to run the codeline q.choice_set.create(choice_text='Not much', votes=0). This part of the code is almost at the end of the segment named Playing With API.I will also post the error. Traceback (most

please help

2017-06-15 Thread danbmathew
I am strictly following the documentation but on this code, *q.choice_set.create(choice_text='Not much', votes=0) *on almost at the bottom of Playing With API section of the documentation, I got the following error. Traceback (most recent call last): File "", line 1, in File "C:\Users\DEL

Re: How to get a list of queryset selected fields

2017-06-15 Thread Bruno Soares
> > Take a look at `values_list` too. https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list Em quinta-feira, 15 de junho de 2017 12:51:56 UTC-3, Todor Velichkov escreveu: > > That's it, I want to get

RE: How to get a list of queryset selected fields

2017-06-15 Thread Matthew Pava
You may be looking for values. MyModel.objects.all().values() returns a QuerySet list of dictionaries with the field names as the keys. You can specify which specific fields you want to return by passing them as arguments to values(). MyModel.objects.all().values('id', 'name') Then you can use th

How to get a list of queryset selected fields

2017-06-15 Thread Todor Velichkov
That's it, I want to get a list of all fields which are going to be selected by a queryset, is it possible? e.g. qs = MyModel.objects.only('id', 'name') select = qs.query.select #should be ['id','name'] PS. I notice there is a `qs.query.select`, but its empty. No idea if its the same as what

Re: django WYSIWYG editor

2017-06-15 Thread ADEWALE ADISA
thanks, i will look at the documentation On Jun 15, 2017 3:32 PM, "Karol Bujaček" wrote: > On 06/15/2017 04:16 PM, ADEWALE ADISA wrote: > >> >> Pls, I need a recommendation for the best easy to implement editor that >> non technical user can use to add image, table to document in django admin >>

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread Александр Христюхин (roboslone)
https://docs.djangoproject.com/en/1.11/ref/csrf/#ajax > On 15 Jun 2017, at 17:20, 李余通 wrote: > > Sorry,the message of Django CSRF and X-CSRFToken i can find is less. > Can you give me an example to use requests or urllib2 and set "X-CSRFTo

Re: django WYSIWYG editor

2017-06-15 Thread Karol Bujaček
On 06/15/2017 04:16 PM, ADEWALE ADISA wrote: Pls, I need a recommendation for the best easy to implement editor that non technical user can use to add image, table to document in django admin textarea. I want my users to be using django admin as there backend when creating blog content and th

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread 李余通
Sorry,the message of Django CSRF and X-CSRFToken i can find is less. Can you give me an example to use requests or urllib2 and set "X-CSRFToken" header to post form? Thank you very much! 在 2017年6月15日星期四 UTC+8下午9:37:25,Александр Христюхин写道: > > You could set "X-CSRFToken" header, that would be en

django WYSIWYG editor

2017-06-15 Thread ADEWALE ADISA
Pls, I need a recommendation for the best easy to implement editor that non technical user can use to add image, table to document in django admin textarea. I want my users to be using django admin as there backend when creating blog content and they needed the following functionality: 1. insertin

Re: Despite what django doc says, multiple inheritance with a common ancestor causes an error(models.E005). I found a tricky solution, but are there any better solutions?

2017-06-15 Thread Hyunsoo Kim
Currently no model is abstract. I can guarantee this because each model is referenced by one or more foreign keys. I don't think this is my special case problem. The same problem happens when you use the common ancestor model in the django document. -- You received this message because you are

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread Александр Христюхин (roboslone)
You could set "X-CSRFToken" header, that would be enough. Why do you post data manually though? > On 15 Jun 2017, at 16:33, 李余通 wrote: > > Ture,my way is wrong,should i send cookies? > > 在 2017年6月15日星期四 UTC+8下午9:29:17,Александр Христюхин写道: > CSRF token value is passed in Django's response hea

Re: Django Channels : High CPU usage by workers and 503 responses.

2017-06-15 Thread Andrew Godwin
The error you have looks like https://github.com/django/channels/issues/643, which was fixed in the master branch but not released yet. Could you install channels from the master git branch and see if that improves things? Andrew On Thu, Jun 15, 2017 at 7:19 PM, RAUSHAN RAJ wrote: > Hi, > I am

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread 李余通
Ture,my way is wrong,should i send cookies? 在 2017年6月15日星期四 UTC+8下午9:29:17,Александр Христюхин写道: > > CSRF token value is passed in Django's response headers. > And anyway, you're no supposed to post data like that. Do you do that in > tests? > > On 15 Jun 2017, at 16:20, liyutong...@gmail.com w

Re: I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread Александр Христюхин (roboslone)
CSRF token value is passed in Django's response headers. And anyway, you're no supposed to post data like that. Do you do that in tests? > On 15 Jun 2017, at 16:20, liyutong19961...@gmail.com wrote: > > I uis this code to submit form > ```python > import requests > > url = 'http://127.0.0.1:8000

I use requests to submit form,how to bate Django's csrfmiddlewaretoken

2017-06-15 Thread liyutong19961231
I uis this code to submit form ```python import requests url = 'http://127.0.0.1:8000/contact/' d = {'subject':'你好','email':'','message':'thank u'} r = requests.post(url,data = d) print(r.text) ``` but i don't has csrfmiddlewaretoken's values I try to use requests.get to get csrfmiddlewaretoken's

Re: Integration of Django with other python codes

2017-06-15 Thread Jani Tiainen
Hi, If you have done the official tutorial [1], you should already hold all the knowledge required to do what you asked. [1] https://docs.djangoproject.com/en/1.11/intro/tutorial01/ On 15.06.2017 14:10, sunitha.b...@algonox.com wrote: Hi guys, Im a newbee to Django.. Actually I was trying t

Django Channels : High CPU usage by workers and 503 responses.

2017-06-15 Thread RAUSHAN RAJ
Hi, I am using HAPROXY --> 2 Daphne interface servers ---> Redis Channel Layer and Running (28)workers on 10 cores. I was doing load testing using artillery artillery quick --duration 60 --rate 100 -n 10 url After few seconds only Getting Errors like 504,503,ECONNRESET,ETIMEDOUT . Same loadtesti

Integration of Django with other python codes

2017-06-15 Thread sunitha . bist
Hi guys, Im a newbee to Django.. Actually I was trying to integrate my python code to Django web application.. For example.. Im having a python code in which if i enter any input it will generate an output.. In web application I have one input box, button and text area.

Send message to group from server on production by channels.

2017-06-15 Thread Петр Гордеев
Hi, I have a problem with send message from backend on production. If I want to send message to group through socket, everything is ok. But if I want to send message from backend (cron, on create object signal), message is not delivered. On localhost mode both sides work fine. Ubuntu 14.04. Dj

Re: Failed building wheels for twisted

2017-06-15 Thread Oladipupo Elegbede
Do you want to share what you did to resolve it? That may help someone else. Thanks. On Jun 14, 2017 5:07 PM, "yingi keme" wrote: I have solved the problem. Thanks anyways..! Yingi Kem > On 14 Jun 2017, at 6:43 PM, yingi keme wrote: > > Hello > > I tried installing django channels on my vir

Re: Need help in calling dispatch on custom mixin for authorization

2017-06-15 Thread Ajat Prabha
I was able to resolve the issue. In mixins.py, .get_object() was unresolvable so I inherited from SingleObjectMixin also I had to use the id to check equality. from django.contrib.auth.mixins import LoginRequiredMixin from django.core.exceptions import PermissionDenied from django.views.generic.d

Re: Need help in calling dispatch on custom mixin for authorization

2017-06-15 Thread Ajat Prabha
There's a typo in > if request.user.is_authenticated() and request.user is not > self.get_object().owner.user: It is > if request.user.is_authenticated() and request.user is not > self.get_object().author.user: But still, it doesn't work. Same issue persists. -- You received this message b