Re: How to use different templates for different sites/domains

2024-05-28 Thread Mike Dewhirst

On 28/05/2024 9:09 pm, Antonis Christofides wrote:

Hello,

I use the sites framework for a Django project that serves many 
different domains. But each of those domains has some templates 
overridden.


Might depend on what you are overriding - entire templates or just 
includes or just vars.


I would probably start by refactoring the templates so they were 
identical for all sites and reduce/extract the differences to includes 
which can be selected via contextvars after calling get_current_site() 
from the view.


Have you looked at template tags?

I use them for displaying additional information on the staging and dev 
sites versus production. Not what you are doing so I haven't thought too 
hard about that. Only worth a thought if you haven't considered it.




If I used a different instance of Django (i.e. a different gunicorn 
service) for each domain, I'd have different settings for each site. 
But I'm using a single instance to serve all sites and, wherever I 
need to, I use things that extract the domain from the request, like 
`get_current_site()`. But this doesn't seem to work with templates. A 
custom template loader won't work without a fight because its methods 
don't accept the request object as an argument.


All solutions I've thought about are ugly hacks.


Practicality beats purity

The least ugly seems to be to create middleware that stores the 
request object in a contextvar 
. But it strikes 
me that I can't find a simpler solution for this. Is what I want that 
uncommon, or am I missing something?


There's an old closed "wontfix" ticket 
 about this but without 
adequate explanation.

--
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/175b4601-2038-479b-9581-48d9c196df7cn%40googlegroups.com 
.



--
We recommend signal.org

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/befa4ac2-40b8-44da-87c2-cbbe3ed307c6%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Django Admin Shortcuts

2024-05-28 Thread Mike Schem
Hey Faisal,

Thanks for taking the time to read the PR and provide some feedback. I
copied all of your concerns here and responded to them accordingly. Please
let me know if you have any further questions!

1.
Have you considered including a section in the Django admin documentation
that outlines the new shortcuts and how to use them?

Yes, I absolutely will document this, I was thinking about adding it to the
"Other Topics" section here:
https://docs.djangoproject.com/en/5.0/ref/contrib/admin/#other-topics. What
do you think?

2.
 Are the keyboard shortcuts configurable?

Not yet, but I would be open to doing this as a future PR.

3.
Have you tested the keyboard shortcuts across different browsers and
operating systems to ensure consistent behavior?

 Any specific browsers or versions where you faced issues?

Yes, we've tested on pretty much all major OSs and browsers and have seen
consistent behavior.  I've been running this in my company for over a year
now. It's been great!

4.
What considerations have been made regarding accessibility?

I'd say this is largely an accessibility feature since it would allow for
the visually impaired to save without needing to see the save buttons,
which is great!

5.
How does the implementation handle potential conflicts with existing
browser or system shortcuts?

There is an existing ctrl + S for saving browser pages as HTML, frakely, I
don't think that should be the default for users. When saving the page, the
action should not be to save it as html, but instead save the content of
the admin.

6.
Have you noticed any performance impacts with the addition of these
shortcuts? Ensuring that the admin interface remains performant is
important for all users.

No, no performance issues. It's a very simple code change without much
impact.

On Sat, May 25, 2024 at 7:25 AM Faisal Mahmood 
wrote:

> Hi *Mike Schem,
>
> Thank you for reaching out and for your work on adding keyboard shortcuts
> to the Django admin. This is a valuable feature that can greatly enhance
> productivity for many users. We appreciate your contribution and the effort
> you've put into this PR.
>
> We have reviewed your pull request and are excited about its potential.
> Here are some thoughts and questions we have:
>
> 1.
> Have you considered including a section in the Django admin documentation
> that outlines the new shortcuts and how to use them?
>
> 2.
>  Are the keyboard shortcuts configurable?
>
> 3.
> Have you tested the keyboard shortcuts across different browsers and
> operating systems to ensure consistent behavior?
>
>  Any specific browsers or versions where you faced issues?
>
> 4.
> What considerations have been made regarding accessibility?
>
> 5.
> How does the implementation handle potential conflicts with existing
> browser or system shortcuts?
>
> 6.
> Have you noticed any performance impacts with the addition of these
> shortcuts? Ensuring that the admin interface remains performant is
> important for all users.
>
> We believe these questions can help further refine the feature and ensure
> it meets the needs of the wider Django community. Once again, thank you for
> your contribution. We look forward to your responses and further discussion.
>
> Best regards,
> [Faisal Mahmood]
>
> On Fri, May 24, 2024, 10:32 PM Mike Schem 
> wrote:
>
>> Hey all,
>>
>> I’m seeking some support and feedback on my PR. I’ve added keyboard
>> shortcuts to the Django admin for the save actions. We use it at my
>> company, and it’s pretty helpful for power users. I’d love to hear what the
>> community thinks.
>>
>> https://github.com/django/django/pull/17599
>>
>>
>> Mike Schem
>> Senior Software Engineer
>> String King Lacrosse, LLC
>> StringKing, Inc.
>> 19100 South Vermont Avenue
>> <https://www.google.com/maps/search/19100+South+Vermont+Avenue+Gardena,+CA%C2%A0+90248?entry=gmail=g>
>> Gardena, CA  90248
>> <https://www.google.com/maps/search/19100+South+Vermont+Avenue+Gardena,+CA%C2%A0+90248?entry=gmail=g>
>> 310-699-7175 Mobile
>>
>> m...@stringking.com 
>> StringKing.com <http://stringkinglacrosse.com/> | uSTRING.com
>> <http://ustring.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/CALUzFO1GyhQct422sU6WDRC3ksYf-qg8qgtR%2BwXGOwrjWDn2_A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CALUzFO1GyhQct422sU6WD

Django Admin Shortcuts

2024-05-24 Thread Mike Schem
Hey all,

I’m seeking some support and feedback on my PR. I’ve added keyboard
shortcuts to the Django admin for the save actions. We use it at my
company, and it’s pretty helpful for power users. I’d love to hear what the
community thinks.

https://github.com/django/django/pull/17599


Mike Schem
Senior Software Engineer
String King Lacrosse, LLC
StringKing, Inc.
19100 South Vermont Avenue
Gardena, CA  90248
310-699-7175 Mobile

m...@stringking.com 
StringKing.com <http://stringkinglacrosse.com/> | uSTRING.com
<http://ustring.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/CALUzFO1GyhQct422sU6WDRC3ksYf-qg8qgtR%2BwXGOwrjWDn2_A%40mail.gmail.com.


Re: Increasing iteration count for the PBKDF2 password hasher

2024-05-23 Thread Mike Dewhirst

On 23/05/2024 6:12 pm, Shaheed Haque wrote:

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 noticeable 
time it takes to run User.set_password()? Is there something that can 
be done to mitigate any further increase in the execution time of 
.set_password(), or am I barking up the wrong tree?


My understanding is the intention is to make brute force attacks more 
expensive for the attacker.


Don't know whether there might be a better way.



Thanks, Shaheed
--
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/CAHAc2jcETxAtMbHfnD1GQFVgWwR8ABOAy%3DjaRuhRW7mQhnOxeQ%40mail.gmail.com 
.



--
We recommend signal.org

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/9c7c7294-08fd-4a6a-91de-e99ab27d4a61%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Does migrate --fake updates django_migrations?

2024-03-23 Thread Mike Dewhirst

On 23/03/2024 12:39 am, Jean-Baptiste Pressac wrote:

Hello,

The doc says about migrate --fake:

/Marks the migrations up to the target one (following the rules above) 
as applied, but without actually running the SQL to change your 
database schema. /


But what is the operations behind this "marks"? Modifications to the 
django_migrations database table?


What is the target migration? The most recent .py file in migrations 
folder?


The target for any migration operation (fake or otherwise) is any 
migration .py file in the migrations directory of the named app and 
which has not (yet) been listed in the Django migrations table.


Hth

Mike



Thank you,
--
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/265806f3-567d-43ae-8c19-f9b15a9ee741n%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/265806f3-567d-43ae-8c19-f9b15a9ee741n%40googlegroups.com?utm_medium=email_source=footer>.



--
We recommend signal.org

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/ac4207fb-8e81-45b8-ba9b-0d3f139c%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Django web site is not opened though runserver us running

2024-03-06 Thread Mike Dewhirst

On 7/03/2024 3:02 pm, ram.mu...@gmail.com wrote:

Hi,

Hoping someone can provide some clue on this?


I think you'll find most people are reluctant to click on unsolicited 
web links no matter how innocent they appear to be.


Perhaps you can describe the problem, tell us what you have tried and 
show the DigitalOcean advice.





Best regards,
~Ram

On Tuesday, March 5, 2024 at 1:32:51 AM UTC-7 ram.mu...@gmail.com wrote:

Hi,

Could someone look at this post and help me understand what is
missing? We think there is no issue in our Django application but
Digital Ocean concluded that the issue is from our application.


https://serverfault.com/questions/1155482/django-site-is-not-opening-up-on-digital-ocean-ubuntu-droplet

Best Regards,
~Ram

--
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/573034cd-fd0a-4a31-97a5-e551416331den%40googlegroups.com 
.



--
We recommend signal.org

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/9849ca6a-3a65-42ea-a5c1-6d7ced3c4763%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


RE: How to send email from django without authenticate smtp server

2024-03-05 Thread Mike Dewhirst
Why don't you use TLS so your connection with the server is encrypted? Port 25 
is a bit ancient.--(Unsigned mail from my phone)
 Original message From: Praveen Chaudhary 
 Date: 5/3/24  04:50  (GMT+10:00) To: 
django-users@googlegroups.com Subject: How to send email from django without 
authenticate smtp server Hello everyone,Basically, I want to send the email 
from django using smtp server. I have my own smtp server domain host at port 
25, but don't want to pass EMAIL_HOST_USER & EMAIL_HOST_PASSWORD. I am using 
EmailMultiAlernatives to send the html and file, I am unable to send email 
without EMAIL_HOST_USER & EMAIL_HOST_PASSWORDThank you for your help.Prabin 
ChaudharySoftware EngineerMobile: +977-9840193890 | prabinchy1...@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/CAN9B8Z08UcPUVgcz19GNXc%2BcYeSQTEraYvGT2xrMNo_%3DmBX2_g%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/65e795a1.020a0220.b4eca.0a63SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


RE: How to send email from django without authenticate smtp server

2024-03-05 Thread Mike Dewhirst
Why don't you use TLS so your connection with the server is encrypted? Port 25 
is a bit ancient.--(Unsigned mail from my phone)
 Original message From: Praveen Chaudhary 
 Date: 5/3/24  04:50  (GMT+10:00) To: 
django-users@googlegroups.com Subject: How to send email from django without 
authenticate smtp server Hello everyone,Basically, I want to send the email 
from django using smtp server. I have my own smtp server domain host at port 
25, but don't want to pass EMAIL_HOST_USER & EMAIL_HOST_PASSWORD. I am using 
EmailMultiAlernatives to send the html and file, I am unable to send email 
without EMAIL_HOST_USER & EMAIL_HOST_PASSWORDThank you for your help.Prabin 
ChaudharySoftware EngineerMobile: +977-9840193890 | prabinchy1...@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/CAN9B8Z08UcPUVgcz19GNXc%2BcYeSQTEraYvGT2xrMNo_%3DmBX2_g%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/65e7959b.810a0220.96455.6556SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Data model design questio: graph in database

2024-02-26 Thread Mike Dewhirst

On 26/02/2024 8:00 pm, Sébastien Hinderer wrote:
I will thus need to find a way to disable in the admin interface the 
possibility to work directly on the Vertex and Edge classes, but I 
expect the documentation will tell me how to achieve this.


In fact you need to enable the classes you want - as per the docs - so 
simply omitting the base classes will do the trick for you.


--
We recommend signal.org

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/a6ddcf97-f180-4060-9212-b38824bf5414%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Data model design questio: graph in database

2024-02-25 Thread Mike Dewhirst
Re-reading your question perhaps I was too brief in my earlier response. 
Let me assume all your actual edges and vertices are objects of child 
classes. I also assume  your base Edge and Vertex classes are abstract for 
inheritance purposes only.

It doesn't matter whether instances of edges and vertices are in lists. You 
can call obj.which_class() on any object which has (inherited) that method 
to determine whether an edge (or vertex) is type_1 or type_2 (using our 
previous terminology)

You cannot query the database using the return value from which_class() 
because that operates on instances not at the database level. Therefore you 
have to retrieve edges and vertices from the database with a query which 
fetches related rows and then filter the results afterwards. Perhaps like 
this ...

vertex_src = result_of_vertex_finder(...)
vertex_det = result_of_vertex_finder(...)
if vertex_src and vertex_dst:
edges_1 = Edge_type_1.objects.filter(src=vertex_src, dst=vertex_dst) or 
[]
edges_2 = Edge_type_2.objects.filter(src=vertex_src, dst=vertex_dst) or 
[]
all_edges = [edges_1].extend[edges_2]

if all_edges:
edges_type_1 = [edge for edge in all_edges if edge.which_class() == 
"type 1"]
edges_type_2 = [edge for edge in all_edges if edge.which_class() == 
"type 2"]

On the other hand, if you want to keep all edges in the same database table 
it might be better/simpler to add a field 'type' to the table as you were 
originally thinking.  

Cheers

Mike



On Sunday, February 25, 2024 at 9:47:12 PM UTC+11 Sébastien Hinderer wrote:

> Dear Mike,
>
> I will definitely play aroudn with your nice suggestion, but I would like
> to share a concern I have. At this stage I am actually unsure how this
> will work.
>
> Indeed, suppose a vertex is given as input and one tries to query the
> database about all the edges that originate from this vertex. The answer
> will be under the form of a list of edges, but those will be of class
> Edge and I assume that their type method will return the Edge class
> and not the class associated to the actual child.
>
> Likewise, once given the list of edges, one has access to the list of
> vertices that are neiighbourgs of the original one, but under the form
> of a list of objects of the base class, Vertex, with still no way to find
> the type of the child object that has given rise to that Vertex one.
>
> Am I perhaps missing something here?
>
> Many thanks in advance and apologies for th likely naïve question,
>
> Seb.
>

-- 
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/0b786b4c-6c95-4920-a2f9-d28c4b541eb9n%40googlegroups.com.


Re: Data model design questio: graph in database

2024-02-25 Thread Mike Dewhirst
SebYour assumption is too pessimistic. The class name of the (child) instance 
will always be returned from obj.__class__If instead your method returned the 
type(obj) you would see the base class name instead of the child class 
name.Perhaps you need to establish some tests which assert what you expect. I 
find such an approach very comforting.CheersMike--(Unsigned mail from my phone)
 Original message From: Sébastien Hinderer 
 Date: 25/2/24  21:46  (GMT+10:00) To: 
django-users@googlegroups.com Subject: Re: Data model design questio: graph in 
database Dear Mike,I will definitely play aroudn with your nice suggestion, but 
I would liketo share a concern I have. At this stage I am actually unsure how 
thiswill work.Indeed, suppose a vertex is given as input and one tries to query 
thedatabase about all the edges that originate from this vertex. The answerwill 
be under the form of a list of edges, but those will be of classEdge and I 
assume that their type method will return the Edge classand not the class 
associated to the actual child.Likewise, once given the list of edges, one has 
access to the list ofvertices that are neiighbourgs of the original one, but 
under the formof a list of objects of the base class, Vertex, with still no way 
to findthe type of the child object that has given rise to that Vertex one.Am I 
perhaps missing something here?Many thanks in advance and apologies for th 
likely naïve question,Seb.-- 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/ZdsadQngSnjTBimQ%40om.localdomain.

-- 
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/65db3321.050a0220.186e4.d2a8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Data model design questio: graph in database

2024-02-24 Thread Mike Dewhirst

On 24/02/2024 7:20 am, Sébastien Hinderer wrote:

Dear all,

Using the mailing list rather than the forum because, like many visually
impaired people, I find mailing lists way easier to use than forums, I
hope the list is still active.

I need to store in database and manipulate graphs of which both
vertices and edges can each be of several types.

At the moment I am modelling this as follows:

class Vertex(models.Model):
 pass

class Vertex_type_1(Vertex):
 # Data specific to vertices of type 1
 ...

class Vertex_type_2(Vertex):
 # Data specific to vertices of type 2
 ...

class Edge(models.Model):
 src = models.ForeignKey(Vertex,
   on_delete=models.CASCADE, related_name="+")
 dst = models.ForeignKey(Vertex,
   on_delete=models.CASCADE, related_name="+")
 class Meta:
 unique_together = ['src', 'dst']

class Edge_type_1(Edge):
 # Data specific to edges of type 1
 ...

class Edge_type_2(Edge):
 # Data specific to edges of type 2
 ...

I will have to wwite algorithms that work at the graph level, e.g.
to find paths. However, once a path has been found, at some point it
will become necessary to see which types of vertices and edges it is
that are involved in the path that has been found and I am wondering how
I will do that.

More concretely, with the current model, if an edge is found,
does Django have a way to also find out which type of edge it is,
i.e. which child class has given rise to that edge? Or do I need to add
type fields to the Vertex and Edge classes so that it becomes possible
to go from the parent to the children?

I feel unsure because on the one hand it feels to me it is necessary
with the current model to add such type fields, but on the other hand I
feel this is kind of wrong, almost like a code smell suggesting that I
am modelling things in a wrong way.

Any insight would be warmly appreciated as I am a total beginner with
Django.


In the base class you need a method like this ...

    def which_class(self):
    return self.__class__

... which will be inherited by each child class and when called will 
reveal the class name of the instance.


To test this in development, in the base class add a save method like 
this ...


    def save(self, *args, **kwargs):
    print(f"\n class name = {self.which_class()}")
    super().save(*args, **kwargs)

Whenever you save a model its name should print in stdout.  I tried it 
in one of my models and this is the result ...


    

... where "Chemical" is the class name.

So if you have a method which understands what the child class names 
mean, you can put your algorithm in there and execute calls to 
which_class() for each instance involved.


That might be enough to get you started.

Cheers

Mike



Many thanks in advance,

Seb.




--
We recommend signal.org

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/f81ef2aa-57eb-4cd8-bd53-679f9f68b143%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: HttpResponse works but HttpResponseRedirect does not

2024-01-02 Thread Mike Dewhirst
Merci AlexI'll have to try what you suggest - not with pandas because the csv 
part is working well - but perhaps assembling the response as a separate object 
and then trying to redirect back to the same URL. Might have to look at the 
Django source and try to comprehend what it is doing.CheersMike--(Unsigned mail 
from my phone)
 Original message From: Alex007 MULUMBA 
 Date: 3/1/24  08:38  (GMT+10:00) To: 
django-users@googlegroups.com Subject: Re: HttpResponse works but 
HttpResponseRedirect does not import pandas as pd
from django.http import HttpResponse  # Assuming Django context

data_frame = pd.DataFrame.from_records(data)
data_frame.to_csv("output.csv", index=False)  # Save as CSV

with open("output.csv", 'rb') as f:
response = HttpResponse(f.read(), content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="output.csv"'

return responseLe mar. 2 janv. 2024 à 05:45, Mike Dewhirst 
 a écrit :

  


  
  
I wonder if someone can point out my mistake?

The following code happily downloads a constructed text file ...

    csv = make_csv(context['result'])
    # This downloads a csv file to the user desktop
    return HttpResponse(
    csv,
    headers={
    'Content-Type': 'text/plain',
    # Set the content-disposition header to prompt user download
    'Content-Disposition': f'attachment; filename="{fname}.csv"'
    },
    )

... but leaves all the entered (unbound) form data on display.
However, I want the form cleared ready for the next set of user
data.

The following code clears the entered data but fails to download the
constructed file.

    csv = make_csv(context['result'])
    # This fails to download a csv file
    return HttpResponseRedirect(
    "",
    csv,
    headers={
    'Content-Type': 'text/plain',
    # Set the content-disposition header to prompt user download
    'Content-Disposition': f'attachment; filename="{fname}.csv"'
    },
    )
    
Many thanks for any help

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

  




-- 
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/3b59be97-0cf9-4654-97ac-86da72ed4737%40dewhirst.com.au.




-- 
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/CANzESc2Pqq6r9Z06RKy%2BY-LBOwn5KdTQtkvuWVe3pCryrKe%2Bzg%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/6594dd40.050a0220.6d9a5.5fa5SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


HttpResponse works but HttpResponseRedirect does not

2024-01-01 Thread Mike Dewhirst

I wonder if someone can point out my mistake?

The following code happily downloads a constructed text file ...

    csv = make_csv(context['result'])

    # This downloads a csv file to the user desktop

    return HttpResponse(

    csv,

    headers={

    'Content-Type': 'text/plain',

    # Set the content-disposition header to prompt user download

    'Content-Disposition': f'attachment; filename="{fname}.csv"'

    },

    )


... but leaves all the entered (unbound) form data on display. However, 
I want the form cleared ready for the next set of user data.


The following code clears the entered data but fails to download the 
constructed file.


    csv = make_csv(context['result'])

    # This fails to download a csv file

    return HttpResponseRedirect(

    "",

    csv,

    headers={

    'Content-Type': 'text/plain',

    # Set the content-disposition header to prompt user download

    'Content-Disposition': f'attachment; filename="{fname}.csv"'

    },

    )


Many thanks for any help

Cheers

Mike

--

Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/3b59be97-0cf9-4654-97ac-86da72ed4737%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: logging admin accesses

2023-12-19 Thread Mike Dewhirst
I was saying Django's inspectdb will write them for you.M--(Unsigned mail from 
my phone)
 Original message From: Larry Martell  
