Re: Need help on reducing cognitive complexity

2022-07-21 Thread Michael Thomas
Personally I think the code has a very weird "smell"... Assuming you don't have any way of rewriting the calling code and are stuck with editing this single method, I'd suggest something along the lines of: @staticmethod def in_circle_check(obj_type, item, uuid): if obj_type not in ['trees', '

Re: DRF question

2022-07-20 Thread Michael Thomas
est-framework.org/api-guide/views/ >>> >>> On Tue, 19 Jul 2022 at 06:38, Nikhil Chawla >>> wrote: >>> >>>> Don't clutter the django views with DRF requests. Keep them separate, >>>> available at, say `api` endpoints. >>&g

Re: DRF question

2022-07-18 Thread Michael Thomas
ssions and serializers mentioned above, as well as any additional actions that didn't fit within the normal REST verbs 4) Created a router and registered the viewsets with it 5) Added the router's urls into the projects url configuration I hope that's useful :) Kind Regards, Michael Thomas

Re: Please criticise use of global keyword in Admin

2022-05-18 Thread Michael Thomas
to get wrong, in my opinion at least! Kind Regards, Michael Thomas On Thu, May 19, 2022 at 9:34 AM Mike Dewhirst wrote: > The code below appears to work perfectly but it worries me because I > have never used the global keyword before. > > Is there a generous guru who will criticise

Re: get country from IP_addres.

2021-12-15 Thread Michael Thomas
https://docs.djangoproject.com/en/4.0/intro/tutorial02/#playing-with-the-api Kind Regards, Michael Thomas On Thu, Dec 16, 2021 at 3:08 PM Amor Zamora wrote: > Can you help me? > I need to obtain the country of where the users access from the IP and > insert that information into the sqlite3 databa

Re: CSS not linking with HTML

2021-06-02 Thread Michael Thomas
es requests too, which is invaluable in the long run. Kind Regards, Michael Thomas On Wed, Jun 2, 2021 at 8:16 PM sukhy gill wrote: > Dear frnd, > I am getting stuck at same point with static with new project. > May I get setting for settings.py ? > > Regards > >

Re: DRF simplejwt refresh access_token stored in httponlycookies

2021-05-08 Thread Michael Thomas
need that then you may be better off with regular django session authentication, signed cookies, etc.. Kind Regards, Michael Thomas On Sat, May 8, 2021 at 11:02 AM narendra thapa wrote: > Thank You @Michal Thomas, i was able to refresh a token now, But i got > another confusion from your answer

Re: DRF simplejwt refresh access_token stored in httponlycookies

2021-05-07 Thread Michael Thomas
re each request, and call the refresh view to get a replacement before making the request. I hope that helps! Kind Regards, Michael Thomas On Sat, May 8, 2021 at 6:49 AM narendra...@gmail.com < narendrathapa...@gmail.com> wrote: > i'm using django as my backend and react as frontend.

Re: 'Sandboxed' Template engine/context

2020-07-10 Thread Michael Thomas
tegr@te System wrote: > > Hi Michael, > > Some templates as mako, jinja, genshi... > > > > > On Fri, Jul 10, 2020, 4:23 PM Michael Thomas > wrote: > >> Hi all, >> >> Does anyone know of a straightforward way to create an independent >> templ

'Sandboxed' Template engine/context

2020-07-10 Thread Michael Thomas
Hi all, Does anyone know of a straightforward way to create an independent template engine instance with a subset of the tags/filters/etc. defined? The use-case is for allowing user-supplied template content, while preventing said users from being able to use features that could be dangerous,

Re: Django server is slow after moving database to remote VM

2020-02-11 Thread Michael Thomas
1500kbps is horrendously slow too, really.. If you're seeing a significant difference between small transfers vs large, you might be stumbling into an incorrect MTU size for the network. This has popped up a little more often in recent years with the rise of vxlans over public connections. If

Re: SPA websites with Django

2019-11-14 Thread Michael Thomas
Django is a backend platform - it's agnostic as to what type of front end you build with it. On Thu, Nov 14, 2019 at 4:27 PM Inna Reddy wrote: > Hi, > > Can we build Single page web applications with Django ? > > -- > You received this message because you are subscribed to the Google Groups > "D

Re: Complex query on inner join - case for __ne?

2019-04-12 Thread Michael Thomas
Naimur: I am - that SQL was in response to Aldian's question :) On Fri, Apr 12, 2019 at 8:23 PM naimur rahman wrote: > use ORM istead of SQL > > On Fri, Apr 12, 2019, 7:42 PM Michael Thomas < > michael.thomas.s...@gmail.com> wrote: > >> SELECT >>

Re: Complex query on inner join - case for __ne?

2019-04-12 Thread Michael Thomas
IN ( SELECT U1."foo_id" FROM "app_bar" U1 WHERE U1."attribute_1" = 1 ) ) AND "app_bar"."attribute_2" = 2 ) On Fri, Apr 12, 2019 at 6:59 PM Aldian Fazrihady wrote: > What'

Re: not getting desired output

2019-04-12 Thread Michael Thomas
You're not using a template, nor generating HTML in your views - where are you expecting bullets to come from? -- 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 dj

Complex query on inner join - case for __ne?

2019-04-12 Thread Michael Thomas
gh, a simple query for attribute_1=1 and attribute_2=2 works as expected, so it would be trivial to do this with a __ne operator (if it existed), without any other changes to the ORM: print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query) SELECT "app_foo"."i