Re: Dictionary not rendering in a html table in a Template

2021-05-15 Thread Benny M
I feel like I missed something in this exchange. The template setup looked as 
though it was designed to loop though a list of dictionaries. As a result, 
based on the code provided, it should have produced two rows of data? Was that 
not the case?

Benny

On May 15, 2021, at 5:25 PM, Walter Randazzo  wrote:


Yes Boris. It works fine now.

Thanks,

El sáb, 15 may 2021 a las 19:18, Boris Pérez 
(mailto:polu...@gmail.com>>) escribió:
Hi Walter, your template is rendering the data ok, after the changes???


2021-05-14 20:56 GMT-04:00, Walter Randazzo 
mailto:wwranda...@gmail.com>>:
> Hi All,
>
> This is how I get this working. (Thanks to Boris for the suggestion)
> I have modified a the structure of the data from list of dictionaries to a
> dictionary.
>
> *#Now This is how the dictionary is printed in console*
>
> {'25': {'socio': 'Randazzo Walter Ariel 25', 'enero': 'P', 'febrero': 'P',
> 'marzo': 'P', 'abril': 'P', 'mayo': 'P', 'junio': 'P', 'julio': 'P',
> 'agosto': 'P', 'septiembre': 'P', 'octubre': 'P', 'noviembre': 'P',
> 'diciembre': 'P'}, '31': {'socio': 'Silvi Edgardo Marcelo 31', 'enero':
> 'P', 'febrero': 'P', 'marzo': 'P', 'abril': 'P', 'mayo': 'P', 'junio': 'P',
> 'julio': '-', 'agosto': '-', 'septiembre': '-', 'octubre': '-',
> 'noviembre': '-', 'diciembre': '-'}}
>
> *#This is how I populate the dictionary:*
>
> dictinfopagosanual[nrosocio]={'socio':soc,
>'enero':EneroPago,
>'febrero':FebreroPago,
>'marzo':MarzoPago,
>'abril':AbrilPago,
>'mayo':MayoPago,
>'junio':JunioPago,
>'julio':JulioPago,
>'agosto':AgostoPago,
>'septiembre':SeptiembrePago,
>'octubre':OctubrePago,
>'noviembre':NoviembrePago,
>'diciembre':DiciembrePago,
> }
>
> *#Then I render in the template as follow:*
>
> 
> {% for key,value in pagos.items %}
> 
> {% for key,value in value.items %}
>{{ value }}
> {% endfor %}
> 
> {% endfor %}
> 
>
>
>
>
> El vie, 14 may 2021 a las 19:59, Walter Randazzo 
> (mailto:wwranda...@gmail.com>>)
> escribió:
>
>> Hi Boris,
>>
>> You're right it is a list of dictionaries. I thought that the template is
>> not able to render the data structure I used.
>>
>> I will take a look on the link,thanks for  the advice.
>>
>> Gracias Boris,
>>
>>
>>
>> El vie, 14 may 2021 a las 17:18, Boris Pérez 
>> (mailto:polu...@gmail.com>>)
>> escribió:
>>
>>> Hi Walter, i think the matter is  that your dictionary, is not a
>>> dictionary,  is a list of dictionaries (it looks more than json
>>> object) perhaps u wanna use jquery and ajax, into your template...
>>> Maybe this link is usefull to u
>>>
>>> https://stackoverflow.com/questions/51209582/django-dictionary-to-html-table-when-values-are-generators.
>>> ..
>>> Greetings, Boris
>>>
>>>
>>> 2021-05-14 12:44 GMT-04:00, Walter Randazzo 
>>> mailto:wwranda...@gmail.com>>:
>>> > Hi Boris, Thanks for the reply.
>>> >
>>> > Here is the code:
>>> >
>>> > View:
>>> > http://del.dog/mavihosuna
>>> >
>>> > Template:
>>> > https://del.dog/mirfanelor
>>> >
>>> > Image of the rendered Template:
>>> > https://tmpsee.com/v/nbkdqhnxee
>>> >
>>> >
>>> > Regards,
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > El vie, 14 may 2021 a las 11:57, Boris Pérez 
>>> > (mailto:polu...@gmail.com>>)
>>> > escribió:
>>> >
>>> >> Where is the code, that u are using...
>>> >> Si quieres igual hablamos en español...
>>> >> Saludos...
>>> >>
>>> >> 2021-05-13 22:03 GMT-04:00, Walter Randazzo 
>>> >> mailto:wwranda...@gmail.com>>:
>>> >> > Hi Gabriel,
>>> >> >
>>> >> > I´ve just share the code via snippet to respect the identation of
>>> >> > the
>>> >> code
>>> >> >
>>> >> >
>>> >> > El jue, 13 may 2021 a las 21:47, Gabriel Araya Garcia (<
>>> >> > gabrielaraya2...@gmail.com>) 
>>> >> > escribió:
>>> >> >
>>> >> >> The links (image, code, and   https://tmpsee.com/v/nbkdqhnxee)
>>> >> >> they
>>> >> >> are
>>> >> >> shit. It is impossible see it. Why you don't cut and paste here in
>>> >> >> forum
>>> >> >> page ?
>>> >> >> Gabriel Araya Garcia
>>> >> >> GMI - Desarrollo de Sistemas Informáticos
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> El jue, 13 may 2021 a las 20:22, Walter Randazzo
>>> >> >> (mailto:wwranda...@gmail.com>
>>> >> >)
>>> >> >> escribió:
>>> >> >>
>>> >> >>> Here is how the dictionary is render out in the template:
>>> >> >>> https://tmpsee.com/v/nbkdqhnxee
>>> >> >>>
>>> >> >>> thanks
>>> >> >>>
>>> >> >>> --
>>> >> >>> You received this message because you are subscribed to the
>>> >> >>> 

Re: Building reports in Django / Python

2021-04-24 Thread Benny M
Ah! Had to go back and read again. I think I misunderstood.

While I don’t have a ton of experience with either, Pandas and Prometheus are 
popular analysis libraries. I’ve seen cases where a CMS is built around Pandas 
for user interaction... but that does requires bit of code work to build out 
the forms and resultant tables.

Benny



On Apr 24, 2021, at 3:33 PM, Andréas Kühne  wrote:

 Thanks Benny,

I think I may have been a bit unclear. We have this working today with excel - 
and it works ok. The problem is that we have issues with layout and graph 
styling and so on. What I want to do is move away from excel to another 
solution - but I can’t seem to find any...

Med vänliga hälsningar,

Andréas

24 apr. 2021 kl. 22:13 skrev Benny M :

 This is a great use of management commands. I use that combined with a cron 
job to generate reports on a schedule. The management command allows you to use 
Django’s ORM for polling data, and there’s excel packages out there (can’t 
think of a name off the top of my head), but even to that point, excel will 
accept a CSV, which can very easily be constructed with python.

Hope this helps,
Benny

On Apr 24, 2021, at 3:04 PM, Andréas Kühne  wrote:


Hi all,

I was wondering if anyone has any good resources for building reports in Django 
/ Python. What I am trying to do is the following:
* I have built a questionnaire motor - it works more or less like google forms 
and collects the input from 1 or more respondents to a questionnaire. So far so 
good.
* We are currently exporting the data into excel, where we can build reports 
(with graphs and so on). However - this is not working the way we want it to.
* What we want to be able to do is somehow create a report from the data, and 
in certain cases group several questions into one graph. Now I know this can be 
done with code - but here's the tricky part - we want the users to be able to 
design their reports themselves.
* Finally we want to be able to PDF the report and send it to the end user (the 
respondent of the questionnaire).

So my questions are:
1. Has anyone done anything like this? Does anyone have any pointers they could 
give me?
2. Does anyone know of any good packages that could help? I am not talking 
about just using reportlab for PDF generation or matplotlib for creating 
graphs, but rather some more high level packages that would be a good 
inspiration?

I am trying to find something that could help me do this task - as I'm not 
really excited about creating this myself :)

