Re: Arbitrary GROUP BY fields

2019-10-18 Thread thinkwell
Thanks for your reply James. I wasn't able to get it to work.

I posted on the new Django forum 

 
because it's easier to format code examples over there. Hopefully that 
clarifies things more...

-- 
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/9d55c47a-c2a9-481e-82b8-d4302f4bec86%40googlegroups.com.


Re: Problem with loaddata fixtures

2019-10-18 Thread Mike Dewhirst

On 19/10/2019 1:37 am, Seba Rossi wrote:
Hello there i was trying to migrate my database from SQLite to 
PostgreSQL following the docs steps but it seems that i encountered a 
problem wich i can't resolve.


I think dumpdata and loaddata  are for fixtures used in unit tests and 
not for migrating between databases.


You need to look at the SQLite docs and the PostgreSQL docs for dumping 
and reloading between them.


The nice thing is you can edit the SQL dump file before reloading in the 
other database if you need to be clever.


Mike



I have a base model called Producto wich has no dependencies.

I have another model called Preaprobado that has the following field:

|
    productos = models.ManyToManyField(Producto, related_name = 
"preaprobados", default = Producto.objects.get(CMS_id = 1))


|

The thing is that in order for the app to work i need one mandatory 
Product with CMS_id field = 1.


I managed to dumpdata from every model separatedly succesfully, then i 
changed the DB config in settings.py and was able to run the migrate 
command succesfully.


The problem is that when i try to loaddata InitialProducts.json the 
console returns an error displaying that the query

|
Producto.objects.get(CMS_id = 1)
|
has no value.

I tried disabling the signals as it says in the loaddata docs 
 but 
honestly i don't know where should i add the code disabling the 
signals since the error is raised when defining the models.py


Any help is more than welcomed.
--
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/d4f31a1d-ea19-48ef-a054-b2bcbe4f8b26%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/43031275-5ca7-556d-87bc-3673f2fca04c%40dewhirst.com.au.


Recorrer una tabla sqlite3 en una view Django

2019-10-18 Thread Gabriel Araya Garcia
¿Como puedo recorrer registro a registro una tabla e ir insertando dicha 
informacion en otra tabla segun criterio de lo que tenga en un campo de la 
primera tabla?

-- 
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/40adc444-46a4-4ad9-b3f5-f3cda65fae1d%40googlegroups.com.


Re: send_mail error

2019-10-18 Thread Bart Jonkers
You need to set
https://www.dev2qa.com/how-do-i-enable-less-secure-apps-on-gmail/

Bart

Op vr 18 okt. 2019 om 17:33 schreef James Gutu :

> What error are you getting? Look at the traceback, or even copy paste it
> here.
> Ensure you have set the EMAIL_HOST_USER, EMAIL_HOST_PASSWORD,
> EMAIL_HOST_PORT correctly in the settings.py file.
>
> On Thu, Oct 17, 2019 at 3:27 PM challa.Harikrishna chowdary <
> challahari0...@gmail.com> wrote:
>
>> Hi
>>
>>   i am sending the mail from front end to gmail account please help he
>>
>>
>>
>>
>> thanks and  regards
>> ch.Hari
>>
>> --
>> 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/f7cf2f08-86f8-4d53-9c31-1066a4bf1476%40googlegroups.com
>> 
>> .
>>
>
>
> --
>
> --
> Regards,
> James Gutu
>
> --
> 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/CAOnWGOLN%3Dcugc59Z1AfNOfi4p7_nueHfoq_NAbFXCXefA3vRuw%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/CAN_VHze1%3DXp5uxa14zLkOvi6SJ3dy20MVrxWUVfQcmUEZQjjAw%40mail.gmail.com.


Re: a variable is not defined

2019-10-18 Thread Joalbert Palacios
Not sure, but I believe that is because scope, given that result variable
is defined in the inner method and not defined in search function.

On Fri, Oct 18, 2019, 3:49 PM sotiris moustogiannis 
wrote:

> thanks for your help!!
>
> On Friday, October 18, 2019 at 6:59:05 AM UTC+3, jlgimeno71 wrote:
>>
>> I saw this that may be relevant:
>>
>>
>> https://stackoverflow.com/questions/7576202/how-can-i-pass-two-models-to-a-class-based-generic-view
>>
>> -Jorge
>>
>> On Thu, Oct 17, 2019 at 8:14 PM sotiris moustogiannis <
>> soto...@outlook.com> wrote:
>>
>>> I want to make custom function because i want to take one result from 2
>>> different models (inner join), and i dont find a way to use 2 models in my
>>> listview class (generic)
>>>
>>> On Friday, October 18, 2019 at 6:03:18 AM UTC+3, sotiris moustogiannis
>>> wrote:

 I read that you can't use the def get_queryset into a function but only
 in a generic class view, so maybe the def get_queryset function does not
 run. I want to  make my own custom function and i want to find a way to get
 self parameter in my function. Thanks a lot.

 On Friday, October 18, 2019 at 5:49:48 AM UTC+3, jlgimeno71 wrote:
>
> wd,
>
> The problem here is that when you're creating the context, the name
> 'result' is not defined. When the get_queryset() method returns, the 
> result
> name goes out of scope.  My guess that's why you're getting a NameError.
>
> If that's not it, I would suggest cutting and pasting the traceback
> and showing us the actual code (with line numbers if you have them). It
> will help us diagnose the problem.
>
> -Jorge
>
> On Thu, Oct 17, 2019 at 7:25 PM wd  wrote:
>
>> oh ,sorry my mistake. But I think the error is pretty clear ...
>>
>> On Fri, Oct 18, 2019 at 10:23 AM wd  wrote:
>>
>>> Dude, you need to indent at the line include 'context' ... it's a
>>> beginners  problem...
>>>
>>> On Fri, Oct 18, 2019 at 10:14 AM sotiris moustogiannis <
>>> soto...@outlook.com> wrote:
>>>
 I have an error: name 'result' is not defined



 def search(request):

 def get_queryset(self):
 query = self.request.GET.get('q')
 result = Shops.objects.filter(Q(city=query))

 return result

 context={
 'shops' : result,
 }

 return render(request, 'booking/search.html',context)





 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/543debc7-d517-4a7a-a9b8-f3fc7c7cc60d%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...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CABexzmhZtCXQRWB7S%3DL8S3B2rzmnbi3Raan1MFKW1asbSoShqg%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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/dcd65a19-628b-4ac9-9f60-d8d4b726d945%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/c602853d-b5c7-4105-b77c-95ed37ac67ea%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop 

Re: Channels 2 using asyncio run_in_executor

2019-10-18 Thread BR
>From your experience, can you provide a brief overview of the types of 
calls that would cause a deadlock?

Maybe that's what I was experiencing earlier, but after spending today on a 
work around, I can't replicate my original problem. Both sync_to_async and 
run_in_executor work just fine right now.

