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

2020-10-16 Thread Salima Begum
Thank you for your reply

I did that again I am getting this error
___
TestViews.test_product_detail_authenticated


klass = , args = (), kwargs =
{'pk': 22}, queryset = ]>

def get_object_or_404(klass, *args, **kwargs):
"""
Use get() to return an object, or raise a Http404 exception if the
object
does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed
arguments and keyword arguments are used in the get() query.

Like with QuerySet.get(), MultipleObjectsReturned is raised if more
than
one object is found.
"""
queryset = _get_queryset(klass)
if not hasattr(queryset, 'get'):
klass__name = klass.__name__ if isinstance(klass, type) else
klass.__class__.__name__
raise ValueError(
"First argument to get_object_or_404() must be a Model,
Manager, "
"or QuerySet, not '%s'." % klass__name
)
try:
>   return queryset.get(*args, **kwargs)

c:\users\user\appdata\local\programs\python\python38\lib\site-packages\django\shortcuts.py:76:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _

self = ]>, args =
(), kwargs = {'pk': 22}, clone = , limit = 21, num = 0

def get(self, *args, **kwargs):
"""
Perform the query and return a single object matching the given
keyword arguments.
"""
clone = self._chain() if self.query.combinator else
self.filter(*args, **kwargs)
if self.query.can_filter() and not self.query.distinct_fields:
clone = clone.order_by()
limit = None
if not clone.query.select_for_update or
connections[clone.db].features.supports_select_for_update_with_limit:
limit = MAX_GET_RESULTS
clone.query.set_limits(high=limit)
num = len(clone)
if num == 1:
return clone._result_cache[0]
if not num:
>   raise self.model.DoesNotExist(
"%s matching query does not exist." %
self.model._meta.object_name
)
E   pages.models.vk_ls_product_search.DoesNotExist:
vk_ls_product_search matching query does not exist.

c:\users\user\appdata\local\programs\python\python38\lib\site-packages\django\db\models\query.py:415:
DoesNotExist

During handling of the above exception, another exception occurred:

self = 

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

>   response = onClickSearch.ProductDetails_ls(request, pk=22)

pages\tests\test_views.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _
pages\views.py:2795: in ProductDetails_ls
product_ls = get_object_or_404(vk_ls_product_search, pk=pk)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _

klass = , args = (), kwargs =
{'pk': 22}, queryset = ]>

def get_object_or_404(klass, *args, **kwargs):
"""
Use get() to return an object, or raise a Http404 exception if the
object
does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed
arguments and keyword arguments are used in the get() query.

Like with QuerySet.get(), MultipleObjectsReturned is raised if more
than
one object is found.
"""
queryset = _get_queryset(klass)
if not hasattr(queryset, 'get'):
klass__name = klass.__name__ if isinstance(klass, type) else
klass.__class__.__name__
raise ValueError(
"First argument to get_object_or_404() must be a Model,
Manager, "
"or QuerySet, not '%s'." % klass__name
)
try:
return queryset.get(*args, **kwargs)
except queryset.model.DoesNotExist:
>   raise Http404('No %s matches the given query.' %
queryset.model._meta.object_name)
E   django.http.response.Http404: No vk_ls_product_search matches
the given query.

c:\users\user\appdata\local\programs\python\python38\lib\site-packages\django\shortcuts.py:78:
Http404


Please can you help me to solve this error too , Thank you


On Fri, Oct 16, 2020 at 4:11 PM Shahprogrammer  wrote:

> You have created a class named  onClickSearch  with method
> ProductDetails . So you can't import a method of a class. To use the method
> you need to import class.
> So in place of importing  from page

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

2020-10-16 Thread Shahprogrammer
You have created a class named  onClickSearch  with method  
ProductDetails . So you can't import a method of a class. To use the method 
you need to import class.
So in place of importing  from pages.views import ProductDetails  in 
test_views.py do from pages.views import onClickSearch  & then use it's 
method as onClickSearch. ProductDetails   as per your need in your code 

On Friday, 16 October, 2020 at 3:33:11 pm UTC+5:30 
sali...@rohteksolutions.com wrote:

> Inside pages folder I already have views.py 
>
> Thanks
> ~salima
>
> On Fri, Oct 16, 2020 at 1:28 PM Akinfolarin Stephen <
> akinfolar...@gmail.com> wrote:
>
>> The problem is you are trying to import views from where you have not 
>> created it I guess the page is  a folder then create the views.py inside of 
>> it
>>
>> On Fri, Oct 16, 2020, 08:10 Salima Begum  
>> wrote:
>>
>>> urls.py
>>>
>>>  path('ProductDetails/', views.onClickSearch.ProductDetails, 
>>> name='ProductDetails'),
>>>
>>> views.py
>>>
>>>
>>> class onClickSearch():
>>>
>>> def ProductDetails(request, id):
>>> try:
>>> email = request.session.get('email')
>>> proddtls = vk_master_table.objects.filter(id=id).first()
>>> if proddtls:
>>> banners = Extras().bestDeals_cat(proddtls.category_desc)
>>>
>>> # print(banners.product_name)
>>> except Exception as e:
>>> logging.error(e)
>>> return render(request, "ProductDetails.html", {'error': 
>>> error, 'form': HomeForm(),
>>>'time': 
>>> settings.SESSION_IDLE_TIMEOUT,
>>>'name': 
>>> first_last_initial(email),
>>>'msg_count': 
>>> msg_count_cl(email),
>>>'fullname': 
>>> fullname(email), 'ProductDetails': proddtls,
>>>'signinForm': 
>>> SigninForm(), 'signupForm': CustomerForm()})
>>> return render(request, "ProductDetails.html", {'ProductDetails': 
>>> proddtls, 'fbanners': banners,
>>>'form': 
>>> HomeForm(), 'signinForm': SigninForm(),
>>>'name': 
>>> first_last_initial(email),
>>>'msg_count': 
>>> msg_count_cl(email),
>>>'fullname': 
>>> fullname(email),
>>>'time': 
>>> settings.SESSION_IDLE_TIMEOUT,
>>>'signupForm': 
>>> CustomerForm()})
>>>
>>>
>>>
>>>
>>> On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah  wrote:
>>>
 Can you post your views.py code

 On Fri, 16 Oct 2020 at 12:26, Salima Begum  
 wrote:

> Hi all,
> vikreya
> mysite
> .cache
> .idea
>.pytest_cache
> logs
> media
> mysite
> __init__.py
>manage.py
>settings.py
>urls.py
>wsgi.py
>  pages
> .cache
> migrations
> static
> templates
> tests
> test_views.py
>__init__.py 
> admin.py
> apps.py
> cron.py
> Forms.py
>functions.py
>models.py
>   urls.py
>   views.py
>
> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
> sali...@rohteksolutions.com> wrote:
>
>> Hi  @Akinfolarin Stephen,
>>
>>
>>
>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>> akinfolar...@gmail.com> wrote:
>>
>>> 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 <
>>> sali...@rohteksolutions.com> 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)
 r

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

2020-10-16 Thread Salima Begum
Inside pages folder I already have views.py

Thanks
~salima

On Fri, Oct 16, 2020 at 1:28 PM Akinfolarin Stephen <
akinfolarinsteph...@gmail.com> wrote:

> The problem is you are trying to import views from where you have not
> created it I guess the page is  a folder then create the views.py inside of
> it
>
> On Fri, Oct 16, 2020, 08:10 Salima Begum 
> wrote:
>
>> urls.py
>>
>>  path('ProductDetails/', views.onClickSearch.ProductDetails,
>> name='ProductDetails'),
>>
>> views.py
>>
>>
>> class onClickSearch():
>>
>> def ProductDetails(request, id):
>> try:
>> email = request.session.get('email')
>> proddtls = vk_master_table.objects.filter(id=id).first()
>> if proddtls:
>> banners = Extras().bestDeals_cat(proddtls.category_desc)
>>
>> # print(banners.product_name)
>> except Exception as e:
>> logging.error(e)
>> return render(request, "ProductDetails.html", {'error':
>> error, 'form': HomeForm(),
>>'time':
>> settings.SESSION_IDLE_TIMEOUT,
>>'name':
>> first_last_initial(email),
>>'msg_count':
>> msg_count_cl(email),
>>'fullname':
>> fullname(email), 'ProductDetails': proddtls,
>>'signinForm':
>> SigninForm(), 'signupForm': CustomerForm()})
>> return render(request, "ProductDetails.html", {'ProductDetails':
>> proddtls, 'fbanners': banners,
>>'form':
>> HomeForm(), 'signinForm': SigninForm(),
>>'name':
>> first_last_initial(email),
>>'msg_count':
>> msg_count_cl(email),
>>'fullname':
>> fullname(email),
>>'time':
>> settings.SESSION_IDLE_TIMEOUT,
>>'signupForm':
>> CustomerForm()})
>>
>>
>>
>>
>> On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah 
>> wrote:
>>
>>> Can you post your views.py code
>>>
>>> On Fri, 16 Oct 2020 at 12:26, Salima Begum 
>>> wrote:
>>>
 Hi all,
 vikreya
 mysite
 .cache
 .idea
.pytest_cache
 logs
 media
 mysite
 __init__.py
manage.py
settings.py
urls.py
wsgi.py
  pages
 .cache
 migrations
 static
 templates
 tests
 test_views.py
__init__.py
 admin.py
 apps.py
 cron.py
 Forms.py
functions.py
models.py
   urls.py
   views.py

 On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
 salim...@rohteksolutions.com> wrote:

> Hi  @Akinfolarin Stephen,
>
>
>
> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
> akinfolarinsteph...@gmail.com> wrote:
>
>> 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 <
>> salim...@rohteksolutions.com> 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.
>>> 

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

2020-10-16 Thread Akinfolarin Stephen
The problem is you are trying to import views from where you have not
created it I guess the page is  a folder then create the views.py inside of
it

On Fri, Oct 16, 2020, 08:10 Salima Begum 
wrote:

> urls.py
>
>  path('ProductDetails/', views.onClickSearch.ProductDetails,
> name='ProductDetails'),
>
> views.py
>
>
> class onClickSearch():
>
> def ProductDetails(request, id):
> try:
> email = request.session.get('email')
> proddtls = vk_master_table.objects.filter(id=id).first()
> if proddtls:
> banners = Extras().bestDeals_cat(proddtls.category_desc)
>
> # print(banners.product_name)
> except Exception as e:
> logging.error(e)
> return render(request, "ProductDetails.html", {'error': error,
> 'form': HomeForm(),
>'time':
> settings.SESSION_IDLE_TIMEOUT,
>'name':
> first_last_initial(email),
>'msg_count':
> msg_count_cl(email),
>'fullname':
> fullname(email), 'ProductDetails': proddtls,
>'signinForm':
> SigninForm(), 'signupForm': CustomerForm()})
> return render(request, "ProductDetails.html", {'ProductDetails':
> proddtls, 'fbanners': banners,
>'form': HomeForm(),
> 'signinForm': SigninForm(),
>'name':
> first_last_initial(email),
>'msg_count':
> msg_count_cl(email),
>'fullname':
> fullname(email),
>'time':
> settings.SESSION_IDLE_TIMEOUT,
>'signupForm':
> CustomerForm()})
>
>
>
>
> On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah  wrote:
>
>> Can you post your views.py code
>>
>> On Fri, 16 Oct 2020 at 12:26, Salima Begum 
>> wrote:
>>
>>> Hi all,
>>> vikreya
>>> mysite
>>> .cache
>>> .idea
>>>.pytest_cache
>>> logs
>>> media
>>> mysite
>>> __init__.py
>>>manage.py
>>>settings.py
>>>urls.py
>>>wsgi.py
>>>  pages
>>> .cache
>>> migrations
>>> static
>>> templates
>>> tests
>>> test_views.py
>>>__init__.py
>>> admin.py
>>> apps.py
>>> cron.py
>>> Forms.py
>>>functions.py
>>>models.py
>>>   urls.py
>>>   views.py
>>>
>>> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
>>> salim...@rohteksolutions.com> wrote:
>>>
 Hi  @Akinfolarin Stephen,



 On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
 akinfolarinsteph...@gmail.com> wrote:

> 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 'ProductDet

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

2020-10-16 Thread Salima Begum
urls.py

 path('ProductDetails/', views.onClickSearch.ProductDetails,
name='ProductDetails'),

views.py


class onClickSearch():

def ProductDetails(request, id):
try:
email = request.session.get('email')
proddtls = vk_master_table.objects.filter(id=id).first()
if proddtls:
banners = Extras().bestDeals_cat(proddtls.category_desc)

# print(banners.product_name)
except Exception as e:
logging.error(e)
return render(request, "ProductDetails.html", {'error': error,
'form': HomeForm(),
   'time':
settings.SESSION_IDLE_TIMEOUT,
   'name':
first_last_initial(email),
   'msg_count':
msg_count_cl(email),
   'fullname':
fullname(email), 'ProductDetails': proddtls,
   'signinForm':
SigninForm(), 'signupForm': CustomerForm()})
return render(request, "ProductDetails.html", {'ProductDetails':
proddtls, 'fbanners': banners,
   'form': HomeForm(),
'signinForm': SigninForm(),
   'name':
first_last_initial(email),
   'msg_count':
msg_count_cl(email),
   'fullname':
fullname(email),
   'time':
settings.SESSION_IDLE_TIMEOUT,
   'signupForm':
CustomerForm()})




On Fri, Oct 16, 2020 at 12:32 PM Dhwanil Shah  wrote:

> Can you post your views.py code
>
> On Fri, 16 Oct 2020 at 12:26, Salima Begum 
> wrote:
>
>> Hi all,
>> vikreya
>> mysite
>> .cache
>> .idea
>>.pytest_cache
>> logs
>> media
>> mysite
>> __init__.py
>>manage.py
>>settings.py
>>urls.py
>>wsgi.py
>>  pages
>> .cache
>> migrations
>> static
>> templates
>> tests
>> test_views.py
>>__init__.py
>> admin.py
>> apps.py
>> cron.py
>> Forms.py
>>functions.py
>>models.py
>>   urls.py
>>   views.py
>>
>> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
>> salim...@rohteksolutions.com> wrote:
>>
>>> Hi  @Akinfolarin Stephen,
>>>
>>>
>>>
>>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>>> akinfolarinsteph...@gmail.com> wrote:
>>>
 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+un

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