Regards,

Andréas

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcANYcwGkHxNTpkU%2BGa6-_d9FRdvaGUJKAg4DqZAN9FJg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAK4qSCcANYcwGkHxNTpkU%2BGa6-_d9FRdvaGUJKAg4DqZAN9FJg%40mail.gmail.com?utm_medium=email&utm_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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH2PR14MB3913F92052E193091E8ACBDCC0449%40CH2PR14MB3913.namprd14.prod.outlook.com<https://groups.google.com/d/msgid/django-users/CH2PR14MB3913F92052E193091E8ACBDCC0449%40CH2PR14MB3913.namprd14.prod.outlook.com?utm_medium=email&utm_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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CFF6E9E5-64D3-49B3-AEFD-13CAB587AB98%40hypercode.se<https://groups.google.com/d/msgid/django-users/CFF6E9E5-64D3-49B3-AEFD-13CAB587AB98%40hypercode.se?utm_medium=email&utm_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/CH2PR14MB39131E5550BF63148ED260A6C0449%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: Building reports in Django / Python

2021-04-24 Thread Benny M
This is a great use of management commands. I use that combined with a cron job 
to generate reports on a schedule. The management command allows you to use 
Django’s ORM for polling data, and there’s excel packages out there (can’t 
think of a name off the top of my head), but even to that point, excel will 
accept a CSV, which can very easily be constructed with python.

