RE: How to get as result a list of all the users ordered by birthday (month day), ignoring year

2017-11-21 Thread Matthew Pava
https://docs.djangoproject.com/en/1.11/ref/models/database-functions/#extract

MyModel.objects.order_by('birthday__month', 'birthday__day')

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Dan Tagg
Sent: Tuesday, November 21, 2017 12:58 PM
To: django-users@googlegroups.com
Subject: Re: How to get as result a list of all the users ordered by birthday 
(month day), ignoring year

Hi Roberta,

I haven't tested it but assuming you want the ordering to happen within the 
database you may be able to do it with a combination of 
TIMESTAMPDIFF
 and 
MOD.

Something like MOD( TIMESTAMPDIFF( 'SECOND', birthday, '1900-01-01'), 31556951) 
assuming you're using MySQL.

On average there are 365.2425 days per year, which equates to 31,556,951 
seconds.

Dan

On 21 November 2017 at 15:52, Roberta Takenaka Granero 
> wrote:
Dear Roy
I had already seen that link. But I didn't like the solution. Anyway it works, 
so I am using it for while.

Thank you

2017-11-17 11:13 GMT-02:00 Roy Shillingburg 
>:
https://stackoverflow.com/questions/4236226/ordering-a-django-queryset-by-a-datetimes-month-day



On Friday, November 17, 2017 at 7:19:43 AM UTC-5, Roberta Takenaka Granero 
wrote:
In models:

birthday = models.DateField()

def birthday_month_day(self):
  # returns month and day
  return '12-31'


In views, I expect to see something pythonic like this:

User.objects.all().order_by('birthday_month_day')

I know it does not work because birthday_month_day is not a column in database.

The question is how to get as result a list of all the users ordered by 
birthday (month + day), ignoring year. (queryset order_by DateField month day)

Can you help me? Anyone has faced this question before?

Thanks



--
Roberta Takenaka
--
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.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97d66095-d7a5-42c9-ad99-673fac39dac5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Roberta Takenaka
--
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.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ9dYMGUbq-QF%3Devx7u%3DtLPatWYUKCQQ0Qd-ks9Sjs3f_kP8SA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath, United 
Kingdom, BA1 2LN, Company no: 05766374
--
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.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4OyC9XnEMjSfbT6G9Zd6K1-TOa6ZPukw%3DowcLG3xUW7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at 

Re: How to use channels and make a site highly available?

2017-11-21 Thread Andrew Godwin
Right now Sentinel is the only Redis way, we have it set to a few seconds'
timeout for failover at work I believe. We can't give a magical solution as
any zero-downtime solution ends up being very project-specific; you'll need
to build on top of Channels to make your own one if you absolutely need
that.

Andrew

On Tue, Nov 21, 2017 at 9:05 AM, Sergey Pashinin 
wrote:

> Channels recommends using Redis.
> I thought I will setup Redis Cluster (https://redis.io/topics/
> cluster-tutorial) behind HAProxy and it will be all fine.
> But Channels does not support working with Redis Cluster -
> https://github.com/django/channels/issues/485.
>
> Then I was looking at Redis Sentinel - seriously? One more process, a
> timeout to detect master failure - then make another one a master.. and all
> that time is downtime? And it's ok if it works correctly at least.
>
>
> People say different things about RabbitMQ and it's cluster. Personally I
> am already tired to make it work inside Docker right now (still stops at
> random times and lost connections and so on)
>
>
> What is a recommended way to make a site with Django channels work without
> a downtime? (And without loosing user sessions if 1 node fails)
>
> --
> 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.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/33d98ea2-2388-41be-b4e5-f908fd6792e1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFwN1uov9NWf%3Dey64UgKw%3DOjx9nux7zeTaAVWRMYAwRDxi3X%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Speed up Loading the First Page of Django Project?

2017-11-21 Thread flora . xiaoyun . huang
But that's all I revised of the code. The configuration file of server 
engine and all the other things keep the same.

On Tuesday, November 21, 2017 at 2:09:08 PM UTC-5, Jason wrote:
>
> That is not a good solution.  There's a reason why the default password 
> hashing algorithm is complex.
>
> And I find it hard to believe that a password hash is the culprit here.  
> Maybe a quarter second or so added to a response, but 10 seconds?  that's 
> definitely not the cause.
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/94d70393-b9a4-43d3-857c-acc9ba9134a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Speed up Loading the First Page of Django Project?

2017-11-21 Thread Jason
That is not a good solution.  There's a reason why the default password 
hashing algorithm is complex.

