bulk_update() causes Select N+1 issue

2023-01-13 Thread Nick Chang
Hi all,

I read django doc on 'bulk_update() 
'  
It said that generally it creates one single query to do so, but in a 
project I have has 'a_model.objects.bulk_update(update_list, 
fields=updated_keys), it actually generates N number of SELECT statements 
where N is the size of 'update_list'  This is being flagged as Select N+1 
bug.

Why did bulk_update() not generate a single query as it advertises? How 
would I fix this Select N+1 issue to increase the performance?

Kind Regards,

Nick

-- 
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/dc688786-e8db-4071-b1d3-13b2a17436bbn%40googlegroups.com.


Re: ChannelsLiveServerTestCase: not posting messages

2023-01-13 Thread shahil joshi
hi, when I am running the test it takes the main DB for storing the inner 
operations data why it's not storing to test DB? can you help me with this?

On Thursday, January 5, 2023 at 11:42:06 PM UTC+5:30 elm.r...@gmail.com 
wrote:

> I've by now realized this issue is related specifically to Selenium and 
> not Django
> On Thursday, January 5, 2023 at 8:07:29 PM UTC+2 Rihhard wrote:
>
>> Hey everyone
>>  
>> I followed the channels tutorial here 
>>  verbatim, however, 
>> ran into weird behavior with the test on the last page of the tutorial 
>> where the tesst for some reason do not actually post/send the messages and 
>> thus fail.
>>
>> If I click on send in the chrome window myself while the test is running, 
>> it passes fine.
>>
>> Any ideas what might be the culprit ? Testing code is here 
>>  at Part 
>> 4.
>>
>> Cheers!
>> R
>
>

-- 
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/b029f49f-7a5c-41b6-90f9-19d841ea2958n%40googlegroups.com.


Re: Unit test is written but coverage report says there are missing statements

2023-01-13 Thread shahil joshi
when i am running the test its storing the inner functional data to main db 
not test db why ?

On Monday, January 9, 2023 at 2:32:20 PM UTC+5:30 sencer...@gmail.com wrote:

> Hi,
>
> I try to get coverage reports using a simple django model.
> Unit test for model was written but report says there are missing 
> statements.
>
> *The model:*
>
> from django.db import models
> from model_utils import FieldTracker
>
> from generics.base_model import BaseModelMixin
>
> class AModel(BaseModelMixin):
> record_name = models.CharField(max_length=255)
> tracker = FieldTracker()
>
> class Meta(BaseModelMixin.Meta):
> db_table = 'a_model_records'
>
> def __str__(self):
> record_name = self.record_name
> if record_name is None:
> record_name = "N/A"
> return record_name
>
>
> *The unit test:*
>
> class TestAModel(TestCase):
>
> def setUp(self):
> super().setUp()
>
> def test_allowed_domain_model(self):
> record_name = "some name"
> is_active = True
>
> user = User.objects.first()
> record = AModel.objects.create(
>
> record_name=record_name,
> is_active=is_active,
> created_by_id=user.id,
> )
>
> self.assertEqual(str(record), record_name)
> self.assertEqual(record.name, record_name)
> self.assertEqual(record.is_active, is_active)
>
>
> *The command line code I run:*
>
> source activate
> set -a
> source local.env
> set +a
> coverage run --source="unit_test_app" --rcfile=.coveragerc 
> project/manage.py test -v 2
> coverage report
> coverage html
>
> *The coverage configuration is like this:*
>
> [run]
> omit=
> */migrations/*
> */tests/*
> */manage.py
> */apps.py
> */settings.py
> */urls.py
> */filters.py
> */serializers.py
> */generics/*
>
> [report]
> show_missing = true
>
>
> *Coverage result shows 1 missing:*
>
> [image: image.png]
>
> This is the simplest example.
> There are many ignored functions by coverage which descends percentage 
> average, but actually covered by unit tests.
> Why does coverage act like this?
>
> Kind regards,
> Sencer HAMARAT
>
>

-- 
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/89acdec2-b889-47a8-b146-8179db80d8a4n%40googlegroups.com.


Re: How to pass "--runworker --asgi" to wsgi.py

2023-01-13 Thread Bala Subramanyam Vemu
Thank you  Andréas !

Regards
Bala

On Friday, January 13, 2023 at 3:58:12 PM UTC+5:30 andrea...@hypercode.se 
wrote:

> The simple answer is - you can't.
>
> Django can run in 2 separate ways: Synchronous - via a WSGI server - or 
> asynchronous via an ASGI server. Websocket requests run via ASGI - so you 
> need an ASGI server. You can read the official documentation and see your 
> alternatives here:
> https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
>
> Regards,
>
> Andréas
>
>
> Den ons 11 jan. 2023 kl 19:41 skrev Bala Subramanyam Vemu <
> balasubram...@gmail.com>:
>
>> Hi
>>
>> I am currently using django channels and have deployed them as well 
>>
>> However , we currently want to separate the runworker from runserver 
>>
>> As mentioned in the channels we have to run "python manage.py runserver 
>> ---noworker"
>>
>> so that all the websocket requests can be handled separately 
>>
>> how do we pass the arguments  "--runworker" to the wsgi.py, btw we are 
>> deploying using uwsgi process
>>
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/47bb9c0f-e1fd-4c00-a33a-2d9cd85e9706n%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/c7089d29-df29-4814-adaf-49c467f0e115n%40googlegroups.com.


Re: Serving Media and Static files on Shared Hosting

2023-01-13 Thread Namanya Daniel
Have you done it before? You can share knowledge

On Fri, 13 Jan 2023 at 15:25, Jeff Kingsley 
wrote:

> Why
>
> On Fri, Jan 13, 2023 at 11:56 AM Namanya Daniel 
> wrote:
>
>> Hello members,
>>
>> Has anyone ever used Namecheap shared hosting to serve static and media
>> files? Apparently nginx can't be used, i only have WhiteNoise which serves
>> static files only.
>>
>> kindly  share you've done it before.. thanks in advance
>>
>> --
>> 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/44a6e29d-65f1-443f-94d4-c9d119abbf77n%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/CAA9WjmFd%3DC-eOv%3DeKw5%3DKg7JMCPLiFs%3DwNv0zU07_vDMw59woQ%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/CAP4VW2V%2BWjeyakDn%2BSrpywpJ7BnQi5WwWVwfHQ32_dyEsM9qhA%40mail.gmail.com.


Re: Serving Media and Static files on Shared Hosting

2023-01-13 Thread Jeff Kingsley
Why

On Fri, Jan 13, 2023 at 11:56 AM Namanya Daniel 
wrote:

> Hello members,
>
> Has anyone ever used Namecheap shared hosting to serve static and media
> files? Apparently nginx can't be used, i only have WhiteNoise which serves
> static files only.
>
> kindly  share you've done it before.. thanks in advance
>
> --
> 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/44a6e29d-65f1-443f-94d4-c9d119abbf77n%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/CAA9WjmFd%3DC-eOv%3DeKw5%3DKg7JMCPLiFs%3DwNv0zU07_vDMw59woQ%40mail.gmail.com.


Re: How to pass "--runworker --asgi" to wsgi.py

2023-01-13 Thread Andréas Kühne
The simple answer is - you can't.

Django can run in 2 separate ways: Synchronous - via a WSGI server - or
asynchronous via an ASGI server. Websocket requests run via ASGI - so you
need an ASGI server. You can read the official documentation and see your
alternatives here:
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/

Regards,

Andréas


Den ons 11 jan. 2023 kl 19:41 skrev Bala Subramanyam Vemu <
balasubramanyam.v...@gmail.com>:

> Hi
>
> I am currently using django channels and have deployed them as well
>
> However , we currently want to separate the runworker from runserver
>
> As mentioned in the channels we have to run "python manage.py runserver
> ---noworker"
>
> so that all the websocket requests can be handled separately
>
> how do we pass the arguments  "--runworker" to the wsgi.py, btw we are
> deploying using uwsgi process
>
> 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/47bb9c0f-e1fd-4c00-a33a-2d9cd85e9706n%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/CAK4qSCfT4%2BBC0wvsxLdk6DpR4%3DSq4d3jA4uwbaaJniN%3DODZshw%40mail.gmail.com.


Serving Media and Static files on Shared Hosting

2023-01-13 Thread Namanya Daniel
Hello members, 

Has anyone ever used Namecheap shared hosting to serve static and media 
files? Apparently nginx can't be used, i only have WhiteNoise which serves 
static files only.

kindly  share you've done it before.. thanks in advance

-- 
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/44a6e29d-65f1-443f-94d4-c9d119abbf77n%40googlegroups.com.