Hope this helps,
Benny

On Apr 24, 2021, at 3:04 PM, Andréas Kühne  wrote:


Hi all,

I was wondering if anyone has any good resources for building reports in Django 
/ Python. What I am trying to do is the following:
* I have built a questionnaire motor - it works more or less like google forms 
and collects the input from 1 or more respondents to a questionnaire. So far so 
good.
* We are currently exporting the data into excel, where we can build reports 
(with graphs and so on). However - this is not working the way we want it to.
* What we want to be able to do is somehow create a report from the data, and 
in certain cases group several questions into one graph. Now I know this can be 
done with code - but here's the tricky part - we want the users to be able to 
design their reports themselves.
* Finally we want to be able to PDF the report and send it to the end user (the 
respondent of the questionnaire).

So my questions are:
1. Has anyone done anything like this? Does anyone have any pointers they could 
give me?
2. Does anyone know of any good packages that could help? I am not talking 
about just using reportlab for PDF generation or matplotlib for creating 
graphs, but rather some more high level packages that would be a good 
inspiration?

I am trying to find something that could help me do this task - as I'm not 
really excited about creating this myself :)

Regards,

Andréas

--
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/CAK4qSCcANYcwGkHxNTpkU%2BGa6-_d9FRdvaGUJKAg4DqZAN9FJg%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/CH2PR14MB3913F92052E193091E8ACBDCC0449%40CH2PR14MB3913.namprd14.prod.outlook.com.


Finding unsupported bytestring

2021-04-07 Thread Benny M
Hi folks,

We’re finally making our move out of 1.x Django and one of the changes we’ve 
ran into is the removed support for bytestring in some places: 
https://docs.djangoproject.com/en/2.0/releases/2.0/#removed-support-for-bytestrings-in-some-places
 



I’m looking for suggestions on any specific areas to look at when attempting to 
find places in the codebase we need to update.
So in this case, am I just looking for any strings that are specifically 
preceded with `b` or encoded, that are being fed into HttpResponse or 
reverse/redirect objects - or are there other gotchas that I may not be 
considering?

More or less I’m just looking for some help in finding these areas aside of 
running python in `-b` mode and hoping for the best.


Thanks in advance,
Benny

-- 
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/CH2PR14MB39138DB3EE228CB31EE33DA9C0759%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: DJANGO AWS: Failed to load resource: the server resp....403 (Forbidden)

2021-02-04 Thread Benny M


> Well, still its first time I read him being sarcastic or kind of fed up.Its 
> hilarious 🤣.

Sometimes hyperbole is the perfect solution. The smart ones realize they’re 
being lazy and make it a point to try some due diligence next time.

It worked on me. Soon as I started figuring out my own bugs, somebody started 
paying me for it. 

-- 
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/CH2PR14MB3913E05CA13F271543AC4920C0B29%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: test client vs jinja?

