Projects

2020-05-12 Thread Nagaraju Singothu
Dear Users,

If you have any free source code live projects please send to
me.

On Tue 12 May, 2020, 7:36 PM Sharanagouda Biradar, 
wrote:

> Hello All,
>
> I have started learning Django last one week and able to fairly understand
> basic poll application in tutorial, Now I need any of your help in meeting
> my requirements:
>
> *Requirement below :*
>
> I have a basic (server1) Django development web server and another server
> (server2) which has a python script that will launch local application.
> Assume that the server1 has necessary authentication in place to run the
> script on server2. All I want to do is, click a button on the django
> website which would run the python script sitting on server2. Apart from
> above I need to get status of tests running as part of server2 application,
> along with csv files from Server2 back to server1 (web server).
>
> Can I achieve the above requirement using Django REST APIs? or Django
> Remote submission ? I am really clueless here, any pointers are highly
> appreciated.
>
> --
> 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/7c7b0ddc-9396-4b13-8c96-4933a13d8014%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMyGuAZZ8wX%3D_A%3DccWUdmNJcgVQ19sGBs4ZkYR%2BUO%3D31YwV5pw%40mail.gmail.com.


How to display multiple pie charts based on multiple lists?

2020-05-12 Thread ratnadeep ray
Hi all, 

I have a requirement where I need to display multiple pie charts based on 
multiple lists. 

Currently, I am able to display one pie chart involving 2 lists. Below is 
the views.py code for the same: 

# Create your views here.
from django.shortcuts import render

def pie_chart(request):
labels = ["A", "B", "C"]
data = ["10", "15", "2"]

   return render(request, 'pie_chart.html', {
'labels': labels,
'data': data,
})

Now what if we have another pair of lists as follows: 
labels1 = ["X", "Y", "Z"]
data1 = ["10", "15", "2"]

So can anyone say what changes should I made in the above code  to display 
2 pie charts displaying labels/data and labels1/data1 ? 

Thanks in advance. 

-- 
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/8308ffd5-68f5-47ff-883d-05b6a22795c8%40googlegroups.com.


How to over ride the get context data method in view

2020-05-12 Thread Ahmed Khairy


I am currently trying to create a like button for my posts in Django

I have reached to the part where I can add a like but I am facing 
difficulty writing the code related to the view which linking the 
PostListView if there is user who liked it or not. I am getting an error: 
page Error 404 although everything is correct


this the views: 


class PostListView(ListView):
model = Post
template_name = "score.html"
ordering = ['-date_posted']
context_object_name = 'posts'
queryset = Post.objects.filter(admin_approved=True)
paginate_by = 5

def get_context_data(self, **kwargs):
post = get_object_or_404(Post, id=self.request.POST.get('post_id'))
context = super(PostListView, self).get_context_data(**kwargs)
context['posts'][0].likes.filter(id=self.request.user.id).exists()
is_liked = False
if post.likes.filter(id=self.request.user.id).exists():
is_liked = True
context = {'post': post,
   'is_like': is_liked,
   }
return context



def like_post(request):
post = get_object_or_404(Post, id=request.POST.get('post_id'))
is_liked = False
if post.likes.filter(id=request.user.id).exists():
posts.likes.remove(request.user)
is_liked = False

else:
post.likes.add(request.user)
is_liked = True

return HttpResponseRedirect(post.get_absolute_url())


This is the model 


class Post(models.Model):
designer = models.ForeignKey(User, on_delete=models.CASCADE)
title = models.CharField(max_length=100)
date_posted = models.DateTimeField(default=timezone.now)
likes = models.ManyToManyField(User, blank=True, related_name='likes')

def __str__(self):
return self.title

Here is the

path('like/', like_post, name='like_post'),

here is the template: 

{% extends "base.html"%} {% block content %} {% for post in posts %}
{{post.title}}

  {% csrf_token %} {% if is_like %}
  
  Unlike
  {% else %}
  Like
  {% endif %}Likes 

{% endfor %} {% endblock content %} 


-- 
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/583492d8-5252-4f86-8e8f-7593b582d404%40googlegroups.com.


Adding a default Variation when creating a new Item

2020-05-12 Thread Ahmed Khairy
I have created this code for defining a default everytime I create a new 
product, 

It is working fine and whenever I create a new Item a new variable (size) 
is create 

I want to check whether this code is correct or not as I have had help from 
someone and I think we could have created an easier way for it 


class Item(models.Model):
title = models.CharField(max_length=100)
price = models.DecimalField(decimal_places=2, max_digits=100)
category = models.CharField(choices=CATEGORY_CHOICES, max_length=2)
label = models.CharField(choices=LABEL_CHOICES, max_length=1)
slug = models.SlugField(unique=True)
timestamp = models.DateTimeField(default=timezone.now)
active = models.BooleanField(default=True)

def __str__(self):
return self.title

class VariationManager(models.Manager):
def all(self):
return super(VariationManager, self).filter(active=True)

def sizes(self):
return self.all().filter(category='size')

def colors(self):
return self.all().filter(category='color')


VAR_CATEGORIES = (
('size', 'size',),
('color', 'color',),
('package', 'package'),
)


class Variation(models.Model):
item = models.ForeignKey(Item, on_delete=models.CASCADE)
category = models.CharField(
max_length=120, choices=VAR_CATEGORIES, default='size')
title = models.CharField(max_length=120)
objects = VariationManager()
updated = models.DateTimeField(auto_now_add=False, auto_now=True)
active = models.BooleanField(default=True)

def __str__(self):
return self.title

@receiver(post_save, sender=Item)
def add_default_Variant(sender, instance, **kwargs):
small_size = Variation.objects.create(
item=instance, category='size', title='Small')
medium_size = Variation.objects.create(
item=instance, category='size', title='Medium')
large_size = Variation.objects.create(
item=instance, category='size', title='Large')


@receiver(post_save, sender=Item)
def add_default_Variant(sender, instance, **kwargs):
variant, created = Variation.objects.get_or_create(
title="Small", item=instance)
variant, created = Variation.objects.get_or_create(
title="Medium", item=instance)
variant, created = Variation.objects.get_or_create(
title="Large", item=instance)
print(f"default variant created : {variant}")

-- 
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/dea775b8-f39d-4da8-a539-fc0c10af1bcd%40googlegroups.com.


How to Run script on remote server from Django Webserver - Help needed

2020-05-12 Thread Wilson Duarte
Hi,

I prefer developer this solution, using REST API, it is more elegante. 

-- 
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/1ed2041f-121a-438a-b53e-39b9e1b03267%40googlegroups.com.


CSS with Django forms

2020-05-12 Thread Anubhav Madhav
My problem is, that I've made a beautiful 'Sign Up' and 'Login' Page using 
HTML and CSS. Later on, in my project, I had to use 'forms' for 
registration and login.
Is there any way to display the forms with my HTML CSS files.
Please Help!!

-- 
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/d53c8101-9243-47b2-9ca5-a727888034ca%40googlegroups.com.


Re: Project available

2020-05-12 Thread Bighnesh Pradhan
  i am interested please send your flow chat in this mail.

On Tue, May 12, 2020 at 11:36 PM tejasri mamidi 
wrote:

> Iam interested to collaborate
>
> On Mon, May 11, 2020, 11:36 maninder singh Kumar <
> maninder.s.ku...@gmail.com> wrote:
>
>> Dear group members,
>>
>> I have a django project available the flowcharts of which will be up in 1
>> week.  Write or call if interested ?
>>
>> Willy
>> +91 9910669700
>> wi...@kawapeople.com
>>
>> Sent from my iPad
>>
>> --
>> 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/58FEE8F5-5336-43BA-B65D-ECDA1C8303EA%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/CAP6hVmDxgnF9STkJxaeMo%2BdDHAKPuJ78mj12jmSA4LXQ-8v80Q%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/CAGa5oYxn_CSyArx0_ONGP%2B4wZjcbGOyeMGXnidy2%3DR81D3et%3Dg%40mail.gmail.com.


Re: Project available

2020-05-12 Thread tejasri mamidi
Iam interested to collaborate

On Mon, May 11, 2020, 11:36 maninder singh Kumar 
wrote:

