Increasing iteration count for the PBKDF2 password hasher

2024-05-23 Thread Shaheed Haque
Hi, As happens from time-to-time, I see the 5.1 alpha recently announced has increased the iteration count for the PBKDF2 password hasher (from 720k to 870k), and the putative release notes for 5.2 mention a further increase (to 1M). I assume this iteration count has something to do with the noti

Streamlining Model validation of ForeignKeys

2024-05-10 Thread Shaheed Haque
Hi, I have two models Source and Input, where Input has an FK to Source like this: class Source(db_models.Model): scheme = db_models.CharField(...) path = db_models.CharField(...) display_as = db_models.CharField(...) class Input(db_models.Model): name = db_models.CharField(...)

Raising StopIteration causes Django to become completely unresponsive

2023-12-19 Thread Shaheed Haque
Hi, I'm running Django 4.2.7 with Python 3.11 on Ubuntu on my development setup (so no gunicorn, nginx etc, just standalone Django). I just ran into the following issue which, once it occurs, causes Django to become completely unresponsive: = 2023-12-19 16:07:02,763 [ERROR] asyncio: E

Re: Performance profiling Django Channels async consumers

2023-11-28 Thread Shaheed Haque
On Tue, 28 Nov 2023, 15:26 Filbert, wrote: > crickets...sigh... > Is your question is more about profiling Python (async) code than anything specifically to do with Django? If so, then obviously Google is likely a good place to start. If not, and your issue is more about support for async from

Running migrations with multiple databases

2023-07-10 Thread Shaheed Haque
Hi, I'm on Django 4.2 atop Postgres. In my project settings.py, I have a main/default database connection, and a second set up like this: == DATABASES = { 'default': { ... 'NAME': 'foo', # Postgres DATABASE NAME ... }, 'archive_r

Re: Slow Performance of Django Web App

2023-06-13 Thread Shaheed Haque
Have you tried using https://django-debug-toolbar.readthedocs.io/en/latest/? It can be a little fiddling about with, but it's time based profiling support has been invaluable in tracking down a few critical queries. On Sun, 11 Jun 2023, 20:00 Kunal Mittal, wrote: > I've a django application serv

Re: Django channels scalling

2022-12-21 Thread Shaheed Haque
Generally, as you may know, it is not very easy to get memory usage stats on Unix/Linux without specialised tooling. However, in my experience, with default TCP settings, the kernel overhead plus whatever "typical" app overhead will not often exceed say 100 kB per connection. Now, we had original

Re: getting unique id

2022-11-23 Thread Shaheed Haque
Are all the threads in the same Python process? Or the same machine? Do they have to persist across process (or machine) restarts? On Wed, 23 Nov 2022, 16:57 Larry Martell, wrote: > I have an app that needs to get a unique ID. Many threads run at the > same time that need one. I would like the I

Re: Multi-tenant SSO that supports OpenID and MS Azure AD

2022-11-08 Thread Shaheed Haque
Hi, On Tue, 8 Nov 2022 at 17:54, Filbert wrote: > Thanks. By multiple IDPs, do you men multiple IDPs for multiple tenants? > Since we are multi-tenant, some tenants will not have IDP providers, others > may use social auths, and most will use their own IDP like > LDAP/AD/Azure/etc. > I'll expla

Re: Multi-tenant SSO that supports OpenID and MS Azure AD

2022-11-07 Thread Shaheed Haque
Tim, On Mon, 7 Nov 2022, 19:28 Tim Nelson, wrote: > I am looking for a Django SSO package that supports OpenId and Azure AD > with multi-tenant support. My sense is I am going to have to roll my own by > forking the best of breed SSO's and adding multi-tenant support to them. > > Is my assessmen

Re: Is there a way to pass arbitrary argument from serializer.save to model.save method