And I find it hard to believe that a password hash is the culprit here.  
Maybe a quarter second or so added to a response, but 10 seconds?  that's 
definitely not the cause.

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8ccac83b-ff61-4a25-b567-11147f03dfc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get as result a list of all the users ordered by birthday (month day), ignoring year

2017-11-21 Thread Dan Tagg
Hi Roberta,

I haven't tested it but assuming you want the ordering to happen within the
database you may be able to do it with a combination of TIMESTAMPDIFF

 and MOD

.

Something like MOD( TIMESTAMPDIFF( 'SECOND', birthday, '1900-01-01'),
31556951) assuming you're using MySQL.

On average there are 365.2425 days per year, which equates to 31,556,951
seconds.

Dan

On 21 November 2017 at 15:52, Roberta Takenaka Granero <
takenaka.robe...@gmail.com> wrote:

> Dear Roy
>
> I had already seen that link. But I didn't like the solution. Anyway it
> works, so I am using it for while.
>
> Thank you
>
> 2017-11-17 11:13 GMT-02:00 Roy Shillingburg :
>
>> https://stackoverflow.com/questions/4236226/ordering-a-djang
>> o-queryset-by-a-datetimes-month-day
>>
>>
>>
>> On Friday, November 17, 2017 at 7:19:43 AM UTC-5, Roberta Takenaka
>> Granero wrote:
>>>
>>> In models:
>>>
>>> birthday = models.DateField()
>>>
>>> def birthday_month_day(self):
>>>   # returns month and day
>>>   return '12-31'
>>>
>>>
>>> In views, I expect to see something pythonic like this:
>>>
>>> User.objects.all().order_by('birthday_month_day')
>>>
>>> I know it does not work because birthday_month_day is not a column in
>>> database.
>>>
>>> The question is how to get as result a list of all the users ordered by
>>> birthday (month + day), ignoring year. (queryset order_by DateField month
>>> day)
>>>
>>> Can you help me? Anyone has faced this question before?
>>>
>>> Thanks
>>>
>>>
>>>
>>> --
>>> Roberta Takenaka
>>>
>> --
>> 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.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/97d66095-d7a5-42c9-ad99-673fac39dac5%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Roberta Takenaka
>
> --
> 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.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAJ9dYMGUbq-QF%3Devx7u%3DtLPatWYUKCQQ0Qd-ks9Sjs3f_
> kP8SA%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 28 Brock Street, Bath,
United Kingdom, BA1 2LN, Company no: 05766374

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4OyC9XnEMjSfbT6G9Zd6K1-TOa6ZPukw%3DowcLG3xUW7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to use channels and make a site highly available?

