Re: Problem with Postgresql-11.9 ??

2020-10-16 Thread David Nugent
Apologies, I must have bumped send accidentally.

To complete the sentence, unless fields have null=True then referencing unsaved 
records here will fail because there is no id in the dependent records to 
provide a reference. By default there is a constraint that the reference is not 
null.

But rather than add null=True to fields, you probably need to ensure those 
model instances are saved and populated with a valid record before saving your 
InputTypeMap record.

It would have little to do with the database, any version. That would be the 
last place I'd go looking for such an issue.

Regards, David

On 17 Oct 2020, at 15:13, David Nugent 
mailto:dav...@uniquode.io>> wrote:

In __your__ code, most certainly.  :-)

You didn't say what 'training', 'input_type' and 'gender' are. It is in one or 
more of those where the problem exists.

Do these referenced save module instances? If they are not yet saved then it 
will trigger this error for fields where



On 13 Oct 2020, at 08:49, Joakim Hove 
mailto:joakim.h...@gmail.com>> wrote:

Thank you for answering. Just to be sure: you agree that the behavior I 
describe looks like a bug somewhere?

-- 
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/C6EE4597-0907-49BE-8E94-1BC8B9E592A0%40uniquode.io.


Re: Problem with Postgresql-11.9 ??

2020-10-16 Thread David Nugent
In __your__ code, most certainly.  :-)

You didn't say what 'training', 'input_type' and 'gender' are. It is in one or 
more of those where the problem exists.

Do these referenced save module instances? If they are not yet saved then it 
will trigger this error for fields where



On 13 Oct 2020, at 08:49, Joakim Hove 
mailto:joakim.h...@gmail.com>> wrote:

Thank you for answering. Just to be sure: you agree that the behavior I 
describe looks like a bug somewhere?

man. 12. okt. 2020, 23:42 skrev Thomas Lockhart 
mailto:tlockhart1...@gmail.com>>:
No one has answered yet, so here is some useless info…

I’ve been using various combinations of Postgres and Django (currently 12.4 and 
3.1.2, respectively) and would think I would have stumbled on this at some 
point when using postgresql-11. But I probably haven’t tried 11.x with 3.1.2 
specifically…

- Tom

On Oct 12, 2020, at 9:24 AM, Joakim Hove 
mailto:joakim.h...@gmail.com>> wrote:



[ This question is also posted to StackOverflow: 
https://stackoverflow.com/questions/64320386/django-postgresql-model-with-only-foreign-keys
 ]

I have a model which looks like this:

class InputTypeMap(models.Model):
input_type = models.ForeignKey(InputType, on_delete=models.CASCADE)
training = models.ForeignKey(Training, on_delete=models.CASCADE)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
gender = models.ForeignKey(Gender, on_delete=models.CASCADE)


When I try to create instances of this model with:

InputTypeMap.objects.create(input_type=input_type,
training=training,
gender=gender,
category=category)


I get an exception when using Postgres-11.9:

Traceback (most recent call last):
  File 
"/home/hove/sleipner/venv/lib/python3.7/site-packages/django/db/backends/utils.py",
 line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.NotNullViolation: null value in column "id" violates not-null 
constraint
DETAIL:  Failing row contains (null, Maintenance, Female, MareGielding, No).


>From the error message it seems to me that a ID key for the new entry is not 
>generated. This code has worked as I expected for quite some time, but has 
>"suddenly" started to fail locally - probably after a apt get upgrade. When I 
>run the same code with sqlite or Postgres-10.14 thing continue to work as 
>before. It is not clear to me whether this is a bug in my code (most probable 
>...), Django or Postgres. I am using Django version 3.1.2

Any hints appreciated.

Regards - Joakim Hove

--
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/CALKD1M-YbR80USkq%2BLLyWHR7iem66ALcc9bH6dYGOEP9ywWkfA%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/1C816206-3EC7-4696-806E-FD810E76C251%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALKD1M8O4%3DtQ%2BxuEE7%2BzC17%2BjnotzUzEDU3EkoqVTPDOTngQMg%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/270DF6AB-0CF9-471B-AF95-B18959CFCF64%40uniquode.io.


Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread David Nugent
After playing with this to answer your question and to correct my previous 
response, I found that it does work as documented when using a "through" model 
without using "through_fields".