> Dear group members,
>
> I have a django project available the flowcharts of which will be up in 1
> week.  Write or call if interested ?
>
> Willy
> +91 9910669700
> wi...@kawapeople.com
>
> Sent from my iPad
>
> --
> 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/58FEE8F5-5336-43BA-B65D-ECDA1C8303EA%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/CAP6hVmDxgnF9STkJxaeMo%2BdDHAKPuJ78mj12jmSA4LXQ-8v80Q%40mail.gmail.com.


Re: Can I use a JS Framework to display small JS tasks in a Django project?

2020-05-12 Thread Bighnesh Pradhan
do you have any project idea?

On Tue, May 12, 2020 at 7:35 PM Alexander Rogowski 
wrote:

> I have an idea to simplify the online experiments from our university. But
> I'm not so familiar with the newest FE frameworks eg. react, angular, vue.
> Any answer on this post is appreciated :)
>
> The idea is, to put our experiments in two folders, "tasks" and
> "treatments". A task could be something trivial like put some sliders on
> the right position or write with a chatbot (this should be coded in js, I
> guess?) and in treatments could be something like collecting badges or the
> setting for the chatbot (e.g. human-like/machine-like).
>
> My question is: Can I use a JS Framework to load the content from the two
> directories and show them as options on a main page? After selecting the
> task and the treatments, it would generate a page with the selected items,
> e.g. the chatbot with the human-like setting.
>
> I Would like to do this with Django (because I already worked with it) so
> we can create unique links to send them to the probands. Is Django with a
> JS Framework the right decision? How would you approach the problem?
>
> --
> 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/847bbfca-6d8e-4ff0-969b-f6cb47aeed00%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGa5oYxZ2WpSOrH4B%2Bts7a2dq9E0JJgVWHOngSjXRKsae_nbEw%40mail.gmail.com.


Re: Project available

2020-05-12 Thread Gurjot Kawatra
Interested
Email : gurjot@gmail.com

On Mon, May 11, 2020, 11:36 AM maninder singh Kumar <
maninder.s.ku...@gmail.com> wrote:

> Dear group members,
>
> I have a django project available the flowcharts of which will be up in 1
> week.  Write or call if interested ?
>
> Willy
> +91 9910669700
> wi...@kawapeople.com
>
> Sent from my iPad
>
> --
> 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/58FEE8F5-5336-43BA-B65D-ECDA1C8303EA%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/CAGn0OvxOP%2Brz_pCsj5jg%3DPZAsg4%2B_nCCVnhLyGEh0bVXp%3DZyPQ%40mail.gmail.com.


Re: gdal installed still

2020-05-12 Thread Thomas Lockhart
It looks like you are running on Windows which I’m not familiar with. But most 
likely your gdal installation is in a different Python installation than your 
django installation.

- Tom