2017-11-21 Thread Sergey Pashinin
Channels recommends using Redis.
I thought I will setup Redis Cluster 
(https://redis.io/topics/cluster-tutorial) behind HAProxy and it will be 
all fine.
But Channels does not support working with Redis Cluster - 
https://github.com/django/channels/issues/485.

Then I was looking at Redis Sentinel - seriously? One more process, a 
timeout to detect master failure - then make another one a master.. and all 
that time is downtime? And it's ok if it works correctly at least.


People say different things about RabbitMQ and it's cluster. Personally I 
am already tired to make it work inside Docker right now (still stops at 
random times and lost connections and so on)


What is a recommended way to make a site with Django channels work without 
a downtime? (And without loosing user sessions if 1 node fails)

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/33d98ea2-2388-41be-b4e5-f908fd6792e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get as result a list of all the users ordered by birthday (month day), ignoring year

2017-11-21 Thread Roberta Takenaka Granero
Dear Roy

I had already seen that link. But I didn't like the solution. Anyway it
works, so I am using it for while.

Thank you

2017-11-17 11:13 GMT-02:00 Roy Shillingburg :

> https://stackoverflow.com/questions/4236226/ordering-a-
> django-queryset-by-a-datetimes-month-day
>
>
>
> On Friday, November 17, 2017 at 7:19:43 AM UTC-5, Roberta Takenaka Granero
> wrote:
>>
>> In models:
>>
>> birthday = models.DateField()
>>
>> def birthday_month_day(self):
>>   # returns month and day
>>   return '12-31'
>>
>>
>> In views, I expect to see something pythonic like this:
>>
>> User.objects.all().order_by('birthday_month_day')
>>
>> I know it does not work because birthday_month_day is not a column in
>> database.
>>
>> The question is how to get as result a list of all the users ordered by
>> birthday (month + day), ignoring year. (queryset order_by DateField month
>> day)
>>
>> Can you help me? Anyone has faced this question before?
>>
>> Thanks
>>
>>
>>
>> --
>> Roberta Takenaka
>>
> --
> 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.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/97d66095-d7a5-42c9-ad99-673fac39dac5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Roberta Takenaka

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ9dYMGUbq-QF%3Devx7u%3DtLPatWYUKCQQ0Qd-ks9Sjs3f_kP8SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Speed up Loading the First Page of Django Project?

2017-11-21 Thread flora . xiaoyun . huang
Hi Jason,

Thanks for your help! I just solved the bug. 

The reason of the bug is that in the first step after I verify the worker's 
identification, I should put them in the database. And in django default 
setting, PASSWORD_HASHERS is set to PBKDF2 to hash the password for each 
worker. It is a complex algorithm, slowing down the speed to put users in 
the database. So I change PASSWORD_HASHERS to SHA1P. In this way, the user 
is put in the database faster, thus the first page is loaded faster.

On Tuesday, November 21, 2017 at 9:15:54 AM UTC-5, Jason wrote:
>
> Does that worker call execute slowly each time you call it?  Or is it just 
> the once?
>
> I'd copy that URL and try calling it several times with an REST API client 
> like Postman.  Does the request execute that slowly each time you call it, 
> or is it just the initial call that is slow?
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/34e36052-9c46-4c07-8386-2e21c9633422%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Vider champs du formulaire

2017-11-21 Thread Mozard Yao
Bonjour ,
Je suis débutant sur le dévelopement avec django.
J'aimerais pourvoir vider les zones de texte après validation mais je ne 
sais comment le faire.

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14b2f810-7883-4d4f-a5c5-fe3e478e4388%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Any django reusable app for outdoor & indoor location, GPS tracking?

2017-11-21 Thread 'Federico Capoano' via Django users
Hi everyone,

I'd like to provide an update on this topic.

First of all, I think my initial question was not 100% clear.

For indoor location and GPS tracking I meant the following:

Indoor location: being able to specify the location of an object in 
buildings, having their floorplan(s).
GPS tracking: being able to track objects that move around, in the case of 
OpenWISP  these objects will be most likely be 
network/radio/wifi devices.

In the end I didn't find any reusable app so I started working on a new app 
which I named django-loci . It's 
not released yet but it kinda works, I have shown a prototype of this work 
during this presentation (I'm linking the exact second in which I show 
it): https://www.youtube.com/watch?v=WgVduiZzuA0 (the recording was 
slightly disturbed so bear with it while you wait for the floorplan demo to 
show up.

Like the other OpenWISP 2 base modules, I will soon provide abstract base 
models, base views and other classes/functions that third party apps can 
import in their project and extend.
We have done this for django-x509  
and is going quite well, since other developers who don't use OpenWISP are 
using django-x509 in their project, reporting bugs and sending patches.

I'll send another announcement when we hit the 0.1 release of django-loci, 
hopefully it will be useful to other people and/or we'll be able to collect 
useful feedback and/or suggestions.

Federico

PS: if you are curious to know more about the modular architecture of 
OpenWISP 2, there's a presentation which has a good level of 
detail 
https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world


On Tuesday, September 26, 2017 at 12:13:30 PM UTC+2, Federico Capoano wrote:
>
> Hi everyone,
>
> before building my own reusable app all over again, I wanted to ask here 
> if there is any reusable django app that does indoor location and or GPS 
> tracking.
> I'm not looking for something full featured, but rather a starting point 
> to which I can contribute to.
>
> Best regards
> Federico Capoano
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/552281bc-87b1-43e5-9812-cfcd2f1ced91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Dominik Szmaj
Hey,

'case_id' is a monkeypatch number(*) field so it works quick for now, not a 
pk, but unique:

class OmEvent(Model):
case = ForeignKey('CaseInfo2', to_field='case_id', related_name='events', 
blank=True, null=True)

class Meta:
db_table = 'om_event'


old form:

class OmEvent(Model):
case = ForeignKey('CaseInfo2', related_name='events', blank=True, null=True)

class Meta:
db_table = 'om_event'

which points to 'case_number' pk which is a varchar.

Everything is managed by db router which prevents migrations on remote db.

Regards,
Dominik

W dniu wtorek, 21 listopada 2017 15:00:49 UTC+1 użytkownik Avraham Serour 
napisał:
>
> can you post your model?
>
> On Tue, Nov 21, 2017 at 3:31 PM, Dominik Szmaj  > wrote:
>
>> Hey,
>>
>> I have a very big performance problem with Django and Oracle db.
>>
>> This legacy db has lots of primary keys as strings from the time when 
>> those id's were alphanumerical so it can't be simply converted to number.
>>
>> So when I set FK on such varchar column django seems to not crash but it 
>> converts to int and search whole table of strings with a number which takes 
>> ages to complete.
>>
>> Is there maybe some sane solution to the problem? Why it forces me to use 
>> numbers on varchar FK?
>>
>> Best regards.
>> Dominik
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/e4e51608-740c-410c-bc47-21d189c0edf6%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
W dniu wtorek, 21 listopada 2017 15:00:49 UTC+1 użytkownik Avraham Serour 
napisał:
>
> can you post your model?
>
> On Tue, Nov 21, 2017 at 3:31 PM, Dominik Szmaj  > wrote:
>
>> Hey,
>>
>> I have a very big performance problem with Django and Oracle db.
>>
>> This legacy db has lots of primary keys as strings from the time when 
>> those id's were alphanumerical so it can't be simply converted to number.
>>
>> So when I set FK on such varchar column django seems to not crash but it 
>> converts to int and search whole table of strings with a number which takes 
>> ages to complete.
>>
>> Is there maybe some sane solution to the problem? Why it forces me to use 
>> numbers on varchar FK?
>>
>> Best regards.
>> Dominik
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/e4e51608-740c-410c-bc47-21d189c0edf6%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8512002-4fac-4ae0-b6ee-35a239d2670f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Speed up Loading the First Page of Django Project?

2017-11-21 Thread Jason
Does that worker call execute slowly each time you call it?  Or is it just 
the once?

I'd copy that URL and try calling it several times with an REST API client 
like Postman.  Does the request execute that slowly each time you call it, 
or is it just the initial call that is slow?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e72065e-9006-4c9f-a7e1-882ba6c8b647%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Jani Tiainen
Please, post your models in question. It's probably something really 
simple to resolve in general.



On 21.11.2017 15.59, Avraham Serour wrote:

can you post your model?

On Tue, Nov 21, 2017 at 3:31 PM, Dominik Szmaj 
> wrote:


Hey,

I have a very big performance problem with Django and Oracle db.

This legacy db has lots of primary keys as strings from the time
when those id's were alphanumerical so it can't be simply
converted to number.

So when I set FK on such varchar column django seems to not crash
but it converts to int and search whole table of strings with a
number which takes ages to complete.

Is there maybe some sane solution to the problem? Why it forces me
to use numbers on varchar FK?

Best regards.
Dominik
-- 
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
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users
.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/e4e51608-740c-410c-bc47-21d189c0edf6%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout
.


--
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 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tKd-c9bUn5qSv9hFQvPSvVVyqOi1GpOWYQWz2uzL52h%2Bg%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Jani Tiainen

--
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39b6207f-6524-a6f3-af51-476e689ea25f%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Avraham Serour
can you post your model?

On Tue, Nov 21, 2017 at 3:31 PM, Dominik Szmaj 
wrote:

> Hey,
>
> I have a very big performance problem with Django and Oracle db.
>
> This legacy db has lots of primary keys as strings from the time when
> those id's were alphanumerical so it can't be simply converted to number.
>
> So when I set FK on such varchar column django seems to not crash but it
> converts to int and search whole table of strings with a number which takes
> ages to complete.
>
> Is there maybe some sane solution to the problem? Why it forces me to use
> numbers on varchar FK?
>
> Best regards.
> Dominik
>
> --
> 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.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/e4e51608-740c-410c-bc47-21d189c0edf6%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tKd-c9bUn5qSv9hFQvPSvVVyqOi1GpOWYQWz2uzL52h%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Building a web app for use of third party python package

2017-11-21 Thread Enikő Regényi
Hello,

I would like to use Django for building a web application for use of a 
third party python package. 

This third party package uses a text file as input, and produces a bunch of 
text files as output (sorted in directories). 

I would like my website to take text/textfile from the user, and give an 
archive (.zip) back with all the output files. 

I went through the tutorial on the django website already, and made some 
progress, but my understanding is still shallow for this project.

Could someone point me to the best direction, or give tips on what bits of 
the documentation I should read to get my head around it as fast as 
possible?


Many thanks!

Eni

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/25569f75-d5f8-407a-aaea-0e4e824988be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I customize a user registration form so it only requires email and password fields?

2017-11-21 Thread sunil mishra
Hi Tom , 
i can solve your code problem . contact me on my mail :- 
sunilmishra1...@gmail.com

On Monday, November 20, 2017 at 8:50:18 AM UTC+5:30, Tom Tanner wrote:
>
> I'm following this [tutorial](
> https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html)
>  
> on making simple registration forms in Django. I'd like to make a user 
> registration form that requires only two fields: "Email" and "Password." No 
> second password field, just one.
>
> So far, My `views.py` looks like this: 
>
> def register(request, template="register.html", redirect='/'):
> if request.method=="POST":
> form= RegisterForm(request.POST)
> if form.is_valid():
> form.save()
> email= form.cleaned_data.get("email")
> raw_password= form.cleaned_data.get("password1")
> user= authenticate(email=email, password=raw_password)
> login(request, user)
> return redirect('/')
> else:
> form= RegisterForm()
> return render(request, template, {"form": form})
>  
> `forms.py` has this class in it:
>
> class RegisterForm(UserCreationForm):
> email= forms.EmailField(label=_("Email"), max_length=254)
> 
> class Meta:
> model= User
> fields= ("email",)
>
> `register.html` looks simple:
>
> {% extends "base.html" %}
> {% block main %}
> Register
> 
> {% csrf_token %}
> {{ form.as_p }}
> Register
> 
> {% endblock main %}
>
> In `urls.py`, I have this line in `urlpatterns`: `url("^register/$", 
> views.register, name="register"),`.
>
> But my registration forms looks like this, with an Email field and two 
> Password fields: http://i.imgur.com/b359A5Z.png. And if I fill out all 
> three fields and hit "Register," I get this error: `UNIQUE constraint 
> failed: auth_user.username`.
>
> Any idea why I'm getting this error? And how can I make sure my form only 
> has two fields: Email and Password?
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/36cc7242-a588-4a0c-97ef-c27e6b7e4aa4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Strange query when using annotate and count