from django.db import models


class Person(models.Model):
name = models.CharField(max_length=255)
friends = models.ManyToManyField("self", through='Friendship', 
symmetrical=True)

def __str__(self):
return self.name


class Friendship(models.Model):
person_a = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='a')
person_b = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='b')
start = models.DateField(auto_now_add=True)

def __str__(self):
return f'{self.person_a.name} => {self.person_b.name}: {self.start}'

>>> from people.models import Person, Friendship
>>> bill = Person.objects.create(name='bill')
>>> rufus = Person.objects.create(name='rufus')
>>> bill.friends.add(ted)
>>> bill.friends.add(rufus)
>>> rufus.friends.add(bill)
>>> rufus.friends.add(ted)
>>> bill.friends.all()
, ]>
>>> ted.friends.all()
, ]>
>>> rufus.friends.all()
, ]>
>>> Friendship.objects.all()
 ted: 2020-10-17>,
   bill: 2020-10-17>,
   rufus: 2020-10-17>,
   bill: 2020-10-17>,
   ted: 2020-10-17>,
   rufus: 2020-10-17>
]>


In your case, naming the related_name the same as the field name may be an 
issue. Since related_name becomes a pseudo field on the model in which it is 
defined, so there is a potential clash in the namespace?

On 17 Oct 2020, at 11:20, gjgilles via Django users 
mailto:django-users@googlegroups.com>> wrote:

Thanks for all for the replies!

@David, the helper function works as expected.

>>> from people.models import Person, Friendship
>>> bill = Person(name='bill')
>>> bill.save()
>>> ted = Person(name='ted')
>>> ted.save()
>>> bill.add_friendship(ted, True)
(, True)
>>> bill.friends.all()
]>
>>> ted.friends.all()
]>


Also, @coolguy for my code, the correct call is >>> ted.personB.all() without 
the helper function. ted.personA.all() returns an empty queryset without the 
helper function.

While I'm here, the Django docs imply that 

 intermediate models can be recursive and 
symmetrical:
"Recursive relationships using an intermediary model and defined as symmetrical 
(that is, with symmetrical=True, which is default) can't determine the 
accessory names, as they would be the same. You need to set a related_name to 
at least one of them. If you'd prefer Django not to create a backwards 
relation, set related_name to '+'."

This implies Django makes the reverse relation by default. Am I 
misunderstanding something?

-- 
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/0B233FC5-01A3-469D-8F85-EFFE0C8F13EC%40uniquode.io.


Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread gjgilles via Django users
Thanks for all for the replies!

@David, the helper function works as expected.

>>> from people.models import Person, Friendship
>>> bill = Person(name='bill')
>>> bill.save()
>>> ted = Person(name='ted')
>>> ted.save()
>>> bill.add_friendship(ted, True)
(, True)
>>> bill.friends.all()
] ted.friends.all()
]>


Also, @coolguy for my code, the correct call is >>> ted.personB.all() without 
the helper function. ted.personA.all() returns an empty queryset without the 
helper function.

While I'm here, the Django docs imply that  
intermediate
 models can be recursive and symmetrical 
:
"Recursive relationships using an intermediary model and defined as symmetrical 
(that is, with symmetrical=True, which is default) can't determine the 
accessory names, as they would be the same. You need to set a related_name to 
at least one of them. If you'd prefer Django not to create a backwards 
relation, set related_name to '+'."

This implies Django makes the reverse relation by default. Am I 
misunderstanding something?

Oct 16, 2020, 16:48 by dav...@uniquode.io:

