Re: Django queryset High CPU Usage

2017-03-11 Thread Camilo Torres
Hi. You can probably use another web framework for that report, or even rethink your architecture and put the report creation outside Django and the web server without Django ORM. You may be interested in evaluating Celery and Django Celery. You can create a separate task outside Django to cre

Re: Django queryset High CPU Usage

2017-03-11 Thread Daniel Hepper
In additions to the suggestions you already received from others, have a look at django-import-export. It allows you to easily export data in various formats. Hope that helps, Daniel Hepper https://consideratecode.com On Friday, March 10, 2017 at 12:06:13 PM UTC+1, Web Architect wrote: > > Hi J

Re: Is this a bug? KeyError: 'is_popup' on mysite/admin, while logging level = DEBUG. Django 1.10.6.

2017-03-11 Thread Daniel Hepper
Yes, this is normal behavior. What you are seeing is the log output for a missing template variable. Django logs these in log level debug. See https://docs.djangoproject.com/en/1.10/topics/logging/#django-template To get rid of these, you can configure the logger for the template system to only

Re: Is it good practice to access the request from a model manager?

2017-03-11 Thread Daniel Hepper
I think it is a good idea to do the permission check on the manager level. I would prefer a more explicit approach, e.g. something like this: MyModel.objects.for_user(request.user).all() MyModel.objects.for_all_users().all() MyModel.objects.all() -> raises Exception This way you don't need a mid

Re: Is it good practice to access the request from a model manager?

2017-03-11 Thread Melvyn Sopacua
On Thursday 09 March 2017 14:36:55 Antonis Christofides wrote: > Exactly, "if you remember to write a test". Unit tests can help, but > when you do the same kind of permissions checking 10 times in 10 > different places of the app, it's really hard to know that you failed > to check edge case XYZ.

Django Channels realtime

2017-03-11 Thread Darkhan Doskul
Hello, everyone~ For example I have an model 'Sales' . I want to show these added Sales to all users, whose connected to my app, in page news. I would like to do it with real time, cause Sales object has a time, count_users... please give the direction -- You received this message because you

initial not work in Form Field

2017-03-11 Thread 郭城熙
Hello, I don't understand why initial not work in my code , here is it: class QuestionListForm(forms.Form): _id = forms.IntegerField() page = forms.IntegerField(required=False, initial=12) class MyView(View): def get(self, request): form = QuestionTypeForm(request.GET, initi

Re: Q? Packaging app best practices (lots of questions)

2017-03-11 Thread Melvyn Sopacua
On Thursday 09 March 2017 14:07:45 Charles Thayer wrote: > * Examples: is there a canonical example app that covers enough ground > to be _the_ "best practices" example? An "app" is a very loosely defined term. There has been work to come to a "reusable app standard[1]". But since there's no ce

Re: Is this a bug? KeyError: 'is_popup' on mysite/admin, while logging level = DEBUG. Django 1.10.6.

2017-03-11 Thread np
Hi Daniel, Thank you for your anwer. I tested the option for using level: INFO for the django.template -logger. Your solution will suppress the Exception while resolving variable 'is_popup' in template 'admin/index.html' . ... being caught. However, I do not understand why should I just *suppre

Re: Simple Join with no matching primary keys

2017-03-11 Thread Camilo Torres
You can also create a database view from the join of the two tables. -- 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 django-users+unsubscr...@googlegroups.com. T

connect Django to MySQL and i get this error

2017-03-11 Thread gaieb hamza
Unhandled exception in thread started by .wrapper at 0x7f0047a0c510> Traceback (most recent call last): File "/home/whomi/demo/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 24, in import MySQLdb as Database ImportError: No module named 'MySQLdb' During handling of t

Re: Is this a bug? KeyError: 'is_popup' on mysite/admin, while logging level = DEBUG. Django 1.10.6.