Date: 20/12/23  00:51  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: logging admin accesses On Mon, Dec 18, 2023 at 7:23 PM Mike Dewhirst 
 wrote:>> On 19/12/2023 9:51 am, Larry Martell wrote:>> 
Hmmm, in my case I do not see any models for those in any of my models.py 
files. Where would I expect to find them?>>> You have to write them 
yourself.Yeah, thanks. I know I can create them myself. I thought you 
weresaying they were already created by django.The best way is to run manage.py 
inspectdb > models.txt then extractthe m2m models from there. In theory and 
provided you follow theadvice at the top of the output ...>> # This is an 
auto-generated Django model module.> # You'll have to do the following manually 
to clean this up:> #   * Rearrange models' order> #   * Make sure each model 
has one field with primary_key=True> #   * Make sure each ForeignKey and 
OneToOneField has `on_delete` set to the desired behavior> #   * Remove 
`managed = False` lines if you wish to allow Django to create, modify, and 
delete the table> # Feel free to rename the models, but don't rename db_table 
values or field names.> from django.db import models>>> ... just having the 
model declarations should not require a migration. Haven't checked that 
myself.>>> On Mon, Dec 18, 2023 at 5:26 PM Mike Dewhirst 
 wrote:>>>> Those many-to-many relations most certainly 
can have models and all of mine always do.>>>> It is more explicit to do so but 
more importantly they generally carry essential real-world information about 
the relationship itself.>>>> I haven't looked at django-simple history beyond 
deciding to roll my own but it may well cover m2m tables if you add the models 
explicitly.>>>>>> -->> (Unsigned mail from my phone)>>>>>>>>  Original 
message >> From: Larry Martell >> Date: 
19/12/23 08:18 (GMT+10:00)>> To: django-users@googlegroups.com>> Subject: Re: 
logging admin accesses>>>> django-simple-history is close to what we need. The 
one issue I see>> (so far) is that it does not support tables that are created 
behind>> the scenes by django to handle one to many relations that do not 
have>> models. Does anyone know how to maintain history on those?>>>> On Mon, 
Dec 18, 2023 at 2:48 PM Larry Martell  wrote:>> >>> > 
No, I have not see django-simple-history - thanks for the pointer - will check 
it out.>> >>> > On Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst 
 wrote:>> >>>> >> Just thinking about it again ... you 
could look at the Admin source to see how it is working now and perhaps find a 
way to include the missing info in a pre-save signal.>> >>>> >> Also, I found 
django-simple-history online but I suppose you have seen that already.>> >>>> 
>> M>> >>>> >> -->> >> (Unsigned mail from my phone)>> >>>> >>>> >>>> >> 
 Original message >> >> From: Mike Dewhirst 
>> >> Date: 16/12/23 12:38 (GMT+10:00)>> >> To: 
django-users@googlegroups.com>> >> Subject: Re: logging admin accesses>> >>>> 
>> You seem to be asking for a full history 'system'.>> >>>> >> I think the 
Admin history exists to show a bit of history with a link to go back to the 
change form where it happened.>> >>>> >> Full history needs to be specified 
fairly carefully so it doesn't bog the system down. For example, every write 
costs a performance hit. Also, how resilient must it be to cope with database 
schema changes? How is it going to be used in practice? What are the benefits 
and are they worth the effort.>> >>>> >> I have worked through some of this in 
my current project and decided to create separate 'mirror' tables for only the 
critical information and automate data collection for others in a plain text 
field for archival.>> >>>> >> It can be quite open ended and might reward very 
aggressive specification.>> >>>> >> Cheers>> >>>> >> Mike>> >>>> >>>> >>>> >> 
-->> >> (Unsigned mail from my phone)>> >>>> >>>> >>>> >>  Original 
message >> >> From: Larry Martell >> >> Date: 
16/12/23 01:47 (GMT+10:00)>> >> To: django-users@g

Re: logging admin accesses

2023-12-18 Thread Mike Dewhirst

On 19/12/2023 9:51 am, Larry Martell wrote:
Hmmm, in my case I do not see any models for those in any of my 
models.py files. Where would I expect to find them?


You have to write them yourself. The best way is to run manage.py 
inspectdb > models.txt then extract the m2m models from there. In theory 
and provided you follow the advice at the top of the output ...



# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey and OneToOneField has `on_delete` set 
to the desired behavior
#   * Remove `managed = False` lines if you wish to allow Django to 
create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or 
field names.

from django.db import models



... just having the model declarations should not require a migration. 
Haven't checked that myself.




On Mon, Dec 18, 2023 at 5:26 PM Mike Dewhirst  
wrote:


Those many-to-many relations most certainly can have models and
all of mine always do.

It is more explicit to do so but more importantly they generally
carry essential real-world information about the relationship itself.

I haven't looked at django-simple history beyond deciding to roll
my own but it may well cover m2m tables if you add the models
explicitly.


-- 
(Unsigned mail from my phone)




 Original message 
From: Larry Martell 
Date: 19/12/23 08:18 (GMT+10:00)
To: django-users@googlegroups.com
Subject: Re: logging admin accesses

django-simple-history is close to what we need. The one issue I see
(so far) is that it does not support tables that are created behind
the scenes by django to handle one to many relations that do not have
models. Does anyone know how to maintain history on those?

On Mon, Dec 18, 2023 at 2:48 PM Larry Martell
 wrote:
>
> No, I have not see django-simple-history - thanks for the
pointer - will check it out.
>
> On Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst
 wrote:
>>
>> Just thinking about it again ... you could look at the Admin
source to see how it is working now and perhaps find a way to
include the missing info in a pre-save signal.
>>
>> Also, I found django-simple-history online but I suppose you
have seen that already.
>>
>> M
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: Mike Dewhirst 
>> Date: 16/12/23 12:38 (GMT+10:00)
>> To: django-users@googlegroups.com
>> Subject: Re: logging admin accesses
>>
>> You seem to be asking for a full history 'system'.
>>
>> I think the Admin history exists to show a bit of history with
a link to go back to the change form where it happened.
>>
>> Full history needs to be specified fairly carefully so it
doesn't bog the system down. For example, every write costs a
performance hit. Also, how resilient must it be to cope with
database schema changes? How is it going to be used in practice?
What are the benefits and are they worth the effort.
>>
>> I have worked through some of this in my current project and
decided to create separate 'mirror' tables for only the critical
information and automate data collection for others in a plain
text field for archival.
>>
>> It can be quite open ended and might reward very aggressive
specification.
>>
>> Cheers
>>
>> Mike
>>
>>
>>
>> --
>> (Unsigned mail from my phone)
>>
>>
>>
>>  Original message 
>> From: Larry Martell 
>> Date: 16/12/23 01:47 (GMT+10:00)
>> To: django-users@googlegroups.com
>> Subject: Re: logging admin accesses
>>
>> On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst
 wrote:
>>>
>>> Top posting because of phone email client.
>>>
>>> Have you seen the Admin history? Might be already logged for you.
>>
>>
>> Thanks, this is useful, but it does not seem to be logging
everything. We have a custom user admin page that updates a few
models in addition to User: UserInfo, UserExtendProduct, and
UserRole. If I add a new user I see this:
>>
>>

+---+-+-+-+-+--

Re: logging admin accesses

2023-12-18 Thread Mike Dewhirst
Those many-to-many relations most certainly can have models and all of mine 
always do. It is more explicit to do so but more importantly they generally 
carry essential real-world information about the relationship itself.I haven't 
looked at django-simple history beyond deciding to roll my own but it may well 
cover m2m tables if you add the models explicitly. --(Unsigned mail from my 
phone)
 Original message From: Larry Martell  
Date: 19/12/23  08:18  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: logging admin accesses django-simple-history is close to what we need. The 
one issue I see(so far) is that it does not support tables that are created 
behindthe scenes by django to handle one to many relations that do not 
havemodels. Does anyone know how to maintain history on those?On Mon, Dec 18, 
2023 at 2:48 PM Larry Martell  wrote:>> No, I have not 
see django-simple-history - thanks for the pointer - will check it out.>> On 
Fri, Dec 15, 2023 at 9:02 PM Mike Dewhirst  wrote:>>>> 
Just thinking about it again ... you could look at the Admin source to see how 
it is working now and perhaps find a way to include the missing info in a 
pre-save signal.>>>> Also, I found django-simple-history online but I suppose 
you have seen that already.>>>> M>>>> -->> (Unsigned mail from my 
phone)>>>>>>>>  Original message >> From: Mike Dewhirst 
>> Date: 16/12/23 12:38 (GMT+10:00)>> To: 
django-users@googlegroups.com>> Subject: Re: logging admin accesses>>>> You 
seem to be asking for a full history 'system'.>>>> I think the Admin history 
exists to show a bit of history with a link to go back to the change form where 
it happened.>>>> Full history needs to be specified fairly carefully so it 
doesn't bog the system down. For example, every write costs a performance hit. 
Also, how resilient must it be to cope with database schema changes? How is it 
going to be used in practice? What are the benefits and are they worth the 
effort.>>>> I have worked through some of this in my current project and 
decided to create separate 'mirror' tables for only the critical information 
and automate data collection for others in a plain text field for archival.>>>> 
It can be quite open ended and might reward very aggressive specification.>>>> 
Cheers>>>> Mike>>>>>>>> -->> (Unsigned mail from my phone)>>>>>>>>  
Original message >> From: Larry Martell >> 
Date: 16/12/23 01:47 (GMT+10:00)>> To: django-users@googlegroups.com>> Subject: 
Re: logging admin accesses>>>> On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst 
 wrote:>>>>>> Top posting because of phone email 
client.>>>>>> Have you seen the Admin history? Might be already logged for 
you.>>>>>> Thanks, this is useful, but it does not seem to be logging 
everything. We have a custom user admin page that updates a few models in 
addition to User: UserInfo, UserExtendProduct, and UserRole. If I add a new 
user I see this:>>>> 
+---+-+-+-+-+-+>>
 | object_id | object_repr | action_flag | change_message   

   | content_type_id | user_id |>> 
+---+-+-+-+-+-+>>
 | 3 | x   |   1 | [{"added": {}}, {"added": {"name": 
"user info", "object": "x"}}, {"added": {"name": "user extend product", 
"object": "x"}}] |   4 |   1 |>> 
+---+-+-+-+-+-+>>>>
 It shows that a row in User, UserInfo, and UserExtendProdct were added, but it 
does not show what was added to the latter 2, and it does not show that rows 
were added to UserRole.>>>> When I modify a user and cause UserRole to be 
updated I see this:>>>> 
+---+-+-++-+-+>>
 | object_id | object_repr | action_flag | change_message | content_type_id | 
user_id |>> 
+---+

Re: logging admin accesses

2023-12-15 Thread Mike Dewhirst
Just thinking about it again ... you could look at the Admin source to see how 
it is working now and perhaps find a way to include the missing info in a 
pre-save signal.Also, I found django-simple-history online but I suppose you 
have seen that already.M--(Unsigned mail from my phone)
 Original message From: Mike Dewhirst  
Date: 16/12/23  12:38  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: logging admin accesses You seem to be asking for a full history 'system'. I 
think the Admin history exists to show a bit of history with a link to go back 
to the change form where it happened.Full history needs to be specified fairly 
carefully so it doesn't bog the system down. For example, every write costs a 
performance hit. Also, how resilient must it be to cope with database schema 
changes? How is it going to be used in practice? What are the benefits and are 
they worth the effort. I have worked through some of this in my current project 
and decided to create separate 'mirror' tables for only the critical 
information and automate data collection for others in a plain text field for 
archival.It can be quite open ended and might reward very aggressive 
specification.CheersMike--(Unsigned mail from my phone) Original 
message From: Larry Martell  Date: 16/12/23  
01:47  (GMT+10:00) To: django-users@googlegroups.com Subject: Re: logging admin 
accesses On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst  
wrote:Top posting because of phone email client.Have you seen the Admin 
history? Might be already logged for you.Thanks, this is useful, but it does 
not seem to be logging everything. We have a custom user admin page that 
updates a few models in addition to User: UserInfo, UserExtendProduct, and 
UserRole. If I add a new user I see 
this:+---+-+-+-+-+-+|
 object_id | object_repr | action_flag | change_message                         
                                                                                
     | content_type_id | user_id 
|+---+-+-+-+-+-+|
 3         | x           |           1 | [{"added": {}}, {"added": {"name": 
"user info", "object": "x"}}, {"added": {"name": "user extend product", 
"object": "x"}}] |               4 |       1 
|+---+-+-+-+-+-+It
 shows that a row in User, UserInfo, and UserExtendProdct were added, but it 
does not show what was added to the latter 2, and it does not show that rows 
were added to UserRole.When I modify a user and cause UserRole to be updated I 
see 
this:+---+-+-++-+-+|
 object_id | object_repr | action_flag | change_message | content_type_id | 
user_id 
|+---+-+-++-+-+|
 3         | x           |           2 | []             |               4 |     
  1 
|+---+-+-++-+-+No
 info about that row being added. If I cause a row in UserRole to be deleted I 
get the exact same entry, so I cannot distinguish between an add and a delete 
and I can't see what was added or deleted. But if I cause a row in UserInfo or 
UserExtendProduct to be added I see 
this:+---+-+-+-+-+-+|
 object_id | object_repr | action_flag | change_message                         
                                                                                
     | content_type_id | user_id 
|+---+-+-+-+-+-+|
 3         | x           |           1 | [{"added": {}}, {"added": {"name": 
"user info", "object": "x"}}, {"added": {"name": "user extend product", 
"object": "x"}}] |               4 |       1 
|+---+-+-+-+-+-+Shows
 an add, but not what w

Re: logging admin accesses

2023-12-15 Thread Mike Dewhirst
You seem to be asking for a full history 'system'. I think the Admin history 
exists to show a bit of history with a link to go back to the change form where 
it happened.Full history needs to be specified fairly carefully so it doesn't 
bog the system down. For example, every write costs a performance hit. Also, 
how resilient must it be to cope with database schema changes? How is it going 
to be used in practice? What are the benefits and are they worth the effort. I 
have worked through some of this in my current project and decided to create 
separate 'mirror' tables for only the critical information and automate data 
collection for others in a plain text field for archival.It can be quite open 
ended and might reward very aggressive specification.CheersMike--(Unsigned mail 
from my phone)
 Original message From: Larry Martell  
Date: 16/12/23  01:47  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: logging admin accesses On Thu, Dec 14, 2023 at 5:49 PM Mike Dewhirst 
 wrote:Top posting because of phone email client.Have 
you seen the Admin history? Might be already logged for you.Thanks, this is 
useful, but it does not seem to be logging everything. We have a custom user 
admin page that updates a few models in addition to User: UserInfo, 
UserExtendProduct, and UserRole. If I add a new user I see 
this:+---+-+-+-+-+-+|
 object_id | object_repr | action_flag | change_message                         
                                                                                
     | content_type_id | user_id 
|+---+-+-+-+-+-+|
 3         | x           |           1 | [{"added": {}}, {"added": {"name": 
"user info", "object": "x"}}, {"added": {"name": "user extend product", 
"object": "x"}}] |               4 |       1 
|+---+-+-+-+-+-+It
 shows that a row in User, UserInfo, and UserExtendProdct were added, but it 
does not show what was added to the latter 2, and it does not show that rows 
were added to UserRole.When I modify a user and cause UserRole to be updated I 
see 
this:+---+-+-++-+-+|
 object_id | object_repr | action_flag | change_message | content_type_id | 
user_id 
|+---+-+-++-+-+|
 3         | x           |           2 | []             |               4 |     
  1 
|+---+-+-++-+-+No
 info about that row being added. If I cause a row in UserRole to be deleted I 
get the exact same entry, so I cannot distinguish between an add and a delete 
and I can't see what was added or deleted. But if I cause a row in UserInfo or 
UserExtendProduct to be added I see 
this:+---+-+-+-+-+-+|
 object_id | object_repr | action_flag | change_message                         
                                                                                
     | content_type_id | user_id 
|+---+-+-+-+-+-+|
 3         | x           |           1 | [{"added": {}}, {"added": {"name": 
"user info", "object": "x"}}, {"added": {"name": "user extend product", 
"object": "x"}}] |               4 |       1 
|+---+-+-+-+-+-+Shows
 an add, but not what was added.So my questions are:-how can I get it to show 
the details of what was added or changed-why are updates to UserInfo and 
UserExtendProduct shown, but updates to UserRole are not?Thanks! 
Original message From: Larry Martell  Date: 
15/12/23  06:44  (GMT+10:00) To: django-users@googlegroups.com Subject: logging 
admin accesses Is there a way to capture all admin changes (add, change, 
delete). I have some middleware that g

RE: logging admin accesses

2023-12-14 Thread Mike Dewhirst
Top posting because of phone email client.Have you seen the Admin history? 
Might be already logged for you.Mike--(Unsigned mail from my phone)
 Original message From: Larry Martell  
Date: 15/12/23  06:44  (GMT+10:00) To: django-users@googlegroups.com Subject: 
logging admin accesses Is there a way to capture all admin changes (add, 
change, delete). I have some middleware that gets called on any admin add, 
change, or delete, but I have not figured out a way to capture specifically 
what was done, something like: model, PK, action, e.g. user, 12, change, first 
name changeduser, 15, adduser, 24, deleteI am looking for something generic 
that will work for all models under admin control.



-- 
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/CACwCsY5tDc6ZJihTJFmrmus4PG7f_HCXewN-pQr3T-WcMGG4ZA%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/657b868c.050a0220.a9a3e.88d3SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: htmx progress indicator problem - might be caching

2023-12-02 Thread Mike Dewhirst

On 2/12/2023 5:42 pm, Mike Dewhirst wrote:
I'm now thinking/wondering if a htmx timed execution - say every one 
or two seconds - might call a view which monitors a singleton being 
updated by the main view kicked off by the form's submit button.


Well that almost worked! I can update the singleton and display it in 
its initialised state but the htmx view is at the other end of the 
wormhole and doesn't get a chance to see it getting updated.


Maybe I have to look at asyncio.




What pushes me in that direction is that a singleton could be updated 
with number processed which would be needed if it ever gets to become 
a progress bar.





--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/928df880-99f8-463f-9616-3b006c85f090%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Select Boxes and Database

2023-12-02 Thread Mike Dewhirst

On 3/12/2023 7:27 am, David Merrick wrote:
Hi. I can put an item from the database into a select box ie Countries 
of the World. What I want to know is saying, having chosen New Zealand 
from the select box, how do I display all the cities of New Zealand in 
another select box.


The database has two tables. First one is Countries. The second table 
is cities with populations and the foreign key of Countries table.


Then having chosen Auckland a city in New Zealand I want to display

Country
City
Population

In a template.

I have done this in Php, Javascript and Mysql already.


Check 
https://simpleisbetterthancomplex.com/tutorial/2018/01/29/how-to-implement-dependent-or-chained-dropdown-list-with-django.html


Also, I recently had a similar task with companies and divisions from 
querysets and had trouble using the form.__init__() method. Here is an 
alternative approach. You can tweak what the form displays by calling a 
form method - here set_division_queryset(). In other words, you can 
populate selection choices based on code elsewhere. In my case I did it 
from within the view code like this ...


# forms.py