> Just to add, I don't think django supports symmetrical M2M relations with 
> additional data / explicit through model without the shim I suggested. 
>
> For example, this works:
>
> from > django.db > import > models
>
>
> class > Person(models.Model):
> name = models.CharField(> max_length> => 255> )
> friends = models.ManyToManyField(> "self"> , > symmetrical> => True> )
>
> > def > __str__> (> self> ):
> > return > self> .name
>
> >>> from people.models import Person
> >>> bill = Person.objects.create(name='bill')
> >>> ted = Person.objects.create(name='ted')
> >>> bill.friends.add(ted)
> >>> bill.friends.all()
> ]>
> >>> ted.friends.all()
> ]>
>
>
>
>
>
>
>> On 17 Oct 2020, at 10:28, coolguy <>> cooldjangoprogram...@gmail.com>> > 
>> wrote:
>>
>>
>> With your example, you can also find the records through>>> 
>> ted.person_set.all().
>>  
>>  
>> On Friday, October 16, 2020 at 7:05:51 PM UTC-4 David Nugent wrote:
>>
>>> This is expected with your code.  You've created an asymmetric relationship 
>>> from bill to ted, but not the reverse. This would be appropriate in a 
>>> "follow" relationship. For symmetric relationships you need to create 
>>> records in both directions. There are a few ways to do this but a helper 
>>> function on the Person model is the most direct approach, something along 
>>> the lines:
>>>
>>>     def add_friendship(self, person, symmetric=True):
>>>         friendship = Friendship.objects.get_or_create(personA=self, 
>>> personB=person)
>>>         if symmetric:
>>>             # avoid recursion
>>>             person.add_friendship(self, False)
>>>         return friendship
>>>
>>>
>>> Regards, David
>>>
>>>


 On 17 Oct 2020, at 05:38, gjgilles via Django users < 
 django...@googlegroups.com <> > wrote:


 There are no responses to the same question on stackoverflow, so hopefully 
 someone here can provide a solution. 
 
  

 I've read the docs. 
 
    I've   read this question too, 
 
    but the following code is not working as the Django docs describe.

 If   bill   and   ted  are friends,   
 bill.friends.all()   should include   ted,    
 and   ted.friends.all()   should include   
 bill . This is not what Django does.   ted 's query is 
 empty, while   bill 's query includes   ted .
 # people.models from  django.db  import  models 
 class   Person ( models.Model ): name = 
 models.CharField(max_length= 255 )friends = 
 models.ManyToManyField( "self" ,   
   through= 'Friendship' , 
 through_fields=( 'personA' ,  'personB' ), 
 symmetrical= True ,
  ) def   __str__ ( self ): 
  return   self.name  class   
 Friendship ( models.Model ): personA = 
 models.ForeignKey(Person, on_delete=models.CASCADE, related_name= 
 'personA' )

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread David Nugent
Just to add, I don't think django supports symmetrical M2M relations with 
additional data / explicit through model without the shim I suggested.

For example, this works:


from django.db import models


class Person(models.Model):
name = models.CharField(max_length=255)
friends = models.ManyToManyField("self", symmetrical=True)

def __str__(self):
return self.name

>>> from people.models import Person
>>> bill = Person.objects.create(name='bill')
>>> ted = Person.objects.create(name='ted')
>>> bill.friends.add(ted)
>>> bill.friends.all()
]>
>>> ted.friends.all()
]>





On 17 Oct 2020, at 10:28, coolguy 
mailto:cooldjangoprogram...@gmail.com>> wrote:


With your example, you can also find the records through>>> 
ted.person_set.all().

On Friday, October 16, 2020 at 7:05:51 PM UTC-4 David Nugent wrote:
This is expected with your code.  You've created an asymmetric relationship 
from bill to ted, but not the reverse. This would be appropriate in a "follow" 
relationship. For symmetric relationships you need to create records in both 
directions. There are a few ways to do this but a helper function on the Person 
model is the most direct approach, something along the lines:

def add_friendship(self, person, symmetric=True):
friendship = Friendship.objects.get_or_create(personA=self, 
personB=person)
if symmetric:
# avoid recursion
person.add_friendship(self, False)
return friendship


Regards, David

On 17 Oct 2020, at 05:38, gjgilles via Django users 
 wrote:

There are no responses to the same question on stackoverflow, so hopefully 
someone here can provide a 
solution.


I've read the 
docs.
 I've read this question 
too,
 but the following code is not working as the Django docs describe.

If bill and ted are friends, bill.friends.all() should include ted,  and 
ted.friends.all() should include bill. This is not what Django does. ted's 
query is empty, while bill's query includes ted.

# people.models
from django.db import models