2020-10-16 Thread Shahprogrammer
Can you post your code of views.py

On Friday, 16 October, 2020 at 12:27:19 pm UTC+5:30 
sali...@rohteksolutions.com wrote:

> Hi all,
> vikreya
> mysite
> .cache
> .idea
>.pytest_cache
> logs
> media
> mysite
>
> __init__.py
>manage.py
>settings.py
>urls.py
>wsgi.py
>  pages
> .cache
> migrations
> static
> templates
> tests
> test_views.py
>__init__.py 
> admin.py
> apps.py
> cron.py
> Forms.py
>functions.py
>models.py
>   urls.py
>   views.py
>
> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum  
> wrote:
>
>> Hi  @Akinfolarin Stephen,
>>
>>
>>
>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>> akinfolar...@gmail.com> wrote:
>>
>>> 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...@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...@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
>>>  
>>> 
>>> .
>>>
>>

-- 
You received this message because you are subscribed 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/6ccb7a89-f757-4522-946e-dcc6ee0321e7n%40googlegroups.com.


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

2020-10-16 Thread Dhwanil Shah
Can you post your views.py code

On Fri, 16 Oct 2020 at 12:26, Salima Begum 
wrote:

> Hi all,
> vikreya
> mysite
> .cache
> .idea
>.pytest_cache
> logs
> media
> mysite
> __init__.py
>manage.py
>settings.py
>urls.py
>wsgi.py
>  pages
> .cache
> migrations
> static
> templates
> tests
> test_views.py
>__init__.py
> admin.py
> apps.py
> cron.py
> Forms.py
>functions.py
>models.py
>   urls.py
>   views.py
>
> On Fri, Oct 16, 2020 at 12:09 PM Salima Begum <
> salim...@rohteksolutions.com> wrote:
>
>> Hi  @Akinfolarin Stephen,
>>
>>
>>
>> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
>> akinfolarinsteph...@gmail.com> wrote:
>>
>>> 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
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed 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/CAMSz6bm1WKP8qjSzSz5Ouhf%2Bc2K9-pLM4Wc%3DfgSsyUek3KKmqA%40mail.gmail.com
> 
> .
>


-- 

*Dhwanil J Shah*
*Near Ashok agency, *
*Madanwad ,*

*Valsad 396001*
*email:dhwani...@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/msg

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

2020-10-15 Thread Salima Begum
Hi all,
vikreya
mysite
.cache
.idea
   .pytest_cache
logs
media
mysite
__init__.py
   manage.py
   settings.py
   urls.py
   wsgi.py
 pages
.cache
migrations
static
templates
tests
test_views.py
   __init__.py
admin.py
apps.py
cron.py
Forms.py
   functions.py
   models.py
  urls.py
  views.py

On Fri, Oct 16, 2020 at 12:09 PM Salima Begum 
wrote:

> Hi  @Akinfolarin Stephen,
>
>
>
> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
> akinfolarinsteph...@gmail.com> wrote:
>
>> 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
>> 
>> .
>>
>

-- 
You received this message because you are subscribed 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/CAMSz6bm1WKP8qjSzSz5Ouhf%2Bc2K9-pLM4Wc%3DfgSsyUek3KKmqA%40mail.gmail.com.


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

2020-10-15 Thread Salima Begum
Hi all,

my project structure
vikreya
mysite
.cache
.idea
.pytest_cache
logs
media
mysute
__init__.py
manage.py
settings.py
urls.py
wsgi.py
pages
.cache
migrations
static
templates
tests
test_views.py
__init__.py
admin.py
apps.py
cron.py
Forms.py
functions.py
models.py
urls.py
views.py

On Fri, Oct 16, 2020 at 12:09 PM Salima Begum 
wrote:

> Hi  @Akinfolarin Stephen,
>
>
>
> On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
> akinfolarinsteph...@gmail.com> wrote:
>
>> 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
>> 
>> .
>>
>

-- 
You received this message because you are subscribed 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%3DbFwx8O05g0xh6Nj35iVxZu72Us6CT5aTLiTAkeUGB-A%40mail.gmail.com.


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

2020-10-15 Thread Salima Begum
Hi  @Akinfolarin Stephen,



On Fri, Oct 16, 2020 at 11:10 AM Akinfolarin Stephen <
akinfolarinsteph...@gmail.com> wrote:

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

-- 
You received this message because you are subscribed 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/CAMSz6bkTxp%3DabagmH%2BzwTzhYcusXzubYOLVOkh-6wujxb5L%2B3Q%40mail.gmail.com.


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.