2022-09-23 Thread Shaheed Haque
Add an attribute to instance? On Fri, 23 Sep 2022, 19:21 Sencer Hamarat, wrote: > Hi, > > I need to pass an arbitrary argument from the serializer.save() method to > model.save() method? > > Such as: > > serialized_data = AModelSerializer(instance, data=adata_dict) > if serialized_data.is_valid(

Re: Need help on reducing cognitive complexity

2022-07-20 Thread Shaheed Haque
The first step is to ensure you have a precise and accurate understanding of the code before optimization. Right now, I am suspicious of at least 2 things in the code. First, the function returns any of {None, -1, True}. While this is certainly allowed, is this correct? If not, please correct the

Re: Django could not parse the remainder

2022-06-23 Thread Shaheed Haque
>From memory, At least in Jinja templates, you can explicitly use the dictionary form {{ key["hypen-ated"] }}... Have you tried that? On Thu, 23 Jun 2022, 14:44 Ryan Nowakowski, wrote: > > https://stackoverflow.com/questions/8252387/how-do-i-access-dictionary-keys-that-contain-hyphens-from-withi

Re: String Concatenate

2022-04-20 Thread Shaheed Haque
On Wed, 20 Apr 2022, 11:05 Kasper Laudrup, wrote: > On 20/04/2022 11.33, Ankit Chaurasia wrote: > > from django.db import models > > class Customer(models.Model): > > name = models.CharField(max_length=20) > > phone = models.IntegerField() > > I want to concatenate name + last digit of

Re: How to create dynamic models in django??

2022-02-27 Thread Shaheed Haque
Check out the api mentioned here https://stackoverflow.com/questions/34768732/temporary-models-in-django#48042468 On Sun, 27 Feb 2022, 03:42 Prashanth Patelc, wrote: > How to create dynamic models in django rest framework? > Is there any chance to create dynamic models with APIs > > Any examples

Re: What to treat as 'source'

2022-02-17 Thread Shaheed Haque
On Fri, 18 Feb 2022 at 00:16, Michael Powell wrote: > > Hello, > > Perhaps a general CMS related topic... What (necessarily, 'how') do we treat > as source code? If we have a Django or an OrchardCore/CMS, for example. The > infrastructure, obviously, i.e. the framework, intermediate derivations,

Re: Idea

2021-11-01 Thread Shaheed Haque
Oh and it's never one language at the front end. Start with HTML(5), throw in CSS and JS(ES6?). And that's before jQuery(old hat), Vue, React, Angular(N). All of which look suspiciously like domain specific languages in their mutual incompatibility despite being JS. The reality is not of language

Re: DJNAGO Many to Many field MultiSelect Into DropdownList

2021-10-18 Thread Shaheed Haque
On Mon, 18 Oct 2021 at 15:41, Sebastian Jung wrote: > When u use SelectMultiple then you get a select widget where you can > select many options Your code are wrong in forms.py in widgets= > > Am Mo., 18. Okt. 2021 um 16:22 Uhr schrieb 'Maryam Yousaf' via Django > users : > >> It is alrea

How to update part of a JSONField with a computed value?

2021-08-04 Thread Shaheed Haque
Hi, I'm using Django 3.2 on Postgres12, and I have a model with a JSONField which contains a simple dict (actually, a Django formset :-)). I would like to update just one value in the dict. I can get this to work when the new value is a hardcoded numeric 333 (quoted, as seems to be needed) like th

Re: Filtering OR-combined queries

2021-05-12 Thread Shaheed Haque
er_) Notice the use of "& ~Q()"... Thanks, Shaheed On Wed, 5 May 2021 at 17:01, Shaheed Haque wrote: > After testing with 3.2.1, I filed > https://code.djangoproject.com/ticket/32717. > > On Tue, 4 May 2021 at 13:23, Shaheed Haque wrote: > >> Simon, >&g

Re: Filtering OR-combined queries

2021-05-05 Thread Shaheed Haque
After testing with 3.2.1, I filed https://code.djangoproject.com/ticket/32717. On Tue, 4 May 2021 at 13:23, Shaheed Haque wrote: > Simon, > > Thanks for the heads up. At first glance, the release notes don't *quite* > seem to match what I see but as you suggest, I will certai

Re: Filtering OR-combined queries