class Person(models.Model):
name = models.CharField(max_length=255)
friends = models.ManyToManyField("self",
 through='Friendship',
 through_fields=('personA', 'personB'),
 symmetrical=True,
 )

def __str__(self):
return self.name


class Friendship(models.Model):
personA = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='personA')
personB = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='personB')
start = models.DateField(null=True, blank=True)
end = models.DateField(null=True, blank=True)

def __str__(self):
return ' and '.join([str(self.personA), str(self.personB)])




>>> import django
>>> django.__version__
'3.1.2'
>>> from people.models import Person, Friendship
>>> bill = Person(name='bill')
>>> bill.save()
>>> ted = Person(name='ted')
>>> ted.save()
>>> bill_and_ted = Friendship(personA=bill, personB=ted)
>>> bill_and_ted.save()
>>> bill.friends.all()
]>
>>> ted.friends.all()

>>> ted.refresh_from_db()
>>> ted.friends.all()

>>> ted = Person.objects.get(name='ted')
>>> ted.friends.all()



Can someone please show me how to make this behave as expected.


--
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/MJmh5Qw--3-2%40tutanota.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/f1b39d06-6100-4b6c-94a5-1ec60fa45f80n%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 

Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread coolguy

With your example, you can also find the records through>>> 
ted.person_set.all().

On Friday, October 16, 2020 at 7:05:51 PM UTC-4 David Nugent wrote:

> This is expected with your code.  You've created an asymmetric 
> relationship from bill to ted, but not the reverse. This would be 
> appropriate in a "follow" relationship. For symmetric relationships you 
> need to create records in both directions. There are a few ways to do this 
> but a helper function on the Person model is the most direct approach, 
> something along the lines:
>
> def add_friendship(self, person, symmetric=True):
> friendship = Friendship.objects.get_or_create(personA=self, 
> personB=person)
> if symmetric:
> # avoid recursion
> person.add_friendship(self, False)
> return friendship
>
>
> Regards, David
>
> On 17 Oct 2020, at 05:38, gjgilles via Django users <
> django...@googlegroups.com> wrote:
>
> There are no responses to the same question on stackoverflow, so hopefully 
> someone here can provide a solution. 
> 
>  
>
> I've read the docs. 
> 
>  I've read this question too, 
> 
>  but the following code is not working as the Django docs describe.
> If *bill* and *ted *are friends,* bill.friends.all() *should include 
> *ted,  *and *ted.friends.all() *should include *bill*. This is not what 
> Django does. *ted*'s query is empty, while *bill*'s query includes *ted*.
>
> # people.modelsfrom django.db import models
>
> class Person(models.Model):
> name = models.CharField(max_length=255)
> friends = models.ManyToManyField("self",
>  through='Friendship',
>  through_fields=('personA', 'personB'),
>  symmetrical=True,
>  )
>
> def __str__(self):
> return self.name
>
> class Friendship(models.Model):
> personA = models.ForeignKey(Person, on_delete=models.CASCADE, 
> related_name='personA')
> personB = models.ForeignKey(Person, on_delete=models.CASCADE, 
> related_name='personB')
> start = models.DateField(null=True, blank=True)
> end = models.DateField(null=True, blank=True)
>
> def __str__(self):
> return ' and '.join([str(self.personA), str(self.personB)])
>
>
>
>
> >>> import django
> >>> django.__version__
> '3.1.2'
> >>> from people.models import Person, Friendship>>> bill = 
> >>> Person(name='bill')>>> bill.save()>>> ted = Person(name='ted')>>> 
> >>> ted.save()>>> bill_and_ted = Friendship(personA=bill, personB=ted)>>> 
> >>> bill_and_ted.save()>>> bill.friends.all()
> ] ted.friends.all()
> >>> ted.refresh_from_db()>>> ted.friends.all()
> >>> ted = Person.objects.get(name='ted')>>> ted.friends.all()
> 
>
>
> Can someone please show me how to make this behave as expected.
>
>
> -- 
> 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/MJmh5Qw--3-2%40tutanota.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/f1b39d06-6100-4b6c-94a5-1ec60fa45f80n%40googlegroups.com.


Re: Pasting images versus uploading

2020-10-16 Thread Mike Dewhirst