2017-03-11 Thread Melvyn Sopacua
On Saturday 11 March 2017 07:55:58 np wrote: > being caught. However, I do not understand why should I just *suppress > *Exceptions/KeyErrors in the templates? I did not understand *why* > this exception is raised. If there is no such variable as 'is_popup', > shoudn't I just provide one? Forgive

Re: connect Django to MySQL and i get this error

2017-03-11 Thread Melvyn Sopacua
On Saturday 11 March 2017 08:38:49 gaieb hamza wrote: > Unhandled exception in thread started by check_errors..wrapper at 0x7f0047a0c510> > Traceback (most recent call last): > File > "/home/whomi/demo/lib/python3.5/site- packages/django/db/backends/mysql > /base.py", line 24, in > import M

Re: Migrations

2017-03-11 Thread Vijay Khemlani
Not really, as long as you understand what's going on and not inputting commands just for the sake of it. On 3/11/17, Mike Dewhirst wrote: > On 11/03/2017 7:17 AM, Matthew Pava wrote: >> >> Does anyone else get a migraine when working migrations? >> > > Only when I try to game them. If I follow i

Re: Django queryset High CPU Usage

2017-03-11 Thread Vijay Khemlani
Am I the only one who thinks that generating a report over a set of just 10.000 records could be done in 10 - 20 secs unless there are some serious computations going on with that data? For a report I have to query around 200.000 records, with aggregations, and it takes less than a minute using th

Re: "trans" template tag using wrong language

2017-03-11 Thread Joan Perals
Hi Antonis, I think I figured this out. I have English as fallback language (LANGUAGE_CODE = 'en') in the settings, but my source language is German, and this mismatch seems to have been the source of all the trouble. Providing German translations (even if the original strings are already in Ge

Re: "trans" template tag using wrong language

2017-03-11 Thread Joan Perals
Hi Antonis, I think I figured this out. I have English as fallback language (LANGUAGE_CODE = 'en') in the settings, but my source language is German, and this mismatch seems to have been the source of all the trouble. Providing German translations (even if the original strings are already in Ge

Will asgi become a PEP like wsgi is ?

2017-03-11 Thread Sebastian Haase
Hi, wsgi is specified by PEP 333 -- Python Web Server Gateway Interface v1.0 https://www.python.org/dev/peps/pep-0333/ Django channels rely on asgi instead. So far ASGI specs appear only here: http://channels.readthedocs.io/en/stable/asgi.html How do these two concepts compare in regards to thei

Re: Django queryset High CPU Usage

2017-03-11 Thread James Schneider
On Mar 11, 2017 12:01 PM, "Vijay Khemlani" wrote: Am I the only one who thinks that generating a report over a set of just 10.000 records could be done in 10 - 20 secs unless there are some serious computations going on with that data? For a report I have to query around 200.000 records, with ag

Re: Django queryset High CPU Usage

2017-03-11 Thread Vijay Khemlani
"But the CPU usage and time taken are high" <- I'm assuming high enough to be problematic for OP. I'm seriously not following. Why are people suggesting reporting and export software when OP hasn't even described the problem in detail. It's not even clear whether the high cpu and time taken are du

Re: Django queryset High CPU Usage

2017-03-11 Thread Melvyn Sopacua
On Saturday 11 March 2017 21:29:10 Vijay Khemlani wrote: > "But the CPU usage and time taken are high" <- I'm assuming high > enough to be problematic for OP. > > I'm seriously not following. Why are people suggesting reporting and > export software when OP hasn't even described the problem in det

Re: Is this a bug? KeyError: 'is_popup' on mysite/admin, while logging level = DEBUG. Django 1.10.6.

2017-03-11 Thread np
Hi Thanks for your help Melvyn and Daniel.I was not familiar with this pattern. Good to hear that there is nothing actually wrong with the code. - np On Saturday, 11 March 2017 19:03:54 UTC+2, Melvyn Sopacua wrote: > > On Saturday 11 March 2017 07:55:58 np wrote: > > > > > being caught. Howev