class List_Import(forms.Form):

    ...

    division = forms.ModelChoiceField(

    required=False,

    empty_label="Must select a Division",

    queryset=Division.objects.none(),

    ...

    def set_division_queryset(self, divqs):

    self.fields["division"].queryset = divqs




    def clean(self):

    cleaned_data = super().clean()

    selected_division = cleaned_data.get('division')

    available_divisions = self.fields['division'].queryset

    if selected_division not in available_divisions:

    self.add_error('division', 'Invalid choice. Please select a valid 
division.')

    return cleaned_data




# views.py

@login_required(redirect_field_name="next")

@ensure_csrf_cookie

def list_import(request, template="list_import.html", context=None):

    ...

    # User model has get_company() method and Company has get_all_divisions()

    divqs = request.user.get_company().get_all_divisions()

    form.set_division_queryset(divqs)

    ...

    if request.method == 'POST':

    form = List_Import(request.POST, request.FILES)

    # because form.is_valid() needs available_divisions and we are

    # not using form.__init__(), we have to send divqs again

    form.set_division_queryset(divqs)

    if form.is_valid():

    ...



Cheers

Mike





Cheers Dave


--
Dave Merrick

TutorInvercargill

http://tutorinvercargill.co.nz

Daves Web Designs

Website https://tutorinvercargill.co.nz/daveswebdesigns/public_html/
_
_Email merrick...@gmail.com

Ph   03 216 2053

Cell 027 3089 169
--
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/CA%2B%3DMcKYDfzhvQ8ueCKKccYX3gcQUmfoX9NXipqf%3DDipsXPzG7g%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CA%2B%3DMcKYDfzhvQ8ueCKKccYX3gcQUmfoX9NXipqf%3DDipsXPzG7g%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/edf8f49f-295e-4ccd-a65f-1cad7b35880e%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: htmx progress indicator problem - might be caching

2023-12-01 Thread Mike Dewhirst

On 2/12/2023 12:19 am, Thomas Couch wrote:

Can I just check I understand the broader requirements here:

* The user completes the form, which includes a list of items, and 
clicks submit
* For each item in the list you want Django to create a new object and 
save it to the database
* It tends to be a very long list and/or each item takes a long time 
to process
* The user should see a progress bar while the server is working its 
way through the list
* When all items have been processed the progress bar should be 
replaced with a done message


If that's the case


Yes it is.



I think you should think about using Celery


I looked at the docs for Celery and hesitate to add so much technology 
just to kick off a progress bar, or actually now a spinner will 
temporarily suffice as mentioned earlier.


It is why I looked at htmx.

I'm now thinking/wondering if a htmx timed execution - say every one or 
two seconds - might call a view which monitors a singleton being updated 
by the main view kicked off by the form's submit button.


What pushes me in that direction is that a singleton could be updated 
with number processed which would be needed if it ever gets to become a 
progress bar.


I think Celery might be overkill until needed for scaling up.

I do accept that Celery is the obvious solution and used everywhere. I 
just need to exhaust potentially simpler methods.


Many thanks Thomas for persisting.

Cheers

Mike

to create tasks for each item. That'll allow your initial htmx post to 
return without being blocked. The htmx endpoint for the progress bar 
can then check completed count for the task group.


On Thursday, November 30, 2023 at 3:42:39 AM UTC Mike Dewhirst wrote:

On 29/11/2023 9:56 pm, Thomas Couch wrote:

Not sure if it's related, but you've got a div inside a p element
there:


That'll probably get corrected by the browser to:
  


It all seems OK to my untrained eye and things stop working if I
play with those elements. I'll take them out later and resort to
css for positioning once it is all working. I didn't know div
inside a p was wrong.






Another thing is, it doesn't look like there's anything linking
the submit button click to the initial htmx


You are right. That button is in an unbound Django forms.Form and
submit triggers the database processing - which is all working
fine returning correct results.

As an enhancement I tried to detect something else to trigger htmx
for a progress indicator.




request, and there's no htmx in the response.


The response is either a downloaded .csv file or a table of comma
separated values for the user to copy and paste into a spreadsheet
- depending on whether the input was pasted into a text field or
uploaded as a file (list or csv).

Sadly, the response doesn't return until the processing is
complete. So it cannot kick off a progress bar.

Perhaps I need to embark on the async ship? That's a strange land
for me.



Have you tried replicating the progress bar example?
https://htmx.org/examples/progress-bar/


I looked at that and felt it was too heavily contrived generating
time increments to expand the bar across the page. It didn't seem
the right place to start.

If I was going to use it (and I would/will) I first need to obtain
progress numbers based on my incrementing count as records are
created in the database. I can easily put them into the user
instance. That works well within the main view called by the
submit button as indicated by print statements as it loops.

I cannot find a way to get the incrementing number across into the
htmx view even though it is the same user in the hx-request - as
indicated by a print statement.

In breaking news, I have tried to get a spinner going to amuse the
user while database records are being created. Not properly
successful. It does start spinning if I click the submit button a
second time but that is less than satisfactory. I have to
experiment after studying the htmx docs some more.

Here is the current form html ... you can see if there IS a
result, the waiting is over and I use htmx to stop the spinner.



    {% csrf_token %}

    {% if form.non_field_errors %}

    {{ form.non_field_errors }}

    {% endif %}

    

    

    {% for field in form %}

    

    

    {{ field }}

    

    {% if field.help_text %}

    

    {{ field.help_text }}

    

    {% endif %}

    {% endfor %}

    

    

    

    {% if not result %}

  

  

  

    

  

    

  

  

    {% else

Re: htmx progress indicator problem - might be caching

2023-11-29 Thread Mike Dewhirst

On 29/11/2023 9:56 pm, Thomas Couch wrote:

Not sure if it's related, but you've got a div inside a p element there:


That'll probably get corrected by the browser to:
  



It all seems OK to my untrained eye and things stop working if I play 
with those elements. I'll take them out later and resort to css for 
positioning once it is all working. I didn't know div inside a p was wrong.






Another thing is, it doesn't look like there's anything linking the 
submit button click to the initial htmx


You are right. That button is in an unbound Django forms.Form and submit 
triggers the database processing - which is all working fine returning 
correct results.


As an enhancement I tried to detect something else to trigger htmx for a 
progress indicator.




request, and there's no htmx in the response.


The response is either a downloaded .csv file or a table of comma 
separated values for the user to copy and paste into a spreadsheet - 
depending on whether the input was pasted into a text field or uploaded 
as a file (list or csv).


Sadly, the response doesn't return until the processing is complete. So 
it cannot kick off a progress bar.


Perhaps I need to embark on the async ship? That's a strange land for me.


Have you tried replicating the progress bar example?
https://htmx.org/examples/progress-bar/


I looked at that and felt it was too heavily contrived generating time 
increments to expand the bar across the page. It didn't seem the right 
place to start.


If I was going to use it (and I would/will) I first need to obtain 
progress numbers based on my incrementing count as records are created 
in the database. I can easily put them into the user instance. That 
works well within the main view called by the submit button as indicated 
by print statements as it loops.


I cannot find a way to get the incrementing number across into the htmx 
view even though it is the same user in the hx-request - as indicated by 
a print statement.


In breaking news, I have tried to get a spinner going to amuse the user 
while database records are being created. Not properly successful. It 
does start spinning if I click the submit button a second time but that 
is less than satisfactory. I have to experiment after studying the htmx 
docs some more.


Here is the current form html ... you can see if there IS a result, the 
waiting is over and I use htmx to stop the spinner.




    {% csrf_token %}

    {% if form.non_field_errors %}

    {{ form.non_field_errors }}

    {% endif %}

    

    

    {% for field in form %}

    

    

    {{ field }}

    

    {% if field.help_text %}

    

    {{ field.help_text }}

    

    {% endif %}

    {% endfor %}

    

    

    

    {% if not result %}

  

  

  

    hx-trigger="click">


  

    

  

  

    {% else %}

  

  

  

    hx-trigger="every 1s">


  

  

  

    {% endif %}

    

    

    

    







{{ result }}




So I have two problems: One is getting the numbers to animate a progress 
bar and two is triggering htmx in parallel with the submit button click.


Many thanks for taking an interest.

Cheers

Mike




On Tuesday, November 28, 2023 at 2:26:20 AM UTC Mike Dewhirst wrote:

I'm trying but failing to get htmx to deliver a progress indication.

The task is creating records in the database for each item in a
list provided by the logged in user.

The view with the submit button collects the list and does the
database insertion. I added a "progress" property to the User
model as follows ...

class User(AbstractUser):

     def __init__(self, *args, **kwargs):

     super().__init__(*args, **kwargs)

     self.progress = ""

     ...

     def set_progress(self, value):

     self.progress = value

     @property

     def get_progress(self):

     return f"{self.progress}"

     ...



In the view I update user.progress with the record insertion
counter and get_progress returns the correct value in the view
itself as proven by print statements. So that part is working.

In the template, I have ...

   

     

   

   


... which in theory should fetch progress every second if the htmx
docs are correct. See https://htmx.org/docs/#polling

This is the htmx view ...

def hx_usr_progress(request):

     progress = request.user.progress

     print(f"\n{progress} ... {request.user}")

     return HttpResponse(mark_safe(f"... {progress}"))


When the import [Submit] button is clicked, the print statement in
hx_usr_progress fires with a blank progress value as per the
User.__init__()

htmx progress indicator problem - might be caching

2023-11-27 Thread Mike Dewhirst

I'm trying but failing to get htmx to deliver a progress indication.

The task is creating records in the database for each item in a list 
provided by the logged in user.


The view with the submit button collects the list and does the database 
insertion. I added a "progress" property to the User model as follows ...


class User(AbstractUser):

    def __init__(self, *args, **kwargs):

    super().__init__(*args, **kwargs)

    self.progress = ""

    ...

    def set_progress(self, value):

    self.progress = value

    @property

    def get_progress(self):

    return f"{self.progress}"

    ...



In the view I update user.progress with the record insertion counter and 
get_progress returns the correct value in the view itself as proven by 
print statements. So that part is working.


In the template, I have ...

  

    

  

  


... which in theory should fetch progress every second if the htmx docs 
are correct. See https://htmx.org/docs/#polling


This is the htmx view ...

def hx_usr_progress(request):

    progress = request.user.progress

    print(f"\n{progress} ... {request.user}")

    return HttpResponse(mark_safe(f"... {progress}"))


When the import [Submit] button is clicked, the print statement in 
hx_usr_progress fires with a blank progress value as per the 
User.__init__() method AND on the page beneath the Submit button the 3 
dots shown above in the last line of the hx_usr_progress() view but 
nothing further even though the main view is definitely incrementing the 
count.


That tells me it is being called at least once instead of every second. 
It should have fired at least 3 or 4 times.


Or if it did perhaps the original response is cached - I don't know.

How can I get this ticking over?

Thanks for any hints.

Cheers

Mike

--
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/2e329e1e-fcfe-47cc-8404-b1e7de1001f6%40dewhirst.com.au.


Re: Management command scheduling options

2023-10-25 Thread Mike Dewhirst

On 25/10/2023 11:49 pm, Adam Stein wrote:

On Wed, 2023-10-25 at 08:24 -0400, Larry Martell wrote:
On Wed, Oct 25, 2023 at 5:35 AM Mike Dewhirst  
wrote:


Ahmedrufai

I looked at APScheduler and like Celery it is too much of a 
sledgehammer for my tiny problem.


I ended up using cron to launch the command each day. It works 
perfectly.


My task now is to find a way to automate establishment of that 
crontab entry when the project is migrated to a new server.


How are new servers deployed? How many new servers will be deployed?
If it's a one off thing you are doing manually, you just have to
remember to do it. If there are many, then you should use a tool like
terraform or octopus, or something similar and have that do it.



I use django-crontab myself for cron jobs. That way, I can add or 
update easily during deployment. Maybe you can make use of that so you 
can keep everything in your project.


This looks excellent, Adam. Thanks. I'll report back in due course.

Mike




--
Adam (a...@csh.rit.edu)

--
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/6433ead4bf666e3ef52ac742df731e0cf7c66743.camel%40csh.rit.edu 
<https://groups.google.com/d/msgid/django-users/6433ead4bf666e3ef52ac742df731e0cf7c66743.camel%40csh.rit.edu?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/bc18ce9a-8ac8-41a6-adce-c36dbe9efee4%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Management command scheduling options

2023-10-25 Thread Mike Dewhirst

On 25/10/2023 11:24 pm, Larry Martell wrote:

On Wed, Oct 25, 2023 at 5:35 AM Mike Dewhirst  wrote:

Ahmedrufai

I looked at APScheduler and like Celery it is too much of a sledgehammer for my 
tiny problem.

I ended up using cron to launch the command each day. It works perfectly.

My task now is to find a way to automate establishment of that crontab entry 
when the project is migrated to a new server.

How are new servers deployed? How many new servers will be deployed?
If it's a one off thing you are doing manually, you just have to
remember to do it.


It is a one-off but I'm assuming it will be someone else needing to do 
it rather than me.



  If there are many, then you should use a tool like
terraform or octopus, or something similar and have that do it.




--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/0a765bc2-ab30-4925-b43f-e31ae2c8b13b%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Management command scheduling options

2023-10-25 Thread Mike Dewhirst
AhmedrufaiI looked at APScheduler and like Celery it is too much of a 
sledgehammer for my tiny problem. I ended up using cron to launch the command 
each day. It works perfectly.My task now is to find a way to automate 
establishment of that crontab entry when the project is migrated to a new 
server.CheersMike--(Unsigned mail from my phone)
 Original message From: Ahmedrufai Otuoze 
 Date: 24/10/23  00:11  (GMT+10:00) To: 
django-users@googlegroups.com Subject: Re: Management command scheduling 
options Hi Mike,I've implemented something similar to what you mentioned 
lately. I used this Python package called APScheduler to schedule and run 
database intensive queries behind the scene and then cache the result for my 
users to fetch from making their experience super fast.The APScheduler can be 
configured to run at any interval daily, weekly, monthly or any customized 
interval you require. It's a game changer and a quick win for Windows based OS 
as they don't support the use of Celery or any other Linux based schedulers 
without WSL.Do let me know if you're interested in my implementation, I'm open 
to show you.Regards On Mon, Oct 23, 2023, 11:09 AM Mike Dewhirst 
 wrote:

  


  
  
Django docs suggest cron or Windows scheduler for running management
commands.

I would like instead to build an internal Django based scheduler -
because after migrating to a new server, setting up the new cron
task will be forgotten. 

Is there a daily (approximately) event in a Django project I can
hook into and test the date? 

The task is somewhat database intensive and needs to run quarterly
for some users, monthly for most and weekly for others depending on
their preferences. 

Ideas anyone?

Thanks

Mike

-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

  




-- 
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/7b29b24b-64f0-4f93-9a43-5d8f5e242b57%40dewhirst.com.au.




-- 
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/CAA50JbfV1VXkpeoXLEcsOp2j0WeXM5dfKH9BbQKLAeipnOhvsQ%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/6538e144.170a0220.b001a.862aSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Management command scheduling options

2023-10-23 Thread Mike Dewhirst

On 23/10/2023 11:48 pm, Rodrigo Bistolfi wrote:

Use devops for setting up cron jobs as part of the deployment process.


My requirement is very lightweight and cron would definitely work for 
me. Both Celery and APScheduler seem like overkill.


How would you ensure the cron job was established on a new server?

Mike

You could also use something like 
https://apscheduler.readthedocs.io/en/3.x/ if you wanna something OS 
independent.


El lun, 23 oct 2023 a las 7:08, Mike Dewhirst 
() escribió:


Django docs suggest cron or Windows scheduler for running
management commands.

I would like instead to build an internal Django based scheduler -
because after migrating to a new server, setting up the new cron
task will be forgotten.

Is there a daily (approximately) event in a Django project I can
hook into and test the date?

The task is somewhat database intensive and needs to run quarterly
for some users, monthly for most and weekly for others depending
on their preferences.

Ideas anyone?

Thanks

Mike

-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

-- 
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/7b29b24b-64f0-4f93-9a43-5d8f5e242b57%40dewhirst.com.au

<https://groups.google.com/d/msgid/django-users/7b29b24b-64f0-4f93-9a43-5d8f5e242b57%40dewhirst.com.au?utm_medium=email_source=footer>.

--
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/CAMQZ-Rf5sRxEZNEoGxHjh6f88FGsWHgTqCp%2BbUY4%2BH4GX3_7Kg%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAMQZ-Rf5sRxEZNEoGxHjh6f88FGsWHgTqCp%2BbUY4%2BH4GX3_7Kg%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/8feecef1-d78b-4db1-a01f-15c08d7035c2%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


Management command scheduling options

2023-10-23 Thread Mike Dewhirst
Django docs suggest cron or Windows scheduler for running management 
commands.


I would like instead to build an internal Django based scheduler - 
because after migrating to a new server, setting up the new cron task 
will be forgotten.


Is there a daily (approximately) event in a Django project I can hook 
into and test the date?


The task is somewhat database intensive and needs to run quarterly for 
some users, monthly for most and weekly for others depending on their 
preferences.


Ideas anyone?

Thanks

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/7b29b24b-64f0-4f93-9a43-5d8f5e242b57%40dewhirst.com.au.


OpenPGP_signature.asc
Description: OpenPGP digital signature


RE: Strange bug with Firefox

2023-10-14 Thread Mike Dewhirst
I've seen that behaviour too. The solution is to use Chrome if you want to view 
source. I assume Mozilla's caching design is somewhat aggressive and ignores 
the URL's view source prefix. Mike--(Unsigned mail from my phone)
 Original message From: 'Simon Connah' via Django users 
 Date: 15/10/23  02:05  (GMT+10:00) To: 
django-users@googlegroups.com Subject: Strange bug with Firefox Hi,I have a 
strange issue that affects the latest stable version of Firefox and the latest 
Firefox Developer Edition as well. I'm making a custom user and am just setting 
all the forms up. I can login with the user and when I go to the password 
change form it is displayed correctly in Firefox but if I right click and click 
view source it shows a completely different form. On the other hand when I use 
Chrome and Chrome Developer Edition it shows the correct form and works exactly 
as intended. I've never seen anything like this before. I thought it was a 
problem with a browser extension so I removed them all (apart from Bitwarden) 
and completely cleared the history but none of that seems to have fixed the 
issue.I'm at a loss. Can someone suggest what might be going on here? As I said 
it works fine in Chrome.Simon.-- 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/zT7ozAu9QZo4FQ9XwBRiSTIc2ZwYA3eknb3Z-NJpibp6KIw3I9HmI0vOjhwtoyUux2qIu_Zqa3dI3ecbdkQKWdHmT86PsXQ378hsYbrp3gw%3D%40protonmail.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/652b1f50.170a0220.7028d.4758SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


RE: Postgres connection error

2023-10-08 Thread Mike Dewhirst
There is a step missing somewhere if migrations has incorrect permissions.If 
Django is correctly installed - as it seems to be - then your settings must be 
deficient somewhere. The first migration ought to create Django's own tables 
etc even if you haven't written any of your own models.I would start again and 
follow the docs exactly. Perhaps follow the tutorial.Also, you can happily keep 
things super-simple if you plan to throw everything away and start fresh after 
learning the ropes.Good luckMike--(Unsigned mail from my phone)
 Original message From: Pranav Sawant 
 Date: 9/10/23  01:24  (GMT+10:00) To: Django users 
 Subject: Postgres connection error Hey all, I 
am new to djangoand i want to connect to postgresql what I have doing:At 
postgres plsqlCREATE DATABASE knapds;

CREATE USER system WITH PASSWORD 'password';

ALTER ROLE system SET client_encoding TO 'utf8';

ALTER ROLE system SET default_transaction_isolation TO 'read committed';

ALTER ROLE system SET timezone TO 'Africa/Johannesburg';

GRANT ALL PRIVILEGES ON DATABASE knapds TO system;

\q
in settings.py:'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'knapds','USER': 'system','PASSWORD': 'password',   
 'HOST': 'localhost','PORT': '',and I am getting this 
error:django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create 
the django_migrations table (permission denied for schema publicLINE 1: CREATE 
TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...Please help



-- 
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/a9eeca40-befa-4a0b-b1fc-db78924e6218n%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/65232d78.050a0220.d36b2.8891SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Reference data while testing - interesting

2023-10-05 Thread Mike Dewhirst
I have an interesting testing problem which requires someone smarter 
than me.


I want to prove correctness of multiple outcomes from multiple 
regulatory computations based on, among other things, international 
lists of assessed chemicals and their hazards.


Hazards include both human health and environmental - land, air and 
aquatic as well as the food chain from microbes on up.


Once a qualified chemistry expert has agreed that our (Django) software 
has correctly categorised a chemical according to local regulations and 
those lists, we need to lock in that behaviour which, as already 
indicated, is based on reference data.


To do so, we wrote a (Django) management command to auto-generate a set 
of tests for that chemical which proves all those outcomes are as 
expected whenever we run our tests. That protects against unintended 
side effects as we develop but not against changes in the reference data.


The interesting problem is that things change. Every day, new 
discoveries are made which indicate individual chemicals or chemical 
groups are actually more hazardous than previously thought.


Reference data fixtures are infeasible (dozens of tables, hundreds of 
thousands of records) because they are enormous and therefore 
unmanageable for frequent testing. Even if we did use fixtures, if not 
continuously refreshed, tests just keep passing.


We need tests to fail when change happens so that our software can 
notify users that they have to rethink what they might be doing with a 
particular chemical or group of chemicals in order to avoid further 
damaging the planet or its inhabitants.


The base reference data is updated when things change. These are 
necessarily manual processes based on subscribing to emails to receive 
notifications from local and international regulators about upcoming 
changes, calls for public input and eventually publishing of actual 
adjustments and deadline dates. That is a continuous process.


I put this scenario to ChatGPT and prompted it down the db_alias path[1] 
of keeping the reference data portion of the database available 
read-only during testing so that tests are directly exposed to the 
source of truth. It came up with a complicated/complex solution which, 
due to underconfidence, I have not tried.


I cannot believe this is the first time a reference data source has been 
needed during Django testing so I'm asking here if anyone has a solution.


Many thanks

Cheers

Mike


- - - - -
[1] Given the specific requirements of your testing scenario, where you 
need to access read-only reference data from a production database while 
emptying the regular testing database between tests, you can achieve 
this by using Django's |db_alias| feature. You can configure a separate 
database alias for read-only access to the reference data.


Here's how you can set it up:

1.

   *Configure a Separate Database for Reference Data*:

   In your Django settings (|settings.py|), define a new database
   configuration for the reference data. You can specify this in the
   |DATABASES| setting using a different alias:

#

|DATABASES = { 'default': { # Your regular database configuration for 
testing 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'test_db', # 
Other settings... }, 'reference_db': { # Configuration for the reference 
data database (read-only) 'ENGINE': 'django.db.backends.postgresql', 
'NAME': 'reference_db', # Other settings... }, } |


Replace |'reference_db'| with an appropriate alias for your reference data.

#

*Create a Router for Reference Data*:

Next, you can create a database router to determine which database to 
use based on the model being accessed. In your Django project, create a 
Python module (e.g., |routers.py|) and define a database router class:


#

|class ReferenceDataRouter: def db_for_read(self, model, **hints): # Use 
the 'reference_db' alias for models that access reference data if 
model._meta.app_label == 'your_app_label': return 'reference_db' return 
None def db_for_write(self, model, **hints): # Prevent writes to the 
'reference_db' database if model._meta.app_label == 'your_app_label': 
return None return 'default' def allow_migrate(self, db, app_label, 
model_name=None, **hints): # Allow migrations only on the default 
database if db == 'default': return True return False |


Replace |'your_app_label'| with the actual app label containing your 
reference data models.


#

*Add the Router to Your Settings*:

In your Django settings (|settings.py|), add the reference data router 
to the |DATABASE_ROUTERS| setting:


#

|DATABASE_ROUTERS = ['your_project.routers.ReferenceDataRouter'] |

#

*Write Tests That Access Reference Data*:

In your test cases, you can access the reference data by using the 
|using| method to specify the database alias:


4.

   |from django.test import TestCase from your_app.models import
   YourReferenceModel class YourTestCase(TestCase): def
   test_access_reference_data(self): reference_objects

Re: Reference data while testing

2023-10-03 Thread Mike Dewhirst
Thank you but unfortunately, none of the suggestions are appropriate. 
Here is more information.


We have a complex system where - in the opinion of a chemical expert - 
it is possible to state that a particular chemical risk profile has been 
correctly calculated by the software.


In addition to molecular properties, base and comparison information 
used bythe software to perform those risk calculations - at multiple 
end-points - is imported from many international regulatory authorities 
and stored in (Django/Postgres) reference tables. There are hundreds of 
thousands of records all of which are (somewhat) regularly updated when 
those authorities notify changes.


Once an expert confirms a risk profile for a particular chemical we use 
a Django management command to generate a new Django test in our test 
harness. The objective is to run that/those tests in our regular testing 
regime to prove the software - and reference data - is still OK.


If the reference data or the software changes, we want to discover any 
discrepancies from the expert opinion.


Automating creation of those tests (underpinning the expert opinion) is 
important because it is the only way I can see to stay sane. I am not a 
chemical expert.


I was hoping someone could suggest a way - perhaps using dbalias - to 
allow read-only use of the reference portion of the database. Another 
thought I had was to load a dump of the reference data prior to starting 
the tests but I believe Django would simply wipe that after the first test.


Factory boy is really good but cannot provide accurate reference 
information. I can see SQLAlchemy might be a solution but I'd prefer to 
stay within Django/Postgres.


Still looking ...

Thanks

On 4/10/2023 5:26 am, Alessandro Madruga Correia wrote:



On Mon, Oct 2, 2023 at 11:30 PM Mike Dewhirst  
wrote:



This is probably in the docs so please drop me a link if you can.

My project has fifteen or more tables of reference data which
determine how the software behaves and therefore is critical to
unit testing.

Fixtures are unworkable and I  need to respond to the actual
reference data.

How can i do real lookups (read-only) during tests?


You can use Factory Boy https://factoryboy.readthedocs.io/en/stable/


--
  ,= ,-_-. =. [] Alessandro Madruga Correia
 ((_/)o o(\_))  [http://counter.li.org]       Debian User# 342751
   `-'(. .)`-'    "O fanatismo é a única forma de força de vontade
       \_/        acessível aos fracos." (Friedrich Nietzsche)

--
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/CAOofabfi%3DErk535OgDo5nPU%3DwM1pVp%3D93muppuGMt1c6M2vSZA%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAOofabfi%3DErk535OgDo5nPU%3DwM1pVp%3D93muppuGMt1c6M2vSZA%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/d50a02f1-bcf9-7ac7-0488-95cc1d54eccd%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Reference data while testing

2023-10-02 Thread Mike Dewhirst
This is probably in the docs so please drop me a link if you can.My project has 
fifteen or more tables of reference data which determine how the software 
behaves and therefore is critical to unit testing.Fixtures are unworkable and I 
 need to respond to the actual reference data.How can i do real lookups 
(read-only) during tests?ThanksMike--(Unsigned mail from my phone)

-- 
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/651b7cc1.170a0220.54b8d.3ebcSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


RE: Splitting views.py and urls.py into a directory rather than single files

2023-09-18 Thread Mike Dewhirst
I like the following method because it lets me start a project with a single 
file of views per app and then later when it grows, split it into named files 
in a 'views' directory - without needing to adjust other code which imports 
them.1. Create a views directory in the app dir2. Create __init__.py in the new 
directory3. Move the monster views.py into ./views renaming it to original.py 
or something similar.4. Split original.py into as many useful individual views 
files as desired - including separate utilities file(s) etc.5. In __init__.py 
import each view used by your urls.py using lines like ...   from .filename 
import ViewNameObviously, multiple views can be grouped into the same file so 
long as they are imported into views.__init__.py6. In urls.py you can then say 
...    import appname.views as appname_views... if that's not what you do 
already!--(Unsigned mail from my phone)
 Original message From: 'Simon Connah' via Django users 
 Date: 18/9/23  22:27  (GMT+10:00) To: 
django-users@googlegroups.com Subject: Splitting views.py and urls.py into a 
directory rather than single files Hi,I have an app which has a lot of views 
and URLs and keeping them in just one file makes it really hard to manage 
because it is so long. I'd like to make a views and URLs folder which will 
allow me to break up views and URLs into different categories but I'm not sure 
what the best way to go about doing that is.Can someone point me in the right 
direction please?Thank you!Simon.-- 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/4svI0xN0uu53BvHzhG9Aa1qvI61v1qPlQOhkOLpaJPRXX1Jysfu-BOmrFlBsDOfHfKRHwTaXJNmKFApZ1W13jQLdpVvXQDEPdWq87T-ILR8%3D%40protonmail.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/6508e58d.0c0a0220.6ef59.78b3SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: What to learn after Django, Node.js or React?1

2023-09-10 Thread Mike Dewhirst

On 10/09/2023 4:40 pm, abu yahya Diab wrote:

Hi guys,

I'm a django developer(junior), do you advice me to learn Node.js, or 
React to be full Stack developer.


Neither. At least not before you have looked at HTMX



Thanks.
Abdulrahman --
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/c11fd593-2a62-4501-998e-d247ed452b28n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/0d52e41c-329f-12df-3566-a8cf76380f1c%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: table bank_app_bank has no column named DOB

2023-08-21 Thread Mike Simkins
Did you regenerate and rerun the migrations ??


python manage.py makemigrations
python manage.py migrate



> On 21 Aug 2023, at 09:46, meenu loranz  wrote:
> 
> Thank you for your response...i changed DOB to dob...but still showing me the 
> error...
> OperationalError at /add/ table bank_app_bank has no column named dob 
> Request Method: 
> POST 
> Request URL: 
> http://127.0.0.1:8000/add/ 
> Django Version: 
> 4.2 
> Exception Type: 
> OperationalError 
> Exception Value: 
> table bank_app_bank has no column named dob 
> Exception Location: 
> C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\sqlite3\base.py,
>  line 328, in execute 
> Raised during: 
> bank_app.views.add_form 
> Python Executable: 
> C:\Users\Admin\AppData\Local\Programs\Python\Python39\python.exe 
> Python Version: 
> 3.9.0 
> Python Path: 
> ['C:\\Users\\Admin\\myprojects\\banking_system\\bank_project', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\lib', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39', 
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages']
>  
> Server time: 
> Mon, 21 Aug 2023 08:44:34 +
> 
> On Saturday, August 19, 2023 at 10:49:13 PM UTC+5:30 RANGA BHARATH JINKA 
> wrote:
>> Hi,
>> 
>> Try changing DOB to small letters dob and run the migrations again. 
>> 
>> All the best 
>> 
>> Thanks and Regards
>> 
>> J. Ranga Bharath
>> Cell: 9110334114
>>
>> 
>> On Sat, 19 Aug 2023, 9:18 pm ivan harold, > wrote:
>>> https://stackoverflow.com/questions/68269165/why-django-is-not-detecting-my-table-column
>>> 
>>> Try reading this article, it may help you.
>>> 
>>> On Saturday, August 19, 2023 at 3:05:57 AM UTC+8 meenu loranz wrote:
 from django.contrib.auth.models import User
 from django.db import models
 from django.urls import reverse
 # Create your models here.
 
 class bank(models.Model):
 name = models.CharField(max_length=255)
 DOB = models.DateField()
 age = models.IntegerField()
 gender = models.CharField(max_length=10)
 phone_no = models.CharField(max_length=10)
 mail_id = models.EmailField(max_length=25)
 address = models.CharField(max_length=255)
 district = models.CharField(max_length=100)
 branch = models.CharField(max_length=100)
 account_type = models.CharField(max_length=100)
 # materials_provided = models.CharField(max_length=100)
 
 
 def __str__(self):
 return self.name
 
 This is my model.py page. And i can see this table and all fields in my 
 database. But while running show me the operational error that no column 
 named DOB. How can i fix this?
 
>>> 
>>> 
>> 
>>> -- 
>>> 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/1aaf9e41-e11c-43bb-bda9-17b609814059n%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/3166bd2f-a556-49ce-9813-6794a3aac838n%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/2040EB80-115E-4242-8582-90C62B6878F3%40gmail.com.


Re: Road Map for a newbie

2023-08-18 Thread Mike Dewhirst

On 18/08/2023 10:59 am, Sebastian Jung wrote:

Hello,

At the beginning i read much tutorials about function based django. It 
is on beginning a little bit easier because you understand how a 
list-, create-/update- and deleteview works. For little project this 
approach is fine. I waste with function based aproach too much time 
because i extend my own project after and after and then when for 
example i find a mistake in one listview most other listviewa from 
another models i must fix. So it is hugh amount of bugfixes.


Then i learn class based approach this i a little bit harder because 
you don't know which classes exists and what of this classes what 
makes. It exists in Internet one website where you find perfectly what 
classes exists and much classes have comments what class does. Since i 
use class based views i am very happy.


For a newbie, the learning curve should be as shallow as possible - "a 
little bit harder" might be too much.


BTW ... https://spookylukey.github.io/django-views-the-right-way/



On beginning i have for every listview and for every form a own 
template. Also i find same problem like in function based approach... 
Often i want to extend all of listview Templates with same feature and 
then i fix muuuch templates. Then i build me self for list-, create-, 
updateview one template where i can insert every model. Since that i 
am very happy.


I learn how i can make own widgets.

I learn how i can makes my own filter/tags for templates.

I disagree mike with his tip to take django documentation because this 
manual is very nice when you search for a specific thing. But for 
learning as beginner this is not right approach.


I give you know my tip: learn short how you writes function based 
listview/deleteview/createview and updateview then when you know how 
it works don't waste time to go deeper in function based. Learn 
instant usage of classes based which class, method exists and what it 
makes and how you override this methods... there exists in internet 
much tutorials also in class based views


When you know this writes me then i give you more tipps

Last thing there exists a Webpage for django simple is better then 
complex. There you find much good tutorials veeery good describe and 
very usefull for example django and Ajax...


Begin with your own project and extend it after and after and if yoz 
have questions then writes me...


Good luck

Mike Dewhirst  schrieb am Fr., 18. Aug. 2023, 
02:24:


On 17/08/2023 7:24 pm, Tesfaye Yimam wrote:

Hello all,

This is my second day of learning Django. I am comfortable with
python (the basics and the OOP).
I wanted to have some guidance from this community to learn
Djanog by taking small steps in a consistent way.
Any one who has a road-map, especially if you tried it and worked
for you,  that will greatly help me in the learning process of
Django. So, please drop me a message here.
I'm happy to be here.


Welcome!

There would be no better way to start than working through the
tutorial in the docs, step by step ...

https://docs.djangoproject.com/en/4.2/

Afterwards, you should decide/specify your own project and when
the spec is more or less settled you should set it up as a fresh
project and make it happen.

The critical part of learning Django is the specification of what
you want. Personally, I keep the (excellent) docs permanently open
in my browser so I can research how to achieve what I want to happen.

You will discover that Django takes a couple of different paths
and you need to choose. Both are valid but I chose functional
views rather than class-based views.

My reasons were that functional views seem simpler and allowed me
absolute flexibility. I felt that class-based views while
brilliant were more difficult for me. YMMV.

Also, Django now allows async programming. That's a bit too
advanced for me - at least until it becomes necessary.

Good luck



-- 
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/e9724d36-e07b-42b2-8902-6a8294c695b5n%40googlegroups.com

<https://groups.google.com/d/msgid/django-users/e9724d36-e07b-42b2-8902-6a8294c695b5n%40googlegroups.com?utm_medium=email_source=footer>.



-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

-- 
You received this message because you are subscribed to the Google

Groups "Django users&

Re: Case-insensitive non-deterministic collation

2023-08-17 Thread Mike Dewhirst

On 18/08/2023 12:34 pm, Vitor Freitas wrote:

Hi Mike,

On Tue, Aug 15, 2023 at 4:30 AM Mike Dewhirst  
wrote:


Found a great article by Adam Johnson written in February ...


https://adamj.eu/tech/2023/02/23/migrate-django-postgresql-ci-fields-case-insensitive-collation/


This is a great reference. It helped me out with the migration from 
postgresql ci fields to db collations.


Everything about this is new for me as well. I'm sure the db collation 
strategy is more powerful and I can see the benefits.


However, the postgresql ci fields were way easier to implement.


I agree



Right now I'm testing it out on a smaller project. One problem that 
I'm currently facing is that exposing some fields that have the 
db_collation configuration to django-filters or to Django Admin search 
parameters are causing an exception:


NotSupportedError
nondeterministic collations are not supported for LIKE



Yes. I got the same error ...

https://code.djangoproject.com/ticket/33901   closed Bug (fixed)

From the discussion in that ticket I got the impression that maybe I 
should postpone using collations until after I upgrade from Django 3.2 
to 4.2.


I was using a very similar collation.

I have already removed my CI fields so I won't put them back.

I manually (__iexact) check to prevent duplicate names for users and 
companies and the sorting is not critical for me at the moment.


I think I'll avoid collations for now. I'm running out of brainspace and 
don't have the time to do the exhaustive research needed to correctly 
define a bug for a new ticket. I'll press on with workarounds until I'm 
absolutely forced to upgrade to 4.2 and hope that some generous soul has 
sorted it out by then.


The fact is it is new for PostgreSQL as well as Django so it isn't 
surprising to see such wrinkles.


Cheers

Mike



This is the collation that I'm using:

CreateCollation(
  "case_insensitive",
  provider="icu",
  locale="und-u-ks-level2",
  deterministic=False,
)


Anyway, all the icu / und-u-ks stuff look a little bit confusing. It 
would be good to have some guidelines or some quick recipes on the 
docs that would help us out making the migration :-)


Kind regards,
Vitor



Covers all the bases.

Thank you Adam

Cheers

Mike

    On 7/08/2023 12:28 pm, Mike Dewhirst wrote:

On 6/08/2023 9:17 pm, Chetan Ganji wrote:

Thanks Chetan

I have seen that 'icu' and 'und-whatever...' in various places on
the web - so it seems to be spreading - but I haven't had the
brainspace to understand it yet.

I'll try an experiment with provider='C' and locale='C' because
that is how most of my databases are already established. If that
passes my tests I might move on to other things.

From what I can see, PostgreSQL are likely to deprecate citext as
inelegant. That would be why Django has deprecated it.

Thanks again.

Mike


Check this out.
https://gist.github.com/hleroy/2f3c6b00f284180da10ed9d20bf9240a

# According to Django documentation, it’s preferable to use
non-deterministic collations
# instead of the citext extension for Postgres > 12.
# Example migation to create the case insensitive collation
class Migration(migrations.Migration):
operations = [
CreateCollation(
'case_insensitive',
provider='icu',
locale='und-u-ks-level2',
deterministic=False
)
]
# Example model using the new db_collation parameter introduced
with Django 3.2
class Tag(models.Model):
name = models.CharField(max_length=50,
db_collation='case_insensitive')
class Meta:
ordering = ['name']
def __str__(self):
return self.name

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


    On Sun, Aug 6, 2023 at 12:32 PM Mike Dewhirst
 wrote:

On 5/08/2023 7:58 pm, Chetan Ganji wrote:

Hi Mike

RE: The primary use case is to establish case-insensitivity
when checking names - including usernames, company names
and abbreviations/acronyms.

I dont know anything about db_collation.


Me neither


Below 4 lookups should solve most common scenarios.


Actually that was how I did it originally. I switched to
using the PostgreSQL CI field because it is all done in the
database - much faster - and my code is much reduced and
therefore fewer possibilities for bugs etc.

Judging from the Django release notes and the PostgreSQL
docs there should be a straightforward answer to my
question. Researching the correct answer is complex enough
to make me ask here first.

Cheers

Mike



https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gma

Re: Road Map for a newbie

2023-08-17 Thread Mike Dewhirst

On 17/08/2023 7:24 pm, Tesfaye Yimam wrote:

Hello all,

This is my second day of learning Django. I am comfortable with python 
(the basics and the OOP).
I wanted to have some guidance from this community to learn Djanog by 
taking small steps in a consistent way.
Any one who has a road-map, especially if you tried it and worked for 
you,  that will greatly help me in the learning process of Django. So, 
please drop me a message here.

I'm happy to be here.


Welcome!

There would be no better way to start than working through the tutorial 
in the docs, step by step ...


https://docs.djangoproject.com/en/4.2/

Afterwards, you should decide/specify your own project and when the spec 
is more or less settled you should set it up as a fresh project and make 
it happen.


The critical part of learning Django is the specification of what you 
want. Personally, I keep the (excellent) docs permanently open in my 
browser so I can research how to achieve what I want to happen.


You will discover that Django takes a couple of different paths and you 
need to choose. Both are valid but I chose functional views rather than 
class-based views.


My reasons were that functional views seem simpler and allowed me 
absolute flexibility. I felt that class-based views while brilliant were 
more difficult for me. YMMV.


Also, Django now allows async programming. That's a bit too advanced for 
me - at least until it becomes necessary.


Good luck



--
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/e9724d36-e07b-42b2-8902-6a8294c695b5n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/ca6aa1dd-f7a0-702c-e317-f8998cda53a4%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Timezone issue in when storing in DB

2023-08-15 Thread Mike Dewhirst

On 16/08/2023 12:35 pm, Madhusudhan Reddy wrote:

Hi All,

I am trying to store the date with the timezone.
for example, my servers are in Mumbai, when my servers are trying to 
get the time of America/Detroit. it is not able to get proper time


pytz is deprecated. You should consider using zoneinfo (install tzdata 
first) instead.


import zoneinfo
from datetime import datetime

tz = "America/Detroit"
rightnow = datetime.now(zoneinfo.ZoneInfo(tz))
datetime_in_tz = "%s-%s-%s %s:%02d:%02d" % (
    rightnow.year,
    rightnow.month,
    rightnow.day,
    rightnow.hour,
    rightnow.minute,
    rightnow.second,
)
print(f'{tz}:  {datetime_in_tz}')







Here is the snippet and details
Screenshot from 2023-08-16 08-00-21.png
def get_created_at(timezone):
local_tz = pytz.timezone(timezone)
print(datetime.utcnow())
created_at = 
local_tz.localize(datetime.utcnow()).astimezone(tz=pytz.timezone(timezone))

return created_at


--
Best regards,
Madhusudhan
+91 90007 79457
Gmail  | LinkedIn 




--
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/CAFwQctLvw9KinV8a%3DVTysi_NSNJfu3rodBoBPCY5Cih_ih-DGQ%40mail.gmail.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/ed002508-9995-eb11-9b99-9e2ea8b99885%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: AWS Polly w/ strictly Django and Javascript

2023-08-15 Thread Mike Dewhirst

On 15/08/2023 7:26 am, Lightning Bit wrote:
Hello, how could one go about integrating AWS Polly voices onto a 
website utilizing only Django, HTML, CSS, and Javascript? I do not 
want to use "node.js" or "react".


Look closely at htmx.org




--
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/8c6489f9-8a0e-4fc2-af6d-de25169c1a15n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/b7919749-8663-3f01-64c8-9b6994e100ba%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Case-insensitive non-deterministic collation

2023-08-15 Thread Mike Dewhirst

Found a great article by Adam Johnson written in February ...

https://adamj.eu/tech/2023/02/23/migrate-django-postgresql-ci-fields-case-insensitive-collation/

Covers all the bases.

Thank you Adam

Cheers

Mike

On 7/08/2023 12:28 pm, Mike Dewhirst wrote:

On 6/08/2023 9:17 pm, Chetan Ganji wrote:

Thanks Chetan

I have seen that 'icu' and 'und-whatever...' in various places on the 
web - so it seems to be spreading - but I haven't had the brainspace 
to understand it yet.


I'll try an experiment with provider='C' and locale='C' because that 
is how most of my databases are already established. If that passes my 
tests I might move on to other things.


From what I can see, PostgreSQL are likely to deprecate citext as 
inelegant. That would be why Django has deprecated it.


Thanks again.

Mike


Check this out.
https://gist.github.com/hleroy/2f3c6b00f284180da10ed9d20bf9240a

# According to Django documentation, it’s preferable to use 
non-deterministic collations

# instead of the citext extension for Postgres > 12.
# Example migation to create the case insensitive collation
class Migration(migrations.Migration):
operations = [
CreateCollation(
'case_insensitive',
provider='icu',
locale='und-u-ks-level2',
deterministic=False
)
]
# Example model using the new db_collation parameter introduced with 
Django 3.2

class Tag(models.Model):
name = models.CharField(max_length=50, db_collation='case_insensitive')
class Meta:
ordering = ['name']
def __str__(self):
return self.name

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sun, Aug 6, 2023 at 12:32 PM Mike Dewhirst  
wrote:


On 5/08/2023 7:58 pm, Chetan Ganji wrote:

Hi Mike

RE: The primary use case is to establish case-insensitivity when
checking names - including usernames, company names and
abbreviations/acronyms.

I dont know anything about db_collation.


Me neither


Below 4 lookups should solve most common scenarios.


Actually that was how I did it originally. I switched to using
the PostgreSQL CI field because it is all done in the database -
much faster - and my code is much reduced and therefore fewer
possibilities for bugs etc.

Judging from the Django release notes and the PostgreSQL docs
there should be a straightforward answer to my question.
Researching the correct answer is complex enough to make me ask
here first.

Cheers

    Mike


https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, Aug 5, 2023 at 1:35 PM Mike Dewhirst
 wrote:

The following warning triggered a bit of research which
looks like a significant amount of study will be required to
find the collation needed ...


django.contrib.postgres.fields.CICharField is deprecated.
Support for it (except in historical migrations) will be
removed in Django 5.1.
    HINT: Use CharField(db_collation="…") with a
case-insensitive non-deterministic collation instead.


Does anyone have experience they would like to share? What
replaces that ellipsis?

The primary use case is to establish case-insensitivity when
checking names - including usernames, company names and
abbreviations/acronyms. Maybe there is a better way to
handle that?

This is my typical PostgreSQL database spec ...

CREATE DATABASE 
    WITH
    OWNER = miked
    ENCODING = 'UTF8'
    LC_COLLATE = 'C'
    LC_CTYPE = 'C'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1
    IS_TEMPLATE = False;

Many thanks for any help

Cheers

Mike

-- 
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/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au

<https://groups.google.com/d/msgid/django-users/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au?utm_medium=email_source=footer>.

-- 
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/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com

<https://groups.google.com/d/msgid/django-users/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7

Re: Case-insensitive non-deterministic collation

2023-08-09 Thread Mike Dewhirst
 My tests stopped working so I have decided to abandon case-insensitive 
fields and do it all manually. 

Thanks everyone.

Cheers

Mike

On Monday, August 7, 2023 at 12:29:28 PM UTC+10 Mike Dewhirst wrote:

> On 6/08/2023 9:17 pm, Chetan Ganji wrote:
>
> Thanks Chetan
>
> I have seen that 'icu' and 'und-whatever...' in various places on the web 
> - so it seems to be spreading - but I haven't had the brainspace to 
> understand it yet.
>
> I'll try an experiment with provider='C' and locale='C' because that is 
> how most of my databases are already established. If that passes my tests I 
> might move on to other things.
>
> From what I can see, PostgreSQL are likely to deprecate citext as 
> inelegant. That would be why Django has deprecated it.
>
> Thanks again.
>
> Mike
>
> Check this out.
> https://gist.github.com/hleroy/2f3c6b00f284180da10ed9d20bf9240a
>
> # According to Django documentation, it’s preferable to use 
> non-deterministic collations
> # instead of the citext extension for Postgres > 12.
> # Example migation to create the case insensitive collation
> class Migration(migrations.Migration):
> operations = [
> CreateCollation(
> 'case_insensitive',
> provider='icu',
> locale='und-u-ks-level2',
> deterministic=False
> )
> ]
> # Example model using the new db_collation parameter introduced with 
> Django 3.2
> class Tag(models.Model):
> name = models.CharField(max_length=50, db_collation='case_insensitive')
> class Meta:
> ordering = ['name']
> def __str__(self):
> return self.name 
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji@gmail.com
> http://ryucoder.in
>
>
> On Sun, Aug 6, 2023 at 12:32 PM Mike Dewhirst  
> wrote:
>
>> On 5/08/2023 7:58 pm, Chetan Ganji wrote:
>>
>> Hi Mike
>>
>> RE: The primary use case is to establish case-insensitivity when checking 
>> names - including usernames, company names and abbreviations/acronyms. 
>>
>> I dont know anything about db_collation. 
>>
>>
>> Me neither
>>
>> Below 4 lookups should solve most common scenarios. 
>>
>>
>> Actually that was how I did it originally. I switched to using the 
>> PostgreSQL CI field because it is all done in the database - much faster - 
>> and my code is much reduced and therefore fewer possibilities for bugs etc.
>>
>> Judging from the Django release notes and the PostgreSQL docs there 
>> should be a straightforward answer to my question. Researching the correct 
>> answer is complex enough to make me ask here first.
>>
>> Cheers
>>
>> Mike
>>
>> https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups
>>
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji@gmail.com
>> http://ryucoder.in
>>
>>
>> On Sat, Aug 5, 2023 at 1:35 PM Mike Dewhirst  
>> wrote:
>>
>>> The following warning triggered a bit of research which looks like a 
>>> significant amount of study will be required to find the collation needed 
>>> ...
>>>
>>>
>>> django.contrib.postgres.fields.CICharField is deprecated. Support for it 
>>> (except in historical migrations) will be removed in Django 5.1.
>>> HINT: Use CharField(db_collation="…") with a case-insensitive 
>>> non-deterministic collation instead.
>>>
>>>
>>> Does anyone have experience they would like to share? What replaces that 
>>> ellipsis?
>>>
>>> The primary use case is to establish case-insensitivity when checking 
>>> names - including usernames, company names and abbreviations/acronyms. 
>>> Maybe there is a better way to handle that?
>>>
>>> This is my typical PostgreSQL database spec ...
>>>
>>> CREATE DATABASE 
>>> WITH
>>> OWNER = miked
>>> ENCODING = 'UTF8'
>>> LC_COLLATE = 'C'
>>> LC_CTYPE = 'C'
>>> TABLESPACE = pg_default
>>> CONNECTION LIMIT = -1
>>> IS_TEMPLATE = False;
>>>
>>> Many thanks for any help
>>>
>>> Cheers
>>>
>>> Mike
>>>
>>> -- 
>>> 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/2eccab9e-e296-

Re: Case-insensitive non-deterministic collation

2023-08-06 Thread Mike Dewhirst

On 6/08/2023 9:17 pm, Chetan Ganji wrote:

Thanks Chetan

I have seen that 'icu' and 'und-whatever...' in various places on the 
web - so it seems to be spreading - but I haven't had the brainspace to 
understand it yet.


I'll try an experiment with provider='C' and locale='C' because that is 
how most of my databases are already established. If that passes my 
tests I might move on to other things.


From what I can see, PostgreSQL are likely to deprecate citext as 
inelegant. That would be why Django has deprecated it.


Thanks again.

Mike


Check this out.
https://gist.github.com/hleroy/2f3c6b00f284180da10ed9d20bf9240a

# According to Django documentation, it’s preferable to use 
non-deterministic collations

# instead of the citext extension for Postgres > 12.
# Example migation to create the case insensitive collation
class Migration(migrations.Migration):
operations = [
CreateCollation(
'case_insensitive',
provider='icu',
locale='und-u-ks-level2',
deterministic=False
)
]
# Example model using the new db_collation parameter introduced with 
Django 3.2

class Tag(models.Model):
name = models.CharField(max_length=50, db_collation='case_insensitive')
class Meta:
ordering = ['name']
def __str__(self):
return self.name

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sun, Aug 6, 2023 at 12:32 PM Mike Dewhirst  
wrote:


On 5/08/2023 7:58 pm, Chetan Ganji wrote:

Hi Mike

RE: The primary use case is to establish case-insensitivity when
checking names - including usernames, company names and
abbreviations/acronyms.

I dont know anything about db_collation.


Me neither


Below 4 lookups should solve most common scenarios.


Actually that was how I did it originally. I switched to using the
PostgreSQL CI field because it is all done in the database - much
faster - and my code is much reduced and therefore fewer
possibilities for bugs etc.

Judging from the Django release notes and the PostgreSQL docs
there should be a straightforward answer to my question.
Researching the correct answer is complex enough to make me ask
here first.

Cheers

    Mike


https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, Aug 5, 2023 at 1:35 PM Mike Dewhirst
 wrote:

The following warning triggered a bit of research which looks
like a significant amount of study will be required to find
the collation needed ...


django.contrib.postgres.fields.CICharField is deprecated.
Support for it (except in historical migrations) will be
removed in Django 5.1.
    HINT: Use CharField(db_collation="…") with a
case-insensitive non-deterministic collation instead.


Does anyone have experience they would like to share? What
replaces that ellipsis?

The primary use case is to establish case-insensitivity when
checking names - including usernames, company names and
abbreviations/acronyms. Maybe there is a better way to handle
that?

This is my typical PostgreSQL database spec ...

CREATE DATABASE 
    WITH
    OWNER = miked
    ENCODING = 'UTF8'
    LC_COLLATE = 'C'
    LC_CTYPE = 'C'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1
    IS_TEMPLATE = False;

Many thanks for any help

Cheers

Mike

-- 
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/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au

<https://groups.google.com/d/msgid/django-users/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au?utm_medium=email_source=footer>.

-- 
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/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com

<https://groups.google.com/d/msgid/django-users/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com?utm_medium=email_source=footer>.



-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure

Re: Case-insensitive non-deterministic collation

2023-08-06 Thread Mike Dewhirst

On 5/08/2023 7:58 pm, Chetan Ganji wrote:

Hi Mike

RE: The primary use case is to establish case-insensitivity when 
checking names - including usernames, company names and 
abbreviations/acronyms.


I dont know anything about db_collation.


Me neither


Below 4 lookups should solve most common scenarios.


Actually that was how I did it originally. I switched to using the 
PostgreSQL CI field because it is all done in the database - much faster 
- and my code is much reduced and therefore fewer possibilities for bugs 
etc.


Judging from the Django release notes and the PostgreSQL docs there 
should be a straightforward answer to my question. Researching the 
correct answer is complex enough to make me ask here first.


Cheers

Mike


https://docs.djangoproject.com/en/4.2/ref/models/querysets/#field-lookups



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Sat, Aug 5, 2023 at 1:35 PM Mike Dewhirst  
wrote:


The following warning triggered a bit of research which looks like
a significant amount of study will be required to find the
collation needed ...


django.contrib.postgres.fields.CICharField is deprecated. Support
for it (except in historical migrations) will be removed in Django
5.1.
    HINT: Use CharField(db_collation="…") with a
case-insensitive non-deterministic collation instead.


Does anyone have experience they would like to share? What
replaces that ellipsis?

The primary use case is to establish case-insensitivity when
checking names - including usernames, company names and
abbreviations/acronyms. Maybe there is a better way to handle that?

This is my typical PostgreSQL database spec ...

CREATE DATABASE 
    WITH
    OWNER = miked
    ENCODING = 'UTF8'
    LC_COLLATE = 'C'
    LC_CTYPE = 'C'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1
    IS_TEMPLATE = False;

Many thanks for any help

Cheers

Mike

-- 
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/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au

<https://groups.google.com/d/msgid/django-users/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au?utm_medium=email_source=footer>.

--
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/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAMKMUjuxfeV5m4QiPz1jEyh7fRobqZn7SCp4dnXnjrSOBirh7Q%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/e3d57fb4-5899-a04c-f2b8-f39591c978c7%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Case-insensitive non-deterministic collation

2023-08-05 Thread Mike Dewhirst
The following warning triggered a bit of research which looks like a 
significant amount of study will be required to find the collation 
needed ...



django.contrib.postgres.fields.CICharField is deprecated. Support for it 
(except in historical migrations) will be removed in Django 5.1.
    HINT: Use CharField(db_collation="…") with a case-insensitive 
non-deterministic collation instead.



Does anyone have experience they would like to share? What replaces that 
ellipsis?


The primary use case is to establish case-insensitivity when checking 
names - including usernames, company names and abbreviations/acronyms. 
Maybe there is a better way to handle that?


This is my typical PostgreSQL database spec ...

CREATE DATABASE 
    WITH
    OWNER = miked
    ENCODING = 'UTF8'
    LC_COLLATE = 'C'
    LC_CTYPE = 'C'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1
    IS_TEMPLATE = False;

Many thanks for any help

Cheers

Mike

--
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/2eccab9e-e296-55e0-05de-e8d4cf708262%40dewhirst.com.au.


Re: Need to trigger action on 4th Saturday of the month

2023-07-25 Thread Mike Dewhirst

On 25/07/2023 10:47 pm, M Cain wrote:
User application permits registration for upcoming events.  User wants 
the registration page to be open on 4th Saturday of every month at 9am 
ET as the events are very popular with limited capacity and made 
available on first come first serve basis.


Django application is deployed on Heroku. Heroku scheduler works 
except it doesn't 'guarantee' running at specific time (but near the 
requested time).


Would celery-redis be better for this?

Any other suggestions?


I wrote baklabel.py to produce grandfather back-up label fragments such 
as "mon", "tue" etc and "fri_1", "fri_2" etc as well as month-end and 
year-end label fragments. It has no dependencies and accepts args so you 
could change "fri_1" etc to "sat_1".


If you called it at 9am ET every day it would tell you "sat_4" once per 
month.


There are options to nullify month-end and year-end which you would need 
to employ to prevent them from spoiling "sat_4" if it fell on a 
month-end or year-end.


pip install baklabel

https://github.com/mdewhirst/baklabel

Cheers

Mike



Thank you in advance for replying.
--
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/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/c1af9c55-b2dd-4ab2-af1d-ce5dec4c4ca6n%40googlegroups.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/9cc2d261-a402-62ae-384e-69187b535777%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: how to convert to Django 3 or 4

2023-06-02 Thread Mike Dewhirst

On 3/06/2023 11:57 am, john fabiani wrote:

aware there is no longer the "patterns"


urlpatterns = [
    ...
]

It is just a list nowadays.

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/21946589-28bb-ff69-9e29-17a1d59ec851%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: how to convert to Django 3 or 4

2023-06-02 Thread Mike Dewhirst

On 3/06/2023 7:20 am, john fabiani wrote:

Hi everyone,

I am tasked with updating/upgrading a very old Django web site - I 
believe it is 1.7.  I need convert and need what is required.

Thanks in advance.


I need to convert the following:



Because all your urls are regular expressions, you can replace them all 
with re_path. A quick and dirty starter might be to replace the next 
line and see where that gets you ...



from django.conf.urls import patterns, include, url


from django.urls import include
from django.urls import re_path as url

If that gets you a bit further there is a lot more to do. Really the 
only methodical way forward is to upgrade Django a step at a time after 
studying the release notes for the next version.


Finally you should decide whether to get rid of re_path (as url) and 
refactor to use path. Depends on you view of the future.



from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',
    # Examples:
    url(r'reg4/$', 'register.views.reg4', name='reg4'),
    url(r'reg3/$', 'register.views.reg3', name='reg3'),
    url(r'reg2/$', 'register.views.reg2', name='reg2'),
    #url(r'reg1/$', 'register.views.reg1', name='reg1'),
    url(r'reg1/$', 'register.views.reg1', name='reg1'),
    #url(r'^$', 'register.views.home', name='home'),
    url(r'reg/$', 'register.views.home', name='home'),
    url(r'get_courts/(\d+)$', 'register.views.get_courts', 
name='get_courts'),
    url(r'get_courses/(\d+)$', 'register.views.get_courses', 
name='get_courses'),
    url(r'autoschedule/', 'register.views.autoschedule', 
name='autoschedule'),
    url(r'get_cities/(\d+)$', 'register.views.get_cities', 
name='get_cities'),
    url(r'get_classes/(\d+)$', 'register.views.get_classes', 
name='get_classes'),
    url(r'get_cities2/(\d+)/(\d+)/$', 'register.views.get_cities2', 
name='get_cities2'),
    url(r'get_classes2/(\d+)/(\d+)/$', 'register.views.get_classes2', 
name='get_classes2'),

    url(r'rejected/$', 'register.views.rejected', name='rejected'),
    url(r'finished/$', 'register.views.finished', name='finished'),

    ##url(r'^$', 'profiles.views.home', name='home'),
    #url(r'^contact/$', 'register.views.home', name='contact'),
    #url(r'^about/$', 'register.views.about', name='about'),
    #url(r'^profile/$', 'register.views.user_profile', name='profile'),
    #url(r'^checkout/$', 'checkout.views.checkout', name='checkout'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
) + static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)

What is required?

--
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/8f8a68b4-a3c5-a10d-8246-2ef41635b406%40jfcomputer.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/9f972f6c-9a19-8da0-c2fb-2a0a56237f24%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Run Python Code on Front-End

2023-05-22 Thread Mike Dewhirst

On 23/05/2023 10:22 am, Muhammad Juwaini Abdul Rahman wrote:
How can one run Python code from the backend that triggers on the 
front-end upon clicking a button on a certain page?




Have a close look at htmx.

It doesn't run Python but will replace any targeted HTML element with 
output from Python (or any other code) running on the backend.


You would otherwise need a Python interpreter running in the browser. 
But who wants that with all the security issues entailed?


Htmx is a javascript library which enhances HTML itself. Your HTML in 
your template then calls your Django views directly to replace any part 
of a page with the result.


If htmx had been around earlier, all those famous js frameworks would 
never have been needed. It is a life saver.


M

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/0fefeee4-530f-6097-ad2b-594dfbf1dd9d%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Is programming in Django intellectually satisfactory

2023-04-26 Thread Mike Dewhirst

On 26/04/2023 10:18 am, Julius Chesoni wrote:
 Hi guys, I find programming in the abstract very interesting and full 
of intellectual benefits similar to those acquired from Mathematics. 
However, when it comes to programming languages I find the practice of 
programming very tiresome since there are very many functions in the 
documentations. I am not able to enjoy reading the documentations even 
though I am eager to know how to master the particular language. How 
do you guys manage to be masters in languages like Django since I see 
some great people contributing to every question. This amazes me.


Django could be thought of as a language. In fact it is a "framework" - 
a jargon word which probably needs decoding but I don't have time.


Django is written in Python. Python started as a teaching language for 
primary school kids but it has sufficient sophistication for masters of 
Python to build almost anything.


The two main benefits of Python are:

 * ease of learning for beginners and
 *  powerful enough for complex projects to be built faster than most 
other languages.


Python was chosen by Django's original authors for a web project and 
they built libraries of useful routines which they eventually 
open-sourced as Django to make website development much more satisfying 
for other developers.


The intellectual satisfaction - and therefore main attraction of Django 
- comes from being able to do anything. There are plenty of guidelines 
and "best practices" but absolutely no frustrating restrictions. If you 
find a web problem you want to solve, I would be very surprised if it 
couldn't be solved with Django.


Many would argue front-end problems cannot be solved with a back-end 
server architecture like Django but nowadays, with htmx, that argument 
is lost.


So, to answer your question in the abstract, Django is used as the 
interface "language" between a database and the user with a web browser. 
It contains an "Object Relational Mapper" (ORM). The mathematics of 
relational database management systems (RDBMS) should pique your 
interest. The language of RDBMS is Structured Query Language (SQL) but 
because Django has its ORM you no longer need to learn SQL. The Django 
library of queries comes to the rescue.


Django, HTML+htmx and CSS therefore is all you really need to build a 
completely fuctional and intellectually satisfying website.


My advice to you is to find a small project you really want to do and 
get started one step at a time.


Someone else said practice practice practice. That is completely 
correct. You need to start somewhere if you are really interested.


With practice you can tackle ever more interesting projects.

Good luck.



Kind regards
Julius
--
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/CANOu6a8axU1sL6GXveq7CufyTm1JWX-6aZ7FU4fJVqLq9M0GAQ%40mail.gmail.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/17f6b06b-546f-069b-4487-d740b5bd7267%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


University chemical management system

2023-03-31 Thread Mike Dewhirst
Does anyone know of an existing Django based chemical inventory 
management system for a large university?


Thanks

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/bfe75d67-a06d-910b-4930-69ca09d9ba3f%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: how i use django in blockchain.

2023-03-23 Thread Mike Dewhirst

On 23/03/2023 6:02 pm, Shubham Lahane wrote:
im currently working on my BE project. my project topic is 'secure 
EFIR using Blockchain'. actually im working on wesbite that is 
decentralized in nature. once user fill the FIR form, in backend smart 
contracts will run and i want to show transaction hash to user who 
filled the FIR form. how i can integrate brownie and django so that i 
can show transaction hash to user ??


1. Put the hash into the context dict in your view for example, 
context["hash"] = r"""{0}""".format(hash)


2. Insert the hash in your template somewhere {{ hash }}

Just like any other data you wish to display



.plz help me i have very less time.
--
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/fffba5d6-005c-42fd-b384-c163e12b0849n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Your
email software can handle signing.

--
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/7c46cbe5-0e28-a273-907b-91482b7c386f%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


RE: Need help

2023-02-21 Thread Mike Dewhirst
https://explore.transifex.com/django/django-docs/Might helpM--(Unsigned mail 
from my phone)
 Original message From: Emmanuel Wilfried Ilboudo 
 Date: 22/2/23  13:08  (GMT+10:00) To: 
Django users  Subject: Need help Hi all !!!
I would like to have the Django documentation in French to learn offline.
I'm in a place where internet access is a real problem.
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/9b8662d1-22fb-4d81-bc27-9216ef6d0a9dn%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/63f59a10.050a0220.7eb71.f696SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: deleting a user model that extends abstractuser

2023-02-03 Thread Mike Dewhirst

On 4/02/2023 7:58 am, d07 wrote:


I am trying to delete a user object that belongs to a User class that 
extends AbstractUser. The extending class looks something like this:


class User(AbstractUser):
    name = CharField("Name", blank=True, max_length=255)
    def __str__(self):
        return self.username

When I try to delete a user like this:

user = User.objects.get(pk=self.user_id) user.delete()

The user object is not deleted (at least from checking the user table 
in the database). Other models that have on_delete=models.CASCADE to 
my custom user class are deleted as expected but the actual user 
object is NOT deleted.




Here's a guess ...

The models.CASCADE seems to be working and everything seems fine. So 
when does the vital object at the head of the cascade get deleted?


It has to be when the delete transaction gets committed to the database 
and all the loose ends are cleaned up.


Therefore, some loose end somewhere is preventing transaction completion.

How clean is your User model?


When I try

user = User.objects.get(pk=self.user_id)
user.delete()
user.delete() # adding extra delete()

i.e. an extra user.delete(), then the user object is deleted, but also 
raises an exception (/which is not unexpected/)


User object can't be deleted because its id attribute is set to None.



That says the database needs to clean up some loose ends for which it 
needs the id of the User being deleted.


Does the User model have a foreign key with on_delete = models.SET_NULL

Transactions need to be committed successfully or they roll back.

Good luck

M

but the user object along with other objects with FK relationship to 
the User class are deleted (as expected). Sounds like the object was 
"deleted" the first time I called user.delete()? But I can still see 
the row in my user's table.


Not sure if related but, I see that the type of User to delete 
is  not 
the User model class.


So, I'm trying to delete a user object that extends abstractuser class 
but I'm having to call delete() twice on the object, which is not 
normal (I think), how can I get rid of this?


AbstarctUser is from from django.contrib.auth.models import AbstractUser

--
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/2f4ffda8-2eac-4546-a8fa-276bfb38df8fn%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/cd703c26-1a23-56e2-0a6c-30bcdefa186d%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Uptime all the time

2023-01-22 Thread Mike Dewhirst

On 23/01/2023 5:12 am, j harvey wrote:
I am looking for ideas on how to keep my app running all the time, 
even when uploading data that will replace the current data. Some of 
these tables will have a million rows or more. Ideas?


Almost a question for the PostgreSQL users list - assuming that is your 
DBMS. It will depend on so many aspects of what is actually happening 
during/after upload.


In theory, if you upload data in a single transaction - or even many 
transactions - there will be no impact on users until the moment of 
committing.


In practice, theory might be inadequate.



Thanks in advance,

John
--
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/8087a569-f379-4e0e-b3fa-92d281abad69n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/4bec18f0-42c2-675a-cc5a-c079add41a81%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: ModelAdmin

2023-01-04 Thread Mike Dewhirst

Satyajit

I'm speaking for myself here.

I'm not comfortable with dilution of list content with what appears to 
be a competing Whatsapp group.


In particular, this thread is one to which I have contributed and if you 
kidnap the thread you cut me out of my conversation.


In general, if you take conversations away from the list you hide them 
from core Django devs who are then deprived of information coming from 
users. Django users are exactly equal to customers of an enterprise and 
if an enterprise doesn't hear customer feedback it risks becoming 
irrelevant and possibly going out of business.


I think Whatsapp, Slack etc are all very appropriate places for private 
conversations. Not so much for a user mutual-support mailing list like 
this one.


 Thanks for understanding

Cheers

Mike

On 5/01/2023 3:31 pm, Satyajit Barik wrote:
Yes. It does. ModelAdmin classes can define list filters that appear 
in the right sidebar of the change list page of the admin.
For more reference: 
https://docs.djangoproject.com/en/4.1/ref/contrib/admin/filters/


For this topic related join our WhatsApp group: https://bit.ly/3oJtfcf

Regards,
Satyajit

On Thu, Jan 5, 2023 at 9:09 AM Mike Dewhirst  
wrote:


On 5/01/2023 5:43 am, Mario St-Gelais wrote:

Hello group, first post here.
Quick question.  Can capabilities of ModelAdmin such as
list_filter or search_fields be used outside of the admin interface?


Have you looked at htmx?

https://www.simplecto.com/htmx-and-the-list_editable-in-django-admin/

htmx is very sweet. Essentially, you can replace a named  on an existing page by calling whatever view
you care to write. Your view might have to borrow from the Django
code if you really like what it does.

Digressing slightly, I discovered that you can make a link in html
using the  entity and just replace href="/search" with
hx_trigger="/hx_search", for example, so that the existing css
works and it looks like an ordinary link.

Cheers

mike



I want a view that would allow non logged users to search a site
through checkboxes and some search fields possibly and obviously,
the way this is implemented in the admin view is rather good.

Alternatively, what approach can be used in django?

Thanks
Mario
-- 
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/CAFmF6_vLzivA3Y-sskqmcZzsuLc27opP6xW3m3wvmV7nepu%3D-A%40mail.gmail.com

<https://groups.google.com/d/msgid/django-users/CAFmF6_vLzivA3Y-sskqmcZzsuLc27opP6xW3m3wvmV7nepu%3D-A%40mail.gmail.com?utm_medium=email_source=footer>.



-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

-- 
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/6b16042c-dd2b-9757-2edc-1bbae0e7d911%40dewhirst.com.au

<https://groups.google.com/d/msgid/django-users/6b16042c-dd2b-9757-2edc-1bbae0e7d911%40dewhirst.com.au?utm_medium=email_source=footer>.

--
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/CANd-%2BoD5Nrj1OxsSHvy8nVru5u1Hw1yWzJ19k7tAoEZOoovQBg%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CANd-%2BoD5Nrj1OxsSHvy8nVru5u1Hw1yWzJ19k7tAoEZOoovQBg%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/83079885-1bb7-81a1-75d9-753d195af702%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: ModelAdmin

2023-01-04 Thread Mike Dewhirst

On 5/01/2023 5:43 am, Mario St-Gelais wrote:

Hello group, first post here.
Quick question.  Can capabilities of ModelAdmin such as list_filter or 
search_fields be used outside of the admin interface?


Have you looked at htmx?

https://www.simplecto.com/htmx-and-the-list_editable-in-django-admin/

htmx is very sweet. Essentially, you can replace a named id="whatever"> on an existing page by calling whatever view you 
care to write. Your view might have to borrow from the Django code if 
you really like what it does.


Digressing slightly, I discovered that you can make a link in html using 
the  entity and just replace href="/search" with 
hx_trigger="/hx_search", for example, so that the existing css works and 
it looks like an ordinary link.


Cheers

mike



I want a view that would allow non logged users to search a site 
through checkboxes and some search fields possibly and obviously, the 
way this is implemented in the admin view is rather good.


Alternatively, what approach can be used in django?

Thanks
Mario
--
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/CAFmF6_vLzivA3Y-sskqmcZzsuLc27opP6xW3m3wvmV7nepu%3D-A%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAFmF6_vLzivA3Y-sskqmcZzsuLc27opP6xW3m3wvmV7nepu%3D-A%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/6b16042c-dd2b-9757-2edc-1bbae0e7d911%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Card-Payment Integration.

2023-01-02 Thread Mike Dewhirst

On 3/01/2023 3:12 pm, Harshwardhan Waghela wrote:

Other Then Stripe ?


Speak to your favourite bank and see what they offer. That's what I did 
before going to Stripe.


Otherwise google for local gateway providers.



On Monday, 2 January 2023 at 18:05:34 UTC+5:30 Mike Dewhirst wrote:

I use Stripe. It works well.

Mike



-- 
(Unsigned mail from my phone)




 Original message 
From: Harshwardhan Waghela 
Date: 2/1/23 22:40 (GMT+10:00)
To: Django users 
Subject: Card-Payment Integration.

Can Anyone Can Suggest me of Card-Payment Integration(means Visa,
Master-Card...etc)  with Documentation.
-- 
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/a6d08f33-f1eb-4d1a-8247-c17236859d59n%40googlegroups.com

<https://groups.google.com/d/msgid/django-users/a6d08f33-f1eb-4d1a-8247-c17236859d59n%40googlegroups.com?utm_medium=email_source=footer>.

--
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/a37322f4-2354-46ea-8618-6626f7dcb812n%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/a37322f4-2354-46ea-8618-6626f7dcb812n%40googlegroups.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/9cb82857-9a09-4da3-1ca6-792a39271d7e%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


RE: Card-Payment Integration.

2023-01-02 Thread Mike Dewhirst
I use Stripe. It works well.Mike--(Unsigned mail from my phone)
 Original message From: Harshwardhan Waghela 
 Date: 2/1/23  22:40  (GMT+10:00) To: Django users 
 Subject: Card-Payment Integration. Can Anyone 
Can Suggest me of Card-Payment Integration(means Visa, Master-Card...etc)  with 
Documentation.



-- 
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/a6d08f33-f1eb-4d1a-8247-c17236859d59n%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/63b2cf72.c80a0220.b8076.0caeSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Apache and mod_wsgi with django

2023-01-01 Thread Mike Dewhirst

On 2/01/2023 1:44 pm, pankaj palmate wrote:


Hi i am using Apache with mod_wsgi.i want to serve 5000 users at a 
time.how many processes and threads should I use in order to serve 
5000 connections concurrently...in wsgi daemon process ?


I can't answer the question because it is above my pay-grade. However, I 
have recently (successfully) adjusted my own mpm-event settings based on 
advice from the Apache support list ... us...@httpd.apache.org


They are very friendly but will probably ask you for more information 
including which mpm module you are using. If you enable apache-status 
you will be able to gather most of that info before asking for help.


Cheers

Mike


--
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/CAPyMU1LG_JWo_4st5mjZ5Ps%2BMdJoBnHQHCya1CK-Qm7AZjGYnw%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAPyMU1LG_JWo_4st5mjZ5Ps%2BMdJoBnHQHCya1CK-Qm7AZjGYnw%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/325ed00e-7fc6-c65c-7c7f-ca9c6b6b328b%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


RE: Django deployment on local host

2022-12-14 Thread Mike Dewhirst
The essential difference between local and remote is how you access the 
website.You need all the same resources including web server, database server 
etc but you might need a local DNS so local users can find the server by 
name.You can always test using hosts files on the test machines so they can 
find the server.Good luckM--(Unsigned mail from my phone)
 Original message From: Tinashe Mphisa 
 Date: 15/12/22  01:35  (GMT+10:00) To: Django users 
 Subject: Django deployment on local host I have 
been looking for clear article or video on how to deploy Django on local server 
with no luck. i would appreciate it if I can get a link or any kind of help.



-- 
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/11c3a6b1-9d18-43c0-b4f9-1e132689637an%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/639a49ce.250a0220.58ac1.8432SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Apache2 hates my Django deployment method

2022-12-11 Thread Mike Dewhirst

On 12/12/2022 11:32 am, Jason wrote:
https://serverfault.com/questions/1058677/apache-2-4-37-reload-causes-error-scoreboard-is-full-not-at-maxrequestworkers 



and

https://serverfault.com/questions/1084635/apache-mpm-workers-stuck-in-g-gracefully-finishing-growing-scoreboard-is-fu

seems reloading is problematic because

>When you gracefully reload Apache, you're terminating the containing 
process. What is happening here is Apache is making each thread wait 
until all the threads in the containing process have completed prior 
to restarting the container PID.


> So, in you're case, you've got a single thread contained in all the 
processes in that list that is still busy or stuck somehow.




I had seen the first of those links and abandoned reload in logrotate. I 
now copytruncate instead with no restarting. That was advice from the 
very friendly Apache list.


I don't think I have the brainspace to identify the actual cause. My 
best strategy (I think) is to restart on redeployment and wait for for 
Apache to self-heal. If it is Apache's fault.


Thanks for jumping in

Cheers

Mike



On Sunday, December 11, 2022 at 5:45:40 PM UTC-5 Mike Dewhirst wrote:

On 12/12/2022 1:33 am, Jason wrote:

AFAIK, restarting apache process on deployment is standard, is
there a reason you don't want to do that?


With Ubuntu 2020.04 and the version of Apache which came with
that, reload worked fine and I always thought that was the right
way to redeploy.

The newer version of Apache or probably more particularly the
newer mpm-event module had a bug whereby ...

[Sun Dec 11 02:09:18.196035 2022] [mpm_event:error] [pid 893:tid
139808992921472] AH03490: scoreboard is full, not at
MaxRequestWorkers.Increase ServerLimit.

... and that consumed resources until Apache crashed. Hence my
questions on the Apache list which resulted in adjusted mpm-event
config recommended by gurus.

Currently, reloading triggers the above error about once per second.

Then issuing a restart generates ...

[Sun Dec 11 02:15:28.478942 2022] [mpm_event:notice] [pid 893:tid
139808992921472] AH00492: caught SIGWINCH, shutting down gracefully
[Sun Dec 11 02:15:31.840212 2022] [core:warn] [pid 893:tid
139808992921472] AH00045: child process 909 still did not exit,
sending a SIGTERM

... and that [core:warn] message repeats for the same pid but a
bunch of different child processes for however many there are
until it changes to a [core:error] for the same bunch ...

[Sun Dec 11 02:15:37.883824 2022] [core:error] [pid 893:tid
139808992921472] AH00046: child process 7868 still did not exit,
sending a SIGKILL
[Sun Dec 11 02:15:50.816477 2022] [mpm_event:notice] [pid
45163:tid 140392171792256] AH00489: Apache/2.4.52 (Ubuntu)
OpenSSL/3.0.2 mod_wsgi/4.9.0 Python/3.10 configured -- resuming
normal operations

... until Apache restarts.

So I reckon there is something wrong.

I now restart Apache on redeployment but it still goes through the
[core:warn] and [core:error] before restarting if I have done a
reload.

I guess I'll give up reloading.

Thanks for responding

Cheers

    Mike




Templates are picked up because they're not evaluated and
compiled, rather they're processed dynamically so any changes
there do not require a restart.

On Saturday, December 10, 2022 at 9:34:42 PM UTC-5 Mike Dewhirst
wrote:

Server Version: Apache/2.4.52 (Ubuntu 2022.04) OpenSSL/3.0.2
mod_wsgi/4.9.0 Python/3.10
Server MPM: event
Server Built: 2022-09-30T04:09:50

Apache *seems* to hang onto something and eventually crashes
after I reload it after deploying a Python file.

That is either scripted (delete site and re-export from repo)
or drag and drop a py file using Filezilla on Windows.

It *seems* ok if I redeploy html templates.

I have asked on the Apache mailing list and the consensus
seems to be that something is "hogging" the mpm-event workers
and I have to figure out what and solve that.

The only solution I have is to restart Apache.

I have to think this is happening in other projects so I'm
wondering if anyone has solved this?

Thanks for any feedback

Mike

-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

-- 
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 d

Re: Apache2 hates my Django deployment method

2022-12-11 Thread Mike Dewhirst

On 12/12/2022 1:33 am, Jason wrote:
AFAIK, restarting apache process on deployment is standard, is there a 
reason you don't want to do that?


With Ubuntu 2020.04 and the version of Apache which came with that, 
reload worked fine and I always thought that was the right way to redeploy.


The newer version of Apache or probably more particularly the newer 
mpm-event module had a bug whereby ...


[Sun Dec 11 02:09:18.196035 2022] [mpm_event:error] [pid 893:tid 
139808992921472] AH03490: scoreboard is full, not at 
MaxRequestWorkers.Increase ServerLimit.


... and that consumed resources until Apache crashed. Hence my questions 
on the Apache list which resulted in adjusted mpm-event config 
recommended by gurus.


Currently, reloading triggers the above error about once per second.

Then issuing a restart generates ...

[Sun Dec 11 02:15:28.478942 2022] [mpm_event:notice] [pid 893:tid 
139808992921472] AH00492: caught SIGWINCH, shutting down gracefully
[Sun Dec 11 02:15:31.840212 2022] [core:warn] [pid 893:tid 
139808992921472] AH00045: child process 909 still did not exit, sending 
a SIGTERM


... and that [core:warn] message repeats for the same pid but a bunch of 
different child processes for however many there are until it changes to 
a [core:error] for the same bunch ...


[Sun Dec 11 02:15:37.883824 2022] [core:error] [pid 893:tid 
139808992921472] AH00046: child process 7868 still did not exit, sending 
a SIGKILL
[Sun Dec 11 02:15:50.816477 2022] [mpm_event:notice] [pid 45163:tid 
140392171792256] AH00489: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 
mod_wsgi/4.9.0 Python/3.10 configured -- resuming normal operations


... until Apache restarts.

So I reckon there is something wrong.

I now restart Apache on redeployment but it still goes through the 
[core:warn] and [core:error] before restarting if I have done a reload.


I guess I'll give up reloading.

Thanks for responding

Cheers

Mike




Templates are picked up because they're not evaluated and compiled, 
rather they're processed dynamically so any changes there do not 
require a restart.


On Saturday, December 10, 2022 at 9:34:42 PM UTC-5 Mike Dewhirst wrote:

Server Version: Apache/2.4.52 (Ubuntu 2022.04) OpenSSL/3.0.2
mod_wsgi/4.9.0 Python/3.10
Server MPM: event
Server Built: 2022-09-30T04:09:50

Apache *seems* to hang onto something and eventually crashes after
I reload it after deploying a Python file.

That is either scripted (delete site and re-export from repo) or
drag and drop a py file using Filezilla on Windows.

It *seems* ok if I redeploy html templates.

I have asked on the Apache mailing list and the consensus seems to
be that something is "hogging" the mpm-event workers and I have to
figure out what and solve that.

The only solution I have is to restart Apache.

I have to think this is happening in other projects so I'm
wondering if anyone has solved this?

Thanks for any feedback

Mike

-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/8853bc85-97fb-48d7-af94-0807f777c0fan%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/8853bc85-97fb-48d7-af94-0807f777c0fan%40googlegroups.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/24597590-6cdd-9c25-2b7d-1b9327a2d028%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Apache2 hates my Django deployment method

2022-12-10 Thread Mike Dewhirst
Server Version: Apache/2.4.52 (Ubuntu 2022.04) OpenSSL/3.0.2 
mod_wsgi/4.9.0 Python/3.10

Server MPM: event
Server Built: 2022-09-30T04:09:50

Apache *seems* to hang onto something and eventually crashes after I 
reload it after deploying a Python file.


That is either scripted (delete site and re-export from repo) or drag 
and drop a py file using Filezilla on Windows.


It *seems* ok if I redeploy html templates.

I have asked on the Apache mailing list and the consensus seems to be 
that something is "hogging" the mpm-event workers and I have to figure 
out what and solve that.


The only solution I have is to restart Apache.

I have to think this is happening in other projects so I'm wondering if 
anyone has solved this?


Thanks for any feedback

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/768c5823-5096-000c-3e4d-c8ada5aaa210%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Django model design best practice guidance

2022-12-08 Thread Mike Dewhirst

On 9/12/2022 3:04 am, Joshua Corlin wrote:
Ive not used this field before so if it is im having a hard time 
wrapping my head around how this would work in this use case.


Many-to-many is simple to conceptualise if you realise it is not a field 
in the table you think it is.


It is actually a separate table containing two foreign key fields. One 
points to a particular record in your target table and the other points 
to a particular target record in either the same table or a different table.


Django makes this easy by defining a many-to-many field in the model 
definition but it actually uses that definition to create the separate 
relationship table (the "through" table) with two foreign keys.


The nice thing is the "through" model can also be included explicitly 
among other model definitions. Doing so lets you add other fields to it 
which can describe the relationship.


It is definitely worthwhile studying the docs to get this right because 
it lets you model the real world much more accurately.


There are migration gotchas when you explicitly define models which have 
already been created implicitly with Django's many-to-many field but 
there are documented solutions.


Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/4ea3a261-b8cc-ff61-5e95-1fd31041b4ab%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: ALLOWED_HOSTS error

2022-11-21 Thread Mike Dewhirst

On 22/11/2022 11:54 am, Lakshyaraj Dash wrote:

Put only domain names in allowed hosts


Thank you - that makes me feel better.

Can you tell me why the error is appearing? Is it some sort of hacking 
attempt?





On Tue, Nov 22, 2022, 06:22 Mike Dewhirst  wrote:

My Django log is full of these errors ...

ERROR
/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py
TIME: 2022-09-28 00:13:17,204 MSG:
exception.py:response_for_exception:99 Invalid HTTP_HOST header:
'111.222.333.444'. You may need to add '111.222.333.444' to
ALLOWED_HOSTS.

... where '111.222.333.444. is the correct IP address of the FQDN
for the site.

Everything seems to be working but these errors are just consuming
disk space.

My reading of the docs
https://docs.djangoproject.com/en/3.2/ref/settings/#allowed-hosts
does not indicate the IP address should be in ALLOWED_HOSTS.

My inclination is it shouldn't be there.

What is the correct way to deal with this?

Many thanks

Mike

-- 
Signed email is an absolute defence against phishing. This email has

been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

-- 
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/053ab6dc-21c0-7914-1638-435838ace9ed%40dewhirst.com.au

<https://groups.google.com/d/msgid/django-users/053ab6dc-21c0-7914-1638-435838ace9ed%40dewhirst.com.au?utm_medium=email_source=footer>.

--
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/CAF7qQgBPyX3vM%2Bt_AKGruABhybCq3LnbXxSRZs%2BnV-KupzSH9Q%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAF7qQgBPyX3vM%2Bt_AKGruABhybCq3LnbXxSRZs%2BnV-KupzSH9Q%40mail.gmail.com?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/4041e2e6-65cb-1cf8-0425-8bc7b5e458c2%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


ALLOWED_HOSTS error

2022-11-21 Thread Mike Dewhirst

My Django log is full of these errors ...

ERROR 
/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py 
TIME: 2022-09-28 00:13:17,204 MSG: 
exception.py:response_for_exception:99 Invalid HTTP_HOST header: 
'111.222.333.444'. You may need to add '111.222.333.444' to ALLOWED_HOSTS.


... where '111.222.333.444. is the correct IP address of the FQDN for 
the site.


Everything seems to be working but these errors are just consuming disk 
space.


My reading of the docs 
https://docs.djangoproject.com/en/3.2/ref/settings/#allowed-hosts does 
not indicate the IP address should be in ALLOWED_HOSTS.


My inclination is it shouldn't be there.

What is the correct way to deal with this?

Many thanks

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/053ab6dc-21c0-7914-1638-435838ace9ed%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


RE: Possible bug in runserver

2022-11-11 Thread Mike Dewhirst
Try using the inline argument --settings when executing runserver--(Unsigned 
mail from my phone)
 Original message From: Matteo Sani  
Date: 12/11/22  05:38  (GMT+10:00) To: Django users 
 Subject: Possible bug in runserver Hello, I 
wanted to run Django runserver with custom settings defined in 
proj/mysettings.py. So I exported the env variable DJANGO_SETTINGS_MODULE to 
point to the custom settings file and then I ran manage.py runserver … The 
printout was showing that Django was still using the default settings in 
proj/settings.py, it seems it is ignoring DJANGO_SETTINGS_MODULE. Is it an 
intended behavior or a bug ? What is the recommended way to do that ? Below the 
commands I used to reproduce the issue:  $ export 
DJANGO_SETTINGS_MODULE=”proj.mysettings”$ python manage.py runserver 
0.0.0.0:7474November 11, 2022 - 10:22:48Django version 3.2.6, using settings 
'proj.settings'Starting development server at http://0.0.0.0:7474/Quit the 
server with CONTROL-C. Best regards,Matteo



-- 
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/821066be-0877-4ab1-a98f-c6a18dd62931n%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/636ee2cd.810a0220.4928f.c912SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


RE: Can't Load Django Dev Sever

2022-11-10 Thread Mike Dewhirst
Try visiting http://localhost:8000 insteadNo guarantees and I'm not going to 
test it myself ;-)--(Unsigned mail from my phone)
 Original message From: James  
Date: 11/11/22  16:13  (GMT+10:00) To: Django users 
 Subject: Can't Load Django Dev Sever Hello,I 
can't connect to my django web server and it's all my fault. I turned on 
SECURE_HSTS_SECONDS to 60 by accident in development, in another project, a few 
days ago.Now I can not load http://127.0.0.1:8000 on FireFox and I don't know 
how to fix it. And yes runserver is set to that port/ip and yes I can connect 
in incognito mode and in chrome.I have cleared all caches and cookies.Thanks 
very much!



-- 
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/29a776ee-e840-45ad-885b-3f5752c9466fn%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/636dfb79.050a0220.368b6.8b8fSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Move apps to different folders or to a root folder

2022-11-06 Thread Mike Dewhirst

On 7/11/2022 2:40 am, Nick Chang wrote:

Hello community,

I am trying to organize my Django project's structure as the number of 
apps is growing. So I am attempting to move an app in the sub-folder 
that contains its model definitions. The app used to be named 
`.foo ` and now it 
will be just named `foo` in the `LOCAL_APPS` setting.


It seems straightforward to do this with the following two steps:

 1. Change the reference from `.foo
` to `foo` in the whole project.
 2. Do `mv foo ..` inside the sub-folder.

Is there any DB migration work that this move requires? Or since the 
app name stays the same. There is nothing that needs to be done as 
Django does not see any change in the models. So far my investigation 
confirms no DB migration work is needed but would like to hear some 
experiences that folks might have done before.


Should work just fine.

In any case, you can also specify the table name the model should use if 
you do decide to switch models between apps ...


    class Meta:
 app_label = "company"
 db_table = "common_user"

If your python code works and your tests pass everything should be fine.




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/5ac5eea7-f620-4d11-9796-3439231939f3n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/d753d252-2ff7-4138-e301-99beb9132066%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: secret api keys

2022-10-26 Thread Mike Dewhirst

On 27/10/2022 3:32 pm, Mike Dewhirst wrote:

Not a dumb question but frequently asked.

There are two approaches - one is to export your secrets as 
environment vars and read them from there. The other is to keep them 
in disk files and read them as required.


In both cases the idea is to keep secrets out of your code and thus 
out of your repo.


I prefer the latter approach.


Further to that, the secrets are consumed by your code on the server 
which constructs html from a template rendered with values inserted by 
your code and sends that all to the browser which made the request.


So if you don't include your secrets in your constructed html they won't 
appear in the browser and will remain secret.


My preferred approach (above) is only secure if the files containing the 
secrets are stored on the server in a location accessible to the web 
server (Apache perhaps in your case) but access is denied to a browser.


In my case, I use a "creds" directory which satisfies that scenario.



Cheers

Mike

 Original message 
From: john fabiani 
Date: 27/10/22 02:09 (GMT+10:00)
To: django-users@googlegroups.com
Subject: secret api keys

Hi,

Maybe a dumb question but if I add secret keys in my settings.py file
(or should it be placed) will they be protected from the front end side
(the part that is displayed to the user of the website).

For example I have a secret key to access Authorize Net.  Will it be
protected from someone opening the website and using chrome to see the
source?

Johnf

--
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/eeb82d0a-f18d-c253-a613-24c685307f41%40jfcomputer.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/6068b999-3cca-f4e3-cb58-493e08800187%40dewhirst.com.au 
<https://groups.google.com/d/msgid/django-users/6068b999-3cca-f4e3-cb58-493e08800187%40dewhirst.com.au?utm_medium=email_source=footer>.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/51795697-9488-777d-a2de-53517c3e8f46%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


secret api keys

2022-10-26 Thread Mike Dewhirst

Not a dumb question but frequently asked.

There are two approaches - one is to export your secrets as environment 
vars and read them from there. The other is to keep them in disk files 
and read them as required.


In both cases the idea is to keep secrets out of your code and thus out 
of your repo.


I prefer the latter approach.

Cheers

Mike

 Original message 
From: john fabiani 
Date: 27/10/22 02:09 (GMT+10:00)
To: django-users@googlegroups.com
Subject: secret api keys

Hi,

Maybe a dumb question but if I add secret keys in my settings.py file
(or should it be placed) will they be protected from the front end side
(the part that is displayed to the user of the website).

For example I have a secret key to access Authorize Net.  Will it be
protected from someone opening the website and using chrome to see the
source?

Johnf

--
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/eeb82d0a-f18d-c253-a613-24c685307f41%40jfcomputer.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/6068b999-3cca-f4e3-cb58-493e08800187%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Django call_command from Admin

2022-10-25 Thread Mike Oliver
Aziz,

I had a similar need and I created my own middleware that checked the
request path and did the call when I got a match.

See https://docs.djangoproject.com/en/4.1/ref/middleware/




*Mike Oliver** Founder**, Open 4 Business Online*
Tel: +1(951)260-0793 | Mobile:**NEW* 639479927462
US Toll free: 1-800-985-4766 **NEW*
http://www.o4bo.com
Mas marunong akong umunawa ng salitang tagalog kaysa magkapagsalita nito
[image: Facebook]
<http://www.facebook.com/pages/Open-4-Business-Online/147285608707176> [image:
Twitter] <https://twitter.com/O4BO> [image: LinkedIn]
<http://ph.linkedin.com/pub/mike-oliver/0/1b9/197> [image: AngelList]
<https://angel.co/open-4-business-online/> [image: Blogger]
<http://blog.open4businessonline.com/> [image: eBay]
<http://www.store.o4bo.com/servlet/StoreFront> [image: YouTube]
<http://www.youtube.com/channel/UCruaIEFosh9uvfkQCq7mtKw> [image: Google
Plus Page] <https://plus.google.com/113688478700619104336/posts>
Contact me: [image: Google Talk] mikeolive...@open4businessonline.com [image:
Skype] MikeOliverAZ