RyanThank you for that research and advice. I need to follow through and absorb 
the implications. That means trying both and then deciding. I'll report in due 
course.Thanks to allMike--(Unsigned mail from my phone)
 Original message From: Ryan Nowakowski  
Date: 15/10/20  09:28  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: Pasting images versus uploading On Fri, Oct 09, 2020 at 06:22:10PM +1100, 
Mike Dewhirst wrote:> On 9/10/2020 11:55 am, Ryan Nowakowski wrote:> > Maybe 
you could swap out the default ImageField widget for> > TinyMCE-lite HTMLField? 
Security-wise you probably want to sanitize> > the input from HTMLField in 
Django to make sure only img tags are allowed.> > With the image pasted in, 
viewing the browser page source it is> represented as just a string although it 
does contain ...> > ... src=data:image/png;base64,iVBOR ...> > > Are you 
saying all I have to do is write a clean() method for the> HTMLField to detect 
various image types?In your Django form class I'd write a clean method 
specifically for thatfield[1] that parses the html, perhaps using 
BeautifulSoup[2].  Thensearch for any "img" tags.  For each img tag, parse the 
data URI[3] toget the image data.You still have the problem that the HTMLField 
is meant to be areplacement for TextField so you'll need to figure out how to 
back thatwith an ImageField instead.  Perhaps you should try to go one 
levellower and use the TinyMCE form widget[4] instead of using the 
HTMLField?[1] 
https://docs.djangoproject.com/en/3.1/ref/forms/validation/#cleaning-a-specific-field-attribute[2]
 https://www.crummy.com/software/BeautifulSoup/bs4/doc/[3] 
https://stackoverflow.com/a/33870677/226697[4] 
http://romanvm.github.io/django-tinymce4-lite/usage.html#tinymce-widget-for-forms--
 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/20201014222827.GW12495%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5f8a2b78.1c69fb81.74a25.3aa4SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread David Nugent
This is expected with your code.  You've created an asymmetric relationship 
from bill to ted, but not the reverse. This would be appropriate in a "follow" 
relationship. For symmetric relationships you need to create records in both 
directions. There are a few ways to do this but a helper function on the Person 
model is the most direct approach, something along the lines:

def add_friendship(self, person, symmetric=True):
friendship = Friendship.objects.get_or_create(personA=self, 
personB=person)
if symmetric:
# avoid recursion
person.add_friendship(self, False)
return friendship


Regards, David

On 17 Oct 2020, at 05:38, gjgilles via Django users 
mailto:django-users@googlegroups.com>> wrote:

There are no responses to the same question on stackoverflow, so hopefully 
someone here can provide a 
solution.


I've read the 
docs.
 I've read this question 
too,
 but the following code is not working as the Django docs describe.

If bill and ted are friends, bill.friends.all() should include ted,  and 
ted.friends.all() should include bill. This is not what Django does. ted's 
query is empty, while bill's query includes ted.

# people.models
from django.db import models


class Person(models.Model):
name = models.CharField(max_length=255)
friends = models.ManyToManyField("self",
 through='Friendship',
 through_fields=('personA', 'personB'),
 symmetrical=True,
 )

def __str__(self):
return self.name


class Friendship(models.Model):
personA = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='personA')
personB = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='personB')
start = models.DateField(null=True, blank=True)
end = models.DateField(null=True, blank=True)

def __str__(self):
return ' and '.join([str(self.personA), str(self.personB)])




>>> import django
>>> django.__version__
'3.1.2'
>>> from people.models import Person, Friendship
>>> bill = Person(name='bill')
>>> bill.save()
>>> ted = Person(name='ted')
>>> ted.save()
>>> bill_and_ted = Friendship(personA=bill, personB=ted)
>>> bill_and_ted.save()
>>> bill.friends.all()
]>
>>> ted.friends.all()

>>> ted.refresh_from_db()
>>> ted.friends.all()

>>> ted = Person.objects.get(name='ted')
>>> ted.friends.all()



Can someone please show me how to make this behave as expected.


--
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/MJmh5Qw--3-2%40tutanota.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/1B85BA34-AB50-4FCF-8D6A-2C57CD15BD77%40uniquode.io.


