Help: 'django.utils.six.moves' is not a package

2018-04-08 Thread Derek Zeng
I got the following error when running pytest in django. Help is 
appreciated.

This is the test I run

import pytest
from .factories import *

@pytest.mark.django_db
def test_with_client(client):
  PostFactory.create() # if commented out, the error is gone
  response = client.get('/')

  body = str(response.content)
  assert 'Mysite' in body

PostFactory creates a Post object in the database


apps/blog/tests/test_post.py:5 (test_with_client)
client = 
@pytest.mark.django_db
def test_with_client(client):
p = PostFactory.create()

> response = client.get('/')
blog/tests/test_post.py:10: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/test/client.py:517:
 
in get
response = super().get(path, data=data, secure=secure, **extra)
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/test/client.py:332:
 
in get
return self.generic('GET', path, secure=secure, **r)
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/test/client.py:404:
 
in generic
return self.request(**r)
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/test/client.py:467:
 
in request
response = self.handler(environ)
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/test/client.py:125:
 
in __call__
self.load_middleware()
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/core/handlers/base.py:37:
 
in load_middleware
middleware = import_string(middleware_path)
../../../../.virtualenvs/django/lib/python3.6/site-packages/django/utils/module_loading.py:17:
 
in import_string
module = import_module(module_path)
../../../../.virtualenvs/django/lib/python3.6/importlib/__init__.py:126: in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
:994: in _gcd_import
???
:971: in _find_and_load
???
:955: in _find_and_load_unlocked
???
:665: in _load_unlocked
???
:678: in exec_module
???
:219: in _call_with_frames_removed
???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
from __future__ import absolute_import

import re

from django import http
from django.apps import apps
from django.utils.cache import patch_vary_headers
> from django.utils.six.moves.urllib.parse import urlparse
E ModuleNotFoundError: No module named 'django.utils.six.moves.urllib'; 
'django.utils.six.moves' is not a package
../../../../.virtualenvs/django/lib/python3.6/site-packages/corsheaders/middleware.py:8:
 
ModuleNotFoundError

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/23957c7e-9aca-4494-a06a-20cbf0fc857b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reverse not found

2018-04-08 Thread toneldaclan
This code works well:

def detail(request, entity_group_id):
entity_group = get_object_or_404(EntityGroup, pk=entity_group_id) # noqa
entity_list = entity_group.members.order_by('name')
context = {
'entity_group': entity_group,
'entity_list': entity_list,
}
return render(request, 'core/detail.html', context)

When I converted it to a Generic View, a Reverse not found error occured

class DetailView(generic.DetailView):
model = EntityGroup
template_name = 'core/detail.html'

def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
context['entity_group'] = EntityGroup
context['entity_list'] = EntityGroup.members
return context

This is mu models.py

class Entity(models.Model):
is_person = models.BooleanField(default=True)
person = models.ForeignKey(Person, on_delete=models.PROTECT, null=True) 
# noqa
company = models.ForeignKey(Company, on_delete=models.PROTECT, 
null=True) # noqa
name = models.CharField(max_length=30)

def __str__(self):
return self.name

@property
def title(self):
return self.name

class Meta:
verbose_name_plural = 'entities'


class EntityGroup(models.Model):
name = models.CharField(max_length=20)
is_individual = models.BooleanField(default=True)
members = models.ManyToManyField(Entity, through='Membership')

def __str__(self):
return self.name

@property
def title(self):
return self.name


class Membership(models.Model):
entity_group = models.ForeignKey(EntityGroup, on_delete=models.PROTECT, 
null=False) # noqa
entity = models.ForeignKey(Entity, on_delete=models.PROTECT, null=False)

def __str__(self):
return self.entity_group.name + '-' + self.entity.name

@property
def title(self):
return self.entity_group.name + '-' + self.entity.name

class Meta:
unique_together = ("entity", "entity_group")

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90df6201-c304-40d4-96db-90b944838513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch on template view with through model

2018-04-08 Thread toneldaclan


This code in my views.py works fine when it was still not in template format

def detail(request, entity_group_id):
entity_group = get_object_or_404(EntityGroup, pk=entity_group_id) # noqa
entity_list = entity_group.members.order_by('name')
context = {
'entity_group': entity_group,
'entity_list': entity_list,
}
return render(request, 'core/detail.html', context)