2021-02-04 Thread Benny M
Hi Roy,

I haven’t been through this personally, but it strikes me as odd that the test 
can’t read the request context. On the surface it would stand to reason that if 
the test can’t read it, then the page wouldn’t render on browser request. Can 
you post an example of one of your failing tests and the accompanying failure 
result?

Benny

-- 
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/CH2PR14MB3913E73F316DE1CD18B79ED9C0B29%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: DJANGO AWS: Failed to load resource: the server resp....403 (Forbidden)

2021-02-04 Thread Benny M
Lightning,
I think what Kasper means to say is that there are a few reasons why AWS isn’t 
authorizing your request, and the likelihood that Django is somehow involved in 
that error is pretty much zero. 

HTTP 403 means that some authorization/permission isn’t sufficient for the 
server to fulfill the request. Look into your AWS configs or contact their 
support team.

That said, I have no right to speak for Kasper, so my interpretation may, in 
itself, generate a 403. 

> On Feb 4, 2021, at 11:36 PM, Kasper Laudrup  wrote:
> 
> On 05/02/2021 06.05, Lightning Bit wrote:
>> Does anyone know how to bypass the 403 error on AWS S3 with Django where the 
>> static files are not allowed to show up on the site?
>> 
> 
> Ah, yes. The 403 error we all heard of. Everyone knows how to bypass that. 
> Everyone except 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/ff1118ea-b429-3264-5bea-8f8a01f245ef%40stacktrace.dk.

-- 
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/CH2PR14MB39130275C1DDBA94452D89E1C0B29%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: how to split in multiple file class models.py?

2021-02-01 Thread Benny M
Not a problem at all, Andréas. Gave me a chuckle.

Best,
Boney

On Feb 2, 2021, at 1:45 AM, Andréas Kühne  wrote:


Sorry, BENNY M. Apologies.

Regards,

Andréas


Den tis 2 feb. 2021 kl 08:44 skrev Andréas Kühne 
mailto:andreas.ku...@hypercode.se>>:
So,

Boney M's assumption here is correct.

You just need to import all of your models in the __init__.py file using 
relative imports, so for example:

from .car import Car

and so on.

This works perfectly and I usually try to split the models in that way as not 
to get a models.py that is over 1 lines long.

Regards,

Andréas


Den tis 2 feb. 2021 kl 07:27 skrev Benny M 
mailto:chibe...@outlook.com>>:
Just a thought, I haven’t tested this: you might be able to trick access to 
subdirectories by importing those models in the top-level models/__init__.py - 
now that I think about it, you might have to do that with all the models... so 
your __init__ file would say something like:

```
from .car import SomeModel
from .otherPackage.other_model import SomeOtherModel
# and so on ...
```

Again, I could be way off here. I’ve never looked at the magic that parses the 
models on migration creation.

Best,
Benny

On Jan 30, 2021, at 5:44 PM, Manuel 
mailto:emanuele@gmail.com>> wrote:

Hello everyone, I have a question about Django and the use of namespaces or 
packages to split the models.py file.
I would like to adopt the Java philosophy in which one file corresponds one 
class and one db table.
I tried to follow this guide, but it doesn’t work.
https://docs.djangoproject.com/en/3.1/ref/applications/#namespace-packages-as-apps

when I execute this command: "python manage.py makemigrations myapp"

Return this warning: "No changes detected in app"

Is it possible to do this structure?

/models
__init__py # if i use package, or without for namespace
 #common import
car.py # class car
group.py # class group
manufactor.py # class manufactor
/otherPackage
__init__py
common import
otherClass.py

