Re: ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Akinfolarin Stephen
First I will like you to tell me the folder where test.py is and views.py

On Fri, Oct 16, 2020, 06:27 Salima Begum 
wrote:

> Hi all,
>
> I have written test case for views for details page. Here is below code I
> have written
>
> ```
> from django.test import RequestFactory
> from django.urls import reverse
> from django.contrib.auth.models import User
> from pages.models import vk_customer
> from mixer.backend.django import mixer
> import pytest
>
> from pages.views import ProductDetails
>
>
> @pytest.mark.django_db
> class TestViews:
>
> def test_product_detail_authenticated(self):
> mixer.blend('pages.vk_master_table')
> path = reverse('detail', kwargs={'pk': 1516})
> request = RequestFactory().get(path)
> request.user = mixer.blend(vk_customer)
>
> response = ProductDetails(request, pk=1516)
> print(response)
> assert response.status_code == 200
> ```
> *This the error i am getting.*
>  ERROR
> collecting pages/tests/test_views.py
> 
> ImportError while importing test module
> 'H:\vikreya\mysite\pages\tests\test_views.py'.
> Hint: make sure your test modules/packages have valid Python names.
> Traceback:
> c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
> in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
> pages\tests\test_views.py:8: in 
> from pages.views import ProductDetails
> E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
> (H:\vikreya\mysite\pages\views.py)
>
> Please help me out to solve this error,
>
> Thank you,
> ~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/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%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/CAFujGLw%3DTZhX-moO6pdp3Ng%3D4LJZ2UQLfE9Y2GmOGsCpxTyVBQ%40mail.gmail.com.


ImportError: cannot import name 'ProductDetails' from 'pages.views'

2020-10-15 Thread Salima Begum
Hi all,

I have written test case for views for details page. Here is below code I
have written

```
from django.test import RequestFactory
from django.urls import reverse
from django.contrib.auth.models import User
from pages.models import vk_customer
from mixer.backend.django import mixer
import pytest

from pages.views import ProductDetails


@pytest.mark.django_db
class TestViews:

def test_product_detail_authenticated(self):
mixer.blend('pages.vk_master_table')
path = reverse('detail', kwargs={'pk': 1516})
request = RequestFactory().get(path)
request.user = mixer.blend(vk_customer)

response = ProductDetails(request, pk=1516)
print(response)
assert response.status_code == 200
```
*This the error i am getting.*
 ERROR
collecting pages/tests/test_views.py

ImportError while importing test module
'H:\vikreya\mysite\pages\tests\test_views.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
c:\users\user\appdata\local\programs\python\python38\lib\importlib\__init__.py:127:
in import_module
return _bootstrap._gcd_import(name[level:], package, level)
pages\tests\test_views.py:8: in 
from pages.views import ProductDetails
E   ImportError: cannot import name 'ProductDetails' from 'pages.views'
(H:\vikreya\mysite\pages\views.py)

Please help me out to solve this error,

Thank you,
~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/CAMSz6bk187G0NSr%2Bza9RKAFnk475Z8nhxVRF%2BFk4iKtzwLXGxg%40mail.gmail.com.


Django conditional field display on form

2020-10-15 Thread Clive Bruton
I am trying to make a simple form, that conditionally shows the  
"website" input field based on the value of another database field  
(that is not on the form) "status". For the sake of this process the  
"status" field is not editable by the user, just by the admin. Both  
fields are in the same table: "profile".


After working at this for a while I copped-out and just did the  
conditional hiding and showing on the template. But, I realise this  
is the unsophisticated method, and would like to improve it.


What I tried so far in forms.py:



class WebsiteForm(forms.ModelForm):
class Meta:
 model = Profile

 fields = ( 'e-mail', 'website', )

 if Profile.status == 'personal' :
 exclude = ('website',)

This method in forms.py works effectively, in that I can  
conditionally show and hide the field if I use test comparitors in  
the if statement like:


if 1 == 1:
or

if 1 != 1:
But, I cannot get an effective test using the field "Profile.status",  
the value in the field seems to be unavailable at the point the "if"  
test in forms.py is performed.