> On May 12, 2020, at 3:53 AM, mick  wrote:
> 
> django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library 
> (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is GDAL 
> installed? If it is, try setting GDAL_LIBRARY_PATH in your setting
> s.
> 
> 
> -- 
> 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/f5552467-2dfb-48d3-88f5-f66ab5abc258%40googlegroups.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98C19BF8-FD13-43F2-B9EF-4D8546F19E64%40gmail.com.


Re: Project available

2020-05-12 Thread maninder singh Kumar
Have decided against it.

regards
willy


On Tue, May 12, 2020 at 7:36 PM Bighnesh Pradhan <
bighnesh.pradhan...@gmail.com> wrote:

> I am interested ,
> i am from bangalore.
>
> On Mon, May 11, 2020 at 10:43 PM Nagaraju Singothu <
> nagarajusingoth...@gmail.com> wrote:
>
>> I'm interested sir
>>
>> On Mon 11 May, 2020, 11:36 AM maninder singh Kumar, <
>> maninder.s.ku...@gmail.com> wrote:
>>
>>> Dear group members,
>>>
>>> I have a django project available the flowcharts of which will be up in
>>> 1 week.  Write or call if interested ?
>>>
>>> Willy
>>> +91 9910669700
>>> wi...@kawapeople.com
>>>
>>> Sent from my iPad
>>>
>>> --
>>> 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/58FEE8F5-5336-43BA-B65D-ECDA1C8303EA%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/CAMyGuAaiJkUeDXhcyczQ2DjAyAByS%2BhCF2tt8bnv24dpz5ENvQ%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/CAGa5oYzJVzdBZYh9KUZzBU-XLny6ri1dGAGUrPn05k3zN4iMaA%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/CABOHK3S7sH0JTa2Qriq51H-9rUCQYt3Z52MNkQysdF1gfgDD%2Bw%40mail.gmail.com.


Re: Project available

2020-05-12 Thread ekong, emmanuel
I am not based in India I am a Nigerian seeking for project
opportunities

On Mon, 11 May 2020 at 2:43 PM, ekong, emmanuel 
wrote:

> I am interested too... I can receive a mail here  for acceptance
>
> On Mon, 11 May 2020 at 2:37 PM, sachin chaurasiya <
> sachinchaurasiyachote...@gmail.com> wrote:
>
>> I am interested 
>>
>> On Mon, May 11, 2020, 6:59 PM Akshat Zala  wrote:
>>
>>> I am interested. Do let me know what is to be done.
>>>
>>> Regards.
>>> Akshat
>>>
>>> On Monday, 11 May 2020 11:36:23 UTC+5:30, maninder singh Kumar wrote:

 Dear group members,

 I have a django project available the flowcharts of which will be up in
 1 week.  Write or call if interested ?

 Willy
 +91 9910669700
 wi...@kawapeople.com

 Sent from my iPad
>>>
>>> --
>>> 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/5c8a86af-12b6-458f-b496-dacada4782c6%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAD_X%3DJqdd_mfpDrgKYbpRrArfVj8F_d1HuaMgpDRkH4dpwnpHA%40mail.gmail.com
>> 
>> .
>>
>

-- 
**Disclaimer**
This e-mail is intended solely for the named recipient. The 
information contained in this message is strictly confidential. 


  * If 
you are not the named recipient, you are hereby notified that any use, 
dissemination or reproduction of this document and or its content is 
prohibited and may be deemed unlawful.
  * If you are not the named 
recipient of this e-mail, please notify the sender by a return e-mail and 
delete all copies of it from your computer and mail.Any views expressed in 
this e-mail are those of the individual sender, except where the sender 
specifically states them to be those of Landmark University 
, to whom no liability shall be attached whatsoever.


Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAP9wczaC88cOk67qi0cCVQH%3D%3DT5JYUehqc8U9ON%3DKE%2BHqFYGg%40mail.gmail.com.


Incorrect query generated from ~Q/exclude

2020-05-12 Thread kirk
Django 2.2.12
Python 3.7.5
Postgres 10.11

I am receiving what I perceive to be an incorrect SQL query from a Django 
queryset.  I am hoping I've just done something wrong.

Here's the setup:

from django.db.models import DecimalField, DO_NOTHING, F, ForeignKey, Model, 
Q, Sum, TextField


class TableA(Model):
name = TextField()

class Meta:
db_table = "tablea"


class TableB(Model):
tablea = ForeignKey(TableA, DO_NOTHING, null=True)
value = DecimalField(max_digits=5, decimal_places=2)

class Meta:
db_table = "tableb"

Here's some sample data:

insert into tablea (id, name)
select * from (values (1, 'NAME 1'), (2, 'NAME 2'), (3, 'NAME 3')) t;

insert into tableb (id, tablea_id, value)
select * from (values
(1, 1, 0), (2, 1, 5),
(3, null, 13),
(4, 2, 0), (5, 2, 0),
(6, 3, -1), (7, 3, 1)
) t;

The goal is to group names from tablea and sum values from tableb where 
value != 0.  If I were to write it purely in SQL I'd probably do something 
like this:

select   a.name, sum(b.value)
from tablea a inner join tableb b on b.tablea_id = a.id
whereb.value != 0
group by a.name;

The answer should be:

NAME 3 0
NAME 1 5

If I write the Django queryset as one of the following:

qs = (
TableA.objects.filter(~Q(tableb__value=0))
.annotate(the_name=F("name"), the_sum=Sum("tableb__value"))
.values("the_name", "the_sum")
)

qs = (
TableA.objects.exclude(tableb__value=0)
.annotate(the_name=F("name"), the_sum=Sum("tableb__value"))
.values("the_name", "the_sum")
)

I get SQL that I really didn't expect:

SELECT   "tablea"."name" AS "the_name",
 SUM("tableb"."value") AS "the_sum"
FROM "tablea"
 LEFT OUTER JOIN "tableb" ON ("tablea"."id" = "tableb"."tablea_id")
WHERENOT (
"tablea"."id" IN (
SELECT  U1."tablea_id"
FROM"tableb" U1
WHERE   (U1."value" = 0 AND U1."tablea_id" IS NOT NULL)
)
 )
GROUP BY "tablea"."id";

which returns the wrong answer:

NAME 3 0

If I rewrite the queryset as such, I get the correct answer:

qs = (
TableA.objects.filter(Q(tableb__value__gt=0) | Q(tableb__value__lt=0))
.annotate(the_name=F("name"), the_sum=Sum("tableb__value"))
.values("the_name", "the_sum")
)

This translates to:

SELECT   "tablea"."name" AS "the_name",
 SUM("tableb"."value") AS "the_sum"
FROM "tablea"
 INNER JOIN "tableb" ON ("tablea"."id" = "tableb"."tablea_id")
WHERE"tableb"."value" > 0 OR "tableb"."value" < 0
GROUP BY "tablea"."id";

Am I doing something wrong in my ~Q/exclude querysets?  Is this working as 
intended?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4cc2f0e6-00ff-47f8-88f0-03705305d23b%40googlegroups.com.


Re: Project available

2020-05-12 Thread Vishnu Khanna
I Am interested .plz let  me in

On Mon, 11 May 2020, 11:35 maninder singh Kumar, 
wrote:

> Dear group members,
>
> I have a django project available the flowcharts of which will be up in 1
> week.  Write or call if interested ?
>
> Willy
> +91 9910669700
> wi...@kawapeople.com
>
> Sent from my iPad
>
> --
> 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/58FEE8F5-5336-43BA-B65D-ECDA1C8303EA%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/CAGMz-RJOOcbpy5ag922Obd9q4h4McCCwqEcoV6f-k%2B7Aop5F0Q%40mail.gmail.com.


Re: How to handle non-uploaded dynamic images ?

2020-05-12 Thread Ryan Nowakowski
On Fri, May 08, 2020 at 06:47:22PM -0700, Dorian LE NET wrote:
> Let's say I have a django app where users can display images by choosing 
> among infinite parameters through a form. These images do not exist before 
> the user generate them as they are built accordingly to its selection of 
> parameters. Such images are dynamically and internally generated. Then they 
> are neither static nor uploaded by users.
> 
> 
> How should I store such images ? As *static* images, as *media* images or 
> as a customized category ?
> 
> 
> As images are internally generated and not uploaded by users, it does not 
> seem necessary to use the file storage systems and the /media/ location. 
> But it does not seem clever to use the /static/ directory either, as many 
> images will be added (and removed) - they are not static by definition.
> 
> 
> I would also like to use a model that contains these images and other 
> information about them. What model field class should I use to handle them 
> ? As the images are not uploaded by users models.ImageField does not seem 
> appropriate.

My rule of thumb is that if an image is referenced in the database then
it goes under "media".

-- 
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/20200512144027.GF29564%40fattuba.com.


Re: Can I use Django for client-server communication ?

2020-05-12 Thread Sharanagouda Biradar
*Let me re-phrase my question.*

I have a basic (server1) Django development web server and another server 
(ex:server2) - (actually multiple windows 10 machines not just 1 machine.) 
which has a python/batch script that launches a python application. Assume 
that the server1 has necessary authentication in place to run the script on 
server2. All I want to do is, click a button on the django website which 
would run the python script sitting on server2. Now can this be achieved 
using Django REST APIs? or how else can i achieve this? help is highly 
appreciated.

PS: reply from Mohammed Khalid seems its possible using Django REST 
Framework, just need one more confirmation as i have re-phrased my question.

On Friday, April 24, 2020 at 4:54:57 PM UTC+5:30, Derek wrote:
>
> Its unclear what you are trying to achieve; in a client-server 
> architecture, the clients will call the server, which in turn may start up 
> processes on their behalf and return responses to them.  The reverse is not 
> true. A server cannot install or startup up processes on independent client 
> machines.
>
> I assume what you meant was: a client will install your desktop GUI on 
> their machine, run it, and then want to return the results to a central 
> location (the server).  In this case, the GUI could (behind the scenes) 
> make a call to, say, the Django DRF (
> https://www.django-rest-framework.org/ ) to send those results.  You 
> could then have a front-end (also developed using Django) running on that 
> same server which could analyse and present those results e.g. aggregate 
> them for all your clients.  The DRF could of course also be called on by 
> the desktop to provide information (e.g. your special parameters or other 
> data that can be used by the GUI).
>
> On Wednesday, 22 April 2020 15:22:07 UTC+2, Sharanagouda Biradar wrote:
>>
>> HI,
>>
>> I have developed a python application(GUI using Tkinter)  which triggers 
>> python test scripts automatically and gives the result But now I want to 
>> launch this GUI App on multiple  machines using a single machine(something 
>> like server-client model), also I want to set required config parameters in 
>> client machine using server itself. Can I achieve all this using Django? I 
>> am very much new to Django and need to know if I can achieve this using 
>> Django. if not kindly let me know what tool I can use to achieve this?
>>
>

-- 
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/37ae2f39-82a8-40ab-a8b7-4c61249f3bfe%40googlegroups.com.


Re: Django Lessons

2020-05-12 Thread Bighnesh Pradhan
Thank you for your email .


On Tue, May 12, 2020 at 12:10 PM Eugen Ciur  wrote:

> You are welcome!
> I am really glad that you found content useful :)
>
> On Tuesday, May 12, 2020 at 1:26:56 AM UTC+2, bnrc wrote:
>>
>> Hey Eugen,
>>
>> your lessons about nginx/gunicorn configuration were exactly what i was
>> looking for the past 5 days.
>>
>> Thanks a lot :)
>>
>> Am Freitag, 8. Mai 2020 08:10:43 UTC+2 schrieb Eugen Ciur:
>>>
>>> Hi,
>>>
>>> on https://django-lessons.com I release weekly screencasts about Django
>>> Web Framework. Lessons are usually very short, around 10 minutes.
>>> Each of them focuses on a single practical topic so that you can
>>> immediately apply learned skills in your projects.
>>> 50% of all content always will be free.
>>>
>>> I would love your feedback!
>>>
>>> Regards,
>>> Eugen / Django Lessons
>>>
>>> --
> 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/e30b5475-935d-42a0-89b6-a8fa524f226a%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGa5oYxB9p89A9KynuNk0BVqHyVvuss7ooKnATMGm2_X_L3VDA%40mail.gmail.com.


Can I use a JS Framework to display small JS tasks in a Django project?

2020-05-12 Thread Alexander Rogowski


I have an idea to simplify the online experiments from our university. But 
I'm not so familiar with the newest FE frameworks eg. react, angular, vue. 
Any answer on this post is appreciated :)

The idea is, to put our experiments in two folders, "tasks" and 
"treatments". A task could be something trivial like put some sliders on 
the right position or write with a chatbot (this should be coded in js, I 
guess?) and in treatments could be something like collecting badges or the 
setting for the chatbot (e.g. human-like/machine-like).

My question is: Can I use a JS Framework to load the content from the two 
directories and show them as options on a main page? After selecting the 
task and the treatments, it would generate a page with the selected items, 
e.g. the chatbot with the human-like setting.

I Would like to do this with Django (because I already worked with it) so 
we can create unique links to send them to the probands. Is Django with a 
JS Framework the right decision? How would you approach the problem?

-- 
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/847bbfca-6d8e-4ff0-969b-f6cb47aeed00%40googlegroups.com.


hi eveyone

2020-05-12 Thread Ravindra Patil
hi eveyone

