[no subject]

2019-11-15 Thread Paras Jain
 i am not able to send email showing odd type of error need help
views.py:
from django.shortcuts import render, redirect
from django.contrib import messages
from profilestorer.settings import EMAIL_HOST_USER
from django.conf import settings
from .forms import SignUpForm
from django.core.mail import send_mail
from django.utils.crypto import get_random_string
from django.contrib.auth import authenticate,  logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, HttpResponse
from .models import User

# Create your views here.
def home(request):
return render(request, 'company/home.html', {'title':'profilestorer'})

@login_required
def user_logout(request):
logout(request)
return HttpResponseRedirect(reverse('login'))


def register(request):
form = SignUpForm()
if request.method == 'POST':
form = SignUpForm(request.POST)

#unique_id = get_random_string(length=8)
subject = 'Welcome to DataFlair'
message = 'Hope you are enjoying your Django Tutorials'
recepient = str(form['Email'].value())
send_mail(subject, message, EMAIL_HOST_USER, [recepient],
fail_silently = False)
return render(request, 'company/success.html',
{'recepient': recepient})
#return redirect('login')

#else:
#form =SignUpForm()
return render(request, 'company/register.html', {'form': form})

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMtmBS9g7XpxPO2AaG8HKmTjvWVAoZ84GCXp8a-WFREaqW8NpA%40mail.gmail.com.


Re: Django GIS query on annotated spatial field

2019-11-15 Thread Bill Bouzas
Good morning Simon,

Sorry for the delayed response. I a using Django 2.2.6 (released October
1st, 2019)

Kind regards,
Bill

On Thu, 14 Nov 2019 at 16:41, Simon Charette  wrote:

> Hello Bill,
>
> Could you give us more details about which version of Django you are using?
>
> There was a few Django bugs related to as_sql returning Union[list, tuple]
> as params that were
> fixed in recent release but this one might not have been caught yet.
>
> Cheers,
> Simon
>
> Le jeudi 14 novembre 2019 09:43:46 UTC-5, Bill Bouzas a écrit :
>>
>>
>>
>> I am currently building a web app based on GeoDjango and I want to check
>> if
>> a number of points lie within a multipolygon. To form the multipolygon, I
>> check which areas are selected and then aggregate them into one
>> multipolygon with the following query:
>>
>> area = Area.objects.filter(id__in =
>> area_ids).aggregate(area=Union('geom'))['area']print(area)
>>
>> SRID=4326;MULTIPOLYGON (((5.014146 52.371687, 5.013973 52.371632,
>> 5.013238 52.37166, 5.012505 52.372437, 5.01294 52.372787, 5.012977 52.373,
>> 5.013142 52.373072, 5.014488 52.373032, 5.014564 52.372957, 5.014701
>> 52.37272, 5.01461 52.372181, 5.014372 52.371786, 5.014146 52.371687)),
>> ((5.014054 52.367988, 5.014448 52.368027, 5.014532 52.367978, 5.014079
>> 52.367899, 5.014033 52.367822, 5.01398 52.367882, 5.012914 52.367781,
>> 5.013032 52.367372, 5.012751 52.367294, 5.00198 52.366278, 5.001809
>> 52.366739, 5.36 52.366614, 5.86 52.366682, 5.013941 52.367968,
>> 5.013987 52.36805, 5.014054 52.367988)), ((4.997837 52.350827, 4.997581
>> 52.350302, 4.996731 52.35072, 4.996493 52.350708, 4.991906 52.352949,
>> 4.989279 52.354708, 4.990234 52.354938, 4.993064 52.353655, 4.997837
>> 52.350827)), ((5.021518 52.384118, 5.018382 52.380388, 5.01628 52.377323,
>> 5.014382 52.37417, 5.014296 52.374171, 5.014094 52.37425, 5.014288
>> 52.374504, 5.014268 52.374785, 5.013763 52.374812, 5.013434 52.375018,
>> 5.013673 52.375082, 5.01377 52.375441, 5.014177 52.375737, 5.014467
>> 52.375531, 5.014801 52.375961, 5.014822 52.376498, 5.014295 52.376588,
>> 5.014194 52.376725, 5.014413 52.377446, 5.015047 52.378, 5.015372
>> 52.378016, 5.015413 52.377633, 5.01574 52.377412, 5.015965 52.377466,
>> 5.015873 52.378071, 5.016008 52.378355, 5.015993 52.378669, 5.016702
>> 52.380502, 5.016514 52.380922, 5.016989 52.381336, 5.017121 52.381644,
>> 5.017756 52.381984, 5.017666 52.382471, 5.018341 52.383453, 5.018662
>> 52.383813, 5.018769 52.383778, 5.019567 52.384011, 5.020317 52.383815,
>> 5.02067 52.38387, 5.022685 52.386085, 5.022946 52.386199, 5.023521
>> 52.386835, 5.023697 52.386851, 5.023905 52.386782, 5.021518 52.384118)),
>> ((4.980684 52.330761, 4.982519 52.330804, 4.983355 52.330747, 4.984946
>> 52.330428, 4.98604 52.329811, 4.987298 52.32893, 4.989045 52.327985,
>> 4.989604 52.327548, 4.990891 52.326142, 4.991615 52.324538, 4.992109
>> 52.323766, 4.995479 52.31931, 4.997103 52.317392, 4.997369 52.316672,
>> 4.997147 52.315905, 4.997091 52.314456, 4.997298 52.314196, 4.997456
>> 52.314246, 4.99786 52.313979, 5.001531 52.315911, 5.006523 52.319077,
>> 5.016134 52.324512, 5.016323 52.324237, 5.016653 52.322987, 5.017933
>> 52.323192, 5.018331 52.320249, 5.021543 52.302457, 5.019476 52.302498,
>> 5.018104 52.302624, 5.016685 52.302881, 5.014265 52.303677, 5.014229
>> 52.30359, 5.012989 52.303605, 5.012279 52.303522, 5.011623 52.303337,
>> 5.011051 52.303029, 5.009933 52.302103, 5.008961 52.301726, 5.007892
>> 52.301522, 5.007544 52.300868, 5.005265 52.298393, 5.003835 52.298509,
>> 5.003233 52.297389, 5.003227 52.296065, 5.002484 52.296035, 5.001851
>> 52.295879, 5.001789 52.292793, 4.998814 52.290239, 4.998551 52.290234,
>> 4.998452 52.289839, 4.998298 52.289815, 4.997475 52.289118, 4.994117
>> 52.289288, 4.990459 52.289603, 4.983506 52.290368, 4.982889 52.289642,
>> 4.975148 52.286342, 4.973249 52.285236, 4.973072 52.285022, 4.972611
>> 52.284846, 4.969726 52.283121, 4.969378 52.281789, 4.968815 52.280973,
>> 4.968753 52.280726, 4.968328 52.280412, 4.967674 52.279582, 4.967576
>> 52.279561, 4.966842 52.279878, 4.966491 52.280096, 4.966166 52.28098,
>> 4.965709 52.280578, 4.965316 52.280448, 4.962548 52.280285, 4.962244
>> 52.280207, 4.961054 52.278174, 4.959968 52.278346, 4.958664 52.278343,
>> 4.957809 52.278612, 4.957144 52.278671, 4.956564 52.278641, 4.955241
>> 52.278305, 4.95184 52.282443, 4.952091 52.282534, 4.946407 52.288562,
>> 4.937142 52.29947, 4.934869 52.301943, 4.934936 52.301969, 4.933217
>> 52.303553, 4.932721 52.304263, 4.931682 52.305025, 4.930256 52.30643,
>> 4.929473 52.307414, 4.929825 52.307515, 4.929416 52.307829, 4.929909
>> 52.308104, 4.929328 52.308532, 4.929615 52.308813, 4.930303 52.309182,
>> 4.930065 52.30934, 4.931656 52.310267, 4.934138 52.311903, 4.936352
>> 52.312663, 4.935229 52.313889, 4.938724 52.315091, 4.938738 52.315636,
>> 4.938042 52.316505, 4.93983 52.31712, 4.940332 52.318302, 4.939585
>> 52.31912, 4.941043 52.31962, 4.940205 52.320815, 4.939927 52.321936,
>> 4.9

How to change how foreign keys are view in admin site

2019-11-15 Thread Usman Hassan
I have a problem with my django app, I created a an that has two models one 
which is post and the other is comment, and the comment has a foreign key 
relationship to post. But anytime I view the admin site and I tried to relate a 
comment to a post I made, it won't show me the title of the post but instead it 
will show 'post object (1)'. Pls I there any way I can change that???

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c92d6f0a-b50f-4d7a-adf8-fd0e3b04a801%40googlegroups.com.


Re: SPA websites with Django

2019-11-15 Thread uday devikar
I want to take a input from a end user

Name , email and message .. I don't want to validate user or anything
...just want a input . In django .
What should I do...?


On Thu 14 Nov, 2019, 6:19 PM Michael Thomas, 
wrote:

> Django is a backend platform - it's agnostic as to what type of front end
> you build with it.
>
> On Thu, Nov 14, 2019 at 4:27 PM Inna Reddy  wrote:
>
>> Hi,
>>
>> Can we build Single page web applications with Django ?
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/26edfa5c-74b9-46f1-9d8f-3512625b3e78%40googlegroups.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEdx1foJTu27k%2B6wtK_F8H2VedpF70MiVLp_vfK%2B0C%3DbBcmr%2BA%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAbiicyuUjcYZur85naXq86jedWoRDibQ0_bXQFDyn%2BUeDgt4Q%40mail.gmail.com.


Re: SPA websites with Django

2019-11-15 Thread Motaz Hejaze
you need to go throw the django poll app tutorial

On Fri, Nov 15, 2019 at 2:48 PM uday devikar  wrote:

> I want to take a input from a end user
>
> Name , email and message .. I don't want to validate user or anything
> ...just want a input . In django .
> What should I do...?
>
>
> On Thu 14 Nov, 2019, 6:19 PM Michael Thomas, <
> michael.thomas.s...@gmail.com> wrote:
>
>> Django is a backend platform - it's agnostic as to what type of front end
>> you build with it.
>>
>> On Thu, Nov 14, 2019 at 4:27 PM Inna Reddy  wrote:
>>
>>> Hi,
>>>
>>> Can we build Single page web applications with Django ?
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/26edfa5c-74b9-46f1-9d8f-3512625b3e78%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAEdx1foJTu27k%2B6wtK_F8H2VedpF70MiVLp_vfK%2B0C%3DbBcmr%2BA%40mail.gmail.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAbiicyuUjcYZur85naXq86jedWoRDibQ0_bXQFDyn%2BUeDgt4Q%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-df%3DZ6D0pOeCKK2z8E0m4ZzDmQh4eJvVWJzYi5Otu73Gw%40mail.gmail.com.


Re: SPA websites with Django

2019-11-15 Thread Motaz Hejaze
yes you can , you can use django rest framework for making backend api and
use javascript libraries in frontend


On Thu, Nov 14, 2019 at 2:26 PM Inna Reddy  wrote:

> Hi,
>
> Can we build Single page web applications with Django ?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/26edfa5c-74b9-46f1-9d8f-3512625b3e78%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-fX9ar_NLv4ZmExA-mJNkUJ_o-VuEcxgqHhvGgaWEX5wg%40mail.gmail.com.


Re: How to change how foreign keys are view in admin site

2019-11-15 Thread Paras Jain
after that model write like this
def __str__(self):
  return self.title

On Fri, Nov 15, 2019 at 6:18 PM Usman Hassan 
wrote:

> I have a problem with my django app, I created a an that has two models
> one which is post and the other is comment, and the comment has a foreign
> key relationship to post. But anytime I view the admin site and I tried to
> relate a comment to a post I made, it won't show me the title of the post
> but instead it will show 'post object (1)'. Pls I there any way I can
> change that???
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c92d6f0a-b50f-4d7a-adf8-fd0e3b04a801%40googlegroups.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMtmBS9LiH7F9D_T0DRNT8-eNJNzGs6rmfxMJOuyqkoCb%3DsHEw%40mail.gmail.com.


Re: Django GIS query on annotated spatial field

2019-11-15 Thread Simon Charette
Can you reproduce with Django 2.2.7 (releases November 4th, 2019)

Le vendredi 15 novembre 2019 06:04:32 UTC-5, Bill Bouzas a écrit :
>
> Good morning Simon,
>
> Sorry for the delayed response. I a using Django 2.2.6 (released October 
> 1st, 2019)
>
> Kind regards,
> Bill
>
> On Thu, 14 Nov 2019 at 16:41, Simon Charette  > wrote:
>
>> Hello Bill,
>>
>> Could you give us more details about which version of Django you are 
>> using?
>>
>> There was a few Django bugs related to as_sql returning Union[list, 
>> tuple] as params that were
>> fixed in recent release but this one might not have been caught yet.
>>
>> Cheers,
>> Simon
>>
>> Le jeudi 14 novembre 2019 09:43:46 UTC-5, Bill Bouzas a écrit :
>>>
>>>
>>>
>>> I am currently building a web app based on GeoDjango and I want to check 
>>> if 
>>> a number of points lie within a multipolygon. To form the multipolygon, 
>>> I 
>>> check which areas are selected and then aggregate them into one 
>>> multipolygon with the following query: 
>>>
>>> area = Area.objects.filter(id__in = 
>>> area_ids).aggregate(area=Union('geom'))['area']print(area) 
>>>
>>> SRID=4326;MULTIPOLYGON (((5.014146 52.371687, 5.013973 52.371632, 
>>> 5.013238 52.37166, 5.012505 52.372437, 5.01294 52.372787, 5.012977 52.373, 
>>> 5.013142 52.373072, 5.014488 52.373032, 5.014564 52.372957, 5.014701 
>>> 52.37272, 5.01461 52.372181, 5.014372 52.371786, 5.014146 52.371687)), 
>>> ((5.014054 52.367988, 5.014448 52.368027, 5.014532 52.367978, 5.014079 
>>> 52.367899, 5.014033 52.367822, 5.01398 52.367882, 5.012914 52.367781, 
>>> 5.013032 52.367372, 5.012751 52.367294, 5.00198 52.366278, 5.001809 
>>> 52.366739, 5.36 52.366614, 5.86 52.366682, 5.013941 52.367968, 
>>> 5.013987 52.36805, 5.014054 52.367988)), ((4.997837 52.350827, 4.997581 
>>> 52.350302, 4.996731 52.35072, 4.996493 52.350708, 4.991906 52.352949, 
>>> 4.989279 52.354708, 4.990234 52.354938, 4.993064 52.353655, 4.997837 
>>> 52.350827)), ((5.021518 52.384118, 5.018382 52.380388, 5.01628 52.377323, 
>>> 5.014382 52.37417, 5.014296 52.374171, 5.014094 52.37425, 5.014288 
>>> 52.374504, 5.014268 52.374785, 5.013763 52.374812, 5.013434 52.375018, 
>>> 5.013673 52.375082, 5.01377 52.375441, 5.014177 52.375737, 5.014467 
>>> 52.375531, 5.014801 52.375961, 5.014822 52.376498, 5.014295 52.376588, 
>>> 5.014194 52.376725, 5.014413 52.377446, 5.015047 52.378, 5.015372 
>>> 52.378016, 5.015413 52.377633, 5.01574 52.377412, 5.015965 52.377466, 
>>> 5.015873 52.378071, 5.016008 52.378355, 5.015993 52.378669, 5.016702 
>>> 52.380502, 5.016514 52.380922, 5.016989 52.381336, 5.017121 52.381644, 
>>> 5.017756 52.381984, 5.017666 52.382471, 5.018341 52.383453, 5.018662 
>>> 52.383813, 5.018769 52.383778, 5.019567 52.384011, 5.020317 52.383815, 
>>> 5.02067 52.38387, 5.022685 52.386085, 5.022946 52.386199, 5.023521 
>>> 52.386835, 5.023697 52.386851, 5.023905 52.386782, 5.021518 52.384118)), 
>>> ((4.980684 52.330761, 4.982519 52.330804, 4.983355 52.330747, 4.984946 
>>> 52.330428, 4.98604 52.329811, 4.987298 52.32893, 4.989045 52.327985, 
>>> 4.989604 52.327548, 4.990891 52.326142, 4.991615 52.324538, 4.992109 
>>> 52.323766, 4.995479 52.31931, 4.997103 52.317392, 4.997369 52.316672, 
>>> 4.997147 52.315905, 4.997091 52.314456, 4.997298 52.314196, 4.997456 
>>> 52.314246, 4.99786 52.313979, 5.001531 52.315911, 5.006523 52.319077, 
>>> 5.016134 52.324512, 5.016323 52.324237, 5.016653 52.322987, 5.017933 
>>> 52.323192, 5.018331 52.320249, 5.021543 52.302457, 5.019476 52.302498, 
>>> 5.018104 52.302624, 5.016685 52.302881, 5.014265 52.303677, 5.014229 
>>> 52.30359, 5.012989 52.303605, 5.012279 52.303522, 5.011623 52.303337, 
>>> 5.011051 52.303029, 5.009933 52.302103, 5.008961 52.301726, 5.007892 
>>> 52.301522, 5.007544 52.300868, 5.005265 52.298393, 5.003835 52.298509, 
>>> 5.003233 52.297389, 5.003227 52.296065, 5.002484 52.296035, 5.001851 
>>> 52.295879, 5.001789 52.292793, 4.998814 52.290239, 4.998551 52.290234, 
>>> 4.998452 52.289839, 4.998298 52.289815, 4.997475 52.289118, 4.994117 
>>> 52.289288, 4.990459 52.289603, 4.983506 52.290368, 4.982889 52.289642, 
>>> 4.975148 52.286342, 4.973249 52.285236, 4.973072 52.285022, 4.972611 
>>> 52.284846, 4.969726 52.283121, 4.969378 52.281789, 4.968815 52.280973, 
>>> 4.968753 52.280726, 4.968328 52.280412, 4.967674 52.279582, 4.967576 
>>> 52.279561, 4.966842 52.279878, 4.966491 52.280096, 4.966166 52.28098, 
>>> 4.965709 52.280578, 4.965316 52.280448, 4.962548 52.280285, 4.962244 
>>> 52.280207, 4.961054 52.278174, 4.959968 52.278346, 4.958664 52.278343, 
>>> 4.957809 52.278612, 4.957144 52.278671, 4.956564 52.278641, 4.955241 
>>> 52.278305, 4.95184 52.282443, 4.952091 52.282534, 4.946407 52.288562, 
>>> 4.937142 52.29947, 4.934869 52.301943, 4.934936 52.301969, 4.933217 
>>> 52.303553, 4.932721 52.304263, 4.931682 52.305025, 4.930256 52.30643, 
>>> 4.929473 52.307414, 4.929825 52.307515, 4.929416 52.307829, 4.929909 
>>> 52.308104, 4.929328 52.308532, 4.929615 52.308813, 4.930303 52.30

Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-15 Thread Patrick Carra
In case anyone is interested I fixed this with some simple regex in my 
view.  I identified the patterns for which apache was removing the // and 
replacing with a single / and then wrote some rules around that and 
replaced the single / with the // before passing it to my query.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2752a54f-4bdc-4781-b8ba-a842ffcb1a36%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-15 Thread DANIEL URBANO DE LA RUA
Nice but i am always with nginx and i dont know if it has the same problem
or not

On Fri, 15 Nov 2019, 18:02 Patrick Carra,  wrote:

> In case anyone is interested I fixed this with some simple regex in my
> view.  I identified the patterns for which apache was removing the // and
> replacing with a single / and then wrote some rules around that and
> replaced the single / with the // before passing it to my query.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2752a54f-4bdc-4781-b8ba-a842ffcb1a36%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO_yRT0DwkcXvukvRWmhOyV5km%3Dn75d7Ssg_UakUktQCGDggdA%40mail.gmail.com.


Conditional Order By

2019-11-15 Thread Kev H
I have a model where a field can be null (and is most of the time).  
However, I need to order_by this both this field and another field (the 2nd 
field is never null) so that the results would be sorted by from high to 
low (1st based on the possible null field if it is not null and then by the 
2nd field).

Example:

Model 1:
  dollar_amount = Char()
  rating = Int()
  effectual_rating = Int(null=True, blank=True)

Example Entries:
$100, 5, Null
$125, 4, 8
$195, 3, 2
$81, 7, Null

So the end result of the query i would want it sorted like so from high to 
low value:
$125, 4, 8
$81, 7, Null
$100, 5, Null
$195, 3, 2


I have millions of rows so doing multiple queries and then looping through 
those would be not feasible.  But I am not sure how to even start to setup 
this query properly.

Model1.objects.all().order_by(???)

Any help would be appreciated.  Thanks!

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4e31e3ee-9bc9-4633-923c-6b9f9b836c37%40googlegroups.com.


Can we nix "group_expiry" from the Channel Layer Specification

2019-11-15 Thread Adam Hooper
Hi group,

I maintain the channels_rabbitmq 
 channel layer.

I and other users of channels_rabbitmq encountered a problem: day-old group 
memberships expire by default.

This isn't a bug in channels_rabbitmq: it's a bug in the specification. To 
my knowledge, *all* users of channels_rabbitmq consider group_expiry to be 
a bug.

(As far as I can tell, group_expiry is a wart that keeps channels_redis 
humming.)

Can we please omit group_expiry from the specification? That way I can 
remove this anti-feature from channels_rabbitmq while still adhering to the 
Channel Layer Specifiation. I filed 
https://github.com/django/channels/issues/1371 with this request, but 
nobody answered.

Enjoy life,
Adam

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d8c2fff8-35f5-4cfb-ad17-dbbdedd1a977%40googlegroups.com.


Re: Django Channels persistent DB connection

2019-11-15 Thread Adam Hooper
On Wednesday, October 30, 2019 at 12:17:54 PM UTC-4, BR wrote:
>
> I moved from a local sqlite3 DB file to a shared remote (local LAN) 
> MariaDB server and noticed a bit of a slow down. On top of the DB now being 
> remote, I'm also using SSL to encrypt the DB information. Based on the 
> description of *database_sync_to_async* it sounds like the connection is 
> closed/cleaned up on each call.
>
> Is there an option for a persistent DB connection in Channels?
>

Use Django's CONN_MAX_AGE 

.

Enjoy life,
Adam 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c729ae25-c944-48d0-9c78-5bc8e569796a%40googlegroups.com.


Re: Django Channels persistent DB connection

2019-11-15 Thread o1bigtenor
On Fri, Nov 15, 2019 at 12:53 PM Adam Hooper  wrote:
>
> On Wednesday, October 30, 2019 at 12:17:54 PM UTC-4, BR wrote:
>>
>> I moved from a local sqlite3 DB file to a shared remote (local LAN) MariaDB 
>> server and noticed a bit of a slow down. On top of the DB now being remote, 
>> I'm also using SSL to encrypt the DB information. Based on the description 
>> of database_sync_to_async it sounds like the connection is closed/cleaned up 
>> on each call.
>>
>> Is there an option for a persistent DB connection in Channels?
>
>
> Use Django's CONN_MAX_AGE.
>
Read the docs and am left with a question.
If I want a connection to the database but want it for only the time
the customer (query source) is logged in - - - how do I specify that?
 (So I don't want the connection to be timed - - - would rather the
connection was related to the online access and then closed when the
client (customer) logged off.)

TIA

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPpdf5-0M%2BP7Lxj941OX1_FZbWh68P3fgcaU%2BAxxc9Vjmqp_%3DA%40mail.gmail.com.


Problem django-allauth

2019-11-15 Thread Nemanja Marković
I want to install django-allauth however it throws me a code error:

Traceback (most recent call last):
  File "c:\program files\python37-32\lib\runpy.py", line 193, in
_run_module_as_main
"__main__", mod_spec)
  File "c:\program files\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
  File "C:\Program Files\Python37-32\Scripts\pip.exe\__main__.py", line 9,
in 
TypeError: 'module' object is not callable

My email is: markovicnemanj...@gmail.com
Please Help me :)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAiBpJ7zeYuAZQZVn%3DREj0_OtYQ48yd2JjR3c%2BVM9e03PL0UhQ%40mail.gmail.com.


Re: Django Channels persistent DB connection

2019-11-15 Thread Adam Hooper
On Friday, November 15, 2019 at 2:02:51 PM UTC-5, ajoeiam wrote:
>
> If I want a connection to the database but want it for only the time 
> the customer (query source) is logged in - - - how do I specify that? 
>  (So I don't want the connection to be timed - - - would rather the 
> connection was related to the online access and then closed when the 
> client (customer) logged off.) 
>

I don't think there's a way to do that.

If you're trying to use one DB connection per short-lived request, the way 
ordinary Django request handlers do when CONN_MAX_AGE is disabled, then 
simply bundle all your database queries into one synchronous function and 
decorate it with database_sync_to_async().

If you actually want to maintain *one database connection per websocket*, 
then don't use Channels. The whole point of Channels is to *not* consume a 
thread per websocket. A database connection is a thread (on the database 
server).

You won't find much help online if you're trying to tie up a database 
connection per Websocket. I found an exception: an academic project from 
some University of Alberta students. https://github.com/Kai-Bailey/WebSock. 
It's not Django.

Enjoy life,
Adam

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c1082698-3b73-4058-a809-fffb5daf6a2b%40googlegroups.com.


Re: Problem django-allauth

2019-11-15 Thread Kevin Dublin
Are you in your virtual environment? And installing with virtualenv or
pipenv vs just pip?

On Fri, Nov 15, 2019, 11:06 AM Nemanja Marković 
wrote:

> I want to install django-allauth however it throws me a code error:
>
> Traceback (most recent call last):
>   File "c:\program files\python37-32\lib\runpy.py", line 193, in
> _run_module_as_main
> "__main__", mod_spec)
>   File "c:\program files\python37-32\lib\runpy.py", line 85, in _run_code
> exec(code, run_globals)
>   File "C:\Program Files\Python37-32\Scripts\pip.exe\__main__.py", line 9,
> in 
> TypeError: 'module' object is not callable
>
> My email is: markovicnemanj...@gmail.com
> Please Help me :)
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAiBpJ7zeYuAZQZVn%3DREj0_OtYQ48yd2JjR3c%2BVM9e03PL0UhQ%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANips4JpSDRBC49H2KcczXAeyV7iO%3DgDnsDaQVx%2BhTNRM1XbAg%40mail.gmail.com.


Re: Conditional Order By

2019-11-15 Thread Simon Charette
Hello there,

You'll want to use Coalesce[0] for this purpose.

Model1.objects.order_by(Coalesce('effectual_rating', 'rating').desc())

Cheers,
Simon

[0] 
https://docs.djangoproject.com/en/2.2/ref/models/database-functions/#coalesce

Le vendredi 15 novembre 2019 13:32:46 UTC-5, Kev H a écrit :
>
> I have a model where a field can be null (and is most of the time).  
> However, I need to order_by this both this field and another field (the 2nd 
> field is never null) so that the results would be sorted by from high to 
> low (1st based on the possible null field if it is not null and then by the 
> 2nd field).
>
> Example:
>
> Model 1:
>   dollar_amount = Char()
>   rating = Int()
>   effectual_rating = Int(null=True, blank=True)
>
> Example Entries:
> $100, 5, Null
> $125, 4, 8
> $195, 3, 2
> $81, 7, Null
>
> So the end result of the query i would want it sorted like so from high to 
> low value:
> $125, 4, 8
> $81, 7, Null
> $100, 5, Null
> $195, 3, 2
>
>
> I have millions of rows so doing multiple queries and then looping through 
> those would be not feasible.  But I am not sure how to even start to setup 
> this query properly.
>
> Model1.objects.all().order_by(???)
>
> Any help would be appreciated.  Thanks!
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/96d77542-f58e-4059-9f7e-04128310de4a%40googlegroups.com.