I hope you understand what I’d like to do.
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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6cdc67de-94cb-4ad3-8c73-bc91da02b8bfn%40googlegroups.com<https://groups.google.com/d/msgid/django-users/6cdc67de-94cb-4ad3-8c73-bc91da02b8bfn%40googlegroups.com?utm_medium=email&utm_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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH2PR14MB3913E5B5C52AD6AC35E63C69C0B59%40CH2PR14MB3913.namprd14.prod.outlook.com<https://groups.google.com/d/msgid/django-users/CH2PR14MB3913E5B5C52AD6AC35E63C69C0B59%40CH2PR14MB3913.namprd14.prod.outlook.com?utm_medium=email&utm_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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCej1DNm7tJ-Nfsm1TyO%2BBZyQZJj40-PnQArjjEA_C4bNQ%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAK4qSCej1DNm7tJ-Nfsm1TyO%2BBZyQZJj40-PnQArjjEA_C4bNQ%40mail.gmail.com?utm_medium=email&utm_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/CH2PR14MB3913A370CF72C494C7866D05C0B59%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: how to split in multiple file class models.py?

2021-02-01 Thread Benny M
Just a thought, I haven’t tested this: you might be able to trick access to 
subdirectories by importing those models in the top-level models/__init__.py - 
now that I think about it, you might have to do that with all the models... so 
your __init__ file would say something like:

```
from .car import SomeModel
from .otherPackage.other_model import SomeOtherModel
# and so on ...
```

Again, I could be way off here. I’ve never looked at the magic that parses the 
models on migration creation.

Best,
Benny

On Jan 30, 2021, at 5:44 PM, Manuel  wrote:

Hello everyone, I have a question about Django and the use of namespaces or 
packages to split the models.py file.
I would like to adopt the Java philosophy in which one file corresponds one 
class and one db table.
I tried to follow this guide, but it doesn’t work.
https://docs.djangoproject.com/en/3.1/ref/applications/#namespace-packages-as-apps

when I execute this command: "python manage.py makemigrations myapp"

Return this warning: "No changes detected in app"

Is it possible to do this structure?

/models
__init__py # if i use package, or without for namespace
 #common import
car.py # class car
group.py # class group
manufactor.py # class manufactor
/otherPackage
__init__py
common import
otherClass.py

I hope you understand what I’d like to do.
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/6cdc67de-94cb-4ad3-8c73-bc91da02b8bfn%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/CH2PR14MB3913E5B5C52AD6AC35E63C69C0B59%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: Django rext framework join multiple table without nested data

2021-02-01 Thread Benny M
If your using a values_list command, try adding the `flat=True` argument.
Or you could set the depth on your Meta parameters: 
https://www.django-rest-framework.org/api-guide/serializers/#specifying-nested-serialization

Benny

On Feb 1, 2021, at 6:17 AM, narendra...@gmail.com  
wrote:

i have  a two table and want to fetch data based on their relationship using 
serializer. I'm able to get nested data like