-- 
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/4c97da5b-f60f-4f9a-973d-3953c7b9cc1f%40googlegroups.com.


How to Run script on remote server from Django Webserver - Help needed

2020-05-12 Thread Sharanagouda Biradar
Hello All,

I have started learning Django last one week and able to fairly understand 
basic poll application in tutorial, Now I need any of your help in meeting 
my requirements:

*Requirement below :*

I have a basic (server1) Django development web server and another server 
(server2) which has a python script that will launch local application. 
Assume that the server1 has necessary authentication in place to run the 
script on server2. All I want to do is, click a button on the django 
website which would run the python script sitting on server2. Apart from 
above I need to get status of tests running as part of server2 application, 
along with csv files from Server2 back to server1 (web server).

Can I achieve the above requirement using Django REST APIs? or Django 
Remote submission ? I am really clueless here, any pointers are highly 
appreciated.

-- 
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/7c7b0ddc-9396-4b13-8c96-4933a13d8014%40googlegroups.com.


Re: Project available

2020-05-12 Thread Bighnesh Pradhan
I am interested ,
i am from bangalore.

On Mon, May 11, 2020 at 10:43 PM Nagaraju Singothu <
nagarajusingoth...@gmail.com> wrote:

> I'm interested sir
>
> On Mon 11 May, 2020, 11:36 AM maninder singh Kumar, <
> maninder.s.ku...@gmail.com> wrote:
>
>> Dear group members,
>>
>> I have a django project available the flowcharts of which will be up in 1
>> week.  Write or call if interested ?
>>
>> Willy
>> +91 9910669700
>> wi...@kawapeople.com
>>
>> Sent from my iPad
>>
>> --
>> 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/58FEE8F5-5336-43BA-B65D-ECDA1C8303EA%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/CAMyGuAaiJkUeDXhcyczQ2DjAyAByS%2BhCF2tt8bnv24dpz5ENvQ%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/CAGa5oYzJVzdBZYh9KUZzBU-XLny6ri1dGAGUrPn05k3zN4iMaA%40mail.gmail.com.


Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread hajar Benjat
I think I am already doing this!

Can you check my mail_item class please

On Tue, May 12, 2020, 11:17 AM Motaz Hejaze  wrote:

> Access the country model through the foreign key in maiĺ_item , so you can
> get the country name and store it in mail_item_count
>
> On Tue, 12 May 2020, 12:37 pm hajar,  wrote:
>
>> can you explain to me more please
>>
>> Le mardi 12 mai 2020 10:01:24 UTC+1, Motaz Hejaze a écrit :
>>>
>>> In signal access the model of country through the foreignkey
>>> Pays.origin.country_name
>>>
>>> On Tue, 12 May 2020, 10:21 am Uri Kogan,  wrote:
>>>
 I would suggest changing your *mail_item_count* model like this:

 class mail_item_count(models.Model):
 country = models.ForeignKey(Pays, on_delete=models.CASCADE)
 count = models.IntegerField(default=1)



 On Tuesday, May 12, 2020 at 10:53:57 AM UTC+3, hajar wrote:
>
> aht do you advice me to do ?
>
> Le mardi 12 mai 2020 08:32:04 UTC+1, Uri Kogan a écrit :
>>
>> From the error message it can be seen that mail_item_count has
>> "country" item which is "CharField".
>> But... the signal receiver sets this to instance of  "Pays" object
>> which assumes it is "ForeignKey".
>>
>> On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:
>>>
>>>
>>> class mail_item(models.Model):
>>>#mail_item_fid =
>>> models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
>>>Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
>>> CASCADE,related_name="mail_item_event_cd")
>>>office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE,
>>> related_name='office_Ev')
>>>Date_Evt = models.DateTimeField()
>>>Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
>>> related_name='paysOrigine')
>>>Pays_destination = models.ForeignKey(Pays,on_delete=models.
>>> CASCADE,related_name='paysDestination')
>>>Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE
>>> ,related_name='expedi')
>>>Destinateur_id = models.ForeignKey(Client,on_delete=models.
>>> CASCADE,related_name='destin')
>>>
>>>
>>>
>>> Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :

 hello django users ,

 I am trying to update a class using signals , you will understand
 once you see the code below

 class mail_item_count(models.Model):
country = models.CharField(max_length=100)
count = models.IntegerField(default=1)


 def __str__(self):
return '{}, {}'.format(self.country,self.count)

 def sum(self):
a = sum(instance.count for instance in self.objects.all())

return a


 @receiver(post_save, sender=mail_item)
 def update_count(sender, instance, created, **kwargs):
count_object,_ = 
 mail_item_count.objects.get_or_create(country=instance.Pays_origine)

 count_object.count = count_object.count + 1
count_object.save()

 but I am getting this error :

 *" Tried to update field dashboard.mail_item_count.country with a
 model instance, . Use a value compatible with CharField. 
 "*

 can you help me out solving it

>>> --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/01889167-1fdb-43f4-b1ed-24021eb00989%40googlegroups.com
 
 .

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/29dd9a0d-e7d9-4843-af78-da94ea0b65c3%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHV4E-c5QG-CdDLrDNC4XnBJbeVNYM7T5bFePAZL733m2Jw2Qg%40mail.gmail.com
> 

Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread Motaz Hejaze
Access the country model through the foreign key in maiĺ_item , so you can
get the country name and store it in mail_item_count

On Tue, 12 May 2020, 12:37 pm hajar,  wrote:

> can you explain to me more please
>
> Le mardi 12 mai 2020 10:01:24 UTC+1, Motaz Hejaze a écrit :
>>
>> In signal access the model of country through the foreignkey
>> Pays.origin.country_name
>>
>> On Tue, 12 May 2020, 10:21 am Uri Kogan,  wrote:
>>
>>> I would suggest changing your *mail_item_count* model like this:
>>>
>>> class mail_item_count(models.Model):
>>> country = models.ForeignKey(Pays, on_delete=models.CASCADE)
>>> count = models.IntegerField(default=1)
>>>
>>>
>>>
>>> On Tuesday, May 12, 2020 at 10:53:57 AM UTC+3, hajar wrote:

 aht do you advice me to do ?

 Le mardi 12 mai 2020 08:32:04 UTC+1, Uri Kogan a écrit :
>
> From the error message it can be seen that mail_item_count has
> "country" item which is "CharField".
> But... the signal receiver sets this to instance of  "Pays" object
> which assumes it is "ForeignKey".
>
> On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:
>>
>>
>> class mail_item(models.Model):
>>#mail_item_fid =
>> models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
>>Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
>> CASCADE,related_name="mail_item_event_cd")
>>office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE,
>> related_name='office_Ev')
>>Date_Evt = models.DateTimeField()
>>Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
>> related_name='paysOrigine')
>>Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE
>> ,related_name='paysDestination')
>>Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
>> related_name='expedi')
>>Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE
>> ,related_name='destin')
>>
>>
>>
>> Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :
>>>
>>> hello django users ,
>>>
>>> I am trying to update a class using signals , you will understand
>>> once you see the code below
>>>
>>> class mail_item_count(models.Model):
>>>country = models.CharField(max_length=100)
>>>count = models.IntegerField(default=1)
>>>
>>>
>>> def __str__(self):
>>>return '{}, {}'.format(self.country,self.count)
>>>
>>> def sum(self):
>>>a = sum(instance.count for instance in self.objects.all())
>>>
>>>return a
>>>
>>>
>>> @receiver(post_save, sender=mail_item)
>>> def update_count(sender, instance, created, **kwargs):
>>>count_object,_ = 
>>> mail_item_count.objects.get_or_create(country=instance.Pays_origine)
>>>
>>> count_object.count = count_object.count + 1
>>>count_object.save()
>>>
>>> but I am getting this error :
>>>
>>> *" Tried to update field dashboard.mail_item_count.country with a
>>> model instance, . Use a value compatible with CharField. 
>>> "*
>>>
>>> can you help me out solving it
>>>
>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/01889167-1fdb-43f4-b1ed-24021eb00989%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/29dd9a0d-e7d9-4843-af78-da94ea0b65c3%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-c5QG-CdDLrDNC4XnBJbeVNYM7T5bFePAZL733m2Jw2Qg%40mail.gmail.com.


