Sunday, January 31, 2021

Hi any body help i want code video belonging views,likes and dislikes



Mahendra Yadav

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAN-6G3x0h_PgxHQsTHXSF15QiLoEFxEdykwNzdGpg%3DKWw4B6sw%40mail.gmail.com.

Error: Login at the Admin Page (Django)


Hi everybody. I am having some troubles. I am taking the free course of Prof. Charles Severance (Dr. Chuck)., on lesson 6, tutorial part 2, I've created the username and password successfully,  but at the  moment to login at http://djtutorial.dj4e.com/admin I receive the following message:

"Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive."

I do not know what's going on. Please I need some help.

Thanks in advanced.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7906d9e9-324d-4e29-a1d4-ad861a479b6cn%40googlegroups.com.

Re: Django site as SOAP endpoint


Hi Fenrir,

You may give Spyne (http://spyne.io/) a try.
It is a RPC framework that can handle SOAP requests and has a Django integration.
Spyne has a couple of drawbacks - IMHO it tries to do too any things and may be somewhat complex - but it does the job.

Hopes this will help,
Xavier O.
Le dimanche 31 janvier 2021 à 08:45:51 UTC+1, fenrir...@gmail.com a écrit :
I'm working on a project where one of the remote parties requires us to serve a SOAP api. I have plenty experience with DRF, but only found soap client examples (using The 'zeep' module: zeep==soap in Dutch)  which I use to call the SOAP api from the other party . There is django-soap-server but the latest version is 10y old)

Does anyone have experience with django as soap endpoint recently?




--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e67f9700-d881-454d-8c8f-897362331cd2n%40googlegroups.com.

Re: Static Folder not loading

Bair me, I am new to group

On Sunday, January 31, 2021 at 10:46:40 PM UTC+5:30 hari49pf wrote:
Its returning

no matching file found for test.css


Regards,
Harish.B


On Friday, January 29, 2021 at 8:26:14 PM UTC+5:30 ule...@gmail.com wrote:

try
./manage.py findstatic test.css
Op vrijdag 29 januari 2021 om 15:52:44 UTC+1 schreef fcip...@gmail.com:
I'm sending from my phone so it won't have markdown.

It looks like your not defining all of them properly. Put a static folder you'll manually in trydjango/trydjango. This will be where Staticfiles_dirs gathers the files. Then static_root will be where is collectstatic will store them. Static_URL is important as it will be the file name target it will look for when running collectstatic.

Try:

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'trydjango/static')



Best Regards,
Frank Cipolone


On Jan 29, 2021, at 6:23 AM, hari49pf <hari...@gmail.com> wrote:


<Screenshot_2021-01-29_16-48-54(django_settings).png>


above is a screenshot and path for the static folder. 
On Friday, January 29, 2021 at 3:05:06 AM UTC+5:30 fcip...@gmail.com wrote:
Whats your STATIC_DIRS, STATIC_PATH, and STATIC_URL and what it the tree to the folder your static is in?

> On Jan 28, 2021, at 1:26 PM, hari49pf <hari...@gmail.com> wrote:
>
> Yes, i did it created a folder with css & other files, but no use.
>
> On 28/01/21 11:49 pm, Larry Martell wrote:
>> On Thu, Jan 28, 2021 at 10:16 AM hari49pf <hari...@gmail.com> wrote:
>>> Hi,
>>>
>>> I am trying to load static file to my project its not loading,
>>> I have changed the path of static in settting.py still its not loading static file.
>>> tryed to check the file is loading by using
>>> manage.py findstatic test.css
>>> PLZ help
>> Have you run collectstatic?
>>
>
> --
> 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/928aaad3-3f02-45e4-91fa-d3a56da673db%40gmail.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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ceb2424c-870d-4467-a29a-7337d0471283n%40googlegroups.com.
<Screenshot_2021-01-29_16-48-54(django_settings).png>

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8056c092-ae57-4478-9bfe-306025bfbd15n%40googlegroups.com.

Re: Static Folder not loading

Its returning

no matching file found for test.css


Regards,
Harish.B


On Friday, January 29, 2021 at 8:26:14 PM UTC+5:30 ule...@gmail.com wrote:

try
./manage.py findstatic test.css
Op vrijdag 29 januari 2021 om 15:52:44 UTC+1 schreef fcip...@gmail.com:
I'm sending from my phone so it won't have markdown.

It looks like your not defining all of them properly. Put a static folder you'll manually in trydjango/trydjango. This will be where Staticfiles_dirs gathers the files. Then static_root will be where is collectstatic will store them. Static_URL is important as it will be the file name target it will look for when running collectstatic.