If I use "print(Profile.status)" I get the following output in the  
terminal: "user__profile__status__isnull", so I think this means that  
I am at least testing the correct field in the database. Although I  
am also noting that this output only shows at initialisation of  
"runserver", not when the form page is accessed.


One final point, the user is authenticated and editing their own record.

Any help very much appreciated.





-- Clive

--
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/99ABE658-5CF2-4EB3-8E96-6AD2D32CB34B%40indx.co.uk.


Re: django staticfiles problem

2020-10-15 Thread Chelsea Fan
thanks guys, I did it ))

On Thu, Oct 15, 2020 at 9:55 PM Luis Zárate  wrote:

> You have a problem here
> {% static '/css/base.css' %}
>
> the correct is
> {% static 'css/base.css' %}
>
> Also is a bad idea set media folder in static.
> take a look here https://docs.djangoproject.com/en/3.1/howto/static-files/
>
>
>
>
> El mié., 14 oct. 2020 a las 23:05, Farai M ()
> escribió:
>
>> Why have the media url if it's point to the same dir as static .Your can
>> just specific it's separately in it's own dir as /media/ and have /static/
>> .You are also missing a static root there .
>>
>> On Wed, Oct 14, 2020, 5:05 PM Chelsea Fan 
>> wrote:
>>
>>> MEDIA_URL = '/images/'
>>> MEDIA_ROOT = BASE_DIR / 'static/images'
>>>
>>>
>>> On Wed, Oct 14, 2020 at 2:12 PM Anh Nguyen  wrote:
>>>
 where is your STATIC_ROOT ?


 On Wed, Oct 14, 2020 at 5:43 PM Chelsea Fan <
 allaberdi16yazha...@gmail.com> wrote:

> hello everyone, I have an issue, I can't connect css style to my
> template, but I can upload images and see it , here is my code,  please
> help me, thanks  for attentions !!!
>
> STATIC_URL = '/static/'
> STATICFILES_DIR = [BASE_DIR / 'static']
>
> {% load static %}
> 
> 
> 
> 
> 
>
> [image: image.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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJwZndd_SYaToM%3D6h1KL-WmXs7eR3e0sgwHqVPPFwo%3Dx2HW5xg%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/CAKaoNbTN2-hiy71RS8H8i_wc9XeQqJBOLkR%3DOjEJxocorO1FRw%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/CAJwZnde%3D8xOePMK5L%2B9YvXtnW_U%2BHCpX2VVq5R%2BmQDZz39kBrQ%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/CAMeub5PM26mY%2BDpB-xK0NorWxXOE1qahL-zf2WJrFirqeGL73A%40mail.gmail.com
>> 
>> .
>>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyN%3DaboOu1c4h9OuaYac1UJeRkrSe7nRXrSHY65EZfuYAA%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/CAJwZndcgnRocVEECN4DJnzE2JY0fa_cVSUk43TA4Xz2p07GE%3DA%40mail.gmail.com.


Re: django staticfiles problem

2020-10-15 Thread Luis Zárate
You have a problem here
{% static '/css/base.css' %}

the correct is
{% static 'css/base.css' %}

Also is a bad idea set media folder in static.
take a look here https://docs.djangoproject.com/en/3.1/howto/static-files/




El mié., 14 oct. 2020 a las 23:05, Farai M ()
escribió:

> Why have the media url if it's point to the same dir as static .Your can
> just specific it's separately in it's own dir as /media/ and have /static/
> .You are also missing a static root there .
>
> On Wed, Oct 14, 2020, 5:05 PM Chelsea Fan 
> wrote:
>
>> MEDIA_URL = '/images/'
>> MEDIA_ROOT = BASE_DIR / 'static/images'
>>
>>
>> On Wed, Oct 14, 2020 at 2:12 PM Anh Nguyen  wrote:
>>
>>> where is your STATIC_ROOT ?
>>>
>>>
>>> On Wed, Oct 14, 2020 at 5:43 PM Chelsea Fan <
>>> allaberdi16yazha...@gmail.com> wrote:
>>>
 hello everyone, I have an issue, I can't connect css style to my
 template, but I can upload images and see it , here is my code,  please
 help me, thanks  for attentions !!!

 STATIC_URL = '/static/'
 STATICFILES_DIR = [BASE_DIR / 'static']

 {% load static %}
 
 
 
 
 

 [image: image.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+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAJwZndd_SYaToM%3D6h1KL-WmXs7eR3e0sgwHqVPPFwo%3Dx2HW5xg%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/CAKaoNbTN2-hiy71RS8H8i_wc9XeQqJBOLkR%3DOjEJxocorO1FRw%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/CAJwZnde%3D8xOePMK5L%2B9YvXtnW_U%2BHCpX2VVq5R%2BmQDZz39kBrQ%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/CAMeub5PM26mY%2BDpB-xK0NorWxXOE1qahL-zf2WJrFirqeGL73A%40mail.gmail.com
> 
> .
>


-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyN%3DaboOu1c4h9OuaYac1UJeRkrSe7nRXrSHY65EZfuYAA%40mail.gmail.com.


Re: need assistant

2020-10-15 Thread John Rajesh
Share about the Django projects
On 15 Oct 2020 20:31, "ericki...@gmail.com"  wrote:

> hello guys am new at Django , i have couple of projects for Django and
> pyside2 if anyone is willing to assist me in this fields i be so great full
> as we learn from each other and carry out more projects
>
>
> 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/c74a57a9-f0df-4a99-94f3-9a34e5bb3500n%
> 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/CA%2BbM%2BwAt3Q4ghAKv8hGn8-L7oV0-UdnnoWviJHf6iR84iik%2Bgg%40mail.gmail.com.


Re: need assistant

2020-10-15 Thread Akinfolarin Stephen
Hi will be willing to colaborate

On Thu, Oct 15, 2020, 16:38 Noel Simela  wrote:

> Hi, what is the nature of your projects?
>
> On Thu, 15 Oct 2020, 17:01 ericki...@gmail.com 
> wrote:
>
>> hello guys am new at Django , i have couple of projects for Django and
>> pyside2 if anyone is willing to assist me in this fields i be so great full
>> as we learn from each other and carry out more projects
>>
>>
>> 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/c74a57a9-f0df-4a99-94f3-9a34e5bb3500n%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/CAGBhr7bkHhosWn6OP5WD-z29NnCNYMaaBBeKgrxc5oDURMVaFA%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/CAFujGLzHXCNwdU1wkzDk4X2%2B%3D0SzgH64y_deOpjtG25aOV34Mg%40mail.gmail.com.


Re: need assistant

2020-10-15 Thread Noel Simela
Hi, what is the nature of your projects?

On Thu, 15 Oct 2020, 17:01 ericki...@gmail.com 
wrote:

> hello guys am new at Django , i have couple of projects for Django and
> pyside2 if anyone is willing to assist me in this fields i be so great full
> as we learn from each other and carry out more projects
>
>
> 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/c74a57a9-f0df-4a99-94f3-9a34e5bb3500n%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/CAGBhr7bkHhosWn6OP5WD-z29NnCNYMaaBBeKgrxc5oDURMVaFA%40mail.gmail.com.


Re: forloop.counter

2020-10-15 Thread GBELE CEDRIC EMMANUEL
{% if forloop.counter < variable  %}

Le jeu. 15 oct. 2020 à 15:01, nirali sanghvi <18comp.niralisang...@gmail.com>
a écrit :

> Ig this is bcoz u are using jinga format in a jinga format.
>
> On Thu 15 Oct, 2020, 8:04 PM luca72.b...@gmail.com, <
> luca72.bertolo...@gmail.com> wrote:
>
>> i have this :
>>  {% if forloop.counter < {{ variable }} %}
>> i have this error:
>>
>> Could not parse the remainder: '{{' from '{{'
>>
>> how i can solve it?
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/58585ced-68c2-4b46-862f-36f919d13555n%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/CANqtQVOsVi6uDpurd2AyDC6zyLJk%3D-wUX%3DC12ay%2B3nFs1S58MA%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/CABTw%3DMVsxCySxHsmiHo04z_PH_thOvPgLnJAv42UZ5hNahODhQ%40mail.gmail.com.


Re: forloop.counter

2020-10-15 Thread nirali sanghvi
Ig this is bcoz u are using jinga format in a jinga format.

On Thu 15 Oct, 2020, 8:04 PM luca72.b...@gmail.com, <
luca72.bertolo...@gmail.com> wrote:

> i have this :
>  {% if forloop.counter < {{ variable }} %}
> i have this error:
>
> Could not parse the remainder: '{{' from '{{'
>
> how i can solve it?
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/58585ced-68c2-4b46-862f-36f919d13555n%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/CANqtQVOsVi6uDpurd2AyDC6zyLJk%3D-wUX%3DC12ay%2B3nFs1S58MA%40mail.gmail.com.


need assistant

2020-10-15 Thread ericki...@gmail.com
hello guys am new at Django , i have couple of projects for Django and 
pyside2 if anyone is willing to assist me in this fields i be so great full 
as we learn from each other and carry out more projects


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/c74a57a9-f0df-4a99-94f3-9a34e5bb3500n%40googlegroups.com.


Re: forloop.counter

2020-10-15 Thread luca72.b...@gmail.com
thanks i forgot it

Il giorno giovedì 15 ottobre 2020 alle 16:39:45 UTC+2 
larry.mart...@gmail.com ha scritto:

> On Thu, Oct 15, 2020 at 7:32 AM luca72.b...@gmail.com
>  wrote:
> >
> > i have this :
> > {% if forloop.counter < {{ variable }} %}
> > i have this error:
> >
> > Could not parse the remainder: '{{' from '{{'
> >
> > how i can solve it?
>
> You don't need {{ }} inside of a {% %}
>

-- 
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/92123136-638f-47c7-a49f-4ce97f34a4b9n%40googlegroups.com.


Re: forloop.counter

2020-10-15 Thread Larry Martell
On Thu, Oct 15, 2020 at 7:32 AM luca72.b...@gmail.com
 wrote:
>
> i have this :
>  {% if forloop.counter < {{ variable }} %}
> i have this error:
>
> Could not parse the remainder: '{{' from '{{'
>
> how i can solve it?

You don't need {{ }} inside of a {% %}

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


forloop.counter

2020-10-15 Thread luca72.b...@gmail.com
i have this :
 {% if forloop.counter < {{ variable }} %}
i have this error:

Could not parse the remainder: '{{' from '{{' 

how i can solve it?
Thanks 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/58585ced-68c2-4b46-862f-36f919d13555n%40googlegroups.com.


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

2020-10-15 Thread shahee...@gmail.com
Thanks Jason, I filed https://code.djangoproject.com/ticket/32111#ticket.

On Thursday, 15 October 2020 at 12:51:22 UTC+1 Jason wrote:

> this is pretty interesting, and may be something to report to the devs at 
> https://groups.google.com/g/django-developers, or open up a ticket at 
> https://code.djangoproject.com/  I don't see any tickets with the query 
> *jsonfield 
> foreign data* that are similar with your experience, so you may have 
> found an edge case.
>
> On Thursday, October 15, 2020 at 5:31:09 AM UTC-4 shahee...@gmail.com 
> wrote:
>
>>
>> Hi,
>>
>> I have a Django model working fine under Django 3.0 (i.e. "Django<3.1") 
>> which looks like this:
>>
>> ===
>> class Job(models.Model):
>> id = models.CharField(max_length=36, primary_key=True)
>> queue = models.CharField(max_length=40)
>> args = JSONField()
>> kwargs = JSONField()
>> type = models.CharField(max_length=80)
>> ...
>>
>> class Meta:
>> managed = False  # <--   The table is implemented as a 
>> Postgres FDW wrapper.
>> db_table = 'jobs'
>> ===
>>
>> I am testing the update to Django 3.1.2 and hit an error in executing 
>> this line:
>>
>> jobs = list(models.Job.objects.filter(queue='celery', 
>> state='scheduled'))
>>
>> The error is as follows from pytest (i.e. stack trace with local 
>> variables too):
>>
>> ==
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>> _ _ _ 
>> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:287: in 
>> __iter__ 
>>self._fetch_all() 
>>self   =  
>> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:1308: in 
>> _fetch_all 
>>self._result_cache = list(self._iterable_class(self)) 
>>self   =  
>> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:70: in 
>> __iter__ 
>>for row in compiler.results_iter(results): 
>>annotation_col_map = {} 
>>compiler   = > 0x7f8685e49160> 
>>db = 'fdw' 
>>init_list  = ['id', 'queue', 'args', 'kwargs', 'type', 'state', 
>> ...] 
>>klass_info = {'model': , 
>> 'select_fields': [0, 1, 2, 3, 4, 5, ...]} 
>>known_related_objects = [] 
>>model_cls  =  
>>model_fields_end = 9 
>>model_fields_start = 0 
>>queryset   =  
>>related_populators = [] 
>>results= [[('8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
>> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
>> 'paiyroll.tasks.function_run', 'scheduled', ...)]] 
>>select = [(Col(jobs, paiyroll.Job.id), ('"jobs"."id"', []), 
>> None), (Col(jobs, paiyroll.Job.queue), ('"jobs"."queue"', []), None..., 
>> paiyroll.Job.type), ('"jobs"."type"', []), None), (Col(jobs, 
>> paiyroll.Job.state), ('"jobs"."state"', []), None), ...] 
>>select_fields = [0, 1, 2, 3, 4, 5, ...] 
>>self   = > 0x7f86836f3040> 
>> /usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py:1100:
>>  
>> in apply_converters 
>>value = converter(value, expression, connection) 
>>connection = > object at 0x7f869a321670> 
>>converter  = > > 
>>converters = [(2, ([> >], Col(jobs, 
>> pa...NField.from_db_value of 
>> >], Col(jobs, 
>> paiyroll.Job.details)))] 
>>convs  = [> >] 
>>expression = Col(jobs, paiyroll.Job.args) 
>>pos= 2 
>>row= ['8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
>> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
>> 'paiyroll.tasks.function_run', 'scheduled', ...] 
>>rows   =  
>>self   = > 0x7f8685e49160> 
>>value  = ['paiyroll.tasks', 'call_to_string', 
>> 'call_to_string', [], {}] 
>>
>>
>>
>>
>>
>> */usr/local/lib/python3.8/dist-packages/django/db/models/fields/json.py:74: 
>> in from_db_valuereturn json.loads(value, cls=self.decoder) 
>>connection = > object at 0x7f869a321670>expression = Col(jobs, paiyroll.Job.args) 
>>self   =  
>>value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string', 
>> [], {}] *
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>> _ _ _ 
>>
>> s = ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], cls = 
>> None 
>> object_hook = None, parse_float = None, parse_int = None, parse_constant 
>> = None 
>> object_pairs_hook = None, kw = {} 
>>
>>def loads(s, *, cls=None, object_hook=None, parse_float=None, 
>>parse_int=None, parse_constant=None, object_pairs_hook=None, 
>> **kw): 
>>"""Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` 
>> instance 
>>containing a JSON document) to a Python object. 
>>
>>``object_hook`` is an optional function that will be called with 
>> the 
>>result of any object literal decode (a 

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

2020-10-15 Thread Jason
this is pretty interesting, and may be something to report to the devs at 
https://groups.google.com/g/django-developers, or open up a ticket at 
https://code.djangoproject.com/  I don't see any tickets with the query 
*jsonfield 
foreign data* that are similar with your experience, so you may have found 
an edge case.

On Thursday, October 15, 2020 at 5:31:09 AM UTC-4 shahee...@gmail.com wrote:

>
> Hi,
>
> I have a Django model working fine under Django 3.0 (i.e. "Django<3.1") 
> which looks like this:
>
> ===
> class Job(models.Model):
> id = models.CharField(max_length=36, primary_key=True)
> queue = models.CharField(max_length=40)
> args = JSONField()
> kwargs = JSONField()
> type = models.CharField(max_length=80)
> ...
>
> class Meta:
> managed = False  # <--   The table is implemented as a 
> Postgres FDW wrapper.
> db_table = 'jobs'
> ===
>
> I am testing the update to Django 3.1.2 and hit an error in executing this 
> line:
>
> jobs = list(models.Job.objects.filter(queue='celery', 
> state='scheduled'))
>
> The error is as follows from pytest (i.e. stack trace with local variables 
> too):
>
> ==
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> _ _ _ 
> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:287: in 
> __iter__ 
>self._fetch_all() 
>self   =  
> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:1308: in 
> _fetch_all 
>self._result_cache = list(self._iterable_class(self)) 
>self   =  
> /usr/local/lib/python3.8/dist-packages/django/db/models/query.py:70: in 
> __iter__ 
>for row in compiler.results_iter(results): 
>annotation_col_map = {} 
>compiler   =  0x7f8685e49160> 
>db = 'fdw' 
>init_list  = ['id', 'queue', 'args', 'kwargs', 'type', 'state', 
> ...] 
>klass_info = {'model': , 
> 'select_fields': [0, 1, 2, 3, 4, 5, ...]} 
>known_related_objects = [] 
>model_cls  =  
>model_fields_end = 9 
>model_fields_start = 0 
>queryset   =  
>related_populators = [] 
>results= [[('8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
> 'paiyroll.tasks.function_run', 'scheduled', ...)]] 
>select = [(Col(jobs, paiyroll.Job.id), ('"jobs"."id"', []), 
> None), (Col(jobs, paiyroll.Job.queue), ('"jobs"."queue"', []), None..., 
> paiyroll.Job.type), ('"jobs"."type"', []), None), (Col(jobs, 
> paiyroll.Job.state), ('"jobs"."state"', []), None), ...] 
>select_fields = [0, 1, 2, 3, 4, 5, ...] 
>self   =  0x7f86836f3040> 
> /usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py:1100: 
> in apply_converters 
>value = converter(value, expression, connection) 
>connection =  object at 0x7f869a321670> 
>converter  =  > 
>converters = [(2, ([ >], Col(jobs, 
> pa...NField.from_db_value of 
> >], Col(jobs, 
> paiyroll.Job.details)))] 
>convs  = [ >] 
>expression = Col(jobs, paiyroll.Job.args) 
>pos= 2 
>row= ['8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery', 
> ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {}, 
> 'paiyroll.tasks.function_run', 'scheduled', ...] 
>rows   =  
>self   =  0x7f8685e49160> 
>value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string', 
> [], {}] 
>
>
>
>
>
> */usr/local/lib/python3.8/dist-packages/django/db/models/fields/json.py:74: 
> in from_db_valuereturn json.loads(value, cls=self.decoder) 
>connection =  object at 0x7f869a321670>expression = Col(jobs, paiyroll.Job.args) 
>self   =  
>value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string', 
> [], {}] *
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
> _ _ _ 
>
> s = ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], cls = 
> None 
> object_hook = None, parse_float = None, parse_int = None, parse_constant = 
> None 
> object_pairs_hook = None, kw = {} 
>
>def loads(s, *, cls=None, object_hook=None, parse_float=None, 
>parse_int=None, parse_constant=None, object_pairs_hook=None, 
> **kw): 
>"""Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` 
> instance 
>containing a JSON document) to a Python object. 
>
>``object_hook`` is an optional function that will be called with 
> the 
>result of any object literal decode (a ``dict``). The return value 
> of 
>``object_hook`` will be used instead of the ``dict``. This feature 
>can be used to implement custom decoders (e.g. JSON-RPC class 
> hinting). 
>
>``object_pairs_hook`` is an optional function that will be called 
> with the 

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

2020-10-15 Thread Shaheed Haque
Hi,

I have a Django model working fine under Django 3.0 (i.e. "Django<3.1")
which looks like this:

===
class Job(models.Model):
id = models.CharField(max_length=36, primary_key=True)
queue = models.CharField(max_length=40)
args = JSONField()
kwargs = JSONField()
type = models.CharField(max_length=80)
...

class Meta:
managed = False  # <--   The table is implemented as a
Postgres FDW wrapper.
db_table = 'jobs'
===

I am testing the update to Django 3.1.2 and hit an error in executing this
line:

jobs = list(models.Job.objects.filter(queue='celery',
state='scheduled'))

The error is as follows from pytest (i.e. stack trace with local variables
too):

==
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
/usr/local/lib/python3.8/dist-packages/django/db/models/query.py:287: in
__iter__
   self._fetch_all()
   self   = 
/usr/local/lib/python3.8/dist-packages/django/db/models/query.py:1308: in
_fetch_all
   self._result_cache = list(self._iterable_class(self))
   self   = 
/usr/local/lib/python3.8/dist-packages/django/db/models/query.py:70: in
__iter__
   for row in compiler.results_iter(results):
   annotation_col_map = {}
   compiler   = 
   db = 'fdw'
   init_list  = ['id', 'queue', 'args', 'kwargs', 'type', 'state', ...]
   klass_info = {'model': ,
'select_fields': [0, 1, 2, 3, 4, 5, ...]}
   known_related_objects = []
   model_cls  = 
   model_fields_end = 9
   model_fields_start = 0
   queryset   = 
   related_populators = []
   results= [[('8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery',
['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {},
'paiyroll.tasks.function_run', 'scheduled', ...)]]
   select = [(Col(jobs, paiyroll.Job.id), ('"jobs"."id"', []),
None), (Col(jobs, paiyroll.Job.queue), ('"jobs"."queue"', []), None...,
paiyroll.Job.type), ('"jobs"."type"', []), None), (Col(jobs,
paiyroll.Job.state), ('"jobs"."state"', []), None), ...]
   select_fields = [0, 1, 2, 3, 4, 5, ...]
   self   = 
/usr/local/lib/python3.8/dist-packages/django/db/models/sql/compiler.py:1100:
in apply_converters
   value = converter(value, expression, connection)
   connection = 
   converter  = >
   converters = [(2, ([>], Col(jobs,
pa...NField.from_db_value of
>], Col(jobs,
paiyroll.Job.details)))]
   convs  = [>]
   expression = Col(jobs, paiyroll.Job.args)
   pos= 2
   row= ['8f4ab6b0-914f-4a75-972d-febbe55011fc', 'celery',
['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], {},
'paiyroll.tasks.function_run', 'scheduled', ...]
   rows   = 
   self   = 
   value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string',
[], {}]





*/usr/local/lib/python3.8/dist-packages/django/db/models/fields/json.py:74:
in from_db_valuereturn json.loads(value, cls=self.decoder)
   connection = expression = Col(jobs, paiyroll.Job.args)
   self   = 
   value  = ['paiyroll.tasks', 'call_to_string', 'call_to_string',
[], {}] *
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _

s = ['paiyroll.tasks', 'call_to_string', 'call_to_string', [], {}], cls =
None
object_hook = None, parse_float = None, parse_int = None, parse_constant =
None
object_pairs_hook = None, kw = {}

   def loads(s, *, cls=None, object_hook=None, parse_float=None,
   parse_int=None, parse_constant=None, object_pairs_hook=None,
**kw):
   """Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
   containing a JSON document) to a Python object.

   ``object_hook`` is an optional function that will be called with the
   result of any object literal decode (a ``dict``). The return value
of
   ``object_hook`` will be used instead of the ``dict``. This feature
   can be used to implement custom decoders (e.g. JSON-RPC class
hinting).

   ``object_pairs_hook`` is an optional function that will be called
with the
   result of any object literal decoded with an ordered list of pairs.
The
   return value of ``object_pairs_hook`` will be used instead of the
``dict``.
   This feature can be used to implement custom decoders.  If
``object_hook``
   is also defined, the ``object_pairs_hook`` takes priority.

   ``parse_float``, if specified, will be called with the string
   of every JSON float to be decoded. By default this is equivalent to
   float(num_str). This can be used to use another datatype or parser
   for JSON floats (e.g. decimal.Decimal).

   ``parse_int``, if specified, will be called with the string
   of every JSON int to be decoded. By default this is equivalent to
   int(num_str). This can be used to use another datatype or parser
   for JSON integers