gdal installed still

2020-05-12 Thread mick
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL 
library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is 
GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your setting
s.

-- 
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/f5552467-2dfb-48d3-88f5-f66ab5abc258%40googlegroups.com.


Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread hajar
can you explain to me more please 

Le mardi 12 mai 2020 10:01:24 UTC+1, Motaz Hejaze a écrit :
>
> In signal access the model of country through the foreignkey 
> Pays.origin.country_name
>
> On Tue, 12 May 2020, 10:21 am Uri Kogan, > 
> wrote:
>
>> I would suggest changing your *mail_item_count* model like this:
>>
>> class mail_item_count(models.Model):
>> country = models.ForeignKey(Pays, on_delete=models.CASCADE)
>> count = models.IntegerField(default=1)
>>
>>
>>
>> On Tuesday, May 12, 2020 at 10:53:57 AM UTC+3, hajar wrote:
>>>
>>> aht do you advice me to do ?
>>>
>>> Le mardi 12 mai 2020 08:32:04 UTC+1, Uri Kogan a écrit :

 From the error message it can be seen that mail_item_count has 
 "country" item which is "CharField".
 But... the signal receiver sets this to instance of  "Pays" object 
 which assumes it is "ForeignKey".

 On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:
>
>
> class mail_item(models.Model):
>#mail_item_fid = 
> models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
>Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
> CASCADE,related_name="mail_item_event_cd")
>office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE, 
> related_name='office_Ev')
>Date_Evt = models.DateTimeField()
>Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
> related_name='paysOrigine')
>Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE,
> related_name='paysDestination')
>Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
> related_name='expedi')
>Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
> related_name='destin')
>
>
>
> Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :
>>
>> hello django users , 
>>
>> I am trying to update a class using signals , you will understand 
>> once you see the code below 
>>
>> class mail_item_count(models.Model):
>>country = models.CharField(max_length=100)
>>count = models.IntegerField(default=1)
>>
>>
>> def __str__(self):
>>return '{}, {}'.format(self.country,self.count)
>>
>> def sum(self):
>>a = sum(instance.count for instance in self.objects.all())
>>return a 
>>
>>
>> @receiver(post_save, sender=mail_item)
>> def update_count(sender, instance, created, **kwargs):
>>count_object,_ = 
>> mail_item_count.objects.get_or_create(country=instance.Pays_origine) 
>>
>> count_object.count = count_object.count + 1
>>count_object.save()
>>
>> but I am getting this error : 
>>
>> *" Tried to update field dashboard.mail_item_count.country with a 
>> model instance, . Use a value compatible with CharField. "*
>>
>> can you help me out solving it 
>>
> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/01889167-1fdb-43f4-b1ed-24021eb00989%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/29dd9a0d-e7d9-4843-af78-da94ea0b65c3%40googlegroups.com.


Re: Error in Installation process

2020-05-12 Thread Ravi Prakash
Hi

Thanks for this information.

On Tue, May 12, 2020 at 3:58 PM Kasper Laudrup 
wrote:

> Hi Ravi,
>
> On 12/05/2020 12.23, Ravi Prakash wrote:
> > Hi
> >
> > When I m installing the pip and Django in Pycharm terminal that there is
> > showing error.
> >
> > Here I attached the error screenshot Please go through the screenshot
> > for a brief understanding.
> >
> > Guide me, please!
>
> "The read operation timed out" means that your connection to wherever
> you're downloading the packages from was too slow and the connection was
> closed.
>
> Not too much to do about that other than trying again or download it
> from somewhere where you have a faster connection.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/74c5a619-cdd2-2e93-ccef-5b69fe054c5f%40stacktrace.dk
> .
>


-- 
Many Thanks,

*Ravi Prakash Tamrakar*
Developer

-- 




VirtualTech Outsourcing Services Pvt Ltd 

59/B, Plot No. 4, 5 and 6, 
Nehru Nagar (West)

Bhilai, Chhattisgarh - 490 020, India


www.virtualclone.in 


-- 
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/CAJoW92Uy1y%3DYXcA_MOBZL-keduxxe5nfm1%2BtZOgsM8pEDoLwYg%40mail.gmail.com.


Re: Error in Installation process

2020-05-12 Thread Kasper Laudrup

Hi Ravi,

On 12/05/2020 12.23, Ravi Prakash wrote:

Hi

When I m installing the pip and Django in Pycharm terminal that there is 
showing error.


Here I attached the error screenshot Please go through the screenshot 
for a brief understanding.


Guide me, please!


"The read operation timed out" means that your connection to wherever 
you're downloading the packages from was too slow and the connection was 
closed.


Not too much to do about that other than trying again or download it 
from somewhere where you have a faster connection.


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/74c5a619-cdd2-2e93-ccef-5b69fe054c5f%40stacktrace.dk.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
Continuing my investigation I got the a following which does not work but 
should:
from django.contrib.auth.models import User
from django.test import TransactionTestCase
from django.db import transaction

class FooTest(TransactionTestCase):
def test_bar(self):
with transaction.atomic():
with transaction.atomic():
u = User.objects.create_user(username="abc", 
password="pass")
print("created user: {}".format(u.username))

The crash of "SAVEPOINT does not exist" occurs when exiting inner `
*transaction.atomic*' block.


On Tuesday, May 12, 2020 at 10:35:31 AM UTC+3, Uri Kogan wrote:
>
> The documentation states that "you cannot test that a block of code is 
> executing within a transaction" while I am looking to "test a block of code 
> that has a transaction".
> In any case, the issue here is that "transaction.atomic" does not work 
> when nested while it should clearly work.
>
> On Tuesday, May 12, 2020 at 10:26:39 AM UTC+3, Aldian Fazrihady wrote:
>>
>> Probably you need to use TransactionTestCase, which is the parent of 
>> TestCase instead: 
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
>> That page also mentions a specific problem when using transaction on 
>> TestCase:
>> ```
>> A consequence of this, however, is that some database behaviors cannot be 
>> tested within a Django TestCase class. For instance, you cannot test 
>> that a block of code is executing within a transaction, as is required when 
>> using select_for_update() 
>> .
>>  
>> In those cases, you should use TransactionTestCase.
>> 111
>>
>> On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:
>>
>>> That not that simple in my case because. I'll show what I mean:
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>> from rolepermissions.roles import assign_role
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> u = User.objects.create_user(username="abc", password="pass")
>>> assign_role(u, "role_admin")
>>> retrieve_and_analyze_view_using_u_credentials()
>>>
>>> I am testing that my permission routines work by creating a user, 
>>> assigning permissions to the user, retrieving the view and analyzing it. 
>>> That "assign_role" call of django-role-permissions uses 
>>> "transaction.atomic". Which, of course, I would not want to change, as this 
>>> is an external library.
>>>
>>> So I can't really remove usages of "transaction.atomic"
>>>
>>>
>>>
>>> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:

 When testing django apps, my unit test usually accesses the django app 
 via django test client: 
 https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
 .
 Django test client simulates http access, so my Django tests always run 
 my Django code starting from Django views. 
 Even though there must be many django app code that has 
 `transaction.atomic` inside it, I never need to add `transaction.atomic` 
 in 
 my unit test code.
 If I need to simulate initial state by having some data inserted to 
 database, I did that either using factoryboy or django ORM framework, but 
 I 
 see no point to add `transaction.atomic` to that data initialization code.

 On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:

> While this can be done in my code, there are libraries that the 
> project use that have "transaction.atomic" in them. For example, pretty 
> popular django-role-permissions.
> From what I see in the documentation, there should be no problem to 
> use transactions within transactions in TestCase.
>
> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>
>> I don't think the subclass of TestCase need to use 
>> transaction.atomic. Why can't you just remove the transaction.atomic? 
>>
>> Regards, 
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  
>> menulis:
>>
>>> Hello,
>>>
>>> I am using TestCase and trying to create an object during test.
>>> There is a log activated on MySQL server, so I see all the queries 
>>> being executed there.
>>>
>>> This "transaction.atomic" sets a SAVEPOINT in the database thinking 
>>> that the transaction is already started. The problem is that there is 
>>> no 
>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>>> the 
>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>
>>> The following states that TestCase "tests within two nested atomic() 
>>> blocks", so it should execute "TRANSACTION START"
>>>
>>> 

Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread Motaz Hejaze
In signal access the model of country through the foreignkey
Pays.origin.country_name