Try:

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'trydjango/static')



Best Regards,
Frank Cipolone


On Jan 29, 2021, at 6:23 AM, hari49pf <hari...@gmail.com> wrote:


<Screenshot_2021-01-29_16-48-54(django_settings).png>


above is a screenshot and path for the static folder. 
On Friday, January 29, 2021 at 3:05:06 AM UTC+5:30 fcip...@gmail.com wrote:
Whats your STATIC_DIRS, STATIC_PATH, and STATIC_URL and what it the tree to the folder your static is in?

> On Jan 28, 2021, at 1:26 PM, hari49pf <hari...@gmail.com> wrote:
>
> Yes, i did it created a folder with css & other files, but no use.
>
> On 28/01/21 11:49 pm, Larry Martell wrote:
>> On Thu, Jan 28, 2021 at 10:16 AM hari49pf <hari...@gmail.com> wrote:
>>> Hi,
>>>
>>> I am trying to load static file to my project its not loading,
>>> I have changed the path of static in settting.py still its not loading static file.
>>> tryed to check the file is loading by using
>>> manage.py findstatic test.css
>>> PLZ help
>> Have you run collectstatic?
>>
>
> --
> 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/928aaad3-3f02-45e4-91fa-d3a56da673db%40gmail.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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ceb2424c-870d-4467-a29a-7337d0471283n%40googlegroups.com.
<Screenshot_2021-01-29_16-48-54(django_settings).png>

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/657d90be-4191-4834-9a6a-a6d208db732en%40googlegroups.com.

Re: Hi

What's the project all about?

On Thu, Jan 28, 2021, 5:46 PM Sunday Iyanu Ajayi <sunnexajayi@gmail.com> wrote:
Hi  Florin,

What support do you need? You can reach out via my email.
AJAYI Sunday 
(+234) 806 771 5394



On Tue, Jan 26, 2021 at 3:10 PM Florin Ngabire <ngabiflo69@gmail.com> wrote:
My name is florin.i need a support. A small Python project in django framework 

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACynOu%2BySEKrNgRhwKXYm0%3DOwOau1AS554ywRrzJ3Ru8mgavwA%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKYSAw2PEDYL6PmFpWOzHqdDyYGmmuLJeHibZACJ8mk0nbgpMw%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANyXpoqa6DFK69%3DifqPZXg6nWh%3DA6Q%3DT_RzFFJhnFhaBW%3DJB3w%40mail.gmail.com.

Re: Static Folder not loading

runned colletcstatic,
there is no output.


On Thursday, January 28, 2021 at 11:51:20 PM UTC+5:30 Larry.Martell@gmail.com wrote:
On Thu, Jan 28, 2021 at 10:16 AM hari49pf <hari...@gmail.com> wrote:
>
> Hi,
>
> I am trying to load static file to my project its not loading,
> I have changed the path of static in settting.py still its not loading static file.
> tryed to check the file is loading by using
> manage.py findstatic test.css
> PLZ help

Have you run collectstatic?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a11ec64-ed24-4bf0-80fa-a0293b792435n%40googlegroups.com.

Re: about django documentation

I recommend following the tutorial all the way through. Getting that tutorial running in your own computer will answer 95% of a beginner's questions.

https://docs.djangoproject.com/en/3.1/intro/tutorial01/

On January 18, 2021 9:27:56 PM CST, a a <m.m.abdelsalam05@gmail.com> wrote:
i have end the django introduction but i do not know where continue
i was start with models but there are error in terminal

NameError: name 'Person' is not defined

this is link: https://docs.djangoproject.com/en/3.1/topics/db/models/

Re: Django site as SOAP endpoint

On January 31, 2021 1:44:46 AM CST, Fenrir Sivar <fenrir.sivar@gmail.com> wrote:
>I'm working on a project where one of the remote parties requires us to
>serve a SOAP api. I have plenty experience with DRF, but only found
>soap
>client examples (using The 'zeep' module: zeep==soap in Dutch) which I
>use
>to call the SOAP api from the other party . There is django-soap-server
>but
>the latest version is 10y old)
>
>Does anyone have experience with django as soap endpoint recently?

I don't, but if I had to time travel back to the 90's and offer a SOAP API here's what I'd do. Twisted offers a SOAP API server:

https://docs.twistedmatrix.com/en/twisted-18.7.0/web/howto/xmlrpc.html#soap-support