On Fri, Oct 21, 2022 at 12:06 AM Aziz Mek  wrote:

> Hi All,
>
> I was wondering  if you have come across the following:
>
> I have a field in the model that's empty, when the user fills it up and
> clicks Save, it
> should trigger/call a management Command (This command is already build
> that sends emails ), Django docs say i can use call_command but not sure
> how to implement it with the save
>
> I am just after the trigger really when the save takes place
>
> Many thanks in advance
>
> Kind regards
> Aziz
>
>
> --
> 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/a0ca69f0-6065-4b86-a977-cfb6dcab8fd7n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a0ca69f0-6065-4b86-a977-cfb6dcab8fd7n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAA2yvOHvP_fWa4cptWxVdjt7UQELPM60LetC-fSBnXhTxivSWA%40mail.gmail.com.


Re: Update from 3.9 to 3.10.8 and uninstall 3.9

2022-10-24 Thread Mike Dewhirst
Sadly I can't advise on Windows 11. Nor am I across Anaconda and I don't know 
what Spyder is.The path is where Windows looks for a program if you don't 
specify where it is. You will need to google the location of the path 
environment variable on Windows 11.Good luck - I'm sure you will enjoy Python. 
BTW - there is not a lot of difference between Python versions for beginners. 
You would be best to stick with the version you have installed until you are 
more comfortable with the lay of the land.M--(Unsigned mail from my phone)
 Original message From: B N  Date: 