When I changed it into a Generic View a NoReverseMatch comes up...

class DetailView(generic.DetailView):
model = EntityGroup
template_name = 'core/detail.html'

def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
context['entity_group'] = EntityGroup
context['entity_list'] = EntityGroup.members
return context

Here is my models.py

class Entity(models.Model):
name = models.CharField(max_length=30)

class EntityGroup(models.Model):
name = models.CharField(max_length=20)
members = models.ManyToManyField(Entity, through='Membership')
class Membership(models.Model):
entity_group = models.ForeignKey(EntityGroup, on_delete=models.PROTECT, 
null=False)
entity = models.ForeignKey(Entity, on_delete=models.PROTECT, null=False)

How do I set a reverse on the Generic view?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c2412652-22e2-41d4-874f-ff180e36c01d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Caching and Browser Caching

2018-04-08 Thread yingi keme
Thanks Jason

Yingi Kem

> On 8 Apr 2018, at 4:19 PM, Jason  wrote:
> 
> Browsers cache images, js and css, but not the actual data that's rendered.  
> In addition, browser caching only works for repeat visitors to your site.  
> Using server side caching complements browser side caching but also works for 
> first time visitors.
> 
>> On Sunday, April 8, 2018 at 10:49:07 AM UTC-4, yingi keme wrote:
>> I Have set up cache in my File System and I have used the following code to 
>> cache my view
>> 
>> from django.views.decorators.cache import cache_page
>> 
>> @cache_page(60 * 15)
>> def myView(request):
>> #some code
>> 
>> 
>> What i want to know is that, How is this caching mechanism different from 
>> the automatic caching some browsers provide?
>> 
>> Browsers usually do cache web apps, so what difference will this manual 
>> caching configuration make?
> 
> -- 
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/9787aa43-5b35-446d-85a1-4609c6b38c5b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8C8EE3BF-D3E3-4947-A0E0-D2C51F098138%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Caching and Browser Caching

2018-04-08 Thread Jason
Browsers cache images, js and css, but not the actual data that's 
rendered.  In addition, browser caching only works for repeat visitors to 
your site.  Using server side caching complements browser side caching but 
also works for first time visitors.

On Sunday, April 8, 2018 at 10:49:07 AM UTC-4, yingi keme wrote:
>
> I Have set up cache in my File System and I have used the following code 
> to cache my view
>
> from django.views.decorators.cache import cache_page
>
>
> @cache_page(60 * 15)
>
> def myView(request):
>
> #some code
>
>
>
> What i want to know is that, How is this caching mechanism different from 
> the automatic caching some browsers provide?
>
> Browsers usually do cache web apps, so what difference will this manual 
> caching configuration make?
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9787aa43-5b35-446d-85a1-4609c6b38c5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Caching and Browser Caching

2018-04-08 Thread yingi keme
I Have set up cache in my File System and I have used the following code to 
cache my view

from django.views.decorators.cache import cache_page


@cache_page(60 * 15)

def myView(request):

#some code



What i want to know is that, How is this caching mechanism different from 
the automatic caching some browsers provide?

Browsers usually do cache web apps, so what difference will this manual 
caching configuration make?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61c8eb2b-0293-4562-a3e2-625a85cdb75f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm trying to edit address form for Saleor ecommerce platform

2018-04-08 Thread Avraham Serour
You seem to have pasted a line from your template, not the error you are
getting, no way of helping you there.

Please post the actual error you are getting

On Sat, Apr 7, 2018 at 2:00 PM, ruslan.aldar  wrote:

> hello.
> I'm trying to build an local merchant website. So I don't know how to edit
> address form for Saleor. It uses google i18n address form.
> and when i'm trying to delete some fields like company_name, city
> city_area, postal_code, country, country_area, i'm having problem.
>
> on the page : http://localhost:8000/checkout/shipping-address/
>
> i'm getting
> {% with address_form_lines=address_form.i18n_fields_order %}
> this kind of error.
>
> Making migration doesn't solve the problem and I don't know why it's
> requesting the field which is doesn't exist!  I even tried deleting DB,
> migrating again!
>
> If someone knows it please tell me.
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/5f44cebc-915e-4c08-b394-13efc4ca5c0c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6t%2BAX%3D_TGh5LLa-RyX9Xc9Y_YVm-iL965d3r1DkcK4zU2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.