I'd start with that and call Django models from Twisted.

Best of luck with your remote party from the past 😉

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/B5D11174-A752-44B5-9700-872CA38EE62A%40fattuba.com.

Re: Show FK as input instead of drop down in admin

Another option if you want to show actual data, but only a portion, is to use an incremental lookup via an app such https://django-autocomplete-light.readthedocs.io/en/master/ - this works in the Admin as well.

On Saturday, 30 January 2021 at 20:58:00 UTC+2 Ryan Nowakowski wrote:
On Wed, Jan 27, 2021 at 05:33:10AM -0800, Kevin Olbrich wrote:
> Is it possible to disable fetching of related models for admin pages?
> I have a field that links to a table containing more than 1M rows which
> django tries to fetch and build the drop down. For my purpose, it is
> sufficient if it is a simple input containing the id instead.
>
> How can I accomplish this?

Yes, raw_id_fields is specifically designed for this:

https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8db9a0dd-336b-451c-85ac-f3fccbddf455n%40googlegroups.com.

Re: problem at saving a file (namecheap)

On 30/01/2021 21.28, mohamed masstour wrote:
> i have a problem with Django project (namecheap) , when i try to saving
> a file i get a Server Error (500)please help me .
>

It doesn't sound like this is related to Django, so it is very unlikely
anyone here can help you.

Instead contact Namecheap support:

https://www.namecheap.com/help-center/

Of course, it is hard for anyone to guess what you mean by "saving a
file" and I doubt Namecheap support can guess that either.

Consider learning how to ask a question if you want someone to help you:

https://stackoverflow.com/help/how-to-ask

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a3c9ab83-a0fc-b69e-212b-ba7c04abf19a%40stacktrace.dk.

Saturday, January 30, 2021

Django site as SOAP endpoint

I'm working on a project where one of the remote parties requires us to serve a SOAP api. I have plenty experience with DRF, but only found soap client examples (using The 'zeep' module: zeep==soap in Dutch)  which I use to call the SOAP api from the other party . There is django-soap-server but the latest version is 10y old)

Does anyone have experience with django as soap endpoint recently?




--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFpG6u-2g9Pms08LzYChwDnXeO2Ja%3D6ZLNuahjfM-Qk_aahXMQ%40mail.gmail.com.

Re: How can I use my Company SSO(Single sign On ) for login into my django application ??

If its shibboleth follow this. 

Use Apache with wsgi.

Thanks,
Dhiraj D J

On Sat, Jan 30, 2021 at 12:16 PM Ryan Nowakowski <tubaman@fattuba.com> wrote:


On January 27, 2021 8:14:55 AM CST, Larry Martell <larry.martell@gmail.com> wrote:
>On Wed, Jan 27, 2021 at 6:02 AM Kumar Gaurav
><gauravcusat1999@gmail.com> wrote:
>>
>> Hii ,
>>
>> My users come to my django application after authenticated from
>company SSO.
>> Now , I don't want to create my own authentication model. I just want
>to login the users who come to my page from the requests storing the
>details.
>>
>> Anyone know how to implement this ?? I am stuck on it from last week
>.
>
>What is your company's SSO? Azure? If so you could use
>https://pypi.org/project/django-microsoft-auth/

A couple of other alternatives that I use or that I've heard of other folks using successfully:

  https://python-social-auth.readthedocs.io/en/stable/configuration/django.html

https://django-allauth.readthedocs.io/en/latest/

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5A054513-6561-4EF3-B32C-9D50BF3F1625%40fattuba.com.


--
sent by DHIRAJ D DJ

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFKhs2Pdskb6J0iG_%3DKXHiQPhJ-RjVejZ%3DFwEQntXCdsWt%3DQ9A%40mail.gmail.com.

problem at saving a file (namecheap)

i have a problem with Django project (namecheap) , when i try to saving a file i get a Server Error (500)please help 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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a529ec68-3d7f-4ec2-b4a4-7cee2d60c733n%40googlegroups.com.

how to split in multiple file class models.py?

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+unsubscribe@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.

Re: How can I use my Company SSO(Single sign On ) for login into my django application ??

On January 27, 2021 8:14:55 AM CST, Larry Martell <larry.martell@gmail.com> wrote:
>On Wed, Jan 27, 2021 at 6:02 AM Kumar Gaurav
><gauravcusat1999@gmail.com> wrote:
>>
>> Hii ,
>>
>> My users come to my django application after authenticated from
>company SSO.
>> Now , I don't want to create my own authentication model. I just want
>to login the users who come to my page from the requests storing the
>details.
>>
>> Anyone know how to implement this ?? I am stuck on it from last week
>.
>
>What is your company's SSO? Azure? If so you could use
>https://pypi.org/project/django-microsoft-auth/