2021-05-04 Thread Shaheed Haque
effect: >> >> Buss.objects.filter(a='b').intersection(qs_or_result) >> >> though it is rather clumsy!!! FWIW, this is with Django 3.2. I'm inclined >> to think this is a bug in the ORM, though I have not dived into the code to >> track it down. &g

Re: Filtering OR-combined queries

2021-04-30 Thread Shaheed Haque
umsy!!! FWIW, this is with Django 3.2. I'm inclined to think this is a bug in the ORM, though I have not dived into the code to track it down. Thanks, Shaheed > > > Shaheed Haque schrieb am Fr., 30. Apr. 2021, > 02:43: > >> Hi, >> >> I have a quer

Filtering OR-combined queries

2021-04-29 Thread Shaheed Haque
Hi, I have a query which ORs some selects on a single table together like this: jurisdiction = 'aaa' qs = Buss.objects.filter(jurisdiction=jurisdiction) qs = qs | Buss.objects.filter(jurisdiction='xxx').exclude(name__in =qs.values_list('name', flat=True)) qs = qs | Buss.objects.filter(jurisdictio

Re: Mixin add field to fields in forms

2021-04-18 Thread Shaheed Haque
Actually, looking again at the source, it might be generally belter to use self.base_fields. (Yes, my previous answer is not an exact copy of my code, so I got it wrong). On Sun, 18 Apr 2021 at 17:16, Shaheed Haque wrote: > > > On Sun, 18 Apr 2021 at 14:38, sebasti...@gmail.com < &g

Re: Mixin add field to fields in forms

2021-04-18 Thread Shaheed Haque
On Sun, 18 Apr 2021 at 14:38, sebasti...@gmail.com < sebastian.ju...@gmail.com> wrote: > Hello, > > Thanks for your fast response. But i don't know how i can > use self.declared_fields and why this would help me... > The "how" is easy. Here is a fragment from my code where the problem is that ev

Re: Mixin add field to fields in forms

2021-04-18 Thread Shaheed Haque
Try updating self.declared_fields instead. On Sun, 18 Apr 2021, 13:47 sebasti...@gmail.com, wrote: > Hello, > > > *forms.py:* > > class Newsletterform(StandardMixin): > class Meta: > model = Newsletter > fields = ['newslettername', 'from_link', 'to_list', > 'email_subject', '

Django 3.1/asgiref 3.3.1 support for StreamingHttpResponse

2020-12-08 Thread Shaheed Haque
Hi, I am attempting to upgrade from Django 3.0 to 3.1 and asgiref 2.x to 3.x, and noticed a breakage in a view which I suspect might be related to its usage of StreamingHttpResponse. The code in question now raises the following exception: 2020-12-08 17:50:05,159 [ERROR] daphne.server: Exception

Re: controlling stdout

2020-12-05 Thread Shaheed Haque
ing me a new word to use. > Lol. Good luck... > -Tom > > On Sat, Dec 5, 2020 at 9:06 AM Shaheed Haque > wrote: > >> I would hazard a guess that Django has already redirected stderr and or >> stdout before your code gets to run. >> >> I recommend tha

Re: controlling stdout

2020-12-05 Thread Shaheed Haque
I would hazard a guess that Django has already redirected stderr and or stdout before your code gets to run. I recommend that you stop your code in the debugger just *before* you try your redirection and look at the state of sys.stderr and sys.stdout. Also, I'm not sure if you are aware of the dun

Re: Process Data during server initialization

2020-10-22 Thread Shaheed Haque
Well, it's a bit of a blunt weapon, but Python is going to run any code it finds at module scope as the process is initialised. So you could cause your heavy stuff to be run there? Or at least spawned from there? On Thu, 22 Oct 2020, 22:59 Okware Aldo, wrote: > Hi Lois, > > To expand on what Sco

Re: Django 3.1.2 JSONField handling error with an Postgres Foreign Data Wrapper-based model

2020-10-18 Thread Shaheed Haque
Indeed. And to close out the discussion I can confirm that my FDW implementations were using JSON columns, and the issue was resolved by switching to JSONB instead. On Sun, 18 Oct 2020, 14:40 Jason, wrote: > looks like you got a response back, and there's more context in the linked > ticket too.

Django 3.1.2 JSONField handling error with an Postgres Foreign Data Wrapper-based model

2020-10-15 Thread Shaheed Haque
Hi, I have a Django model working fine under Django 3.0 (i.e. "Django<3.1") which looks like this: === class Job(models.Model): id = models.CharField(max_length=36, primary_key=True) queue = models.CharField(max_length=40) args = JSONField() kwa

Re: Django ORM Model meta internal API to current API update

2020-09-08 Thread Shaheed Haque
On Tue, 8 Sep 2020 at 03:54, Asif Saif Uddin wrote: > any help? I can share the full function > I've poked around some of these dark corners, but only since the late 2.x series. After a bit of searching this find-the-field-that-connects-a-model-to-a-through-model

Re: unexpected change

2020-09-03 Thread Shaheed Haque
To clarify, try creating an empty file (e.g. using the "touch" command) with the right path. On Thu, 3 Sep 2020, 17:39 Shaheed Haque, wrote: > Sorry to hear about your problems. One other avenue to possibly explore is > Pycharm's "local history" facili

Re: unexpected change

2020-09-03 Thread Shaheed Haque
Sorry to hear about your problems. One other avenue to possibly explore is Pycharm's "local history" facility. This keeps track of changes independently of any VCS such as git. It seems to be based on the original file paths. So, try creating one file with the EXACT path before the rename. Then go

A question about running Channels and Django code under Celery

2020-08-22 Thread Shaheed Haque
I have a question about running Channels and Django code under Celery. Originally, I had some code that used neither Channels nor Celery, but simply run as part of the View code: def import_all(...) ...database access... This is an expensive operation and to avoid timing out the browser, I

Re: Django modelformset is_valid method retrieves entire model from database

2020-07-30 Thread Shaheed Haque
If you use the "empty_form " functionality, you may also wish to check that. In my case, I had added queryset filtering for the normal form case, but recently noticed to my horror that constructing the empty_form caused my fil

Re: Good usage of native JSON functions and operators in ORM queries

2020-06-02 Thread Shaheed Haque
On Sat, 30 May 2020 at 13:49, Shaheed Haque wrote: > Hi, > > I have a model MyModel which has a JSONField() called 'snapshot'. In > Python terms, each snapshot looks like this: > > == > snapshot = { > 'pay_definition&#x

Good usage of native JSON functions and operators in ORM queries

2020-05-30 Thread Shaheed Haque
Hi, I have a model MyModel which has a JSONField() called 'snapshot'. In Python terms, each snapshot looks like this: == snapshot = { 'pay_definition' : { '1234': {..., 'name': 'foo', ...}, '99': {..., 'name': 'bar', ...}, } == I'd like

Re: Additional data added to the HTTP Get Request.

2020-05-09 Thread Shaheed Haque
I think you are missing a closing double quote on your data-url. On Sat, 9 May 2020, 09:59 Ronald Kamulegeya, < ronald.kamulegeya.2...@gmail.com> wrote: > Hello Members. > > I am a django beginner and i am going trough online tutorials. > > I have the following view functions: > > # Create your v

Re: Channels/Daphne offloading SSL Certs to AWS ELB fails to establish socket

2020-04-21 Thread Shaheed Haque
to look into those in due course. Shaheed > > On Mon, Apr 20, 2020 at 5:55 PM Shaheed Haque > wrote: > >> >> >> On Mon, 20 Apr 2020 at 21:54, Filbert wrote: >> >>> *Answering my own question.AWS classic ELBs never worked properly >>>

Re: Channels/Daphne offloading SSL Certs to AWS ELB fails to establish socket

2020-04-20 Thread Shaheed Haque
On Mon, 20 Apr 2020 at 21:54, Filbert wrote: > *Answering my own question.AWS classic ELBs never worked properly with > websockets. Need to convert them to ALBs.* > Thanks for closing the loop; this is quite likely to be in my future. Did you need any nginx config changes? Shaheed On Tuesd

Re: How to best secure environment variables (secret key, passwords etc.) stored in .yml files?

2020-01-30 Thread Shaheed Haque
I don't think you are overthinking this. On Thu, 30 Jan 2020, 12:40 Tom Moore, wrote: > Hi there, I'm following the guidelines by making sure the environment > variables are stored outside of the settings.py files. > > The project is "dockerised" and so the environment variables have been > stor

Re: Make a Django query filter at runtime

2020-01-08 Thread Shaheed Haque
On Wed, 8 Jan 2020 at 20:09, Ezequias Rocha wrote: > Hi everyone > > I am in a doubt about creating django filters dynamically. > > All you know a filter is made by using the parameters like: > > model.filter(name='John', age=42) > > But if I can't type all fields and values at design time but at

Re: How to make Django Application more secure

2020-01-02 Thread Shaheed Haque
Hi, On Thu, 2 Jan 2020, 19:30 Jody Fitzpatrick, wrote: > Hi Balaji > > It's not necessarily template views. > > Let's come up with a scenario so you can see. > > > Let's assume you have an order form, and your customers can view that > order form by viewing: > > yoururl.com/orders/?order_id=101

Re: Django 3.0 Released.

2019-12-05 Thread Shaheed Haque
On that subject... On Thu, 5 Dec 2019, 15:12 Jonathan Morgan, wrote: > Another thing to consider is whether you need to update the packages you > use to build your application. I've found that support for the LTS version > of django is not consistent across packages, where support for the lates

Re: Microservice with django

2019-11-09 Thread Shaheed Haque
At the end of the day, assuming you combine the Django "application server" with a REST wrapper, you can build any level or type of service you could want. The crucial question is how you want to trade off the power of the ORM against custom code? For example, let's say you wrapped every single ta

Testing the validity of a form which has inline formsets from a View subclass

2019-09-03 Thread Shaheed Haque
Hi all, I have a set of views in a superclass/subclass hierarchy like this: - mobile_view is a subclass of - generic___view is a subclass of - django-extra-views formset support view As expected, the django-extra-views formset support's "post()" logic does a "if form.is_valid() then for

Re: architecture for Blue/Green deployments

2019-05-03 Thread Shaheed Haque
I should clarify one thing... On Thu, 2 May 2019 at 20:28, Shaheed Haque wrote: > On Thu, 2 May 2019 at 19:37, wrote: > >> What gold! >> >> The essential piece of your logic is here: >> >>> Enforce a development process that ensures that (roughly speakin

Re: architecture for Blue/Green deployments

2019-05-02 Thread Shaheed Haque
On Thu, 2 May 2019 at 19:37, wrote: > What gold! > > The essential piece of your logic is here: > >> Enforce a development process that ensures that (roughly speaking) all >> database changes result in a new column, and where the old cannot be >> removed until a later update cycle. All migrations

Re: architecture for Blue/Green deployments

2019-05-02 Thread Shaheed Haque
Hi Dan, I recently went through a similar exercise to the one you describe to move our prototype code on AWS. First, my background includes a stint building a control plane for autoscaling VMs on OpenStack (and being generally long in tooth), but this is my first attempt at a Web App, and therefo

Re: Django reporting Library recommendations

2019-04-16 Thread Shaheed Haque
Hi Brian, On Tue, 16 Apr 2019 at 12:21, Brian Mcnabola wrote: > > Im looking for a Django reporting library something similar to Django report > builder ? Can you clarify what you are looking for that Django report builder does not provide? For example, we use JasperReports wrapped for use from

Measuring code coverage when using Selenium and pytest

2019-04-13 Thread Shaheed Haque
Hi, I'd like to get coverage.py running against my code base. The code consists of standard Django, some Celery code, some django-viewflow code and some Celery-and-django-viewflow code [1]. The main problem I see is that if I say "coverage -p manage.py runserver ...", I need a way for the serve