24/10/22  19:27  (GMT+10:00) To: Mike Dewhirst  Subject: 
Re: Update from 3.9 to 3.10.8 and uninstall 3.9 

Thank you, that was quick.. My problem is/are the technical terms such as path 
and environment . It took me about 10 hours, (I am retired so have time), to 
upgrade to Spyder 5.3.3 because the input command didn't work; the solution 
offered by Spyder did not
 work. I am grateful . I shall now try to understand how to activate  anaconda 
environment and path. I have Windows 11.



Best wishes

John







From: Mike Dewhirst
Sent: Sunday, October 23, 2022 22:46
To: B N; python-l...@python.org
Subject: Re: Update from 3.9 to 3.10.8 and uninstall 3.9





On 23/10/2022 9:13 pm, B N wrote:


I am new to python and wish to update 3.9 to3.10.8 which I have downloaded. How 
do I replace 3.9 with the 3.10.8 I downloaded.
Kind regards
JohnGee



It depends on the operating system. 

Typically, you can just install the new version and adjust your environment 
vars (ie., path) to point to the new version instead of the old.

The theoretical reason is that you may have other programs/scripts etc which 
still rely on the old version.

If you are new to Python, you should probably avoid installing later versions 
until you have studied virtual environments. A venv will let you keep your 
"system" Python(s) clean and unencumbered while being able to experiment with 
all sorts of additional libraries,
 packages etc in multiple separate sub-environments.