A couple of other alternatives that I use or that I've heard of other folks using successfully:

https://python-social-auth.readthedocs.io/en/stable/configuration/django.html

https://django-allauth.readthedocs.io/en/latest/

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5A054513-6561-4EF3-B32C-9D50BF3F1625%40fattuba.com.

Re: How would this be done within the Django framework?

Hi Ryan,

Thanks, that's very helpful.  I suspected that this would require REST.

DRE

On Sat, Jan 30, 2021 at 12:54 PM Ryan Nowakowski <tubaman@fattuba.com> wrote:
On Sat, Jan 30, 2021 at 08:49:09AM -0800, dazzle.razzle.em wrote:
> I am new to Django and to web development, and am trying to get my bearings.
>
> Suppose that I provide a web page that asks the user for an airport, a
> start date, an end date, a number of days.  The server is supposed to go to
> the NOAA website, grab temperature data for the range of dates, and do a
> moving average filter over the given number of days; and then display for
> the client a graph of the smoothed data, constructed maybe with SVG.  I
> know how to do the NOAA access and create the graph (if I do it just on my
> computer using Python), but I don't know how to fit the client data
> specification and the server's response into the Django framework.  My
> point is that none of this involves Django models at all, and what I am
> having trouble with is: where does my code that does stuff fit in.

I'd start by calling your code from a Django view.

1. You can start with some hard-coded NOAA client request data in the view
2. The response from NOAA probably returns json which you can convert
   into Python data structures(dicts, lists) using the json lib.
3. Pass that response data into your template as the context.  ex:

    return render(request, 'weather.html', context=noaa_response_data)

4. In your template, iterate through the noaa response data to display
   it as a table for now.
5. Replace the hard coded noaa client request from step 1 with data from
   a form that the user submits (see form tutorial as an example).  You may
   have to do some work here converting the form data into the data format
   that your NOAA client code expects.
6. Add a way to display your SVG graph of the data in your template
   in addition to the simple table from step 4

> Can this type of client-server interaction be handled by the Django
> framework, and if so, how would this be structured very generally?

I am a big fan of "type until it works".  So you'd start with one Django
view and just type code into that view function until you have your
desired behavior.  Messy code is ok.  Example here:

https://simpleisbetterthancomplex.com/tutorial/2018/02/03/how-to-use-restful-apis-with-django.html

Then if you want, you can refactor the code to make it
more modular and reusable.  I like the services.py pattern:

https://stackoverflow.com/a/30312778/226697

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/iYKASIeIUvI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20210130185306.GN9805%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANjDXS_Wbj%3DZ3x62nSOp4LS16X%3D%2B93Fsj5foqaY%2Bd8SBfhkXSA%40mail.gmail.com.

Re: Show FK as input instead of drop down in admin

On Wed, Jan 27, 2021 at 05:33:10AM -0800, Kevin Olbrich wrote:
> Is it possible to disable fetching of related models for admin pages?
> I have a field that links to a table containing more than 1M rows which
> django tries to fetch and build the drop down. For my purpose, it is
> sufficient if it is a simple input containing the id instead.
>
> How can I accomplish this?

Yes, raw_id_fields is specifically designed for this:

https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20210130185707.GO9805%40fattuba.com.

Re: How would this be done within the Django framework?

On Sat, Jan 30, 2021 at 08:49:09AM -0800, dazzle.razzle.em wrote:
> I am new to Django and to web development, and am trying to get my bearings.
>
> Suppose that I provide a web page that asks the user for an airport, a
> start date, an end date, a number of days. The server is supposed to go to
> the NOAA website, grab temperature data for the range of dates, and do a
> moving average filter over the given number of days; and then display for
> the client a graph of the smoothed data, constructed maybe with SVG. I
> know how to do the NOAA access and create the graph (if I do it just on my
> computer using Python), but I don't know how to fit the client data
> specification and the server's response into the Django framework. My
> point is that none of this involves Django models at all, and what I am
> having trouble with is: where does my code that does stuff fit in.

I'd start by calling your code from a Django view.

1. You can start with some hard-coded NOAA client request data in the view
2. The response from NOAA probably returns json which you can convert
into Python data structures(dicts, lists) using the json lib.
3. Pass that response data into your template as the context. ex:

return render(request, 'weather.html', context=noaa_response_data)

4. In your template, iterate through the noaa response data to display
it as a table for now.
5. Replace the hard coded noaa client request from step 1 with data from
a form that the user submits (see form tutorial as an example). You may
have to do some work here converting the form data into the data format
that your NOAA client code expects.
6. Add a way to display your SVG graph of the data in your template
in addition to the simple table from step 4

> Can this type of client-server interaction be handled by the Django
> framework, and if so, how would this be structured very generally?

I am a big fan of "type until it works". So you'd start with one Django
view and just type code into that view function until you have your
desired behavior. Messy code is ok. Example here:

https://simpleisbetterthancomplex.com/tutorial/2018/02/03/how-to-use-restful-apis-with-django.html

Then if you want, you can refactor the code to make it
more modular and reusable. I like the services.py pattern:

https://stackoverflow.com/a/30312778/226697

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20210130185306.GN9805%40fattuba.com.

Re: Django Microsoft Authentication Backend not succeeding on new deployments

On Fri, Jan 29, 2021 at 08:58:48AM -0800, Larry Martell wrote:
> We finally found the issue - I said we had the same version of all the
> python packages but we did not - the new system had 2.0.1 version of
> pyjwt. When we downgraded to 1.7.1 it started working again. The
> requirements file for Django Microsoft Authentication Backend have
> pyjwt [required: Any]

Yuuuuuup! That kind of thing has bitten me more than once. I end up
pinning the version of the dependency in requirements.txt to the one I
know works.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20210130183020.GM9805%40fattuba.com.

multi process Daphne with supervisor, getting [Errno 88] Socket operation on non-socket

any Solution for this problem?
https://stackoverflow.com/questions/60275656/multi-process-daphne-with-supervisor-getting-errno-88-socket-operation-on-non#_=_

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9e7c6812-b7b2-4411-b66d-d81710a9d346n%40googlegroups.com.

How would this be done within the Django framework?

I am new to Django and to web development, and am trying to get my bearings.

Suppose that I provide a web page that asks the user for an airport, a start date, an end date, a number of days.  The server is supposed to go to the NOAA website, grab temperature data for the range of dates, and do a moving average filter over the given number of days; and then display for the client a graph of the smoothed data, constructed maybe with SVG.  I know how to do the NOAA access and create the graph (if I do it just on my computer using Python), but I don't know how to fit the client data specification and the server's response into the Django framework.  My point is that none of this involves Django models at all, and what I am having trouble with is: where does my code that does stuff fit in.  Can this type of client-server interaction be handled by the Django framework, and if so, how would this be structured very generally?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/05daa40b-c69e-4793-9f9e-12424afde3aan%40googlegroups.com.

IntegrityError on a foreign key constraint

Hi, I'm having a really incomprehensible error currently. We are working with three models here, "DataImport", "Contact" and "Dataset", the DataImport model import data from a file to a Dataset object, the data is imported as a Contact object , the DataImport model have a foreign key to the Dataset model. This is how the app works:

- a user upload a file
- we convert the content of the file to a TablibDataset or TablibDatabook, these are tablib (python package) classes, don't worry too much about this, tablib have their own Dataset and I have my own, that's why I import the tablib classes with aliases
- if the loaded data is a TablibDataset, the import start and create contacts from the loaded data (this works)
- if the loaded_data is a TablibDatabook, the databook is split into multiple sheet (yes I'm working with excel files) and new Dataset (my model)  and DataImport objects are created to handle the import for each  sheet (here is the issue)

All import are done as async task using the django_q package
The issue I have is that, when I create a new dataset, start the import and try to add a new contact I get this:
```
insert or update on table "datasets_contact" violates foreign key constraint "datasets_contact_dataset_id_9dda7f76_fk_datasets_dataset_id"
DETAIL:  Key (dataset_id)=(39) is not present in table "datasets_dataset".
```
It seems like the dataset is not save in db that's why I'm getting this error when I try to create a new contact, but I'm creating my Dataset object with Dataset.objects.create(), I don't understand the problem.

The code for all this is a bit long, so here is a gist with all the necessary code 
https://gist.github.com/Tobi-De/411ee7b7fc988864869c8d7ad93ab34f

The method that create the Dataset and DataImpot objects is the class method "create_import_from_databook"

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dbfc0761-347d-47a5-9689-9886ce1e37fcn%40googlegroups.com.

Re: multiplying two fields

This will work 

data = Articles.objects.all().annotate(result=ExpressionWrapper(F('cost_buy') * F('quantity') , output_field=FloatField()))
now data is a queryset. so you can do something like this
data[0].result
data.values("result")

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJPiQOQR%3DpxnMTNKajOxiNsUh--14TGMH-Ao5bKHr7LM%2B3PPUA%40mail.gmail.com.

Friday, January 29, 2021

Django Channels:Detect whether disconnect() was done client or server?


Hello!
I need to detect whether connection was closed by server or client.How to do it?

disconnect() gets called when client disconnects or server disconnects (using self.close() or by not accept()-ing during connect() ).So I need to detect who caused the disconnect and take action based on that.I tried using custom close codes too.
But if the server disconnects using self.close() or client disconnects abnormally ,then I always get the close_code as 1006.So I cant detect caused the disconnect.
Is there way to do it?

Here's the link to the question in SO with code example.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1673a71e-a4dc-4063-a232-332d428e3db8n%40googlegroups.com.

Re: multiplying two fields

You need to read the documentation as always - https://docs.djangoproject.com/en/3.1/ref/models/expressions/#using-f-with-annotations

It says that the output_field is a keyword argument for the annotate method.

On Fri, Jan 29, 2021 at 10:56 PM jose angel encinas ramos <encinasj.angel@gmail.com> wrote:
tanks Ross, i fixed my error but now only show me this

>>> data = Articles.objects.all().annotate(F=('cost_buy') * F('quantity')).output_field=FloatField('result')
>>> print(data)
<django.db.models.fields.FloatField>
>>>

what do you think?

On Fri, Jan 29, 2021 at 2:54 PM Ross Meredith <rossmere67@gmail.com> wrote:
Apologies, typo myself!

That meant to say "typo" not "type".



On Fri, Jan 29, 2021 at 9:52 PM Ross Meredith <rossmere67@gmail.com> wrote:
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result'),

contains a type for the field "cost_buy" (i.e. not "coust_by").

If that isn't it please give us the traceback.

On Fri, Jan 29, 2021 at 8:50 PM jose angel encinas ramos <encinasj.angel@gmail.com> wrote:
Guys gd evening

I need help,really i don't kwnow how to do a multiply two fields, have a model called Articles.

class Articles(models.Model):
#models article
Nuevo = 'Nuevo'
Semi_nuevo = 'Semi_nuevo'
Usado = 'Usado'
Otros = 'Otros'
STATE_ACTUAL = (
(Nuevo, 'Nuevo'),
(Semi_nuevo,'Semi_nuevo'),
(Usado,'Usado'),
(Otros,'Otros')
)
name = models.CharField(max_length=50)
quantity = models.PositiveIntegerField()
fk_brand = models.ForeignKey(Brand, null=True, on_delete=models.SET_NULL)
model = models.CharField(max_length=50)
fk_category = models.ForeignKey(Category, null=True, on_delete=models.SET_NULL)
cost_buy = models.DecimalField(max_digits=10, decimal_places=2)
fk_supplier = models.ForeignKey(Supplier, null=True, on_delete=models.SET_NULL)
userful_life = models.DateField()
actual_state = models.CharField(max_length=12, choices=STATE_ACTUAL)
date_check = models.DateField()
location = models.CharField(max_length=50)
img = models.ImageField(upload_to='articles', null=True, blank=True)
description = models.TextField(blank=True)
#actions
created = models.DateTimeField(auto_now_add=True)
update = models.DateTimeField(auto_now=True)

class Meta:
verbose_name = 'Article'
verbose_name_plural = 'Articles'

@property
def result(self,*args, **kwargs):
mult = self.cost_buy * self.quantity
return mult

class Meta:
verbose_name = 'Article'
verbose_name_plural = 'Articles'

def __str__(self):
return '{} {} {}'.format(self.name ,self.cost_buy, self.quantity)

so i want to multiply 2 filed , cost_buy * quantity and the result show in the template

i was to try did this query in view.py 
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result')
 

but isn't work





--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3b573d77-b89a-4b39-95fd-dfd6f9d90910n%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA1Tdz2ka2NskiK5rn8sc8yVQ%3D3xZ8YkTEAUv9HH%2Bb1yiALWqw%40mail.gmail.com.


--
José Ángel Encinas
Ing. Tecnologias de la información


Cel:  6622267620 

  
                   Never give up...
   I     I  https://us04web.zoom.us/j/4514417813

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF3iVr_MJi%3DkrPxjD%3DeD%2B0s9zf0-NFVs%3Dmb5jAMhjjmSsk8rZg%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA1Tdz0btS5Vf%2BNd_7qrH%2BMMwRj-Hot_AkHMennsFJ2cCN7LCw%40mail.gmail.com.

Re: multiplying two fields

tanks Ross, i fixed my error but now only show me this

>>> data = Articles.objects.all().annotate(F=('cost_buy') * F('quantity')).output_field=FloatField('result')
>>> print(data)
<django.db.models.fields.FloatField>
>>>

what do you think?

On Fri, Jan 29, 2021 at 2:54 PM Ross Meredith <rossmere67@gmail.com> wrote:
Apologies, typo myself!

That meant to say "typo" not "type".



On Fri, Jan 29, 2021 at 9:52 PM Ross Meredith <rossmere67@gmail.com> wrote:
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result'),

contains a type for the field "cost_buy" (i.e. not "coust_by").

If that isn't it please give us the traceback.

On Fri, Jan 29, 2021 at 8:50 PM jose angel encinas ramos <encinasj.angel@gmail.com> wrote:
Guys gd evening

I need help,really i don't kwnow how to do a multiply two fields, have a model called Articles.

class Articles(models.Model):
#models article
Nuevo = 'Nuevo'
Semi_nuevo = 'Semi_nuevo'
Usado = 'Usado'
Otros = 'Otros'
STATE_ACTUAL = (
(Nuevo, 'Nuevo'),
(Semi_nuevo,'Semi_nuevo'),
(Usado,'Usado'),
(Otros,'Otros')
)
name = models.CharField(max_length=50)
quantity = models.PositiveIntegerField()
fk_brand = models.ForeignKey(Brand, null=True, on_delete=models.SET_NULL)
model = models.CharField(max_length=50)
fk_category = models.ForeignKey(Category, null=True, on_delete=models.SET_NULL)
cost_buy = models.DecimalField(max_digits=10, decimal_places=2)
fk_supplier = models.ForeignKey(Supplier, null=True, on_delete=models.SET_NULL)
userful_life = models.DateField()
actual_state = models.CharField(max_length=12, choices=STATE_ACTUAL)
date_check = models.DateField()
location = models.CharField(max_length=50)
img = models.ImageField(upload_to='articles', null=True, blank=True)
description = models.TextField(blank=True)
#actions
created = models.DateTimeField(auto_now_add=True)
update = models.DateTimeField(auto_now=True)

class Meta:
verbose_name = 'Article'
verbose_name_plural = 'Articles'

@property
def result(self,*args, **kwargs):
mult = self.cost_buy * self.quantity
return mult

class Meta:
verbose_name = 'Article'
verbose_name_plural = 'Articles'

def __str__(self):
return '{} {} {}'.format(self.name ,self.cost_buy, self.quantity)

so i want to multiply 2 filed , cost_buy * quantity and the result show in the template

i was to try did this query in view.py 
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result')
 

but isn't work





--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3b573d77-b89a-4b39-95fd-dfd6f9d90910n%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA1Tdz2ka2NskiK5rn8sc8yVQ%3D3xZ8YkTEAUv9HH%2Bb1yiALWqw%40mail.gmail.com.


--
José Ángel Encinas
Ing. Tecnologias de la información


Cel:  6622267620 

  
                   Never give up...
   I     I  https://us04web.zoom.us/j/4514417813

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF3iVr_MJi%3DkrPxjD%3DeD%2B0s9zf0-NFVs%3Dmb5jAMhjjmSsk8rZg%40mail.gmail.com.

Re: How to programmatically set the model when using Django CreateView?

Hi Robert

Just looking at the code
Why do you change context to empty?

context = {}
            return render(request, self.template_name, context)



Aisophy

2021年1月30日(土) 3:09 Robert F. <robert.flaugher@gmail.com>:
I am trying to programmatically set the model for a Django class-based view that inherits from CreateView and displays a form for creating a 'member' object. My problem is that  my template is not displaying the form itself. Note that I override the 'get' method to determine what model the view should use. The template page renders and I see the submit button but when I view the page's source code, the form is missing. Here's my code:

    # urls.py
    path('profile/create/', views.ProfileCreate.as_view(), name='profile-create'),

    # views.py
    class ProfileCreate(CreateView):
        model = None
        template_name = None

        def get(self, request, *args, **kwargs):
            member = Member.objects.get(user=request.user)
            if member.is_couple:
                self.model = ProfileCouple
                self.template_name = 'account/profile_couple_create.html'
                self.fields = ['person1_name', 'person2_name',
                               'person1_dob', 'person2_dob']
            else:
                self.model = ProfileSingle
                self.template_name = 'account/profile_single_create.html'
                self.fields = ['person1_name', 'person1_dob']

            context = {}
            return render(request, self.template_name, context)

    # models.py
    class ProfileSingle(models.Model):
        user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
        person1_name = models.CharField(_("Name"), max_length=50)
        person1_dob = models.DateField()

        def __str__(self):
            return self.user.username

    class ProfileCouple(models.Model):
        user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
        person1_name = models.CharField(_("Name 1"), max_length=50)
        person1_dob = models.DateField()
        person2_name = models.CharField(_("Name 2"), max_length=50)
        person2_dob = models.DateField()

        def __str__(self):
            return self.user.username

    # forms.py
    class CreateSingleProfileForm(forms.ModelForm):
        class Meta:
            model = ProfileSingle
            fields = ('user', 'person1_name', 'person1_dob')
            labels = {'user': _('Username'), 'person1_name': _(
                'Person 1 Name'), 'person1_dob': _('Person 1 DOB')}
    
    class CreateCoupleProfileForm(forms.ModelForm):
        class Meta:
            model = ProfileCouple
            ...

    # profile_single_create.html
    <div class="container mt-4">
      <h1>Create Your Profile</h1>
      <form method="post">{% csrf_token %}
          {{ form.as_p }}
          <input type="submit" value="Save">
      </form>
    </div>

    # profile_couple_create.html
    (Code similar to single template)

I know that with CBVs, Django will build the form for me.  But there will be times when I need to customize the form as I do here. What am I missing?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6d394628-6132-4927-8324-466347c8c427n%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B2LtkB%3DBiXAzZUHiBCdtMciBKRAfCahthoaP9XXRv%2BW3zN5Ng%40mail.gmail.com.

Re: multiplying two fields

Apologies, typo myself!

That meant to say "typo" not "type".



On Fri, Jan 29, 2021 at 9:52 PM Ross Meredith <rossmere67@gmail.com> wrote:
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result'),

contains a type for the field "cost_buy" (i.e. not "coust_by").

If that isn't it please give us the traceback.

On Fri, Jan 29, 2021 at 8:50 PM jose angel encinas ramos <encinasj.angel@gmail.com> wrote:
Guys gd evening

I need help,really i don't kwnow how to do a multiply two fields, have a model called Articles.

class Articles(models.Model):
#models article
Nuevo = 'Nuevo'
Semi_nuevo = 'Semi_nuevo'
Usado = 'Usado'
Otros = 'Otros'
STATE_ACTUAL = (
(Nuevo, 'Nuevo'),
(Semi_nuevo,'Semi_nuevo'),
(Usado,'Usado'),
(Otros,'Otros')
)
name = models.CharField(max_length=50)
quantity = models.PositiveIntegerField()
fk_brand = models.ForeignKey(Brand, null=True, on_delete=models.SET_NULL)
model = models.CharField(max_length=50)
fk_category = models.ForeignKey(Category, null=True, on_delete=models.SET_NULL)
cost_buy = models.DecimalField(max_digits=10, decimal_places=2)
fk_supplier = models.ForeignKey(Supplier, null=True, on_delete=models.SET_NULL)
userful_life = models.DateField()
actual_state = models.CharField(max_length=12, choices=STATE_ACTUAL)
date_check = models.DateField()
location = models.CharField(max_length=50)
img = models.ImageField(upload_to='articles', null=True, blank=True)
description = models.TextField(blank=True)
#actions
created = models.DateTimeField(auto_now_add=True)
update = models.DateTimeField(auto_now=True)

class Meta:
verbose_name = 'Article'
verbose_name_plural = 'Articles'

@property
def result(self,*args, **kwargs):
mult = self.cost_buy * self.quantity
return mult

class Meta:
verbose_name = 'Article'
verbose_name_plural = 'Articles'

def __str__(self):
return '{} {} {}'.format(self.name ,self.cost_buy, self.quantity)

so i want to multiply 2 filed , cost_buy * quantity and the result show in the template

i was to try did this query in view.py 
data = Articles.objects.all().annotate(result=F('coust_buy') * F('quantity')).output_field=FloatField('result')
 

but isn't work





--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3b573d77-b89a-4b39-95fd-dfd6f9d90910n%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA1Tdz2ka2NskiK5rn8sc8yVQ%3D3xZ8YkTEAUv9HH%2Bb1yiALWqw%40mail.gmail.com.