{
'ID':1,
'name':'abc',
'address':[
{

}
]


but i want it as in single not as nested
{
.
}

can any body help me with sample code or reference me a good example so i can 
understand


--
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/551a9e41-d743-40d2-bab9-f4e6eb8ea941n%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/CH2PR14MB3913607AF402D3532C3A6A07C0B59%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: Classifieds page loading is to slow

2021-02-01 Thread Benny M
You could try caching your results, or even store them in the table, or related 
table. If the ads location doesn’t change, there doesn’t seem to be a need to 
call the api every single time. Additionally, if the results aren’t needed 
right away, you could queue the job of calling the api, such that even if the 
api round-trip takes a while, the user can continue uninterrupted, while the 
queued job does the work of fetching and storing the results.

Benny

On Feb 1, 2021, at 11:07 PM, Salima Begum  wrote:


Thank you everyone. We identified the issue.
Basically we are using an API which calculates distance
between two different ads using zip code value and this help us
to show the distance of the ad from logged-in users location.
So when classifies page is being loaded, this API is called for each and every.
Ad and taking time to process distance calculation for each Ad.
So we need to avoid this somehow and we are looking for any advanced method or 
package to achieve 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMSz6b%3DzPyf8_p8zxKw2DRMpcdmVeVXoAaSGnxo%2BLa4t2yaTQg%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/CH2PR14MB3913BDBA42CF0F356DDCD8D6C0B59%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: Classifieds page loading is to slow

2021-01-16 Thread Benny M
Ram,
These are all pieces to a puzzle. Indexing, ORM optimization and through tables 
all add up to an efficient page render. Additionally, you could consider 
caching some of your results, using a key like ‘postal code’ - some sort of 
constant that you could use as a metric/pivot. Use a cron job to populate your 
through tables and cache the results for a faster return.

Benny

On Jan 16, 2021, at 5:47 PM, Ram  wrote:


Hi,

We have a similar type of challenge in our project. We will definitely try 
indexing.

Basically we are currently doing like this.

1. Registered users can post an ad in Classifieds by uploading 4 - 6 images per 
ad. All the ads are placed in one postgres db table. (classifieds table)

2. Same user opens the Classifieds page where we list all the Ads posted by 
this user as well as other users. This page loading is taking a lot of time.

3. Each ad will display a thumbnail image, title of the ad, 2 line description, 
price value, distance value from nearby zip code, age of the ad, zip code

4. Since we  are calculating the distance between zip codes each Ad using a 
third party API, I think page loading is taking a lot of time.
4.1. I've dumb idea here where I can add a. new table, 'nearby_ads table'. As 
soon as the ad was submitted successfully, process the ads distance and add all 
the nearby ads into this table. When the classifieds page is launched, only 
nearby ads will be displayed. First of all I'm not sure whether this is a good 
idea because we are going to have two tables, one is classifieds table and the 
other one is a nearby_ads table.  Second of all I'm not sure what is the limit 
that I can set limit on how far I could calculate nearby ads ( like 10 miles or 
30 miles or 50 miles radius).

5. Our goal is to present all the nearby ads based on the logged in user zip 
code and if a visitor opens this Classifieds page, we have to capture nearby 
location of the visitor and present the nearby ads.

6. Additionally registered users and visitors should be able to filter the ads 
based on different zip code though both are from different location

Please let me know if you recommend any advanced packages or libraries in 
Django or Python to achieve the above. Or indexing is the only option to reduce 
the page loading time? I appreciate it if you can share any recommendations and 
pointers.

Best Regards
~Ram

On Fri, Jan 15, 2021 at 12:51 AM Benjamin Schollnick 
mailto:bscholln...@schollnick.net>> wrote:
Also don’t forget to include Indexing.

As a general rule, any field that you perform any query against, should be 
indexed.
Yes, it costs a “bit” for disk space, but indexing can dramatically increase 
your query speed.

- Benjamin



On Jan 14, 2021, at 10:44 PM, Benny M 
mailto:chibe...@outlook.com>> wrote:

Slow loading can be sometimes be caused by non-optimized or overly complex 
queries. Look into prefetch_related and select_related for starters. 
https://docs.djangoproject.com/en/3.1/ref/models/querysets/

Django Debug Toolbar is also a great packages for examining the interaction 
between Django’s ORM and your database.

Best,
Benny

On Jan 14, 2021, at 9:18 PM, Salima Begum 
mailto:salim...@rohteksolutions.com>> wrote:


Hi all,

We are building a Web application, We have a classifieds page that is loading 
too slow. How to fix this issue. how to reduce loading time of classifieds page.

Thanks
~Salima

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMSz6bnvP51oD_dfhY0YEWiGHGq3DbZ04u%2Bz6Vg_9sBPGvjgOw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMSz6bnvP51oD_dfhY0YEWiGHGq3DbZ04u%2Bz6Vg_9sBPGvjgOw%40mail.gmail.com?utm_medium=email&utm_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<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH2PR14MB391358D987FFC8303F087CD5C0A70%40CH2PR14MB3913.namprd14.prod.outlook.com<https://groups.google.com/d/msgid/django-users/CH2PR14MB391358D987FFC8303F087CD5C0A70%40CH2PR14MB3913.namprd14.prod.outlook.com?utm_medium=email&utm_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<mailto:django-users+unsubscr...@googlegroups.

Re: Classifieds page loading is to slow

2021-01-14 Thread Benny M
Slow loading can be sometimes be caused by non-optimized or overly complex 
queries. Look into prefetch_related and select_related for starters. 
https://docs.djangoproject.com/en/3.1/ref/models/querysets/

Django Debug Toolbar is also a great packages for examining the interaction 
between Django’s ORM and your database.

Best,
Benny

On Jan 14, 2021, at 9:18 PM, Salima Begum  wrote:


Hi all,

We are building a Web application, We have a classifieds page that is loading 
too slow. How to fix this issue. how to reduce loading time of classifieds page.

Thanks
~Salima

--
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/CAMSz6bnvP51oD_dfhY0YEWiGHGq3DbZ04u%2Bz6Vg_9sBPGvjgOw%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/CH2PR14MB391358D987FFC8303F087CD5C0A70%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: Compatibility List

2020-12-30 Thread Benny M
P.S.
> 
> Effectively 2.2 is as far as you need to go for the time being because it is 
> an LTS release. Might make a convenient initial goal. Should be pain-free.
> 
Unfortunately that’s not an option.

-- 
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/CH2PR14MB391377CB97F4273EEDC0759DC0D60%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: Compatibility List

2020-12-30 Thread Benny M
Thanks for your response, Mike.
I was using “changelog” and “release notes” interchangeably; sorry for the 
confusion.

My question is more about packages that extend Django’s capabilities (i.e. 
django_csp, django_rq, etc.) as opposed to Django itself.

Thankfully Django has great release notes, so catching up there isn’t a 
problem. However, what would be good way to audit third-party dependencies to 
find out which ones need to be updated to work with 3.1, or which haven’t 
caught up?

Benny

-- 
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/CH2PR14MB391372A0B03FB70C422841F2C0D60%40CH2PR14MB3913.namprd14.prod.outlook.com.


Compatibility List

2020-12-30 Thread Benny M
Hi all,

I have a project that’s doing a rather sizable jump from 1.11.29 to 3.1.
I’m aware of the internal gotchas (enforced on_delete, settings syntax, etc) - 
but I was curious if anyone knows of a package compatibility list exists?
Something like caniuse but for django-focused packages. Right now I’m just 
going through the changelogs of the packages used in the project and making an 
educated guess.

If one doesn’t exist (could be a fun and useful project?) please feel free to 
mention any gotchas you’ve found.

Thanks!
Benny

-- 
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/CH2PR14MB39132F7199BF556D16FE13C2C0D60%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: How can I host my django project on my pc for someone to see it outside my WIFI network

2020-12-23 Thread Benny M
I’m going to second Kasper on this. There’s enough affordable options out there 
that self hosting to a “safe enough” degree would be the more expensive route 
to go. 

I did this myself for a little while - had a makeshift cloud service for myself 
right up until I had a dev-ops friend take a look. His little giggles and 
eye-rolls were enough to convince me that I was wholly out of my league.

It’s a fun idea, but if you’re going to do it right, it’s not going to be cheap 
and it’s still not going to be secure enough to keep your network from being 
compromised. 

> On Dec 23, 2020, at 3:02 PM, Kasper Laudrup  wrote:
> 
> On 23/12/2020 18.46, joseenoc...@gmail.com wrote:
>> Can some one pls explain what steps show I follow to host my django project 
>> on my pc and allow anyone outside my network WIFI to see the webiste
>> 
> 
> You don't want to do that, but just in case:
> 
> You probably want to ensure that you have a static IP from your internet 
> provider. If you don't have that or for some reason cannot get one, consider 
> looking into dynamic DNS so you have a well known DNS name when your public 
> IP address changes.
> 
> Configure your router to forward requests on the port where your Django 
> website is running to the IP of your PC.
> 
> But you seriously don't want to do that. Look into how to deploy your website 
> instead.
> 
> Kind regards,
> 
> Kasper Laudrup
> 
> -- 
> 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/90d7384c-e6ea-4485-60da-3a57c0cd3707%40stacktrace.dk.

-- 
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/CH2PR14MB3913826C4668B8F16D33278AC0DE0%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: MultipleChoiceField form bug?

2020-12-22 Thread Benny M
Oh this worked out beautifully! Not sure why it hadn’t occurred to me to call 
super().__init__ before hand. And manipulating self.fields was the farthest 
thing from my mind.


As for using ModelMultipleChoiceField - that’s ultimately what I went with for 
the project, but I couldn’t let go of why I couldn’t figure this out. Lol
This is going to be handy in the future. I feel like I have leveled up!

Thanks a ton, Carles!

-- 
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/CH2PR14MB391328ADA5F398BF81643C36C0DE0%40CH2PR14MB3913.namprd14.prod.outlook.com.


Re: MultipleChoiceField form bug?

2020-12-22 Thread Benny M
That’s correct. I am using a class variable since there doesn’t seem to be a 
DRY - or at least not messy - way of manipulating this from __init__.

That said, your explanation makes sense and does answer the “why” of this. If 
there’s a way of defining forms inside __init__ I haven’t found it… which is 
not to say that it doesn’t exist.

Here’s an example of what I’m referring to:
(Pardon my poorly labeled model/form names)

```
class M2MForm(forms.ModelForm):
“”” Populate/update M2MModel name and m2m references ””"
REF_OPTIONS = ((r.id, r.name) for r in RefModel.objects.all())

ref_models = forms.MultipleChoiceField(
widget=forms.SelectMultiple,
choices=REF_OPTIONS,
required=False
)

class Meta:
model = M2MModel
fields = ['name']
```

> On Dec 22, 2020, at 9:31 AM, Carles Pina i Estany  wrote:
> 
> 
> 
> Hi,
> 
> On Dec/22/2020, Benny M wrote:
> 
>> I’ve ran into some unexpected behavior while testing a ModelForm with
>> a MultipleChoiceField and am trying to determine if this is a bug, or
>> if maybe I’m doing something out of the ordinary.
> 
> I think that I might guess what it is. If I could see the code it might
> be easier.
> 
> Are you doing something like:
> 
> class SomeForm(forms.ModelForm):
>some_field_options = a_dynamic_expression_that_queries_the_DB
> 
>def __init__(*args, **kwargs):
>your code
> 
> So using a class variable instead of an instance variable?
> 
> Class variables are initialised on "startup" (I'm simplifying) and only
> once (and might be used via __new__ on ModelFormMetaclass probably, read
> and validated).
> 
> Either way, if it's not what I've guessed and you paste some code it
> might help me / someone else to understand it better.
> 
> I had once a bug because of using datetime.now() in a class variable
> when I wanted it the "now" that the view was used not the "now" when the
> application was started up.
> 
> -- 
> Carles Pina i Estany
> https://carles.pina.cat
> 
> -- 
> 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/20201222153133.GA31856%40pina.cat.

-- 
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/CH2PR14MB39136CDA719529325B91F0E3C0DF0%40CH2PR14MB3913.namprd14.prod.outlook.com.


MultipleChoiceField form bug?

2020-12-22 Thread Benny M
Hi all,

I’ve ran into some unexpected behavior while testing a ModelForm with a 
MultipleChoiceField and am trying to determine if this is a bug, or if maybe 
I’m doing something out of the ordinary.

In the form, I’m generating the MultipleChoiceField choices on the fly. e.g. 
`OPTIONS = ((m.id, m.name) for m in Model.objects.all())` then 
assigning `OPTIONS` to the `choices` attribute in the field declaration.

When running the test the form generates the choices from the non-test db, 
which results in a failure, as I’m creating the model instance for POST in the 
test. So because of this behavior, the instance created in the test isn’t part 
of the form choices.

It seems like:
- ./manage.py test
- Generate form choices
- Instantiate Test
- Test creates expected choice(s) and calls view with POST data
- form.is_valid() fails due to generated test instance not being in choices

It seems odd to me that the form is (or at least parts of it are) being built 
before any direct reference to it is instantiated. But this may be 
normal/expected behavior. I’ve seen the same behavior in 1.11 and 3.1.4, so 
it’s most likely that my method for dynamically generating choices isn’t kosher.

Anyway, if this sounds like a possible bug let me know and I’ll submit an issue 
with steps to reproduce, or provide more information here on request.


Thanks,
Benny

-- 
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/CH2PR14MB391319A069301FDB1FE1DE4FC0DF0%40CH2PR14MB3913.namprd14.prod.outlook.com.