Cheers

Mike
-- 
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.






-- 
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/635699d9.050a0220.e229f.a5f7SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Sanity check please

2022-10-23 Thread Mike Dewhirst
In the Django Admin I have a model central to a bunch of FKs and M:Ms 
plus a lot of processing on saving.


This is my solution which seems to work but frightens me a bit.

class Chemical(models.Model):

    # lots of fields

    def save(self, *args, **kwargs):

    self.process_stuff_based_on_field_values_pre_save()

        first = False

        if not self.id:

    first = True

    super().save(force_insert=True, *args, **kwargs)

    if self.id:

            self.create_or_update_a_bunch_of_related_records(first=first)

    super().save(force_insert=False, *args, **kwargs)

    self.create_or_update_a_bunch_of_m2m_records(first=first)

def process_stuff_based_on_field_values_pre_save(self, first=False):
...



def create_or_update_a_bunch_of_m2m_records(self, first=False):
...


    # lots of other methods

Thanks for any warnings, caveats

Cheers

Mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/a9164eef-3297-d6ac-e126-aad62d7e7488%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: On button click need to call a python function...

2022-10-18 Thread Mike Dewhirst

On 18/10/2022 5:04 pm, Saswat Mahapatra wrote:

Hi ,

I am new to django.
On button click I need to call a python function which returns 2 
values. If both the values are the same then I need to display the 
same image in 2 places on the web page or else a different image.