2017-11-21 Thread Cristiano Coelho
Hmm, should I try with the dev mailing list? Guess it's something no one 
faced before?

El martes, 14 de noviembre de 2017, 22:54:23 (UTC-3), Cristiano Coelho 
escribió:
>
> I'm getting some very odd query when combining annotate with count. See 
> the following:
>
> >>> q = 
>> Vulnerability.objects.annotate(score=WordTrigramCustomSimilarity('test','summary'))
>> >>> q.count()
>> 3094
>> >>> print connection.queries[-1]
>> 'SELECT COUNT(*) 
>> FROM (
>> SELECT "vulnerabilities_vulnerability"."id" AS Col1, 
>> custom_word_similarity(\'test\', "vulnerabilities_vulnerability"."summary") 
>> AS "score" 
>> FROM "vulnerabilities_vulnerability" 
>> GROUP BY "vulnerabilities_vulnerability"."id", 
>> custom_word_similarity(\'test\', "vulnerabilities_vulnerability"."summary")
>> ) subquery
>> >>> q2 = Vulnerability.objects.filter(summary__icontains='test')
>> >>> q2.count()
>> 33
>> >>> print connection.queries[-1]
>> 'SELECT COUNT(*) AS "__count" 
>> FROM "vulnerabilities_vulnerability" 
>> WHERE UPPER("vulnerabilities_vulnerability"."summary"::text) LIKE 
>> UPPER(\'%test%\')
>
>
>
> Custom function code, is this what's causing the odd count behavior? Did I 
> miss anything?
>
> class WordTrigramCustomSimilarity(Func):
>> function = 'custom_word_similarity' 
>> def __init__(self, string, expression, **extra):
>> if not hasattr(string, 'resolve_expression'):
>> string = Value(string)
>> super(WordTrigramCustomSimilarity, self).__init__(string, 
>> expression, output_field=FloatField(), **extra)
>
>
> I would expect for the query to be a simple count, rather than a nested 
> query with a useless group by (correct me if I'm wrong).
> The issue gets even worse if the function is expensive, since it gets 
> called when it's not needed at all, more than once.
> Also the issue behaves pretty much the same if the queryset includes 
> filtering and ordering but I didn't include it here for simplicity.
>
> Using Django 1.11.7 + postgres (psycopg) backend.
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b6e37c84-c09d-4486-af8a-e23c399cf975%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Dominik Szmaj
Hey,

I have a very big performance problem with Django and Oracle db.

This legacy db has lots of primary keys as strings from the time when those 
id's were alphanumerical so it can't be simply converted to number.

So when I set FK on such varchar column django seems to not crash but it 
converts to int and search whole table of strings with a number which takes 
ages to complete.

Is there maybe some sane solution to the problem? Why it forces me to use 
numbers on varchar FK?

Best regards.
Dominik

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e4e51608-740c-410c-bc47-21d189c0edf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.