On Friday, October 18, 2019 at 2:37:25 PM UTC-4, Andrew Godwin wrote:
>
> It should be fine, but you will need to be careful - there's a lot of 
> side-effects with run_in_executor you should be aware of like the way 
> exceptions propagate (Django won't handle them right for you) and the 
> possibility of deadlock.
>
> Andrew
>
> On Fri, Oct 18, 2019 at 11:27 AM BR > 
> wrote:
>
>> Should I expect any issues using asyncio run_in_executor to run blocking 
>> code? I realize there is the sync_to_async function as well, but that 
>> wasn't working in my case. I'm using multiprocessing.Queue to share data 
>> with a new process, and when I try to use queue.get() with either 
>> sync_to_async or run_in_executor, the calling method hangs.
>>
>> My solution for now was to run a queue.get() listener in a separate 
>> thread, but it would have been nicer to use await with run_in_executor. Is 
>> there any custom configuration of the consumer event loop that prevents 
>> some times of functions from running, even when run with appropriate 
>> wrapping functions?
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3be88116-f199-483e-9ee9-73d3a292c81d%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/7d4ce7dc-2000-41e6-9de8-280769c92ddb%40googlegroups.com.


Re: a variable is not defined

2019-10-18 Thread sotiris moustogiannis
thanks for your help!!

On Friday, October 18, 2019 at 6:59:05 AM UTC+3, jlgimeno71 wrote:
>
> I saw this that may be relevant:
>
>
> https://stackoverflow.com/questions/7576202/how-can-i-pass-two-models-to-a-class-based-generic-view
>
> -Jorge
>
> On Thu, Oct 17, 2019 at 8:14 PM sotiris moustogiannis  > wrote:
>
>> I want to make custom function because i want to take one result from 2 
>> different models (inner join), and i dont find a way to use 2 models in my 
>> listview class (generic)
>>
>> On Friday, October 18, 2019 at 6:03:18 AM UTC+3, sotiris moustogiannis 
>> wrote:
>>>
>>> I read that you can't use the def get_queryset into a function but only 
>>> in a generic class view, so maybe the def get_queryset function does not 
>>> run. I want to  make my own custom function and i want to find a way to get 
>>> self parameter in my function. Thanks a lot.
>>>
>>> On Friday, October 18, 2019 at 5:49:48 AM UTC+3, jlgimeno71 wrote:

 wd,

 The problem here is that when you're creating the context, the name 
 'result' is not defined. When the get_queryset() method returns, the 
 result 
 name goes out of scope.  My guess that's why you're getting a NameError.

 If that's not it, I would suggest cutting and pasting the traceback and 
 showing us the actual code (with line numbers if you have them). It will 
 help us diagnose the problem.

 -Jorge

 On Thu, Oct 17, 2019 at 7:25 PM wd  wrote:

> oh ,sorry my mistake. But I think the error is pretty clear ...
>
> On Fri, Oct 18, 2019 at 10:23 AM wd  wrote:
>
>> Dude, you need to indent at the line include 'context' ... it's a 
>> beginners  problem...
>>
>> On Fri, Oct 18, 2019 at 10:14 AM sotiris moustogiannis <
>> soto...@outlook.com> wrote:
>>
>>> I have an error: name 'result' is not defined
>>>
>>>
>>>
>>> def search(request):
>>>
>>> def get_queryset(self):
>>> query = self.request.GET.get('q')
>>> result = Shops.objects.filter(Q(city=query))
>>>
>>> return result
>>>
>>> context={
>>> 'shops' : result,
>>> }
>>>
>>> return render(request, 'booking/search.html',context)
>>>
>>>
>>>
>>>
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/543debc7-d517-4a7a-a9b8-f3fc7c7cc60d%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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CABexzmhZtCXQRWB7S%3DL8S3B2rzmnbi3Raan1MFKW1asbSoShqg%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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/dcd65a19-628b-4ac9-9f60-d8d4b726d945%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/c602853d-b5c7-4105-b77c-95ed37ac67ea%40googlegroups.com.


Re: Channels 2 using asyncio run_in_executor

2019-10-18 Thread Andrew Godwin
It should be fine, but you will need to be careful - there's a lot of
side-effects with run_in_executor you should be aware of like the way
exceptions propagate (Django won't handle them right for you) and the
possibility of deadlock.

Andrew

On Fri, Oct 18, 2019 at 11:27 AM BR  wrote:

> Should I expect any issues using asyncio run_in_executor to run blocking
> code? I realize there is the sync_to_async function as well, but that
> wasn't working in my case. I'm using multiprocessing.Queue to share data
> with a new process, and when I try to use queue.get() with either
> sync_to_async or run_in_executor, the calling method hangs.
>
> My solution for now was to run a queue.get() listener in a separate
> thread, but it would have been nicer to use await with run_in_executor. Is
> there any custom configuration of the consumer event loop that prevents
> some times of functions from running, even when run with appropriate
> wrapping functions?
>
> --
> 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/3be88116-f199-483e-9ee9-73d3a292c81d%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/CAFwN1uo%2BC9wS-%2BjEpz9OaUXcS7hO2SauxA9evUUuTiraOS69ww%40mail.gmail.com.


Channels 2 using asyncio run_in_executor

2019-10-18 Thread BR
Should I expect any issues using asyncio run_in_executor to run blocking 
code? I realize there is the sync_to_async function as well, but that 
wasn't working in my case. I'm using multiprocessing.Queue to share data 
with a new process, and when I try to use queue.get() with either 
sync_to_async or run_in_executor, the calling method hangs.

My solution for now was to run a queue.get() listener in a separate thread, 
but it would have been nicer to use await with run_in_executor. Is there 
any custom configuration of the consumer event loop that prevents some 
times of functions from running, even when run with appropriate wrapping 
functions?

-- 
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/3be88116-f199-483e-9ee9-73d3a292c81d%40googlegroups.com.


Problem with loaddata fixtures

2019-10-18 Thread Seba Rossi
Hello there i was trying to migrate my database from SQLite to PostgreSQL 
following the docs steps but it seems that i encountered a problem wich i 
can't resolve.

I have a base model called Producto wich has no dependencies.

I have another model called Preaprobado that has the following field:

productos = models.ManyToManyField(Producto, related_name = 
"preaprobados", default = Producto.objects.get(CMS_id = 1))


The thing is that in order for the app to work i need one mandatory Product 
with CMS_id field = 1.

I managed to dumpdata from every model separatedly succesfully, then i 
changed the DB config in settings.py and was able to run the migrate 
command succesfully.

The problem is that when i try to loaddata InitialProducts.json the console 
returns an error displaying that the query 
Producto.objects.get(CMS_id = 1)
has no value.

I tried disabling the signals as it says in the loaddata docs 
 but 
honestly i don't know where should i add the code disabling the signals 
since the error is raised when defining the models.py

Any help is more than welcomed.

-- 
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/d4f31a1d-ea19-48ef-a054-b2bcbe4f8b26%40googlegroups.com.


Re: Implementing multiple choice selection

2019-10-18 Thread James Gutu
Check this out here

.
It shows the solution at the form level.

On Fri, Oct 18, 2019 at 3:59 PM briodev  wrote:

> Halo guys, in the below snapshot, both Campus and Faculty classes have
> tuple of choices in the model.py file. I'd want a user to get available
> faculties depending on the choice selected on the campus, but I don't know
> how to implement this in the code. Help kindly.
>
> --
> 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/0630f042-9fa8-4237-a293-d0adcffbe83b%40googlegroups.com
> 
> .
>


-- 

-- 
Regards,
James Gutu

-- 
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/CAOnWGOKvbYF4oqjbLo9ArnpWfdKZYBA_B%3DBtaQkxzA15oYv4qQ%40mail.gmail.com.


Re: send_mail error

2019-10-18 Thread James Gutu
What error are you getting? Look at the traceback, or even copy paste it
here.
Ensure you have set the EMAIL_HOST_USER, EMAIL_HOST_PASSWORD,
EMAIL_HOST_PORT correctly in the settings.py file.

On Thu, Oct 17, 2019 at 3:27 PM challa.Harikrishna chowdary <
challahari0...@gmail.com> wrote:

> Hi
>
>   i am sending the mail from front end to gmail account please help he
>
>
>
>
> thanks and  regards
> ch.Hari
>
> --
> 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/f7cf2f08-86f8-4d53-9c31-1066a4bf1476%40googlegroups.com
> 
> .
>


-- 

-- 
Regards,
James Gutu

-- 
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/CAOnWGOLN%3Dcugc59Z1AfNOfi4p7_nueHfoq_NAbFXCXefA3vRuw%40mail.gmail.com.


Re: Arbitrary GROUP BY fields

2019-10-18 Thread James Gutu
I am thinking along the lines of this:

page_titles =
PageTitles.object.select_related('category','rating').values('id',
'category_id', 'rating_id').order_by('date','id').annotate(
allow=Sum('allow'),
block=Sum('block'),
hits=Sum('hits'))

To get it right, you may have to share your models. Hope this helps. Let me
know how it goes.

On Fri, Oct 18, 2019 at 12:00 AM thinkwell 
wrote:

> I'm using pg-partitioning
>  to partition tables
> on Django 2.2 & Postgres 11. It's working great as far as that goes, except
> that I bumped hard into annotated queries. Since PG can't guarantee PK
> uniqueness across partitioned tables, it requires including all fields in
> the GROUP BY that will in the output.
>
> Django generates this query:
>
> SELECT
>
>   "page_titles"."id",
>
>   "page_titles"."date",
>
>   "page_titles"."name",
>
>   "page_titles"."title",
>
>   SUM("page_titles"."allow") AS "allow",
>
>   SUM("page_titles"."block") AS "block",
>
>   SUM("page_titles"."hit_count") AS "hits",
>
>   "categories_category"."name" AS "category_name",
>
>   "categories_rating"."name" AS "rating_name"
>
> FROM
>
>   "page_titles"
>
>   LEFT OUTER JOIN "categories_category" ON ("page_titles"."category_id" =
> "categories_category"."id")
>
>   LEFT OUTER JOIN "categories_rating" ON ("page_titles"."rating_id" =
> "categories_rating"."id")
>
> GROUP BY
>
>   "page_titles"."id",
>
>   "categories_category"."name",
>
>   "categories_rating"."name"
>
> ORDER BY
>
>   "page_titles"."date" DESC,
>
>   "page_titles"."id" DESC;
>
> That query raises an error:
>
> ERROR:  column "page_titles.date" must appear in the GROUP BY clause or
> be used in an aggregate function
>
> LINE 3: "page_titles"."date",
>
> ^
>
> So if we add all the (non-summed) fields in the GROUP BY that the query
> will return, as the query below, then the query runs successfully.
>
>
> SELECT
>
>   "page_titles"."id",
>
>   "page_titles"."date",
>
>   "page_titles"."name",
>
>   SUM("page_titles"."allow") AS "allow",
>
>   SUM("page_titles"."block") AS "block",
>
>   SUM("page_titles"."hit_count") AS "hits",
>
>   "categories_category"."name" AS "category_name",
>
>   "categories_rating"."name" AS "rating_name"
>
> FROM
>
>   "page_titles"
>
>   LEFT OUTER JOIN "categories_category" ON ("page_titles"."category_id" =
> "categories_category"."id")
>
>   LEFT OUTER JOIN "categories_rating" ON ("page_titles"."rating_id" =
> "categories_rating"."id")
>
> GROUP BY
>
>   "page_titles"."id",
>
>   "page_titles"."date",
>
>   "page_titles"."name",
>   "page_titles"."title",
>   "categories_category"."name",
>
>   "categories_rating"."name"
>
> ORDER BY
>
>   "page_titles"."date" DESC,
>
>   "page_titles"."id" DESC;
>
>
> I really can't be using raw SQL for these queries because of dynamic WHERE
> clauses. Is there a way to use / extend the ORM to add arbitrary GROUP BY
> fields?
>
> Or any other suggestion about how to use the ORM to generate queries on
> partitioned tables where Postgres doesn't have a global index...?
>
> 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/414d3e70-418c-41e9-becb-65209ed0b7eb%40googlegroups.com
> 
> .
>


-- 

-- 
Regards,
James Gutu

-- 
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/CAOnWGOJD%2B-Mb8PwPgYwyY8odkfU%2B%2BW1CPXZiEBNTk-nQj%3Dgtew%40mail.gmail.com.


Re: Creating an app that generates static files

2019-10-18 Thread Jack Sundberg
Thank you both! This helps a ton.


On Friday, October 18, 2019 at 5:02:40 AM UTC-4, vineet daniel wrote:
>
> and use ssd for maximum I/O as youd creating and deleting files a lot, 
> move session from db to something like redis and python has concurrency 
> libraries make use of them as well.
>
> On Fri, 18 Oct 2019, 14:29 vineet daniel,  > wrote:
>
>> Dont forget inode and files limit if you are creating too many files real 
>> quickly. 
>>
>> On Fri, 18 Oct 2019, 13:15 James Gutu, > 
>> wrote:
>>
>>> Jack,
>>> That sounds about right.
>>>
>>> On Thu, Oct 17, 2019 at 11:22 PM Jack Sundberg >> > wrote:
>>>
 Thank you, James! This seems like a good fix. From reading through the 
 documentation (here 
 ), this 
 is how I understand the workflow -- so correct me if I'm wrong please!

  > First, I can activate Django sessions by 
 adding 'django.contrib.sessions' to my installed apps. 
  > Django by-default stores session info in the SQLite database -- 
 therefore, each session entry will have an ID assigned to it 
 automatically. 
  > I can use each session_id to create a temporary folder in some 
 directory (say /tmp) where the generated files can be made. So folder 
 structure will look like:
 tmp/
 [session_id1]/ 
 file1.tlgf
 file2.bin
 [session_id2]/ 
 file1.tlgf
 file2.bin
 
  > when sessions data hits a certain threshold, I can call 
 django.contrib.sessions.clearsessions which will delete expired session 
 entries in the database
  > pull out which entries were deleted and then delete the 
 corresponding tmp/[session_id] directory 

 Is that the best way to do it?

 -Jack


 On Thursday, October 17, 2019 at 4:42:04 PM UTC-4, James Gutu wrote:
>
> Jack,
>
> From what I understand it looks like a conflict of uniquely named 
> files when they are generated simultaneously.
> Could you resolve this by creating a folder named from the session_id, 
> with the file inside of that. So that if two users request the same file, 
> there will never be a conflict, as the unique file will be created in 
> both 
> folders.
>
> [user_1_session_id]/entry123.jpeg
> [user_2_session_id]/entry123.jpeg
>
> Though, this might seem like a fix, but the issue may be more 
> fundamental than file names.
> Let me know what you think.
>
> Regards,
> James
>
> On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg  
> wrote:
>
>> Yes, I tried getting the idea across in layman terms, as I hope this 
>> helps discussion of the issue -- and then I can later translate the 
>> solution into django implementation. 
>>
>> I avoided the full process in my original post for clarity. I used 
>> the *.jpeg file as an illustrative example, when I'm actually generating 
>> *.gltf and *.bin files. These files are typically a couple hundred KB in 
>> size, but I will have thousands of them (millions as I add to my 
>> database). 
>> These files are used in coordination with Verge3D  - an app built on top 
>> of 
>> Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which 
>> is 
>> a python-based program that my scripts are written in. Running of these 
>> scripts are certainly cpu intensive; however I am going to get around 
>> this 
>> by using an  of this Verge3D request.
>>
>> So to be more specific, my app does the following:
>>  - the url mapping pulls a database entry
>>  - the app serves the proper html template with an  embedded 
>> in it. It displays a loading screen while the 3D model is created 
>> backend.
>>  - the  calls a separate app using the identical data entry
>>  - using the data entry, static files are created from the data 
>> (Blender script creates a *.gltf and *.bin)
>>  - the app serves the html template with the generated static files 
>> embedded inside the 
>>
>> Is this helpful? Also thank you for the quick response. I really 
>> appreciate the help.
>>
>> -Jack
>>
>>
>> On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel 
>> wrote:
>>>
>>> This problem can happen with any stack and shouldn't be considered 
>>> as django specific. What you are looking for is a solution in a layman 
>>> terms.which then can be translated to django implementation.
>>>
>>> Before that i would like to know image size and kind of image that 
>>> you create. Is it some qr code or what?
>>>
>>> Please note that working with images on the fly is always a cpu 
>>> intensive operation. Ill can come up 

Re: Django URL not working on my windows 10

2019-10-18 Thread kishor kumar Bharti
use following code  in project urls.py

from django.contrib import admin
from django.conf.urls import url,include
from second_app import views

urlpatterns = [
url(r'^$',views.index, name='index'),
url(r'^second_app/',include('second_app.urls')),
url(r'^admin/', admin.site.urls),
]


and use following code in urls.py in app
from django.contrib import admin
from second_app import views
from django.conf.urls import url,include

urlpatterns = [
url(r'^$',views.index,name='index'),
]

On Thu, Oct 17, 2019 at 8:23 PM Muhamed Bešić 
wrote:

> wtf i have done wrong, i'm getting bored, URL mapping not working anyway,
> anyone please, review the files and give a solution
>
> --
> 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/478ca311-9b23-4a36-a6e2-018aef44d99d%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/CAMe8XT3qoiuxD6DHe2x_-CeS5JFEG-%3D4NcMg1EGTCpsriJgt%2Bw%40mail.gmail.com.


Django-jwt use cookie instead of Authorization header

2019-10-18 Thread Suraj Thapa FC
Django-jwt use cookie instead of Authorization header
I want to build the SPA application using Django Rest Framework as a
back-end. The application will use JsonWebToken authentication.

For maximum security, I want to store the authentication token inside of
httpOnly cookie, so it will not be accessible from javascript. However,
because the cookie is not accessible from the javascript, I am not able to
set the 'Authorization: JWT ...' header.

So, my question is, can I make the DRF system to read the authentication
token from the cookie instead of reading it from the "Authorization"
header? Or the "Authorization" header is the only and correct way to
authenticate in DRF?

-- 
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/CAPjsHcEnosf-N3aUTRcz%3DhZuZHDUEKvdepQFZVOYugAOH%2BZ-0A%40mail.gmail.com.


Re: Creating an app that generates static files

2019-10-18 Thread vineet daniel
and use ssd for maximum I/O as youd creating and deleting files a lot, move
session from db to something like redis and python has concurrency
libraries make use of them as well.

On Fri, 18 Oct 2019, 14:29 vineet daniel,  wrote:

> Dont forget inode and files limit if you are creating too many files real
> quickly.
>
> On Fri, 18 Oct 2019, 13:15 James Gutu,  wrote:
>
>> Jack,
>> That sounds about right.
>>
>> On Thu, Oct 17, 2019 at 11:22 PM Jack Sundberg 
>> wrote:
>>
>>> Thank you, James! This seems like a good fix. From reading through the
>>> documentation (here
>>> ), this is
>>> how I understand the workflow -- so correct me if I'm wrong please!
>>>
>>>  > First, I can activate Django sessions by
>>> adding 'django.contrib.sessions' to my installed apps.
>>>  > Django by-default stores session info in the SQLite database --
>>> therefore, each session entry will have an ID assigned to it automatically.
>>>  > I can use each session_id to create a temporary folder in some
>>> directory (say /tmp) where the generated files can be made. So folder
>>> structure will look like:
>>> tmp/
>>> [session_id1]/
>>> file1.tlgf
>>> file2.bin
>>> [session_id2]/
>>> file1.tlgf
>>> file2.bin
>>> 
>>>  > when sessions data hits a certain threshold, I can call
>>> django.contrib.sessions.clearsessions which will delete expired session
>>> entries in the database
>>>  > pull out which entries were deleted and then delete the corresponding
>>> tmp/[session_id] directory
>>>
>>> Is that the best way to do it?
>>>
>>> -Jack
>>>
>>>
>>> On Thursday, October 17, 2019 at 4:42:04 PM UTC-4, James Gutu wrote:

 Jack,

 From what I understand it looks like a conflict of uniquely named files
 when they are generated simultaneously.
 Could you resolve this by creating a folder named from the session_id,
 with the file inside of that. So that if two users request the same file,
 there will never be a conflict, as the unique file will be created in both
 folders.

 [user_1_session_id]/entry123.jpeg
 [user_2_session_id]/entry123.jpeg

 Though, this might seem like a fix, but the issue may be more
 fundamental than file names.
 Let me know what you think.

 Regards,
 James

 On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg 
 wrote:

> Yes, I tried getting the idea across in layman terms, as I hope this
> helps discussion of the issue -- and then I can later translate the
> solution into django implementation.
>
> I avoided the full process in my original post for clarity. I used the
> *.jpeg file as an illustrative example, when I'm actually generating 
> *.gltf
> and *.bin files. These files are typically a couple hundred KB in size, 
> but
> I will have thousands of them (millions as I add to my database). These
> files are used in coordination with Verge3D  - an app built on top of
> Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which is
> a python-based program that my scripts are written in. Running of these
> scripts are certainly cpu intensive; however I am going to get around this
> by using an  of this Verge3D request.
>
> So to be more specific, my app does the following:
>  - the url mapping pulls a database entry
>  - the app serves the proper html template with an  embedded
> in it. It displays a loading screen while the 3D model is created backend.
>  - the  calls a separate app using the identical data entry
>  - using the data entry, static files are created from the data
> (Blender script creates a *.gltf and *.bin)
>  - the app serves the html template with the generated static files
> embedded inside the 
>
> Is this helpful? Also thank you for the quick response. I really
> appreciate the help.
>
> -Jack
>
>
> On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel
> wrote:
>>
>> This problem can happen with any stack and shouldn't be considered as
>> django specific. What you are looking for is a solution in a layman
>> terms.which then can be translated to django implementation.
>>
>> Before that i would like to know image size and kind of image that
>> you create. Is it some qr code or what?
>>
>> Please note that working with images on the fly is always a cpu
>> intensive operation. Ill can come up with something once you share the
>> details with me.
>>
>> On Thu, 17 Oct 2019, 20:00 Jack Sundberg, 
>> wrote:
>>
>>> Hi all,
>>>
>>> I am currently writing an app that generates static files before
>>> serving them, and I could use some input! Here's a step-by-step example 
>>> of

Re: Creating an app that generates static files

2019-10-18 Thread vineet daniel
Dont forget inode and files limit if you are creating too many files real
quickly.

On Fri, 18 Oct 2019, 13:15 James Gutu,  wrote:

> Jack,
> That sounds about right.
>
> On Thu, Oct 17, 2019 at 11:22 PM Jack Sundberg 
> wrote:
>
>> Thank you, James! This seems like a good fix. From reading through the
>> documentation (here
>> ), this is
>> how I understand the workflow -- so correct me if I'm wrong please!
>>
>>  > First, I can activate Django sessions by
>> adding 'django.contrib.sessions' to my installed apps.
>>  > Django by-default stores session info in the SQLite database --
>> therefore, each session entry will have an ID assigned to it automatically.
>>  > I can use each session_id to create a temporary folder in some
>> directory (say /tmp) where the generated files can be made. So folder
>> structure will look like:
>> tmp/
>> [session_id1]/
>> file1.tlgf
>> file2.bin
>> [session_id2]/
>> file1.tlgf
>> file2.bin
>> 
>>  > when sessions data hits a certain threshold, I can call
>> django.contrib.sessions.clearsessions which will delete expired session
>> entries in the database
>>  > pull out which entries were deleted and then delete the corresponding
>> tmp/[session_id] directory
>>
>> Is that the best way to do it?
>>
>> -Jack
>>
>>
>> On Thursday, October 17, 2019 at 4:42:04 PM UTC-4, James Gutu wrote:
>>>
>>> Jack,
>>>
>>> From what I understand it looks like a conflict of uniquely named files
>>> when they are generated simultaneously.
>>> Could you resolve this by creating a folder named from the session_id,
>>> with the file inside of that. So that if two users request the same file,
>>> there will never be a conflict, as the unique file will be created in both
>>> folders.
>>>
>>> [user_1_session_id]/entry123.jpeg
>>> [user_2_session_id]/entry123.jpeg
>>>
>>> Though, this might seem like a fix, but the issue may be more
>>> fundamental than file names.
>>> Let me know what you think.
>>>
>>> Regards,
>>> James
>>>
>>> On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg 
>>> wrote:
>>>
 Yes, I tried getting the idea across in layman terms, as I hope this
 helps discussion of the issue -- and then I can later translate the
 solution into django implementation.

 I avoided the full process in my original post for clarity. I used the
 *.jpeg file as an illustrative example, when I'm actually generating *.gltf
 and *.bin files. These files are typically a couple hundred KB in size, but
 I will have thousands of them (millions as I add to my database). These
 files are used in coordination with Verge3D  - an app built on top of
 Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which is
 a python-based program that my scripts are written in. Running of these
 scripts are certainly cpu intensive; however I am going to get around this
 by using an  of this Verge3D request.

 So to be more specific, my app does the following:
  - the url mapping pulls a database entry
  - the app serves the proper html template with an  embedded in
 it. It displays a loading screen while the 3D model is created backend.
  - the  calls a separate app using the identical data entry
  - using the data entry, static files are created from the data
 (Blender script creates a *.gltf and *.bin)
  - the app serves the html template with the generated static files
 embedded inside the 

 Is this helpful? Also thank you for the quick response. I really
 appreciate the help.

 -Jack


 On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel wrote:
>
> This problem can happen with any stack and shouldn't be considered as
> django specific. What you are looking for is a solution in a layman
> terms.which then can be translated to django implementation.
>
> Before that i would like to know image size and kind of image that you
> create. Is it some qr code or what?
>
> Please note that working with images on the fly is always a cpu
> intensive operation. Ill can come up with something once you share the
> details with me.
>
> On Thu, 17 Oct 2019, 20:00 Jack Sundberg, 
> wrote:
>
>> Hi all,
>>
>> I am currently writing an app that generates static files before
>> serving them, and I could use some input! Here's a step-by-step example 
>> of
>> how the app is setup:
>>
>>  - the url mapping pulls a database entry
>>  - using the data entry, static files are created from the data (for
>> example, a *.jpeg or a *.gltf)
>>  - the app serves the html template with the generated static files
>> embedded (for example, via an  tag)
>>
>> The issue comes with the creation of the 

Django cookie in rest api

2019-10-18 Thread Suraj Thapa FC
After reading the cookies.. How do i set them in headers...

-- 
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/CAPjsHcFjhJB-kuYD0tjJF2HO%3Dz20_sXFWaFALUxYDg1%3DewaJ1A%40mail.gmail.com.


Re: Creating an app that generates static files

2019-10-18 Thread James Gutu
Jack,
That sounds about right.

On Thu, Oct 17, 2019 at 11:22 PM Jack Sundberg 
wrote:

> Thank you, James! This seems like a good fix. From reading through the
> documentation (here
> ), this is
> how I understand the workflow -- so correct me if I'm wrong please!
>
>  > First, I can activate Django sessions by
> adding 'django.contrib.sessions' to my installed apps.
>  > Django by-default stores session info in the SQLite database --
> therefore, each session entry will have an ID assigned to it automatically.
>  > I can use each session_id to create a temporary folder in some
> directory (say /tmp) where the generated files can be made. So folder
> structure will look like:
> tmp/
> [session_id1]/
> file1.tlgf
> file2.bin
> [session_id2]/
> file1.tlgf
> file2.bin
> 
>  > when sessions data hits a certain threshold, I can call
> django.contrib.sessions.clearsessions which will delete expired session
> entries in the database
>  > pull out which entries were deleted and then delete the corresponding
> tmp/[session_id] directory
>
> Is that the best way to do it?
>
> -Jack
>
>
> On Thursday, October 17, 2019 at 4:42:04 PM UTC-4, James Gutu wrote:
>>
>> Jack,
>>
>> From what I understand it looks like a conflict of uniquely named files
>> when they are generated simultaneously.
>> Could you resolve this by creating a folder named from the session_id,
>> with the file inside of that. So that if two users request the same file,
>> there will never be a conflict, as the unique file will be created in both
>> folders.
>>
>> [user_1_session_id]/entry123.jpeg
>> [user_2_session_id]/entry123.jpeg
>>
>> Though, this might seem like a fix, but the issue may be more fundamental
>> than file names.
>> Let me know what you think.
>>
>> Regards,
>> James
>>
>> On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg 
>> wrote:
>>
>>> Yes, I tried getting the idea across in layman terms, as I hope this
>>> helps discussion of the issue -- and then I can later translate the
>>> solution into django implementation.
>>>
>>> I avoided the full process in my original post for clarity. I used the
>>> *.jpeg file as an illustrative example, when I'm actually generating *.gltf
>>> and *.bin files. These files are typically a couple hundred KB in size, but
>>> I will have thousands of them (millions as I add to my database). These
>>> files are used in coordination with Verge3D  - an app built on top of
>>> Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which is
>>> a python-based program that my scripts are written in. Running of these
>>> scripts are certainly cpu intensive; however I am going to get around this
>>> by using an  of this Verge3D request.
>>>
>>> So to be more specific, my app does the following:
>>>  - the url mapping pulls a database entry
>>>  - the app serves the proper html template with an  embedded in
>>> it. It displays a loading screen while the 3D model is created backend.
>>>  - the  calls a separate app using the identical data entry
>>>  - using the data entry, static files are created from the data (Blender
>>> script creates a *.gltf and *.bin)
>>>  - the app serves the html template with the generated static files
>>> embedded inside the 
>>>
>>> Is this helpful? Also thank you for the quick response. I really
>>> appreciate the help.
>>>
>>> -Jack
>>>
>>>
>>> On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel wrote:

 This problem can happen with any stack and shouldn't be considered as
 django specific. What you are looking for is a solution in a layman
 terms.which then can be translated to django implementation.

 Before that i would like to know image size and kind of image that you
 create. Is it some qr code or what?

 Please note that working with images on the fly is always a cpu
 intensive operation. Ill can come up with something once you share the
 details with me.

 On Thu, 17 Oct 2019, 20:00 Jack Sundberg,  wrote:

> Hi all,
>
> I am currently writing an app that generates static files before
> serving them, and I could use some input! Here's a step-by-step example of
> how the app is setup:
>
>  - the url mapping pulls a database entry
>  - using the data entry, static files are created from the data (for
> example, a *.jpeg or a *.gltf)
>  - the app serves the html template with the generated static files
> embedded (for example, via an  tag)
>
> The issue comes with the creation of the unique static files. I can
> have the app create a file in the static folder, send it off, then delete
> the file to ready for the next request -- but the webpage will run into
> issues if multiple requests are made at the same time. If two people
>