How to call the python function from html ?


I would be looking at htmx.org

Maybe django-htmx

I haven't tried it but I intend to one of these days.

N





Thanks & Regards,
Saswat
--
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/294c7d09-d558-4b18-97c6-ee369c27a591n%40googlegroups.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/2ff0b19e-5aca-bfec-38f4-d902f24d3410%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: save_model doesn't run on Django version 4

2022-09-13 Thread Mike Kilmer
One thing I'm not sure of it, how to tell if a particular Admin page is 
triggering a particular Admin instance.

On Tuesday, September 13, 2022 at 11:27:54 AM UTC-5 Mike Kilmer wrote:

> After having upgraded from Django 3 to 4 the save_model() method isn't 
> running, though the form it imports does.
>
> ```
> class MyCoolMapAdmin(SuperUserChangeOnlyMixIn, FilterByOwnerAdmin):
> form = MyCoolModelForm
> print("this prints on app initialization")
> 
> def save_model(self, request, obj, form, change):
> print("this never runs")
>
> class MyCoolModelForm(forms.ModelForm):
>
> def clean(self):
> print("this does run")
> ```
>
> The `save_model` method doesn't seem to run for new or updated form 
> submission from the "MyCool" admin page.
>
> Thank you. 
>

-- 
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/29eeac28-112a-4935-b0c8-62e48b6a49den%40googlegroups.com.


save_model doesn't run on Django version 4

2022-09-13 Thread Mike Kilmer
After having upgraded from Django 3 to 4 the save_model() method isn't 
running, though the form it imports does.

```
class MyCoolMapAdmin(SuperUserChangeOnlyMixIn, FilterByOwnerAdmin):
form = MyCoolModelForm
print("this prints on app initialization")

def save_model(self, request, obj, form, change):
print("this never runs")

class MyCoolModelForm(forms.ModelForm):

def clean(self):
print("this does run")
```

The `save_model` method doesn't seem to run for new or updated form 
submission from the "MyCool" admin page.

Thank you. 

-- 
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/2051c3c8-d6ca-4d99-a5fe-d1b9f0897b08n%40googlegroups.com.


Looking for a Django firm

2022-09-12 Thread Mike Dewhirst
Hi all - I'm looking for a Django outfit with an interest in chemistry 
or customers in the chemical industry in Australia.


Possible opportunity.

Best to respond off list and there will be an NDA.

Cheers

Mike

--
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/5b7dfee7-dc18-052d-994f-a27bb78ed71d%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


RE: What do you do with large project and forms?

2022-08-30 Thread Mike Dewhirst
1. Create a forms directory2. Create ../forms/__init__.py3. Move your forms.py 
into the forms directory4. In ./__init__.py write from .forms import (  
FormThis,  FormThat,  EtcForm,)This gives you unchanged forms calling from 
wherever ... from appname.forms import etc5. When all that is working split 
your 3k forms.py into appropriately named smaller files each containing the 
form class or classes you prefer and adjust the ./__init__.py imports 
accordinglyYou might encounter occasional circular imports but you should get 
the hang of it soon enough.CheersMike--(Unsigned mail from my phone)
 Original message From: Julio Cojom  
Date: 31/8/22  03:42  (GMT+10:00) To: django-users@googlegroups.com Subject: 
What do you do with large project and forms? I have a large project and 
forms.py per app is bigger than I thought with 3k+ lines in each file, I'm 
looking for options to make a good scalation structure, does anyone have 
experience with this? What do you do to organize your forms in your projects?



-- 
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/CAHRQUHnd2zdPeaOmw2VzWhP2y1xN%3Dv2Z%2BQ%2B%2BsSw1B10AuxEnjA%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/630ea50d.620a0220.480de.4507SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Can an app subclass a core django class to channge its behavior

2022-08-25 Thread Mike Oliver
Ok will try the shell


On Thursday, August 25, 2022 at 2:00:33 PM UTC+8 bboy...@gmail.com wrote:

>
> Ur config with me are the same.
>
> [image: Screenshot_2022-08-25-12:50:38-1661406638.png]
> But i put it in the bottom of the middleware
>
> MIDDLEWARE = [
> "django.middleware.security.SecurityMiddleware",
> "whitenoise.middleware.WhiteNoiseMiddleware",
> "django.contrib.sessions.middleware.SessionMiddleware",
>
> "django.middleware.common.CommonMiddleware",
> "django.middleware.csrf.CsrfViewMiddleware",
> "django.contrib.auth.middleware.AuthenticationMiddleware",
> "django.contrib.messages.middleware.MessageMiddleware",
> "django.middleware.clickjacking.XFrameOptionsMiddleware",
>
> "chuthe.middlewares.supervisor.ChutheIOMiddleware",
> ]
>
> Think you should try by shell to make sure you can call it, or importable 
> `from mysite.mymiddleware import DoseControllerMiddleware`. Shell very 
> helpful.
> On Thu, Aug 25, 2022 at 11:09 AM Mike Oliver <
> mikeol...@open4businessonline.com> wrote:
>
>> Currently, I have 
>> /mysite/
>> mymiddleware.py
>>settings.py
>>
>> My CustomMiddlware class looks like...
>> class DoseControllerMiddleware(object):
>>
>> def process_request(self, request):
>> """
>> get ready to call the Dose Controller
>> """
>> print("DoseControllerModdleware.process_request Hooray")
>> return None
>>
>> my settings has...
>> MIDDLEWARE = [
>> 'django.middleware.security.SecurityMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'mysite.mymiddleware.DoseControllerMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> ]
>>
>> runserver gives me...
>>
>> ModuleNotFoundError: No module named 'mysite.mymiddleware'
>>
>>
>>
>> On Thursday, August 25, 2022 at 12:04:55 PM UTC+8 Mike Oliver wrote:
>>
>>> Well I have continued to search and now I see that CustomMiddleware will 
>>> do what I want, but I cannot find a current example and some of the 
>>> StackOverflow answers are old and not working in the latest Django.
>>>
>>> On Thursday, August 25, 2022 at 10:23:41 AM UTC+8 bboy...@gmail.com 
>>> wrote:
>>>
>>>> Could you tell us more detail of process flow?
>>>>
>>>> On Wed, 24 Aug 2022 at 20:52 Mike Oliver <
>>>> mikeol...@open4businessonline.com> wrote:
>>>>
>>>>> Hello, 
>>>>>
>>>>> I want to follow a microservices architecture and have some shared 
>>>>> services I can include in a process flow instead of the 1:1 View:Model 
>>>>>
>>>>> Suggestions?
>>>>>
>>>>> MO
>>>>>
>>>>> -- 
>>>>> 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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/django-users/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>> -- 
>> 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/a907da19-4a73-41c5-964d-67b0e67e91e5n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/a907da19-4a73-41c5-964d-67b0e67e91e5n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/98f04efc-daa3-4403-9b03-bd3942c2ac2fn%40googlegroups.com.


Re: Can an app subclass a core django class to channge its behavior

2022-08-24 Thread Mike Oliver
Currently, I have 
/mysite/
mymiddleware.py
   settings.py

My CustomMiddlware class looks like...
class DoseControllerMiddleware(object):

def process_request(self, request):
"""
get ready to call the Dose Controller
"""
print("DoseControllerModdleware.process_request Hooray")
return None

my settings has...
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'mysite.mymiddleware.DoseControllerMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

runserver gives me...

ModuleNotFoundError: No module named 'mysite.mymiddleware'



On Thursday, August 25, 2022 at 12:04:55 PM UTC+8 Mike Oliver wrote:

> Well I have continued to search and now I see that CustomMiddleware will 
> do what I want, but I cannot find a current example and some of the 
> StackOverflow answers are old and not working in the latest Django.
>
> On Thursday, August 25, 2022 at 10:23:41 AM UTC+8 bboy...@gmail.com wrote:
>
>> Could you tell us more detail of process flow?
>>
>> On Wed, 24 Aug 2022 at 20:52 Mike Oliver <
>> mikeol...@open4businessonline.com> wrote:
>>
>>> Hello, 
>>>
>>> I want to follow a microservices architecture and have some shared 
>>> services I can include in a process flow instead of the 1:1 View:Model 
>>>
>>> Suggestions?
>>>
>>> MO
>>>
>>> -- 
>>> 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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>

-- 
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/a907da19-4a73-41c5-964d-67b0e67e91e5n%40googlegroups.com.


Re: Can an app subclass a core django class to channge its behavior