On Tue, 12 May 2020, 10:21 am Uri Kogan,  wrote:

> I would suggest changing your *mail_item_count* model like this:
>
> class mail_item_count(models.Model):
> country = models.ForeignKey(Pays, on_delete=models.CASCADE)
> count = models.IntegerField(default=1)
>
>
>
> On Tuesday, May 12, 2020 at 10:53:57 AM UTC+3, hajar wrote:
>>
>> aht do you advice me to do ?
>>
>> Le mardi 12 mai 2020 08:32:04 UTC+1, Uri Kogan a écrit :
>>>
>>> From the error message it can be seen that mail_item_count has "country"
>>> item which is "CharField".
>>> But... the signal receiver sets this to instance of  "Pays" object which
>>> assumes it is "ForeignKey".
>>>
>>> On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:


 class mail_item(models.Model):
#mail_item_fid =
 models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
 CASCADE,related_name="mail_item_event_cd")
office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE,
 related_name='office_Ev')
Date_Evt = models.DateTimeField()
Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
 related_name='paysOrigine')
Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE,
 related_name='paysDestination')
Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
 related_name='expedi')
Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
 related_name='destin')



 Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :
>
> hello django users ,
>
> I am trying to update a class using signals , you will understand once
> you see the code below
>
> class mail_item_count(models.Model):
>country = models.CharField(max_length=100)
>count = models.IntegerField(default=1)
>
>
> def __str__(self):
>return '{}, {}'.format(self.country,self.count)
>
> def sum(self):
>a = sum(instance.count for instance in self.objects.all())
>return a
>
>
> @receiver(post_save, sender=mail_item)
> def update_count(sender, instance, created, **kwargs):
>count_object,_ = 
> mail_item_count.objects.get_or_create(country=instance.Pays_origine)
>
> count_object.count = count_object.count + 1
>count_object.save()
>
> but I am getting this error :
>
> *" Tried to update field dashboard.mail_item_count.country with a
> model instance, . Use a value compatible with CharField. "*
>
> can you help me out solving it
>
 --
> 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/01889167-1fdb-43f4-b1ed-24021eb00989%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-dP-tKhpdhqAsAmjYJMHFGnKUq42LGzMsJbQ6JaE9kvZA%40mail.gmail.com.


Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread Uri Kogan
I would suggest changing your *mail_item_count* model like this:

class mail_item_count(models.Model):
country = models.ForeignKey(Pays, on_delete=models.CASCADE)
count = models.IntegerField(default=1)



On Tuesday, May 12, 2020 at 10:53:57 AM UTC+3, hajar wrote:
>
> aht do you advice me to do ?
>
> Le mardi 12 mai 2020 08:32:04 UTC+1, Uri Kogan a écrit :
>>
>> From the error message it can be seen that mail_item_count has "country" 
>> item which is "CharField".
>> But... the signal receiver sets this to instance of  "Pays" object which 
>> assumes it is "ForeignKey".
>>
>> On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:
>>>
>>>
>>> class mail_item(models.Model):
>>>#mail_item_fid = 
>>> models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
>>>Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
>>> CASCADE,related_name="mail_item_event_cd")
>>>office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE, 
>>> related_name='office_Ev')
>>>Date_Evt = models.DateTimeField()
>>>Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
>>> related_name='paysOrigine')
>>>Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE,
>>> related_name='paysDestination')
>>>Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
>>> related_name='expedi')
>>>Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
>>> related_name='destin')
>>>
>>>
>>>
>>> Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :

 hello django users , 

 I am trying to update a class using signals , you will understand once 
 you see the code below 

 class mail_item_count(models.Model):
country = models.CharField(max_length=100)
count = models.IntegerField(default=1)


 def __str__(self):
return '{}, {}'.format(self.country,self.count)

 def sum(self):
a = sum(instance.count for instance in self.objects.all())
return a 


 @receiver(post_save, sender=mail_item)
 def update_count(sender, instance, created, **kwargs):
count_object,_ = 
 mail_item_count.objects.get_or_create(country=instance.Pays_origine) 

 count_object.count = count_object.count + 1
count_object.save()

 but I am getting this error : 

 *" Tried to update field dashboard.mail_item_count.country with a model 
 instance, . Use a value compatible with CharField. "*

 can you help me out solving it 

>>>

-- 
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/01889167-1fdb-43f4-b1ed-24021eb00989%40googlegroups.com.


Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread hajar
aht do you advice me to do ?

Le mardi 12 mai 2020 08:32:04 UTC+1, Uri Kogan a écrit :
>
> From the error message it can be seen that mail_item_count has "country" 
> item which is "CharField".
> But... the signal receiver sets this to instance of  "Pays" object which 
> assumes it is "ForeignKey".
>
> On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:
>>
>>
>> class mail_item(models.Model):
>>#mail_item_fid = 
>> models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
>>Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
>> CASCADE,related_name="mail_item_event_cd")
>>office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE, 
>> related_name='office_Ev')
>>Date_Evt = models.DateTimeField()
>>Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
>> related_name='paysOrigine')
>>Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE,
>> related_name='paysDestination')
>>Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
>> related_name='expedi')
>>Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
>> related_name='destin')
>>
>>
>>
>> Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :
>>>
>>> hello django users , 
>>>
>>> I am trying to update a class using signals , you will understand once 
>>> you see the code below 
>>>
>>> class mail_item_count(models.Model):
>>>country = models.CharField(max_length=100)
>>>count = models.IntegerField(default=1)
>>>
>>>
>>> def __str__(self):
>>>return '{}, {}'.format(self.country,self.count)
>>>
>>> def sum(self):
>>>a = sum(instance.count for instance in self.objects.all())
>>>return a 
>>>
>>>
>>> @receiver(post_save, sender=mail_item)
>>> def update_count(sender, instance, created, **kwargs):
>>>count_object,_ = 
>>> mail_item_count.objects.get_or_create(country=instance.Pays_origine) 
>>>
>>> count_object.count = count_object.count + 1
>>>count_object.save()
>>>
>>> but I am getting this error : 
>>>
>>> *" Tried to update field dashboard.mail_item_count.country with a model 
>>> instance, . Use a value compatible with CharField. "*
>>>
>>> can you help me out solving it 
>>>
>>

-- 
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/302eac12-0870-45c6-94a5-febc2c0b4112%40googlegroups.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
The documentation states that "you cannot test that a block of code is 
executing within a transaction" while I am looking to "test a block of code 
that has a transaction".
In any case, the issue here is that "transaction.atomic" does not work when 
nested while it should clearly work.

