django-admin list in readonly

2018-04-27 Thread Hervé Edorh



In django admin, we have 3 rules that we can attribute to a table we can 
add, modify and delete. when you choose for an user the rule of modify, he 
can't add and delete, My problem is that a have list of object and i don't 
want that the user modify but can select it. how disable 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/695626ea-1f0a-4c4e-917c-4d1d4937096e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: The sending of an attachment in pdf format under django.

2018-04-27 Thread Jason
That suggests its an issue with your email reader.  What are you using, 
gmail or something else?

On Thursday, April 26, 2018 at 7:09:34 AM UTC-4, Bienvenue Emmanuel wrote:
>
> Hello ! I hope you are well...
> I am working on project of registration in a school where I must recover, 
> put the information entered by the user in a template and be able to 
> translate this template into pdf in the end send the generated PDF file as 
> an attachment of a mail that I send back to the user. Until then the other 
> processes work, but after sending the email when I consult my mailbox on my 
> phone I find the mail sent with the attachment on the other hand when I 
> consult my mailbox on my PC or even with a browser (even on) I can not find 
> the attachment. I have never encountered this kind of hard-to-understand 
> error. Help me please.
>
> def pdf_genarete(request):
>
> form = MyModelForm(request.POST or None)
>
> if form.is_valid():
>
> nom = form.cleaned_data.get("nom")
> email = form.cleaned_data.get("email")
> obj = MyModel.objects.create(nom=nom, email=email)
> print(obj.nom)
> print(obj.email)
>
> context = {"models_instance": obj}
>
> pdf = render_to_pdf("pdfapp/template_pdf.html", context)
> filename = "mypdf_{}.pdf".format(obj.order_id)
> obj.pdf.save(filename, BytesIO(pdf.content))
> # print(obj.pdf.name, obj.pdf.size)
>
> subject = "Thank you"
> from_email = settings.EMAIL_HOST_USER
> to_email = [obj.email]
> body = "Votre inscription"
>
> email_pdf = EmailMultiAlternatives(
>
> subject = subject,
> body =body,
> from_email = from_email,
> to=to_email, 
> )
>
> instance_attach = obj.pdf.read()
> # print(instance.pdf.name, instance.pdf.size)
> email_pdf.attach_alternative(instance_attach, "application/pdf")
> # import pdb;pdb.set_trace()
>
> email_pdf.send()
>
> return redirect(reverse("home"))
>
> return render(request, "pdfapp/formulaire.html", {"form": form})
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/19e984ac-02bf-482e-ae6c-a9ed2ef0d42b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Current user ip address on form.py

2018-04-27 Thread lakshitha kumara
Hello Guys

Is there way to get current user ip address on form.py 

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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Current user ip address on form.py

2018-04-27 Thread Andréas Kühne
Hi,

You can get the IP address from the request. See here:
https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django

Regards,

Andréas

2018-04-27 14:28 GMT+02:00 lakshitha kumara :

> Hello Guys
>
> Is there way to get current user ip address on form.py
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Current user ip address on form.py

2018-04-27 Thread lakshitha kumara
Hello Andréas

Thank for your reply. but unfortunately i need get user ip on form.py or 
custom py file in django. is there way to to that ? 
 
Some one post on this example can be work but its also doesn't work 

class RegistrationForm(UserCreationForm):

def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super(RegistrationForm, self).__init__(*args, **kwargs)

On Friday, April 27, 2018 at 6:06:36 PM UTC+5:30, Andréas Kühne wrote:
>
> Hi,
>
> You can get the IP address from the request. See here:
>
> https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django
>
> Regards,
>
> Andréas
>
> 2018-04-27 14:28 GMT+02:00 lakshitha kumara  >:
>
>> Hello Guys
>>
>> Is there way to get current user ip address on form.py 
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f82200e2-f329-450e-a8a0-1eaf2dc07bc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Current user ip address on form.py

2018-04-27 Thread James Farris
This should work

https://github.com/un33k/django-ipware/blob/master/README.md


On Fri, Apr 27, 2018 at 5:45 AM lakshitha kumara 
wrote:

> Hello Andréas
>
> Thank for your reply. but unfortunately i need get user ip on form.py or
> custom py file in django. is there way to to that ?
>
> Some one post on this example can be work but its also doesn't work
>
> class RegistrationForm(UserCreationForm):
>
> def __init__(self, *args, **kwargs):
> self.request = kwargs.pop('request')
> super(RegistrationForm, self).__init__(*args, **kwargs)
>
> On Friday, April 27, 2018 at 6:06:36 PM UTC+5:30, Andréas Kühne wrote:
>
>> Hi,
>>
>> You can get the IP address from the request. See here:
>>
>> https://stackoverflow.com/questions/4581789/how-do-i-get-user-ip-address-in-django
>>
>> Regards,
>>
>
>> Andréas
>>
>> 2018-04-27 14:28 GMT+02:00 lakshitha kumara :
>>
> Hello Guys
>>>
>>> Is there way to get current user ip address on form.py
>>>
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>
>>
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f82200e2-f329-450e-a8a0-1eaf2dc07bc2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django-admin list in readonly

2018-04-27 Thread James Farris
In Django admin I would create a group and give it permissions and add
users to that group.

On Fri, Apr 27, 2018 at 2:58 AM Hervé Edorh  wrote:

>
> In django admin, we have 3 rules that we can attribute to a table we can
> add, modify and delete. when you choose for an user the rule of modify, he
> can't add and delete, My problem is that a have list of object and i don't
> want that the user modify but can select it. how disable 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/695626ea-1f0a-4c4e-917c-4d1d4937096e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE-E-_2UeddP4UyPC8-uDds1DCTJVCzGugNMgsK9kNj%3DPSSzaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Current user ip address on form.py

2018-04-27 Thread Andréas Kühne
If you want the request in a form, you need to supply it.

You can use the code you posted - but then when you create the form - you
need to add the request.

Something like:

form = Form(request=request)

every time you init the form - then it will work for you.

Regards,

Andréas

2018-04-27 16:07 GMT+02:00 James Farris :

> This should work
>
> https://github.com/un33k/django-ipware/blob/master/README.md
>
>
> On Fri, Apr 27, 2018 at 5:45 AM lakshitha kumara 
> wrote:
>
>> Hello Andréas
>>
>> Thank for your reply. but unfortunately i need get user ip on form.py or
>> custom py file in django. is there way to to that ?
>>
>> Some one post on this example can be work but its also doesn't work
>>
>> class RegistrationForm(UserCreationForm):
>>
>> def __init__(self, *args, **kwargs):
>> self.request = kwargs.pop('request')
>> super(RegistrationForm, self).__init__(*args, **kwargs)
>>
>> On Friday, April 27, 2018 at 6:06:36 PM UTC+5:30, Andréas Kühne wrote:
>>
>>> Hi,
>>>
>>> You can get the IP address from the request. See here:
>>> https://stackoverflow.com/questions/4581789/how-do-i-
>>> get-user-ip-address-in-django
>>>
>>> Regards,
>>>
>>
>>> Andréas
>>>
>>> 2018-04-27 14:28 GMT+02:00 lakshitha kumara :
>>>
>> Hello Guys

 Is there way to get current user ip address on form.py

 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...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
>>>
>>>
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%
 40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/f82200e2-f329-450e-a8a0-1eaf2dc07bc2%
>> 40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAE-E-_2DwSfmnLNbDh2tge9gHxkUMHMyOWfM
> oj7Ep20k3LuX4w%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Django ODBC connect to DB2 IBM(AKA AS400) how to?

2018-04-27 Thread Jose Perez
Guys need an example how to use DJANGO with an ODBC that get connected to 
an IBM(AKA AS400).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e5c8f37d-4128-4b0f-a600-b0cf4ff75038%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-admin list in readonly

2018-04-27 Thread Hervé Edorh
Yes it is what i have done but i if i remove the modify rules in the admin, 
the simple user will not have the list appear in his session. i want him to 
just make the select without modify

Le vendredi 27 avril 2018 14:11:14 UTC, James Farris a écrit :
>
> In Django admin I would create a group and give it permissions and add 
> users to that group. 
>
> On Fri, Apr 27, 2018 at 2:58 AM Hervé Edorh  > wrote:
>
>>
>> In django admin, we have 3 rules that we can attribute to a table we can 
>> add, modify and delete. when you choose for an user the rule of modify, he 
>> can't add and delete, My problem is that a have list of object and i don't 
>> want that the user modify but can select it. how disable 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/695626ea-1f0a-4c4e-917c-4d1d4937096e%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/016f61d4-9688-4d5c-b946-aee2249e7eb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Jim Illback
To make this easier, here is just a simple the question.

Does Django give a method that can be overridden while processing a form which 
has access to the incoming URL parameters and precedes the display of the 
form’s fields, specifically being able to alter the fields’s query set before 
it is displayed?

Thanks for any help to answer this question.

Jim Illback

On Apr 25, 2018, at 10:41 AM, Jim Illback 
mailto:subaru...@hotmail.com>> wrote:

I wondered if anyone has had to alter the queryset behind a model form’s 
foreign key field which presents as a model choice field?
Briefly, I have a client attribute table with the foreign key to a chore/time 
table. For an add of the client attribute table, I want to limit entries to 
unassigned chore/time combinations only. This works perfectly during my 
CreateView. Here are some extracts to show specifics:
Models.py:
class ChoreTime(models.Model):
chore = models.ForeignKey(Chore, on_delete=models.CASCADE)
time = models.ForeignKey(TimePeriod, on_delete=models.CASCADE)
priority = models.BooleanField(default=False)
…
class Checkin(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
choretime = models.ForeignKey(ChoreTime, on_delete=models.CASCADE)
…
Forms.py:
class CheckinForm(forms.ModelForm):
assigned_qs = 
Checkin.objects.values(‘choretime').filter(choretime_id__isnull=False)
choretime = 
forms.ModelChoiceField(queryset=ChoreTime.objects.exclude(pk__in=assigned_qs))
…
However, I cannot get the any design to work on an UpdateView form. Using the 
same form as above, the current value does not even show up – it is blank – 
because, of course, that entry is already assigned so is excluded.
What I’d like is to have the above exclusions BUT be able to also add in the 
single entry assigned to the client being updated – so the entry will show that 
specific assignment (as well as limiting any possible change options to 
unassigned values - just like on the Create).
The problems with various approaches I’ve tried are:

1. Anything done before the form is fully assembled won’t have the existing 
form’s Checkin ID value (which is part of the URL, just BTW). This is needed to 
look up and add the existing entry. So, having a database view won’t work 
without being able to communicate the existing person’s assignment ID to the 
view. Similarly, using an override queryset on the form, like done above for 
the Create, needs that ID, too.

2. If I do the queries in the class's GET method routine as ORM objects, I 
must use UNION (a union of the exclusions as above plus the existing update 
client’s assignment). That union option keeps giving an error that one of the 
ORM querysets is not a queryset. However, they are both using 
“.objects.filter…”. It seems like complex queries don’t work with the 
union command. If I use raw SQL, the query works but the assignment to the 
choretime field’s queryset fails.
Does anyone have experience with this sort of behavior and be willing to give 
guidance?

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/F0B95720-C669-4CE5-912E-5167E3B89DFE%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C42DA3B1-C882-4889-995B-49580840F539%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Matthew Pava
In the form’s __init__ method, you’ll have to modify the queryset of the field.

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[‘choretime’].queryset |= 
ChoiceTime.objects.filter(pk=self.instance.pk)

I hope that helps!

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:16 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

To make this easier, here is just a simple the question.

Does Django give a method that can be overridden while processing a form which 
has access to the incoming URL parameters and precedes the display of the 
form’s fields, specifically being able to alter the fields’s query set before 
it is displayed?

Thanks for any help to answer this question.

Jim Illback


On Apr 25, 2018, at 10:41 AM, Jim Illback 
mailto:subaru...@hotmail.com>> wrote:

I wondered if anyone has had to alter the queryset behind a model form’s 
foreign key field which presents as a model choice field?
Briefly, I have a client attribute table with the foreign key to a chore/time 
table. For an add of the client attribute table, I want to limit entries to 
unassigned chore/time combinations only. This works perfectly during my 
CreateView. Here are some extracts to show specifics:
Models.py:
class ChoreTime(models.Model):
chore = models.ForeignKey(Chore, on_delete=models.CASCADE)
time = models.ForeignKey(TimePeriod, on_delete=models.CASCADE)
priority = models.BooleanField(default=False)
…
class Checkin(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
choretime = models.ForeignKey(ChoreTime, on_delete=models.CASCADE)
…
Forms.py:
class CheckinForm(forms.ModelForm):
assigned_qs = 
Checkin.objects.values(‘choretime').filter(choretime_id__isnull=False)
choretime = 
forms.ModelChoiceField(queryset=ChoreTime.objects.exclude(pk__in=assigned_qs))
…
However, I cannot get the any design to work on an UpdateView form. Using the 
same form as above, the current value does not even show up – it is blank – 
because, of course, that entry is already assigned so is excluded.
What I’d like is to have the above exclusions BUT be able to also add in the 
single entry assigned to the client being updated – so the entry will show that 
specific assignment (as well as limiting any possible change options to 
unassigned values - just like on the Create).
The problems with various approaches I’ve tried are:

1. Anything done before the form is fully assembled won’t have the existing 
form’s Checkin ID value (which is part of the URL, just BTW). This is needed to 
look up and add the existing entry. So, having a database view won’t work 
without being able to communicate the existing person’s assignment ID to the 
view. Similarly, using an override queryset on the form, like done above for 
the Create, needs that ID, too.

2. If I do the queries in the class's GET method routine as ORM objects, I 
must use UNION (a union of the exclusions as above plus the existing update 
client’s assignment). That union option keeps giving an error that one of the 
ORM querysets is not a queryset. However, they are both using 
“.objects.filter…”. It seems like complex queries don’t work with the 
union command. If I use raw SQL, the query works but the assignment to the 
choretime field’s queryset fails.
Does anyone have experience with this sort of behavior and be willing to give 
guidance?

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/F0B95720-C669-4CE5-912E-5167E3B89DFE%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/C42DA3B1-C882-4889-995B-49580840F539%40hotmail.com

django does not open html file properly

2018-04-27 Thread qop
Hi guys! 
I've created some graphics with gephi using the sigma exporter plugin which 
creates a project like this one 
, for use the 
interactive graphic it's just needed open the index.html Now i've created a 
little site with django and i'd like to show the interactive graphics that 
i've generated by gephi on my site: i've created a button in this way:

1.1 - OpenOrd 
- Centrality


in the network folder there are all the files generated from gephi, but i can't 
open properly the project by django, infact when i open the 
index.html appears only this . 
In the urlpatterns in urls.py i've added this:

path('gephi/1/1/network/index.html', views.graph)

in the view.py i've added this:

def graph(request): return render(request, 
'home/gephi/1/1/network/index.html', {})

 what am i doing wrong?
this is the tree 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b4715577-3a50-4ae5-a6bd-cfce43ade517%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Jim Illback
I also need to have the specific ID specified in the URL, so that is the other 
part needed. I’ve successfully done your suggestion for CreateView. Now, I just 
can’t seem to get UpdateView to work properly.

Thanks much!
Jim

On Apr 27, 2018, at 9:20 AM, Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:

In the form’s __init__ method, you’ll have to modify the queryset of the field.

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[‘choretime’].queryset |= 
ChoiceTime.objects.filter(pk=self.instance.pk)

I hope that helps!

From: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] On Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:16 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

To make this easier, here is just a simple the question.

Does Django give a method that can be overridden while processing a form which 
has access to the incoming URL parameters and precedes the display of the 
form’s fields, specifically being able to alter the fields’s query set before 
it is displayed?

Thanks for any help to answer this question.

Jim Illback


On Apr 25, 2018, at 10:41 AM, Jim Illback 
mailto:subaru...@hotmail.com>> wrote:

I wondered if anyone has had to alter the queryset behind a model form’s 
foreign key field which presents as a model choice field?
Briefly, I have a client attribute table with the foreign key to a chore/time 
table. For an add of the client attribute table, I want to limit entries to 
unassigned chore/time combinations only. This works perfectly during my 
CreateView. Here are some extracts to show specifics:
Models.py:
class ChoreTime(models.Model):
chore = models.ForeignKey(Chore, on_delete=models.CASCADE)
time = models.ForeignKey(TimePeriod, on_delete=models.CASCADE)
priority = models.BooleanField(default=False)
…
class Checkin(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
choretime = models.ForeignKey(ChoreTime, on_delete=models.CASCADE)
…
Forms.py:
class CheckinForm(forms.ModelForm):
assigned_qs = 
Checkin.objects.values(‘choretime').filter(choretime_id__isnull=False)
choretime = 
forms.ModelChoiceField(queryset=ChoreTime.objects.exclude(pk__in=assigned_qs))
…
However, I cannot get the any design to work on an UpdateView form. Using the 
same form as above, the current value does not even show up – it is blank – 
because, of course, that entry is already assigned so is excluded.
What I’d like is to have the above exclusions BUT be able to also add in the 
single entry assigned to the client being updated – so the entry will show that 
specific assignment (as well as limiting any possible change options to 
unassigned values - just like on the Create).
The problems with various approaches I’ve tried are:

1. Anything done before the form is fully assembled won’t have the existing 
form’s Checkin ID value (which is part of the URL, just BTW). This is needed to 
look up and add the existing entry. So, having a database view won’t work 
without being able to communicate the existing person’s assignment ID to the 
view. Similarly, using an override queryset on the form, like done above for 
the Create, needs that ID, too.

2. If I do the queries in the class's GET method routine as ORM objects, I 
must use UNION (a union of the exclusions as above plus the existing update 
client’s assignment). That union option keeps giving an error that one of the 
ORM querysets is not a queryset. However, they are both using 
“.objects.filter…”. It seems like complex queries don’t work with the 
union command. If I use raw SQL, the query works but the assignment to the 
choretime field’s queryset fails.

Does anyone have experience with this sort of behavior and be willing to give 
guidance?

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/F0B95720-C669-4CE5-912E-5167E3B89DFE%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users

RE: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Matthew Pava
That ID in the URL should be taken care of in the view, not the form.  You pass 
the object in as keyword instance to instantiate the form.  How are you 
defining your form in the view?

Typically, you would do something like this:

instance = CheckIn.objects.get(pk=self.kwargs.get(‘pk’))
form = CheckInForm(request.POST or None, instance=instance)

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:33 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

I also need to have the specific ID specified in the URL, so that is the other 
part needed. I’ve successfully done your suggestion for CreateView. Now, I just 
can’t seem to get UpdateView to work properly.

Thanks much!
Jim


On Apr 27, 2018, at 9:20 AM, Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:

In the form’s __init__ method, you’ll have to modify the queryset of the field.

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[‘choretime’].queryset |= 
ChoiceTime.objects.filter(pk=self.instance.pk)

I hope that helps!

From: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] On Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:16 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

To make this easier, here is just a simple the question.

Does Django give a method that can be overridden while processing a form which 
has access to the incoming URL parameters and precedes the display of the 
form’s fields, specifically being able to alter the fields’s query set before 
it is displayed?

Thanks for any help to answer this question.

Jim Illback



On Apr 25, 2018, at 10:41 AM, Jim Illback 
mailto:subaru...@hotmail.com>> wrote:

I wondered if anyone has had to alter the queryset behind a model form’s 
foreign key field which presents as a model choice field?
Briefly, I have a client attribute table with the foreign key to a chore/time 
table. For an add of the client attribute table, I want to limit entries to 
unassigned chore/time combinations only. This works perfectly during my 
CreateView. Here are some extracts to show specifics:
Models.py:
class ChoreTime(models.Model):
chore = models.ForeignKey(Chore, on_delete=models.CASCADE)
time = models.ForeignKey(TimePeriod, on_delete=models.CASCADE)
priority = models.BooleanField(default=False)
…
class Checkin(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
choretime = models.ForeignKey(ChoreTime, on_delete=models.CASCADE)
…
Forms.py:
class CheckinForm(forms.ModelForm):
assigned_qs = 
Checkin.objects.values(‘choretime').filter(choretime_id__isnull=False)
choretime = 
forms.ModelChoiceField(queryset=ChoreTime.objects.exclude(pk__in=assigned_qs))
…
However, I cannot get the any design to work on an UpdateView form. Using the 
same form as above, the current value does not even show up – it is blank – 
because, of course, that entry is already assigned so is excluded.
What I’d like is to have the above exclusions BUT be able to also add in the 
single entry assigned to the client being updated – so the entry will show that 
specific assignment (as well as limiting any possible change options to 
unassigned values - just like on the Create).
The problems with various approaches I’ve tried are:

1. Anything done before the form is fully assembled won’t have the existing 
form’s Checkin ID value (which is part of the URL, just BTW). This is needed to 
look up and add the existing entry. So, having a database view won’t work 
without being able to communicate the existing person’s assignment ID to the 
view. Similarly, using an override queryset on the form, like done above for 
the Create, needs that ID, too.

2. If I do the queries in the class's GET method routine as ORM objects, I 
must use UNION (a union of the exclusions as above plus the existing update 
client’s assignment). That union option keeps giving an error that one of the 
ORM querysets is not a queryset. However, they are both using 
“.objects.filter…”. It seems like complex queries don’t work with the 
union command. If I use raw SQL, the query works but the assignment to the 
choretime field’s queryset fails.
Does anyone have experience with this sort of behavior and be willing to give 
guidance?

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

Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Jim Illback
Absolutely agree. The “instance” (your note) is for Checkin and it includes a 
ForeignKey field to ChoreTime, which is a selection (choice field). But, I want 
that choice field to be limited for the forms to be only what has been not 
assigned yet. That way the user on the page will know that any shown pick is 
available. Otherwise, there are over 100 choices and no guidance as to what is 
truly available or already filled.

I have to alter the query set for that field. On a CreateView, I have it 
working perfectly (it’s shown below). However, on an UpdateView, the person’s 
choice is one of the “unavailable”. So, I’m trying to add just that one choice 
back into the query set before showing it on the form. Therefore, I need both 
the URL (to get the update’s choice) and the pre-form display method override 
(to exclude assigned entries) where I can override the field’s query set.

Thanks for the inputs, Matthew. I hope I’ve made it clearer. If you think 
there’s a better overall approach, I’m all ears!
Jim

On Apr 27, 2018, at 11:01 AM, Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:

That ID in the URL should be taken care of in the view, not the form.  You pass 
the object in as keyword instance to instantiate the form.  How are you 
defining your form in the view?

Typically, you would do something like this:

instance = CheckIn.objects.get(pk=self.kwargs.get(‘pk’))
form = CheckInForm(request.POST or None, instance=instance)

From: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] On Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:33 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

I also need to have the specific ID specified in the URL, so that is the other 
part needed. I’ve successfully done your suggestion for CreateView. Now, I just 
can’t seem to get UpdateView to work properly.

Thanks much!
Jim


On Apr 27, 2018, at 9:20 AM, Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:

In the form’s __init__ method, you’ll have to modify the queryset of the field.

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[‘choretime’].queryset |= 
ChoiceTime.objects.filter(pk=self.instance.pk)

I hope that helps!

From: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] On Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:16 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

To make this easier, here is just a simple the question.

Does Django give a method that can be overridden while processing a form which 
has access to the incoming URL parameters and precedes the display of the 
form’s fields, specifically being able to alter the fields’s query set before 
it is displayed?

Thanks for any help to answer this question.

Jim Illback



On Apr 25, 2018, at 10:41 AM, Jim Illback 
mailto:subaru...@hotmail.com>> wrote:

I wondered if anyone has had to alter the queryset behind a model form’s 
foreign key field which presents as a model choice field?
Briefly, I have a client attribute table with the foreign key to a chore/time 
table. For an add of the client attribute table, I want to limit entries to 
unassigned chore/time combinations only. This works perfectly during my 
CreateView. Here are some extracts to show specifics:
Models.py:
class ChoreTime(models.Model):
chore = models.ForeignKey(Chore, on_delete=models.CASCADE)
time = models.ForeignKey(TimePeriod, on_delete=models.CASCADE)
priority = models.BooleanField(default=False)
…
class Checkin(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
choretime = models.ForeignKey(ChoreTime, on_delete=models.CASCADE)
…
Forms.py:
class CheckinForm(forms.ModelForm):
assigned_qs = 
Checkin.objects.values(‘choretime').filter(choretime_id__isnull=False)
choretime = 
forms.ModelChoiceField(queryset=ChoreTime.objects.exclude(pk__in=assigned_qs))
…
However, I cannot get the any design to work on an UpdateView form. Using the 
same form as above, the current value does not even show up – it is blank – 
because, of course, that entry is already assigned so is excluded.
What I’d like is to have the above exclusions BUT be able to also add in the 
single entry assigned to the client being updated – so the entry will show that 
specific assignment (as well as limiting any possible change options to 
unassigned values - just like on the Create).
The problems with various approaches I’ve tried are:

1. Anything done before the form is fully assembled won’t have the existing 
form’s Checkin ID value (which is part of the URL, just BTW). This is needed to 
look up and add the existing entry. So, having a database view won’t work 
without being able to communicate the existing person’s assignment ID to the 
view. Similarly, using an override queryset on the form, like done 

RE: Dynamically altering a (ForeignKey) ModelChoiceField’s values

2018-04-27 Thread Matthew Pava
Well, Jim, my first message should have addressed your issue with the 
UpdateView.
Your URL keyword argument should be pk by default.  If it’s not, you have to 
set pk_url_kwarg in UpdateView.
Example:  /checkin/update/(?)

https://ccbv.co.uk/projects/Django/2.0/django.views.generic.edit/UpdateView/

class CheckinUpdate(UpdateView):
  model = Checkin
  form_class = CheckinForm


class CheckinForm(forms.ModelForm):
assigned_qs = 
Checkin.objects.values(‘choretime').filter(choretime_id__isnull=False)
choretime = 
forms.ModelChoiceField(queryset=ChoreTime.objects.exclude(pk__in=assigned_qs))

  def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# if an instance has been passed in, we need to include its value 
in the ChoreTime queryset
if hasattr(self, “instance”) and self.instance:
  self.fields[‘choretime’].queryset |= 
ChoreTime.objects.filter(pk=self.instance.choretime.pk)



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jim Illback
Sent: Friday, April 27, 2018 1:39 PM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

Absolutely agree. The “instance” (your note) is for Checkin and it includes a 
ForeignKey field to ChoreTime, which is a selection (choice field). But, I want 
that choice field to be limited for the forms to be only what has been not 
assigned yet. That way the user on the page will know that any shown pick is 
available. Otherwise, there are over 100 choices and no guidance as to what is 
truly available or already filled.

I have to alter the query set for that field. On a CreateView, I have it 
working perfectly (it’s shown below). However, on an UpdateView, the person’s 
choice is one of the “unavailable”. So, I’m trying to add just that one choice 
back into the query set before showing it on the form. Therefore, I need both 
the URL (to get the update’s choice) and the pre-form display method override 
(to exclude assigned entries) where I can override the field’s query set.

Thanks for the inputs, Matthew. I hope I’ve made it clearer. If you think 
there’s a better overall approach, I’m all ears!
Jim


On Apr 27, 2018, at 11:01 AM, Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:

That ID in the URL should be taken care of in the view, not the form.  You pass 
the object in as keyword instance to instantiate the form.  How are you 
defining your form in the view?

Typically, you would do something like this:

instance = CheckIn.objects.get(pk=self.kwargs.get(‘pk’))
form = CheckInForm(request.POST or None, instance=instance)

From: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] On Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:33 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

I also need to have the specific ID specified in the URL, so that is the other 
part needed. I’ve successfully done your suggestion for CreateView. Now, I just 
can’t seem to get UpdateView to work properly.

Thanks much!
Jim



On Apr 27, 2018, at 9:20 AM, Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:

In the form’s __init__ method, you’ll have to modify the queryset of the field.

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields[‘choretime’].queryset |= 
ChoiceTime.objects.filter(pk=self.instance.pk)

I hope that helps!

From: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] On Behalf Of Jim Illback
Sent: Friday, April 27, 2018 11:16 AM
To: Django users
Subject: Re: Dynamically altering a (ForeignKey) ModelChoiceField’s values

To make this easier, here is just a simple the question.

Does Django give a method that can be overridden while processing a form which 
has access to the incoming URL parameters and precedes the display of the 
form’s fields, specifically being able to alter the fields’s query set before 
it is displayed?

Thanks for any help to answer this question.

Jim Illback




On Apr 25, 2018, at 10:41 AM, Jim Illback 
mailto:subaru...@hotmail.com>> wrote:

I wondered if anyone has had to alter the queryset behind a model form’s 
foreign key field which presents as a model choice field?
Briefly, I have a client attribute table with the foreign key to a chore/time 
table. For an add of the client attribute table, I want to limit entries to 
unassigned chore/time combinations only. This works perfectly during my 
CreateView. Here are some extracts to show specifics:
Models.py:
class ChoreTime(models.Model):
chore = models.ForeignKey(Chore, on_delete=models.CASCADE)
time = models.ForeignKey(TimePeriod, on_delete=models.CASCADE)
priority = models.BooleanField(default=False)
…
class Checkin(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE)
choretime = models.Forei

is that really not possible with the Django ORM?

2018-04-27 Thread Andy
In my 10 years playing with Django i found a few bugs, but i never had to 
fall back to a raw SQL query. Fiddling with Django for almost a full day 
now im out of ideas except of asking for help here:

I have an organizer app with days containing shifts and people working 
those shifts (M2M). There also are supervisors for each day that are 
directly stored on the day (M2M). For the user stats i want to see who has 
how many shifts. For speed reasons i WANT to handle this with only one 
query. Here is the query i started with:

assigned_to = self.shifts.filter(day_id=OuterRef('id')).order_by()
days = Day.data.filter(date__range=(start, end)).distinct().annotate(
assigned_shifts=Count(
Subquery(assigned_to.values('id'))
)).annotate(
assigned_pl=Max(Case(
When(production_managers=self, then=1),
default=0, output_field=models.IntegerField(),
distinct=True
))).annotate(
assigned_tl=Max(Case(
When(day_managers=self, then=1),
default=0, output_field=models.IntegerField(), distinct=True
))).annotate(
assigned_al=Max(Case(
When(managers=self, then=1),
default=0, output_field=models.IntegerField(), distinct=True
))).annotate(
assigned_cash=Max(Case(
When(cash_managers=self, then=1),
default=0, output_field=models.IntegerField(), distinct=True
))).order_by()


This is giving me an SQL error "more than one row returned by a subquery 
used as an expression", without the subquery i was getting false values - 
probably because the grouping didnt work out as its supposed to. Turns out 
there is a warning in the docs and a very old ticket 
(https://code.djangoproject.com/ticket/10060) warning about this exact 
scenario, but somehow i dont get the subquery to work like it should.

The final and a lil simplified SQL looks like this:

days = Day.data.raw("""
SELECT distinct
  "events_day"."id","events_day"."date",
  (select count(*) 
   from events_shift 
   left outer join events_shift_employees 
   on events_shift_employees.shift_id = events_shift.id 
   where events_shift_employees.user_id = {user_id} and 
   events_shift.day_id = events_day.id and 
   events_shift.deleted is null) AS "assigned_shifts",
  Max(CASE WHEN"events_day_production_managers"."user_id"={user_id} THEN 1 
ELSE 0 END)AS"assigned_pl",
  Max(CASE WHEN"events_day_day_managers"."user_id"={user_id} THEN 1 ELSE 0 
END)AS"assigned_tl",
  Max(CASE WHEN"events_day_managers"."user_id"={user_id} THEN 1 ELSE 0 
END)AS"assigned_al",
  max(CASE WHEN"events_day_cash_managers"."user_id"={user_id} THEN 1 ELSE 0 
END)AS"assigned_cash"
FROM"events_day"
LEFT JOIN"events_shift"ON("events_day"."id"="events_shift"."day_id")
LEFT 
JOIN"events_shift_employees"ON("events_shift"."id"="events_shift_employees"."shift_id")
LEFT 
JOIN"events_day_production_managers"ON("events_day"."id"="events_day_production_managers"."day_id")
LEFT 
JOIN"events_day_day_managers"ON("events_day"."id"="events_day_day_managers"."day_id")
LEFT 
JOIN"events_day_managers"ON("events_day"."id"="events_day_managers"."day_id")
LEFT 
JOIN"events_day_cash_managers"ON("events_day"."id"="events_day_cash_managers"."day_id")
WHERE("events_day"."deleted"IS NULL AND"events_day"."date" BETWEEN 
'{start}' AND '{end}')
GROUP BY "events_day"."id"
ORDER BY"events_day"."date"DESC
""".format(**{
'user_id': self.id,
'start': start,
'end': end
}))



I could need a lil hand here in achiving the SELECT COUNT(*) in line 4 
rather then the Count(Subquery()) Django allows me to add to the query, but 
produces an SQL error.

Im Working on Python 3.6.5, Django 2.0.3 and Postgres 10

This problem is hardcore SQL ORM stuff so THX for anyone looking into 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/816185ac-58eb-4f71-986c-04ac34e22e02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django does not open html file properly

2018-04-27 Thread Andy
It looks as if you see all contents of you index.html while also missing 
all dependencies .. check the network tab of your browser to confirm this.
The report created by gephi is probably an html page that is soppused to be 
opened via the browser directly or served with a webserver. Just rendering 
the page through Django wont fix included styles sheets of needed 
javascript tags.

You should setup a docker nginx, mount your report into its html root 
folder and link there from your django app.
What you are trying to do sounds to complicated. Dont try to push the 
reports through Django. You might rather build a catalogue listing all the 
reports, but for actually showing them, use an nginx docker.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7b33a09a-5ca9-4082-8773-4eac89b1c5a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


It looks as if you see all contents of you index.html while also missing all dependencies .. check the network tab of your browser to confirm this. The report created by gephi is probably an html page

2018-04-27 Thread Agent Smith
It looks as if you see all contents of you index.html while also missing all 
dependencies .. check the network tab of your browser to confirm this.
The report created by gephi is probably an html page that is soppused to be 
opened via the browser directly or served with a webserver. Just rendering the 
page through Django wont fix included styles sheets of needed javascript tags.

You should setup a docker nginx, mount your report into its html root folder 
and link there from your django app.
What you are trying to do sounds to complicated. Dont try to push the reports 
through Django. You might rather build a catalogue listing all the reports, but 
for actually showing them, use an nginx doc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eafef1f5-f633-43a5-98da-5ec9c28eb18d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Architecting a Crypto Market Data Feed using Django Channels

2018-04-27 Thread Michael
Hi,

What is the best way to architect a Django Channels app that provides a 
very fast infinite stream of market data? This is what I have so far, but I 
think it's not the best solution.

This data is updated every millisecond so I would prefer to not persist it 
(unless there is a way of using redis pub/sub without actually saving the 
data, only for messaging)




class ChatConsumer(WebsocketConsumer):
def connect(self):
self.room_name = 'foo'
self.room_group_name = 'foo'
async_to_sync(self.channel_layer.group_add)(
self.room_group_name,
self.channel_name
)


self.accept()
while True:
  # Imagine this is another WS feed or Zero MQ Feed.
  feed = Feed()
  for event in feed:
  if event.name == "text":
  data = event.json
  self.send(str(data)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01bf458c-ff1a-4cf6-bd58-da9b2f43123c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Fullcalendar.

2018-04-27 Thread Andy
What kind of error are you getting?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f157cd20-7ddd-4692-aa66-9ca028fb143a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.