2022-08-24 Thread Mike Oliver
Well I have continued to search and now I see that CustomMiddleware will do 
what I want, but I cannot find a current example and some of the 
StackOverflow answers are old and not working in the latest Django.

On Thursday, August 25, 2022 at 10:23:41 AM UTC+8 bboy...@gmail.com wrote:

> Could you tell us more detail of process flow?
>
> On Wed, 24 Aug 2022 at 20:52 Mike Oliver <
> mikeol...@open4businessonline.com> wrote:
>
>> Hello, 
>>
>> I want to follow a microservices architecture and have some shared 
>> services I can include in a process flow instead of the 1:1 View:Model 
>>
>> Suggestions?
>>
>> MO
>>
>> -- 
>> 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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/bb266e45-c506-4e3d-be1d-e7a4363ba9ccn%40googlegroups.com.


Can an app subclass a core django class to channge its behavior

2022-08-24 Thread Mike Oliver
Hello, 

I want to follow a microservices architecture and have some shared services 
I can include in a process flow instead of the 1:1 View:Model 

Suggestions?

MO

-- 
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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com.


How to enable/disable a hyperlink based on the clock

2022-08-23 Thread Mike Dewhirst
I want to provide a link to join a regular Zoom webinar but 
enable/disable it just like a garden sprinkler.


Enable at noon on Friday, disable fifteen minutes later. Repeat for next 
Friday.


It feels like I need some sort of push. I'm not a js person.

Perhaps I should be looking at htmx?

Any hints?

Thanks

mike

--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/760895a6-8415-ddd4-303d-5846ba4f1fc6%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Model switching - how to avoid saving twice

2022-08-15 Thread Mike Dewhirst

Django 3.2 Admin

I have a model with two 1:n models and need to convert one type of model 
into the other.


I know this sounds mad but it is a specialised document management to-do 
system. It has Note models and Link models connected to the main model.


When converting a Note into a Link the Link gets created and the Note 
gets deleted. This currently happens in the main model.save() after 
calling super().


The method removes the Note from the to-do side and puts it on the done 
side as a Link complete with a URL.


So far I can only detect if the user wishes to convert a Note into a 
Link after the Note is saved with True in its conversion field.


That means the main model needs to be saved to commit that True value 
and then saved again to convert any Notes with that True value.


The crux of the problem (to me) is that I'm using a queryset to detect 
Notes in the database ready for conversion into links.


Is it possible to do this saving only once?

Thanks

Mike


class Chemical(models.Model):
    ...
    def save(self, *args, **kwargs):
    super().save(*args, **kwargs)
    self.convert_notes_to_links(line=line)

    def convert_notes_to_links(self, line=None):
    for note in Note.objects.filter(chemical=self, link=True):
    link, new = Link.objects.get_or_create(chemical=self, 
name=note.title)

    if new:
    link.synopsis = note.note
    link.save()
    note.delete()






--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/fbe7cbc2-c7b4-807c-aafe-4b2f820ca075%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Need help on reducing cognitive complexity

2022-07-21 Thread Mike Dewhirst

On 21/07/2022 3:52 pm, Sencer Hamarat wrote:

Hi everyone,

I have a code block with high cognitive complexity below:

    @staticmethod
    def in_circle_check(obj_type, item, uuid, item_is_array=False):


Partly because the args seem weird.

Try writing a docstring which says what the method needs to do. Then 
rewrite the code as nested if statements, bearing in mind that if 
nothing fits, it will fall through to the end and return either None or 
whatever you want to return, perhaps -1.




        if obj_type not in ['trees', 'flowers']:
            return None

        plant = get_plant_with_circles(uuid)
        if not plant:
            return None

        if obj_type == 'trees':
            if plant['in_all_tree_types']:
                return True
            circle_objects = plant['tree_circle']['items']
        else:
            if plant['in_all_flower_types']:
                return True
            circle_objects = plant['flower_circle']['items']

        if isinstance(circle_objects, list):
            if item_is_array:
                for item in item:
                    if item not in circle_objects:
                        return -1
                return True
            else:
                if item in circle_objects:
                    return True
        else:
            return -1

        return -1


I try to move the first 3 if statements on the beginning of the block 
into new methods but that maneuver ends up with raising complexity.


Can anybody help me to learn how to reduce cognitive complexity in 
code blocks 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/CACp8TZhBa9EbekcT1ApmzdDRVk2vCb64%3DvvXHrSawO2RJSySpQ%40mail.gmail.com 
.



--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/fbbd1ba9-47ac-64de-88cc-5a784e151db3%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


RE: remove django polymorphism

2022-07-16 Thread Mike Dewhirst
--(Unsigned mail from my phone)
 Original message From: Joseph Amiri  
Date: 17/7/22  05:41  (GMT+10:00) To: Django users 
 Subject: remove django polymorphism hey all.i 
have models like this :class basemodel(polymorphism):...class 
teachers(basemodel):...class courses(basemodel):...now i want to remove 
teachers from polymorphism basemodel and transfer records from basemodel to 
teachers table. any document to do that ?Yes. Django has you totally covered. 
You need to look at docs.djangoproject.com and search "migrations".Essentially, 
you write the code to move records between tables according to your heart's 
desire. On that page there is a section called 'Data migrations' which will 
solve your problem.Good luckM



-- 
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/1bd0a2bd-8521-43a6-8fc8-aa6e92feafe2n%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/62d37861.1c69fb81.2820e.b8e0SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: Django tried these URL patterns

2022-06-17 Thread Mike Kilmer
Not sure why, but moving path("integrations/", 
include("integrations.urls")), above the "" slash seems to have solved the 
problem.

On Friday, June 17, 2022 at 5:45:19 PM UTC-5 Mike Kilmer wrote:

> This app is set up to create webhooks and receive requests, however the 
> routing has broken and the requests are getting a 404.
>
> The path looks like this:
>
>
> http://127.0.0.1:8000/integrations/dc3509ac-1aa8-4c9a-a439-904342d885cd/order
>
> The Stack Track/Routing:
>
> Using the URLconf defined in fulfill.urls, Django tried these URL 
> patterns, in this order:
>
>1. baton/
>2. [name='index']
>3. etc...
>4. integrations/request/
>5. reports/clientreport/
>6. 
> ^(?Pauth|sites|account|socialaccount|users|core|integrations|reports)/$
>  
>[name='app_list']
>7. (?P.*)$
>
> The current path, integrations/dc3509ac-1aa8-4c9a-a439-904342d885cd/order, 
> matched the last one.
>
> My URL setup is like this:
> urlpatterns = [
> path("baton/", include("baton.urls")),
> # Be sure "baton/" is at the beginning of the list, before "".
> path("", admin.site.urls),
> path('accounts/', include('allauth.urls')),
> path("integrations/", include("integrations.urls")),
> path("queryfilter/", include("core.urls")),
> path("docs/", include("docs.urls")),
> path(
> "favicon.ico", 
> RedirectView.as_view(url=staticfiles_storage.url("favicon.ico"))
> ),
> ]
>
> With integrations.urls like this:
>
> urlpatterns = [
>   path(
> "/order",
>   incoming_order,
>   name="incoming-order",
> ),
> ]
>
>
> The incoming_order method looks like this:
>
> @csrf_exempt
> @require_http_methods(["POST"])
> def incoming_order(request, integration_uuid):
> headers = request.headers
> request_body = request.body.decode("utf-8")
> log = Request.objects.create(
> url=request.build_absolute_uri(), body=request_body, 
> headers=dict(headers)
> )
>
> log.process(integration_uuid)
>
> return JsonResponse({"status": "ok"})
>
> Any suggestions?
>

-- 
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/c23ab998-6331-44a0-ace2-a2f273fc36d5n%40googlegroups.com.


Django tried these URL patterns

2022-06-17 Thread Mike Kilmer
This app is set up to create webhooks and receive requests, however the 
routing has broken and the requests are getting a 404.

The path looks like this:

http://127.0.0.1:8000/integrations/dc3509ac-1aa8-4c9a-a439-904342d885cd/order

The Stack Track/Routing:

Using the URLconf defined in fulfill.urls, Django tried these URL patterns, 
in this order:

   1. baton/
   2. [name='index']
   3. etc...
   4. integrations/request/
   5. reports/clientreport/
   6. 
^(?Pauth|sites|account|socialaccount|users|core|integrations|reports)/$
 
   [name='app_list']
   7. (?P.*)$

The current path, integrations/dc3509ac-1aa8-4c9a-a439-904342d885cd/order, 
matched the last one.

My URL setup is like this:
urlpatterns = [
path("baton/", include("baton.urls")),
# Be sure "baton/" is at the beginning of the list, before "".
path("", admin.site.urls),
path('accounts/', include('allauth.urls')),
path("integrations/", include("integrations.urls")),
path("queryfilter/", include("core.urls")),
path("docs/", include("docs.urls")),
path(
"favicon.ico", 
RedirectView.as_view(url=staticfiles_storage.url("favicon.ico"))
),
]

With integrations.urls like this:

urlpatterns = [
  path(
"/order",
  incoming_order,
  name="incoming-order",
),
]


The incoming_order method looks like this:

@csrf_exempt
@require_http_methods(["POST"])
def incoming_order(request, integration_uuid):
headers = request.headers
request_body = request.body.decode("utf-8")
log = Request.objects.create(
url=request.build_absolute_uri(), body=request_body, 
headers=dict(headers)
)

log.process(integration_uuid)

return JsonResponse({"status": "ok"})

Any suggestions?

-- 
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/98d3971b-41da-4b33-8bbe-3b9a59332b9bn%40googlegroups.com.


Re: CSRF issue in default login

2022-06-17 Thread Mike Kilmer
If you're interested in some piecemeal work, I could use some help. mike at 
mzoo.org.

On Friday, June 17, 2022 at 3:10:16 PM UTC-5 181...@northsouth.edu wrote:

> I have basic to intermediate knowledge on Django, but don't find any entry 
> level job to master my django knowledge in my country, can any one suggest 
> me where I can get some project or industry level job in django , please. I 
> am badly need that
>
> On Friday, June 17, 2022 at 11:29:04 PM UTC+6 Mike Kilmer wrote:
>
>> That sounds hopeful. Where do you put that config? Settings.py?
>>
>> On Friday, June 17, 2022 at 12:25:29 PM UTC-5 vicker...@gmail.com wrote:
>>
>>> I was having a similar issue after setting up https with certbot. After 
>>> searching around, I found adding this to settings worked.
>>>
>>> CSRF_TRUSTED_ORIGINS = ["https://yourdomain.com;, 
>>> "https://www.yourdomain.com;]
>>>
>>> I'd be curious to hear from others, because I'm *not *an expert in how to 
>>> best set up django for production.
>>>
>>>
>>> On Fri, 17 Jun 2022 at 11:48, Mike Kilmer  wrote:
>>>
>>>> Hi.
>>>>
>>>> I'm fairly new to Django. Here's what I need insight on:
>>>>
>>>> Local server, no issue.
>>>>
>>>> On production: CSRF 403 error on login.
>>>>
>>>> There's a cookie loaded on the login page containing csrftoken: 
>>>> pAFeeUI8YFXZ2PKRYxOTX1qz4Xgto42WVNi7FFvBlZDqcFLwQ2rdQvVeZBHFSpLW
>>>>
>>>> (Local and Session storage are empty)
>>>>
>>>> In the FORM element:
>>>>
>>>> >>> value="Vz4FiujD4qkLpxCwWNJU0HCWs4u0Qf4RrMHyJf66rK0cznDbOimeTb7BnIVckANR">
>>>>
>>>> Notice they don't match.
>>>>
>>>> I tried running ./migrate.py clearsessions.
>>>>
>>>> Once, yesterday, it seemed that the error did not occur in an Incognito 
>>>> Window, but today it persists even in an incognito window, as well as a 
>>>> different browser.
>>>>
>>>> One additional piece of information, I have allauth installed, but it 
>>>> doesn't seem to be correctly configured. It's login page is not loading. 
>>>>
>>>> Additionally, the problem was there even when I removed allauth from 
>>>> Apps and Authentication Backends.
>>>>
>>>> Thanks much.
>>>>
>>>> –Mike
>>>>
>>>> -- 
>>>> 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/551AFE93-8B25-4CB9-8D3F-F1BF1EC4F585%40mzoo.org
>>>> .
>>>>
>>>

-- 
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/810b5821-7117-48d5-a71b-3ad09df7a1ean%40googlegroups.com.


Re: CSRF issue in default login

2022-06-17 Thread Mike Kilmer
That sounds hopeful. Where do you put that config? Settings.py?

On Friday, June 17, 2022 at 12:25:29 PM UTC-5 vicker...@gmail.com wrote:

> I was having a similar issue after setting up https with certbot. After 
> searching around, I found adding this to settings worked.
>
> CSRF_TRUSTED_ORIGINS = ["https://yourdomain.com;, 
> "https://www.yourdomain.com;]
>
> I'd be curious to hear from others, because I'm *not *an expert in how to 
> best set up django for production.
>
>
> On Fri, 17 Jun 2022 at 11:48, Mike Kilmer  wrote:
>
>> Hi.
>>
>> I'm fairly new to Django. Here's what I need insight on:
>>
>> Local server, no issue.
>>
>> On production: CSRF 403 error on login.
>>
>> There's a cookie loaded on the login page containing csrftoken: 
>> pAFeeUI8YFXZ2PKRYxOTX1qz4Xgto42WVNi7FFvBlZDqcFLwQ2rdQvVeZBHFSpLW
>>
>> (Local and Session storage are empty)
>>
>> In the FORM element:
>>
>> > value="Vz4FiujD4qkLpxCwWNJU0HCWs4u0Qf4RrMHyJf66rK0cznDbOimeTb7BnIVckANR">
>>
>> Notice they don't match.
>>
>> I tried running ./migrate.py clearsessions.
>>
>> Once, yesterday, it seemed that the error did not occur in an Incognito 
>> Window, but today it persists even in an incognito window, as well as a 
>> different browser.
>>
>> One additional piece of information, I have allauth installed, but it 
>> doesn't seem to be correctly configured. It's login page is not loading. 
>>
>> Additionally, the problem was there even when I removed allauth from Apps 
>> and Authentication Backends.
>>
>> Thanks much.
>>
>> –Mike
>>
>> -- 
>> 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/551AFE93-8B25-4CB9-8D3F-F1BF1EC4F585%40mzoo.org
>> .
>>
>

-- 
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/d592ab6f-68ee-483e-9ae6-6f4074cdbcefn%40googlegroups.com.


Re: CSRF issue in default login

2022-06-17 Thread mike vickers
I was having a similar issue after setting up https with certbot.
After searching around, I found adding this to settings worked.

CSRF_TRUSTED_ORIGINS = ["https://yourdomain.com;, "https://www.yourdomain.com;]

I'd be curious to hear from others, because I'm *not *an expert in how
to best set up django for production.


On Fri, 17 Jun 2022 at 11:48, Mike Kilmer  wrote:

> Hi.
>
> I'm fairly new to Django. Here's what I need insight on:
>
> Local server, no issue.
>
> On production: CSRF 403 error on login.
>
> There's a cookie loaded on the login page containing csrftoken:
> pAFeeUI8YFXZ2PKRYxOTX1qz4Xgto42WVNi7FFvBlZDqcFLwQ2rdQvVeZBHFSpLW
>
> (Local and Session storage are empty)
>
> In the FORM element:
>
>  value="Vz4FiujD4qkLpxCwWNJU0HCWs4u0Qf4RrMHyJf66rK0cznDbOimeTb7BnIVckANR">
>
> Notice they don't match.
>
> I tried running ./migrate.py clearsessions.
>
> Once, yesterday, it seemed that the error did not occur in an Incognito
> Window, but today it persists even in an incognito window, as well as a
> different browser.
>
> One additional piece of information, I have allauth installed, but it
> doesn't seem to be correctly configured. It's login page is not loading.
>
> Additionally, the problem was there even when I removed allauth from Apps
> and Authentication Backends.
>
> Thanks much.
>
> –Mike
>
> --
> 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/551AFE93-8B25-4CB9-8D3F-F1BF1EC4F585%40mzoo.org
> .
>

-- 
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/CACaDatQQiGcmw62HNgajxBJsibfu%2BW-0LqdhasckNGsK4iymCA%40mail.gmail.com.


CSRF issue in default login

2022-06-17 Thread Mike Kilmer
Hi.

I'm fairly new to Django. Here's what I need insight on:

Local server, no issue.

On production: CSRF 403 error on login.

There's a cookie loaded on the login page containing csrftoken: 
pAFeeUI8YFXZ2PKRYxOTX1qz4Xgto42WVNi7FFvBlZDqcFLwQ2rdQvVeZBHFSpLW

(Local and Session storage are empty)

In the FORM element:



Notice they don't match.

I tried running ./migrate.py clearsessions.

Once, yesterday, it seemed that the error did not occur in an Incognito Window, 
but today it persists even in an incognito window, as well as a different 
browser.

One additional piece of information, I have allauth installed, but it doesn't 
seem to be correctly configured. It's login page is not loading. 

Additionally, the problem was there even when I removed allauth from Apps and 
Authentication Backends.

Thanks much.

–Mike

-- 
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/551AFE93-8B25-4CB9-8D3F-F1BF1EC4F585%40mzoo.org.


Re: how to deploy python django project using heroku

2022-06-16 Thread Mike Kilmer
Do you have your codebase tracked in a version tracking system like Github? 
If you do, then, from within Heroku, you can use the Github integration.

On Thursday, June 16, 2022 at 11:01:52 AM UTC-5 maheshb...@gmail.com wrote:

> please support me how deploy django project using git and heroku 
> help me
> deploy on heroku and operation on it ...i am fresher so i dont no how to 
> work on dajngo rest framework please support 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/99774508-2d1a-43e4-8b2b-9dfe6ac4b523n%40googlegroups.com.


Re: How to hash fields and detect changes in a record

2022-06-14 Thread Mike Dewhirst

On 14/06/2022 11:20 pm, Ryan Nowakowski wrote:


Summing the ordinal of the characters won't catch transposition:

>>> chars = 'ab'
>>> sum([ord(c) for c in chars])
195
>>> chars = 'ba'
>>> sum([ord(c) for c in chars])
195

Better to use a real hash algorithm if you're trying to detect 
changes.  My note above about hashing not being required is because 
you don't need to detect changes because you explicitly already know 
when changes are being made.




Thanks Ryan.

It is all working now. I append " - No longer relevant" to the note 
title if any change is detected. Otherwise the note gets deleted.


Cheers

Mike




--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.

--
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/75458bb4-bb4b-0e44-54c1-59768d34d403%40dewhirst.com.au.


OpenPGP_signature
Description: OpenPGP digital signature


Re: How to hash fields and detect changes in a record

2022-06-12 Thread Mike Dewhirst
--(Unsigned mail from my phone)
 Original message From: Ryan Nowakowski  
Date: 13/6/22  07:09  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: How to hash fields and detect changes in a record On Sat, Jun 11, 2022 at 
12:13:16AM +1000, Mike Dewhirst wrote:> On 10/06/2022 11:24 pm, Ryan Nowakowski 
wrote:> > On Fri, Jun 10, 2022 at 05:52:48PM +1000, Mike Dewhirst wrote:> > > I 
think the solution might be to hash note.title and note.note into a new> > > 
field note.hash on being auto-created. On subsequent saves, compare the> > > 
latest hash with note.hash to decide whether to delete auto-inserted notes> > > 
prior to generating the next set. Those subsequent saves could be months or> > 
> years later.> > Hashing is useful if you want to check that something has 
been> > unexpectedly changed.  I assume the note can only be changed through> > 
your web app so you know when a user is changing a note.> > These are 
automatically generated notes which taken together constitute> advice on how to 
deal with the analysis. Users can edit them. For example,> someone might record 
some action taken regarding the advice. I don't want to> delete that. If 
nothing has been edited, it is safe to delete.> > So how do I know it is the 
same as when originally generated - and safe to> delete - except by storing a 
hash of the interesting fields.Because when the user edits a note, during the 
form.save()(assumingyou're using Django forms), you'll set `altered_by_user` to 
True.Notes can also be altered in the Admin> And if that is the best approach, 
what sort of hashing will survive Python> upgrades etc?Pick a hash 
algorithm[1](ex: sha256).  The output will remain the sameeven with Python 
upgrades.So the mechanism doesn't need to be a hash - as you said. I now just 
sum ord(char) for the title and the note and keep that in a flag field.Only the 
auto-notes get a flag because they are the only ones I would consider deleting. 
[1] https://docs.python.org/3/library/hashlib.html> > Since you're> > expecting 
users to change some of the notes and you know when they do,> > hashing might 
be overkill.  Instead, add a boolean `altered_by_user`> > field to the note 
model.  Initially when you automatically create the> > note altered_by_user 
would be set to False.  If a user changes the note,> > set altered_by_user to 
True.>> Not sure this would work. Note creation and eventually automatic 
deletion is> all driven from model methods executed on saving.Why wouldn't this 
work? During note creation, altered_by_user would beset to False automatically 
because that's the default.  Whenautomatically deleting, do:    
Note.objects.filter(altered_by_user=False).delete()-- 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/20220612210931.GA32625%40fattuba.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/62a6c0f0.1c69fb81.c1d5.c26fSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


  1   2   3   4   5   6   7   8   9   10   >