On Tuesday, May 12, 2020 at 10:26:39 AM UTC+3, Aldian Fazrihady wrote:
>
> Probably you need to use TransactionTestCase, which is the parent of 
> TestCase instead: 
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
> That page also mentions a specific problem when using transaction on 
> TestCase:
> ```
> A consequence of this, however, is that some database behaviors cannot be 
> tested within a Django TestCase class. For instance, you cannot test that 
> a block of code is executing within a transaction, as is required when 
> using select_for_update() 
> .
>  
> In those cases, you should use TransactionTestCase.
> 111
>
> On Tue, May 12, 2020 at 1:59 PM Uri Kogan > 
> wrote:
>
>> That not that simple in my case because. I'll show what I mean:
>>
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>> from rolepermissions.roles import assign_role
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> u = User.objects.create_user(username="abc", password="pass")
>> assign_role(u, "role_admin")
>> retrieve_and_analyze_view_using_u_credentials()
>>
>> I am testing that my permission routines work by creating a user, 
>> assigning permissions to the user, retrieving the view and analyzing it. 
>> That "assign_role" call of django-role-permissions uses 
>> "transaction.atomic". Which, of course, I would not want to change, as this 
>> is an external library.
>>
>> So I can't really remove usages of "transaction.atomic"
>>
>>
>>
>> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>>>
>>> When testing django apps, my unit test usually accesses the django app 
>>> via django test client: 
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>>> .
>>> Django test client simulates http access, so my Django tests always run 
>>> my Django code starting from Django views. 
>>> Even though there must be many django app code that has 
>>> `transaction.atomic` inside it, I never need to add `transaction.atomic` in 
>>> my unit test code.
>>> If I need to simulate initial state by having some data inserted to 
>>> database, I did that either using factoryboy or django ORM framework, but I 
>>> see no point to add `transaction.atomic` to that data initialization code.
>>>
>>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>>
 While this can be done in my code, there are libraries that the project 
 use that have "transaction.atomic" in them. For example, pretty popular 
 django-role-permissions.
 From what I see in the documentation, there should be no problem to use 
 transactions within transactions in TestCase.

 On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>
> I don't think the subclass of TestCase need to use transaction.atomic. 
> Why can't you just remove the transaction.atomic? 
>
> Regards, 
>
> Aldian Fazrihady
> http://aldianfazrihady.com
>
> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  
> menulis:
>
>> Hello,
>>
>> I am using TestCase and trying to create an object during test.
>> There is a log activated on MySQL server, so I see all the queries 
>> being executed there.
>>
>> This "transaction.atomic" sets a SAVEPOINT in the database thinking 
>> that the transaction is already started. The problem is that there is no 
>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
>> the 
>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>
>> The following states that TestCase "tests within two nested atomic() 
>> blocks", so it should execute "TRANSACTION START"
>>
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>
>> 
>> from django.contrib.auth.models import User
>> from django.test import TestCase
>>
>>
>> class FooTest(TestCase):
>> def test_bar(self):
>> with transaction.atomic():
>> user = User.objects.create_user(username="abc", 
>> password="pass")
>>
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com

Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread Uri Kogan
>From the error message it can be seen that mail_item_count has "country" 
item which is "CharField".
But... the signal receiver sets this to instance of  "Pays" object which 
assumes it is "ForeignKey".

On Tuesday, May 12, 2020 at 9:41:16 AM UTC+3, hajar wrote:
>
>
> class mail_item(models.Model):
>#mail_item_fid = 
> models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
>Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.
> CASCADE,related_name="mail_item_event_cd")
>office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE, 
> related_name='office_Ev')
>Date_Evt = models.DateTimeField()
>Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
> related_name='paysOrigine')
>Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE,
> related_name='paysDestination')
>Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
> related_name='expedi')
>Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
> related_name='destin')
>
>
>
> Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :
>>
>> hello django users , 
>>
>> I am trying to update a class using signals , you will understand once 
>> you see the code below 
>>
>> class mail_item_count(models.Model):
>>country = models.CharField(max_length=100)
>>count = models.IntegerField(default=1)
>>
>>
>> def __str__(self):
>>return '{}, {}'.format(self.country,self.count)
>>
>> def sum(self):
>>a = sum(instance.count for instance in self.objects.all())
>>return a 
>>
>>
>> @receiver(post_save, sender=mail_item)
>> def update_count(sender, instance, created, **kwargs):
>>count_object,_ = 
>> mail_item_count.objects.get_or_create(country=instance.Pays_origine) 
>>
>> count_object.count = count_object.count + 1
>>count_object.save()
>>
>> but I am getting this error : 
>>
>> *" Tried to update field dashboard.mail_item_count.country with a model 
>> instance, . Use a value compatible with CharField. "*
>>
>> can you help me out solving it 
>>
>

-- 
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/72e39da1-0ccc-4e36-a03c-d024022c20e6%40googlegroups.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
Probably you need to use TransactionTestCase, which is the parent of
TestCase instead:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#transactiontestcase
That page also mentions a specific problem when using transaction on
TestCase:
```
A consequence of this, however, is that some database behaviors cannot be
tested within a Django TestCase class. For instance, you cannot test that a
block of code is executing within a transaction, as is required when using
select_for_update()
.
In those cases, you should use TransactionTestCase.
111

On Tue, May 12, 2020 at 1:59 PM Uri Kogan  wrote:

> That not that simple in my case because. I'll show what I mean:
>
> from django.contrib.auth.models import User
> from django.test import TestCase
> from rolepermissions.roles import assign_role
>
> class FooTest(TestCase):
> def test_bar(self):
> u = User.objects.create_user(username="abc", password="pass")
> assign_role(u, "role_admin")
> retrieve_and_analyze_view_using_u_credentials()
>
> I am testing that my permission routines work by creating a user,
> assigning permissions to the user, retrieving the view and analyzing it.
> That "assign_role" call of django-role-permissions uses
> "transaction.atomic". Which, of course, I would not want to change, as this
> is an external library.
>
> So I can't really remove usages of "transaction.atomic"
>
>
>
> On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>>
>> When testing django apps, my unit test usually accesses the django app
>> via django test client:
>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
>> .
>> Django test client simulates http access, so my Django tests always run
>> my Django code starting from Django views.
>> Even though there must be many django app code that has
>> `transaction.atomic` inside it, I never need to add `transaction.atomic` in
>> my unit test code.
>> If I need to simulate initial state by having some data inserted to
>> database, I did that either using factoryboy or django ORM framework, but I
>> see no point to add `transaction.atomic` to that data initialization code.
>>
>> On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:
>>
>>> While this can be done in my code, there are libraries that the project
>>> use that have "transaction.atomic" in them. For example, pretty popular
>>> django-role-permissions.
>>> From what I see in the documentation, there should be no problem to use
>>> transactions within transactions in TestCase.
>>>
>>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:

 I don't think the subclass of TestCase need to use transaction.atomic.
 Why can't you just remove the transaction.atomic?

 Regards,

 Aldian Fazrihady
 http://aldianfazrihady.com

 Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan 
 menulis:

> Hello,
>
> I am using TestCase and trying to create an object during test.
> There is a log activated on MySQL server, so I see all the queries
> being executed there.
>
> This "transaction.atomic" sets a SAVEPOINT in the database thinking
> that the transaction is already started. The problem is that there is no
> "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
> the
> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>
> The following states that TestCase "tests within two nested atomic()
> blocks", so it should execute "TRANSACTION START"
>
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>
>
> from django.contrib.auth.models import User
> from django.test import TestCase
>
>
> class FooTest(TestCase):
> def test_bar(self):
> with transaction.atomic():
> user = User.objects.create_user(username="abc",
> password="pass")
>
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com

Watch "django gives an error in virtualenv | Create Virtual Environment" on YouTube

2020-05-12 Thread Anonymous Patel
https://youtu.be/HensdOAgszo

If you are facing error while creating virtual environment.
Follow up with a link and get going

Raj Patel

-- 
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/CAF_9CiuYf%3DTX4Nspz9%2BkKPJMWSpSBMAdeMUoDpG%2BkKHbeQhm0A%40mail.gmail.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Uri Kogan
That not that simple in my case because. I'll show what I mean:

from django.contrib.auth.models import User
from django.test import TestCase
from rolepermissions.roles import assign_role

class FooTest(TestCase):
def test_bar(self):
u = User.objects.create_user(username="abc", password="pass")
assign_role(u, "role_admin")
retrieve_and_analyze_view_using_u_credentials()

I am testing that my permission routines work by creating a user, assigning 
permissions to the user, retrieving the view and analyzing it. That "
assign_role" call of django-role-permissions uses "transaction.atomic". 
Which, of course, I would not want to change, as this is an external 
library.

So I can't really remove usages of "transaction.atomic"



