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

2017-03-13 Thread Antonis Christofides
> MyModel.objects.for_user(request.user).all() > MyModel.objects.for_all_users().all() > MyModel.objects.all() -> raises Exception I like this idea. def get_queryset(self): result = super(MyManager, self).get_queryset() try: if self.user is None: ret

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

2017-03-13 Thread Antonis Christofides
Let's talk with a concrete (real but simplified) example. There's a database of documents. Some documents are publicly available, whereas some are available only to logged-on users. The "document list" view shows all documents if you're logged-on, and a subset if not. The "document detail" view w

Re: Will asgi become a PEP like wsgi is ?

2017-03-13 Thread Alan
Would you mind replying here too please? I'd rather avoid another list for me to subscribe. Thanks, Alan On 13 March 2017 at 01:38, Andrew Godwin wrote: > I'll reply to this in the same subject thread on django-developers. > > Andrew > > On Sat, Mar 11, 2017 at 2:29 PM, Sebastian Haase > wrot

Re: Uplaod execl file to populate django database

2017-03-13 Thread Shawn Milochik
1. Write code that puts data into your models. Do the Django tutorial if you don't know how. 2. Write code that reads data out of your​ Excel file using the appropriate library, easily found on pypi. 3. Use them together. -- You received this message because you are subscribed to the Google Gro

Re: Will asgi become a PEP like wsgi is ?

2017-03-13 Thread Shawn Milochik
You don't have to subscribe. Just read it online. https://groups.google.com/forum/m/#!forum/django-developers -- 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 dj

Re: Uplaod execl file to populate django database

2017-03-13 Thread Rafael E. Ferrero
2017-03-13 3:51 GMT-03:00 JJEMBA KENNETH : > Hello guyz, > Can any one help with this. I want to upload an excel file with data and i > use this data to populate the database. > > -- > Jjemba kenneth > > -- > I used this https://github.com/pyexcel/django-excel -- You received this message becau

Re: Full domain url subfolder redirected my django application with apache with mod_wsgi

2017-03-13 Thread valerio orfano
Hi the problem is that i want to mount django app on a subfolder of my root url that is www.mydomain.com. Pratically www.mydomain.com/nuovopatentdb (nuovopatentdb is not really existing , it is used for natting the address to local address) is natted to my django server 10.184.2.231. Now setting

Re: Uplaod execl file to populate django database

2017-03-13 Thread Thiago Parolin
I change my excel to csv file and populate db 2017-03-13 8:24 GMT-03:00 Rafael E. Ferrero : > 2017-03-13 3:51 GMT-03:00 JJEMBA KENNETH : > >> Hello guyz, >> Can any one help with this. I want to upload an excel file with data and >> i use this data to populate the database. >> >> -- >> Jjemba ken

Django makemigrations cannot detect change when changing custom field overriding charfield.

2017-03-13 Thread 김지환
# category.py from django.db.models.fields import CharField class CategoryField(CharField): verbose_name = "category" max_length = 40 NORMAL = 'normal' PUBLIC = 'public' choices = ( (NORMAL, "normal"), (PUBLIC, "public), ) def __init__(self, *arg

Updating files without web server restart

2017-03-13 Thread Thiago Parolin
We have a small webserver that is used by many projects (php) from many users. Now, i am hosting a django project. The problem is: - when user changed some file in his project, the apache continues serving old file until restart the httpd service. - the users don't have sudo access, and i don't

RE: Migrations

2017-03-13 Thread Matthew Pava
My problems this time around came from a circular dependency that squashmigrations caused. I have had issues in the past with removing a field from a model and basically having a simple pass statement for the model. I saw a ticket or some discussion somewhere about that issue elsewhere. I als

Re: Updating files without web server restart

2017-03-13 Thread Avraham Serour
you may use uwsgi and tell uwsgi to gracefully reload, it won't even close any eventual tcp sockets, they will wait until the new code is loaded, users will never now you reloaded the application On Mon, Mar 13, 2017 at 3:25 PM, Thiago Parolin wrote: > We have a small webserver that is used by m

Re: Updating files without web server restart

2017-03-13 Thread Antonis Christofides
Are you using mod_wsgi? http://modwsgi.readthedocs.io/en/develop/user-guides/reloading-source-code.html has information on how to have it reload the code. Antonis Christofides +30-2118000592 (work) +30-6979924665 (mobile) On 2017-03-13 15:25, Thiago Parolin wrote: > We have a small webserver that

Re: Django makemigrations cannot detect change when changing custom field overriding charfield.

2017-03-13 Thread Tim Graham
It looks like you need to add a CategoryField.deconstruct() method. https://docs.djangoproject.com/en/stable/howto/custom-model-fields/#custom-field-deconstruct-method On Monday, March 13, 2017 at 8:05:02 AM UTC-4, 김지환 wrote: > > # category.py > > > from django.db.models.fields import CharField >

Re: Updating files without web server restart

2017-03-13 Thread Thiago Parolin
Thanks a lot to all! I will try uwsgi and i will read about mod_wsgi to know who is the best to my needs and will solve my problem. 2017-03-13 10:29 GMT-03:00 Avraham Serour : > you may use uwsgi and tell uwsgi to gracefully reload, it won't even close > any eventual tcp sockets, they will wait

Re: Updating files without web server restart

2017-03-13 Thread Antonis Christofides
Hello, 1) My opinion is that uwsgi is difficult without offering any equivalent advantage. The WSGI server I usually recommend is Gunicorn. I've explained this in Which WSGI server should I use? If you start Gunicorn with th