How to make recursive ManyToMany relationships through an intermediate model symmetrical

2020-10-16 Thread gjgilles via Django users
There are no responses to the same question on stackoverflow, so hopefully 
someone here can provide a solution. 

 

I've read the docs. 

 I've read this question too, 

 but the following code is not working as the Django docs describe.

If bill and ted are friends, bill.friends.all() should include ted,  and 
ted.friends.all() should include bill. This is not what Django does. ted's 
query is empty, while bill's query includes ted.
# people.modelsfrom django.db import modelsclass Person(models.Model):name 
= models.CharField(max_length=255)friends = models.ManyToManyField("self",  
   through='Friendship',
 through_fields=('personA', 'personB'), 
symmetrical=True, )def 
__str__(self):return self.nameclass Friendship(models.Model):
personA = models.ForeignKey(Person, on_delete=models.CASCADE, 
related_name='personA')personB = models.ForeignKey(Person, 
on_delete=models.CASCADE, related_name='personB')start = 
models.DateField(null=True, blank=True)end = models.DateField(null=True, 
blank=True)def __str__(self):return ' and 
'.join([str(self.personA), str(self.personB)])



>>> import django
>>> django.__version__
'3.1.2'>>> from people.models import Person, Friendship>>> bill = 
Person(name='bill')>>> bill.save()>>> ted = Person(name='ted')>>> ted.save()>>> 
bill_and_ted = Friendship(personA=bill, personB=ted)>>> bill_and_ted.save()>>> 
bill.friends.all()] ted.friends.all()>>> ted.refresh_from_db()>>> ted.friends.all()>>> ted = 
Person.objects.get(name='ted')>>> ted.friends.all()
Can someone please show me how to make this behave as expected.

-- 
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/MJmh5Qw--3-2%40tutanota.com.


How to allow App1 users to use App2

2020-10-16 Thread r.raj...@gmail.com
Django Rest Framework:

Django RestApp1 and DB-1 - All the users exist in DB-1, django oauth2 token 
based authentication  (Bearer token) is used by the users.

Now i got a new app:

Django RestApp2 and DB-2 

Requirement:
I would  consider doing the new user creation and get token calls ..etc in 
App1

I want to allow the App1 users access token to authenticate with the App2. 
Sharing the same token for authentication

Please suggest your approach for this requirement

Regards,
Raja Ravi


-- 
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/35c28bdd-afd9-4e33-821c-1eaebd930796n%40googlegroups.com.


pages.models.vk_ls_product_search.DoesNotExist: vk_ls_product_search matching query does not exist.

2020-10-16 Thread Salima Begum
Hi all,

I have written test case for ProductDetails_ls for views

*views.py*
  ```
class onClickSearch():

def ProductDetails_ls(request, id):
# product_ls = vk_ls_product_search.objects.get(id=id)
product_ls = get_object_or_404(vk_ls_product_search, id=id)
email = request.session.get('email')
return render(request, "productdetails_ls.html", {
'product_ls': product_ls,'msg_count': msg_count_cl(email),
  'time':
settings.SESSION_IDLE_TIMEOUT,
  'name':
first_last_initial(email),
  'fullname':
fullname(email),
  })
```

*urls.py*

*```*
 path('ProductDetails_ls/', views.onClickSearch.ProductDetails_ls,
name='ProductDetails_ls'),
*```*
*test_views.py*

*```*

@pytest.mark.django_db
class TestViews:

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

response = onClickSearch.ProductDetails_ls(request, id=19)
print(response)
assert response.status_code == 200
*```*

*Here, I am getting this error please anyone can help me out to solve this
error,*

*```*
=
FAILURES
=
__
TestViews.test_product_detail_ls_authenticated
__

klass = , args = (), kwargs =
{'id': 19}, 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 = {'id': 19}, 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_ls_authenticated(self):
mixer.blend('pages.vk_ls_product_search')
path = reverse('ProductDetails_ls', kwargs={'id': 19})
request = RequestFactory().get(path)
request.user = mixer.blend(vk_customer)

>   response = onClickSearch.ProductDetails_ls(request, id=19)

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

klass = , args = 

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 

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)
 

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 

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 

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 

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

2020-10-16 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-16 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-16 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.