On Tuesday, May 12, 2020 at 9:48:21 AM UTC+3, Aldian Fazrihady wrote:
>
> When testing django apps, my unit test usually accesses the django app via 
> django test client: 
> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client
> .
> Django test client simulates http access, so my Django tests always run my 
> Django code starting from Django views. 
> Even though there must be many django app code that has 
> `transaction.atomic` inside it, I never need to add `transaction.atomic` in 
> my unit test code.
> If I need to simulate initial state by having some data inserted to 
> database, I did that either using factoryboy or django ORM framework, but I 
> see no point to add `transaction.atomic` to that data initialization code.
>
> On Tue, May 12, 2020 at 12:39 PM Uri Kogan > 
> wrote:
>
>> While this can be done in my code, there are libraries that the project 
>> use that have "transaction.atomic" in them. For example, pretty popular 
>> django-role-permissions.
>> From what I see in the documentation, there should be no problem to use 
>> transactions within transactions in TestCase.
>>
>> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>>
>>> I don't think the subclass of TestCase need to use transaction.atomic. 
>>> Why can't you just remove the transaction.atomic? 
>>>
>>> Regards, 
>>>
>>> Aldian Fazrihady
>>> http://aldianfazrihady.com
>>>
>>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan  
>>> menulis:
>>>
 Hello,

 I am using TestCase and trying to create an object during test.
 There is a log activated on MySQL server, so I see all the queries 
 being executed there.

 This "transaction.atomic" sets a SAVEPOINT in the database thinking 
 that the transaction is already started. The problem is that there is no 
 "TRANSACTION START". So, when exiting "with transaction.atomic()" block 
 the 
 whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"

 The following states that TestCase "tests within two nested atomic() 
 blocks", so it should execute "TRANSACTION START"

 https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase

 
 from django.contrib.auth.models import User
 from django.test import TestCase


 class FooTest(TestCase):
 def test_bar(self):
 with transaction.atomic():
 user = User.objects.create_user(username="abc", 
 password="pass")


 -- 
 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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.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/91984522-1535-4f37-8fb8-ae76c7095298%40googlegroups.com.


Re: TestCase failing when using transaction.atomic() inside test

2020-05-12 Thread Aldian Fazrihady
When testing django apps, my unit test usually accesses the django app via
django test client:
https://docs.djangoproject.com/en/3.0/topics/testing/tools/#the-test-client.
Django test client simulates http access, so my Django tests always run my
Django code starting from Django views.
Even though there must be many django app code that has
`transaction.atomic` inside it, I never need to add `transaction.atomic` in
my unit test code.
If I need to simulate initial state by having some data inserted to
database, I did that either using factoryboy or django ORM framework, but I
see no point to add `transaction.atomic` to that data initialization code.

On Tue, May 12, 2020 at 12:39 PM Uri Kogan  wrote:

> While this can be done in my code, there are libraries that the project
> use that have "transaction.atomic" in them. For example, pretty popular
> django-role-permissions.
> From what I see in the documentation, there should be no problem to use
> transactions within transactions in TestCase.
>
> On Tuesday, May 12, 2020 at 12:34:50 AM UTC+3, Aldian Fazrihady wrote:
>>
>> I don't think the subclass of TestCase need to use transaction.atomic.
>> Why can't you just remove the transaction.atomic?
>>
>> Regards,
>>
>> Aldian Fazrihady
>> http://aldianfazrihady.com
>>
>> Pada tanggal Sel, 12 Mei 2020 04.02, Uri Kogan 
>> menulis:
>>
>>> Hello,
>>>
>>> I am using TestCase and trying to create an object during test.
>>> There is a log activated on MySQL server, so I see all the queries being
>>> executed there.
>>>
>>> This "transaction.atomic" sets a SAVEPOINT in the database thinking that
>>> the transaction is already started. The problem is that there is no
>>> "TRANSACTION START". So, when exiting "with transaction.atomic()" block the
>>> whole thing crashes with "SAVEPOINT xxx DOES NOT EXIST"
>>>
>>> The following states that TestCase "tests within two nested atomic()
>>> blocks", so it should execute "TRANSACTION START"
>>>
>>> https://docs.djangoproject.com/en/3.0/topics/testing/tools/#django.test.TestCase
>>>
>>>
>>> from django.contrib.auth.models import User
>>> from django.test import TestCase
>>>
>>>
>>> class FooTest(TestCase):
>>> def test_bar(self):
>>> with transaction.atomic():
>>> user = User.objects.create_user(username="abc",
>>> password="pass")
>>>
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/ecff11bd-9d35-4130-9d3a-0d48f70af73f%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3741328a-941b-4864-a20d-5e2d9c4937d5%40googlegroups.com
> 
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAYO3N3E7Jrds9sqmnfKOUFHwtdf%3DXMra2WZ3WCiDiJfEw%40mail.gmail.com.


Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread hajar

class mail_item(models.Model):
   #mail_item_fid = 
models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE)
   Event_cd = models.OneToOneField(Mail_item_Event,on_delete=models.CASCADE,
related_name="mail_item_event_cd")
   office_Evt_cd = models.ForeignKey(Office,on_delete=models.CASCADE, 
related_name='office_Ev')
   Date_Evt = models.DateTimeField()
   Pays_origine = models.ForeignKey(Pays, on_delete=models.CASCADE ,
related_name='paysOrigine')
   Pays_destination = models.ForeignKey(Pays,on_delete=models.CASCADE,
related_name='paysDestination')
   Expediteur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
related_name='expedi')
   Destinateur_id = models.ForeignKey(Client,on_delete=models.CASCADE,
related_name='destin')



Le mardi 12 mai 2020 06:43:43 UTC+1, hajar a écrit :
>
> hello django users , 
>
> I am trying to update a class using signals , you will understand once you 
> see the code below 
>
> class mail_item_count(models.Model):
>country = models.CharField(max_length=100)
>count = models.IntegerField(default=1)
>
>
> def __str__(self):
>return '{}, {}'.format(self.country,self.count)
>
> def sum(self):
>a = sum(instance.count for instance in self.objects.all())
>return a 
>
>
> @receiver(post_save, sender=mail_item)
> def update_count(sender, instance, created, **kwargs):
>count_object,_ = 
> mail_item_count.objects.get_or_create(country=instance.Pays_origine) 
>
> count_object.count = count_object.count + 1
>count_object.save()
>
> but I am getting this error : 
>
> *" Tried to update field dashboard.mail_item_count.country with a model 
> instance, . Use a value compatible with CharField. "*
>
> can you help me out solving it 
>

-- 
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/c12b8c96-2630-477a-bb7d-7e2742f48117%40googlegroups.com.


Re: Django Lessons

2020-05-12 Thread Eugen Ciur
You are welcome!
I am really glad that you found content useful :)

On Tuesday, May 12, 2020 at 1:26:56 AM UTC+2, bnrc wrote:
>
> Hey Eugen,
>
> your lessons about nginx/gunicorn configuration were exactly what i was 
> looking for the past 5 days. 
>
> Thanks a lot :)
>
> Am Freitag, 8. Mai 2020 08:10:43 UTC+2 schrieb Eugen Ciur:
>>
>> Hi, 
>>
>> on https://django-lessons.com I release weekly screencasts about Django 
>> Web Framework. Lessons are usually very short, around 10 minutes.
>> Each of them focuses on a single practical topic so that you can 
>> immediately apply learned skills in your projects.
>> 50% of all content always will be free.
>>
>> I would love your feedback!
>>
>> Regards,
>> Eugen / Django Lessons
>>
>>

-- 
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/e30b5475-935d-42a0-89b6-a8fa524f226a%40googlegroups.com.


Re: Tried to update field X with a model instance, < X >. Use a value compatible with CharField.

2020-05-12 Thread Uri Kogan
I think, for that you'll have to show your "mail_item" model too.

On Tuesday, May 12, 2020 at 8:43:43 AM UTC+3, hajar wrote:
>
> hello django users , 
>
> I am trying to update a class using signals , you will understand once you 
> see the code below 
>
> class mail_item_count(models.Model):
>country = models.CharField(max_length=100)
>count = models.IntegerField(default=1)
>
>
> def __str__(self):
>return '{}, {}'.format(self.country,self.count)
>
> def sum(self):
>a = sum(instance.count for instance in self.objects.all())
>return a 
>
>
> @receiver(post_save, sender=mail_item)
> def update_count(sender, instance, created, **kwargs):
>count_object,_ = 
> mail_item_count.objects.get_or_create(country=instance.Pays_origine) 
>
> count_object.count = count_object.count + 1
>count_object.save()
>
> but I am getting this error : 
>
> *" Tried to update field dashboard.mail_item_count.country with a model 
> instance, . Use a value compatible with CharField. "*
>
> can you help me out solving it 
>

-- 
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/aea6aa0a-26bd-495f-bad0-ae4781a9c02f%40googlegroups.com.