Re: Migrations

2017-03-13 Thread marcin . j . nowak
On Friday, March 10, 2017 at 9:18:42 PM UTC+1, Matthew Pava wrote: > > Does anyone else get a migraine when working migrations? > Yes*. Long time ago. Stayed with Liquibase wrapped with Liquimigrate. Builtin migrations are pretty unrielable, because they're strongly dependent on your applicati

OneToOne mappings

2017-03-13 Thread marcin . j . nowak
Hi. The problem is: A 1:1 B B.a = OneToOne(A) and there is a vA - an unmanaged model of A's view A and B are linked together. vA view is not linked with B, of course. When I try to declare OneToOne within vA, Django expects vA.b_id field which is missing (that's ok). When I try to declar

Re: Full domain url subfolder redirected my django application with apache with mod_wsgi

2017-03-13 Thread valerio orfano
Sorry the correct address www.mydomain.com/nuovopatentdb/static/images/giphy.gif but in my template i get www.mydomain.com/static/images/giphy.gif

No support for UNION (OUTER JOIN instead)

2017-03-13 Thread guettli
We have performance issues on postgres because some SQL statements have up to six LEFT OUTER joins. Union and intersection would be easier to read for me (human being) and maybe better to optimize for the postgres query planer. It seems that other people have this issue, too: https://code.d

Re: No support for UNION (OUTER JOIN instead)

2017-03-13 Thread Tim Graham
Support for QuerySet.union(), intersection(), and difference() is added in Django 1.11. https://github.com/django/django/commit/84c1826ded17b2d74f66717fb745fc36e37949fd On Monday, March 13, 2017 at 11:54:15 AM UTC-4, guettli wrote: > > We have performance issues on postgres because some SQL stat

Customs Django Admin "add" view.

2017-03-13 Thread Daniel Gola
Hello Everyone, I trying to figure out how to override admin add view for specific app. I've read docs and have found some information about get_urls() method, but It is not clear for me and nice examples are lacking there... Could you help me? I will be grateful for you support. Best regard

What was the rationale behind ClassBasedView.as_view()

2017-03-13 Thread Frederik Creemers
Django views are just functions that take a request, and possibly some other args, and return a response. To get such a view from a class based view, you can `as_view()` on it. Why is that? Wouldn't it make the code neater to just implement `__call__` on the views? What was the reing behind ha

Re: Will asgi become a PEP like wsgi is ?

2017-03-13 Thread Alan
Thanks! On 13 March 2017 at 08:39, Shawn Milochik wrote: > You don't have to subscribe. Just read it online. > > https://groups.google.com/forum/m/#!forum/django-developers > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe

Re: What was the rationale behind ClassBasedView.as_view()

2017-03-13 Thread Daniel Roseman
On Monday, 13 March 2017 18:36:46 UTC, Frederik Creemers wrote: > > Django views are just functions that take a request, and possibly some > other args, and return a response. To get such a view from a class based > view, you can `as_view()` on it. Why is that? Wouldn't it make the code > neate

Re: Migrations

2017-03-13 Thread Mike Dewhirst
On 14/03/2017 12:25 AM, Matthew Pava wrote: My problems this time around came from a circular dependency I have encountered that but I blame myself for asking too much of migrations. I have renamed a model and table successfully using migrations and I believe that led to the circular dependen

Re: What was the rationale behind ClassBasedView.as_view()

2017-03-13 Thread Frederik Creemers
That makes heaps of sense, thanks! On Mon, Mar 13, 2017 at 10:49 PM Daniel Roseman wrote: > On Monday, 13 March 2017 18:36:46 UTC, Frederik Creemers wrote: > > Django views are just functions that take a request, and possibly some > other args, and return a response. To get such a view from a cl

Re: What was the rationale behind ClassBasedView.as_view()

2017-03-13 Thread Russell Keith-Magee
There’s also a summary of the various options that were considered: https://code.djangoproject.com/wiki/ClassBasedViews Yours, Russ Magee %-) On Tue, Mar 14, 2017 at 10:08 AM, Frederik Creemers < frederikcreem...@gmail.com> wrote: > That makes heaps of sense, thanks! > > On Mon, Mar 13, 2017 at

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
Hi Vjiay, My apologies if the scenario is not clear. Following are the details: Lets say there is a Model A (with fields, foreignkeys and ManyToMany relationships with other models). There are 10k records for A. Lets say following is the pseudo code for the report: As = A.objects.all() for a

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
On Sunday, March 12, 2017 at 4:53:25 AM UTC+5:30, James Schneider wrote: > > > > 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 computa

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
Hi Camilo, Thanks for your suggestion. Would certainly look for solutions outside Django if Django cannot suffice. But was trying to find something with Django since the web part was in Django and for easy of development. We are already using Celery Extensively but then high Resource Usage is n

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
Hi Daniel, Thanks for the suggestion. Would look into django-import-export. Thanks. On Saturday, March 11, 2017 at 6:29:57 PM UTC+5:30, Daniel Hepper wrote: > > In additions to the suggestions you already received from others, have a > look at django-import-export. It allows you to easily expor

Re: Django makemigrations cannot detect change when changing custom field overriding charfield.

2017-03-13 Thread 김지환
CategoryField subclassed CharField, so I think I don't need to add deconstruct method in CategoryField. And, when call CategoryField().deconstruct(), the values return correctly. Why django makemigrations cannot detect max_length and choices change? 2017년 3월 13일 월요일 오후 10시 43분 53초 UTC+9, Tim