Re: object_list in html

2018-02-26 Thread Alan
That worked! Many thanks!

On 23 February 2018 at 17:38, Dylan Reinhold  wrote:

> I would add an is_running flag into the context_data
>
> def get_context_data(self, **kwargs):
> data = super().get_context_data(**kwargs)
> data['is_running'] = Submission.objects.filter(juser=self.request.user
> jstatus='Running').exists()
> return data
>
>   Then in your template {% if is_running %}x{% endif %}
>
> Dylan
>
> On Fri, Feb 23, 2018 at 8:00 AM, Alan  wrote:
>
>> Hi Constantine,
>>
>> from my views.py:
>>
>> class status(ListView):
>>
>> model = Submission
>>
>> template_name = 'status.html'
>>
>>
>> def get_queryset(self):
>>
>> return Submission.objects.filter(juse
>> r=self.request.user).exclude(jstatus='Deleted')
>>
>> If I could create a parameter say runFlag (True of False) where it would
>> be true for:
>>
>> select * from submit_submission where jstatus = 'Running' and juser =
>> 'jonhdoe';
>>
>> Would django equivalente be:
>> Submission.objects.filter(juser=self.request.user, jstatus=‘Running)
>>
>> If so, then how to tweak this class so I could have 'runFlag' in the
>> template html?
>>
>> Sorry for those questions, I used to use Django 10 years ago and had
>> solutions for that, now I am trying to learn Django 2.0.
>>
>> Alan
>>
>>
>> On 23 February 2018 at 03:18, Costja Covtushenko 
>> wrote:
>>
>>> Hi Alan,
>>>
>>> How did you receive that `object_list`?
>>> You should filter it based on you user and ‘Running’ inside the view.
>>> And then just check if it has count > 0.
>>>
>>> I hope that does have sense to you.
>>>
>>> Regards,
>>> Constantine C.
>>>
>>> On Feb 22, 2018, at 7:34 PM, Alan  wrote:
>>>
>>> Hi there,
>>>
>>> I am using Django 2 with Python 3.5
>>>
>>> I have this query, simple, in mysql:
>>>
>>> select * from submit_submission where jstatus = 'Running' and juser =
>>> 'jonhdoe';
>>>
>>> Basically, I have a table that tracks the jobs I am running.
>>>
>>> In my html, I'd like to replace this part (in red):
>>>
>>> {% if *object_list.last.jstatus* == 'Running' %}
>>>  Page automatically
>>> refreshed every 5 seconds | {% now "jS M y H:i" %}
>>> {% else %}No running jobs.
>>> {% endif %}
>>>
>>> ​with something equivalent to my query above where I need to know if
>>> there's at least one job running for a given user.
>>>
>>> I've been looking at https://docs.djangoproject.com
>>> /en/2.0/ref/models/querysets ​but I couldn't work out a solution.
>>>
>>> ​Many thanks in advance,
>>>
>>> Alan​
>>>
>>> --
>>> I'll cycle across Britain in 2018 for a charity, would you consider
>>> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
>>> Many thanks!
>>> --
>>> Alan Wilter SOUSA da SILVA, DSc
>>> Senior Bioinformatician, UniProt
>>> European Bioinformatics Institute (EMBL-EBI)
>>> European Molecular Biology Laboratory
>>> Wellcome Trust Genome Campus
>>> Hinxton
>>> Cambridge CB10 1SD
>>> United Kingdom
>>> Tel: +44 (0)1223 494588 <01223%20494588>
>>>
>>> --
>>> 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/ms
>>> gid/django-users/CAEznbznNwJW4omM%3DMncj8aoBcg3AW8r-yFTMMkb5
>>> ZBiB%3Dsv96Q%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/ms
>>> gid/django-users/7E9B0630-E1A7-4759-B082-998273D6B330%40gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> I'll cycle across Britain in 2018 for a charity, would you consider
>> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
>> Many thanks!
>> --
>> Alan Wilter SOUSA da SILVA, DSc
>> Senior Bioinformatician, UniProt
>> European Bioinformatics Institute (EMBL-EBI)
>> European Molecular Biology Laboratory
>> Wellcome Trust Genome Campus
>> Hinxton
>> Cambridge CB10 1SD
>> United Kingdom
>> Tel: +44 (0)1223 494588 <+44%201223%20494588>
>>
>>

Re: object_list in html

2018-02-23 Thread Dylan Reinhold
I would add an is_running flag into the context_data

def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data['is_running'] = Submission.objects.filter(juser=self.request.user
jstatus='Running').exists()
return data

  Then in your template {% if is_running %}x{% endif %}

Dylan

On Fri, Feb 23, 2018 at 8:00 AM, Alan  wrote:

> Hi Constantine,
>
> from my views.py:
>
> class status(ListView):
>
> model = Submission
>
> template_name = 'status.html'
>
>
> def get_queryset(self):
>
> return Submission.objects.filter(juser=self.request.user).exclude(
> jstatus='Deleted')
>
> If I could create a parameter say runFlag (True of False) where it would
> be true for:
>
> select * from submit_submission where jstatus = 'Running' and juser =
> 'jonhdoe';
>
> Would django equivalente be:
> Submission.objects.filter(juser=self.request.user, jstatus=‘Running)
>
> If so, then how to tweak this class so I could have 'runFlag' in the
> template html?
>
> Sorry for those questions, I used to use Django 10 years ago and had
> solutions for that, now I am trying to learn Django 2.0.
>
> Alan
>
>
> On 23 February 2018 at 03:18, Costja Covtushenko 
> wrote:
>
>> Hi Alan,
>>
>> How did you receive that `object_list`?
>> You should filter it based on you user and ‘Running’ inside the view. And
>> then just check if it has count > 0.
>>
>> I hope that does have sense to you.
>>
>> Regards,
>> Constantine C.
>>
>> On Feb 22, 2018, at 7:34 PM, Alan  wrote:
>>
>> Hi there,
>>
>> I am using Django 2 with Python 3.5
>>
>> I have this query, simple, in mysql:
>>
>> select * from submit_submission where jstatus = 'Running' and juser =
>> 'jonhdoe';
>>
>> Basically, I have a table that tracks the jobs I am running.
>>
>> In my html, I'd like to replace this part (in red):
>>
>> {% if *object_list.last.jstatus* == 'Running' %}
>>  Page automatically
>> refreshed every 5 seconds | {% now "jS M y H:i" %}
>> {% else %}No running jobs.
>> {% endif %}
>>
>> ​with something equivalent to my query above where I need to know if
>> there's at least one job running for a given user.
>>
>> I've been looking at https://docs.djangoproject.com
>> /en/2.0/ref/models/querysets ​but I couldn't work out a solution.
>>
>> ​Many thanks in advance,
>>
>> Alan​
>>
>> --
>> I'll cycle across Britain in 2018 for a charity, would you consider
>> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
>> Many thanks!
>> --
>> Alan Wilter SOUSA da SILVA, DSc
>> Senior Bioinformatician, UniProt
>> European Bioinformatics Institute (EMBL-EBI)
>> European Molecular Biology Laboratory
>> Wellcome Trust Genome Campus
>> Hinxton
>> Cambridge CB10 1SD
>> United Kingdom
>> Tel: +44 (0)1223 494588 <01223%20494588>
>>
>> --
>> 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/ms
>> gid/django-users/CAEznbznNwJW4omM%3DMncj8aoBcg3AW8r-yFTMMkb5
>> ZBiB%3Dsv96Q%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/ms
>> gid/django-users/7E9B0630-E1A7-4759-B082-998273D6B330%40gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> I'll cycle across Britain in 2018 for a charity, would you consider
> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
> Many thanks!
> --
> Alan Wilter SOUSA da SILVA, DSc
> Senior Bioinformatician, UniProt
> European Bioinformatics Institute (EMBL-EBI)
> European Molecular Biology Laboratory
> Wellcome Trust Genome Campus
> Hinxton
> Cambridge CB10 1SD
> United Kingdom
> Tel: +44 (0)1223 494588 <+44%201223%20494588>
>
> --
> 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 t

Re: object_list in html

2018-02-23 Thread Alan
Hi Constantine,

from my views.py:

class status(ListView):

model = Submission

template_name = 'status.html'


def get_queryset(self):

return Submission.objects.filter(juser=self.request.user).
exclude(jstatus='Deleted')

If I could create a parameter say runFlag (True of False) where it would be
true for:

select * from submit_submission where jstatus = 'Running' and juser =
'jonhdoe';

Would django equivalente be:
Submission.objects.filter(juser=self.request.user, jstatus=‘Running)

If so, then how to tweak this class so I could have 'runFlag' in the
template html?

Sorry for those questions, I used to use Django 10 years ago and had
solutions for that, now I am trying to learn Django 2.0.

Alan


On 23 February 2018 at 03:18, Costja Covtushenko 
wrote:

> Hi Alan,
>
> How did you receive that `object_list`?
> You should filter it based on you user and ‘Running’ inside the view. And
> then just check if it has count > 0.
>
> I hope that does have sense to you.
>
> Regards,
> Constantine C.
>
> On Feb 22, 2018, at 7:34 PM, Alan  wrote:
>
> Hi there,
>
> I am using Django 2 with Python 3.5
>
> I have this query, simple, in mysql:
>
> select * from submit_submission where jstatus = 'Running' and juser =
> 'jonhdoe';
>
> Basically, I have a table that tracks the jobs I am running.
>
> In my html, I'd like to replace this part (in red):
>
> {% if *object_list.last.jstatus* == 'Running' %}
>  Page automatically
> refreshed every 5 seconds | {% now "jS M y H:i" %}
> {% else %}No running jobs.
> {% endif %}
>
> ​with something equivalent to my query above where I need to know if
> there's at least one job running for a given user.
>
> I've been looking at https://docs.djangoproject.com/en/2.0/ref/models/
> querysets ​but I couldn't work out a solution.
>
> ​Many thanks in advance,
>
> Alan​
>
> --
> I'll cycle across Britain in 2018 for a charity, would you consider
> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
> Many thanks!
> --
> Alan Wilter SOUSA da SILVA, DSc
> Senior Bioinformatician, UniProt
> European Bioinformatics Institute (EMBL-EBI)
> European Molecular Biology Laboratory
> Wellcome Trust Genome Campus
> Hinxton
> Cambridge CB10 1SD
> United Kingdom
> Tel: +44 (0)1223 494588 <01223%20494588>
>
> --
> 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/CAEznbznNwJW4omM%3DMncj8aoBcg3AW8r-
> yFTMMkb5ZBiB%3Dsv96Q%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/7E9B0630-E1A7-4759-B082-998273D6B330%40gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
I'll cycle across Britain in 2018 for a charity, would you consider
supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
Many thanks!
--
Alan Wilter SOUSA da SILVA, DSc
Senior Bioinformatician, UniProt
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Trust Genome Campus
Hinxton
Cambridge CB10 1SD
United Kingdom
Tel: +44 (0)1223 494588

-- 
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/CAEznbzmC0dA%3DKUpmMf_DCZh3bKWzi_sgAYcpZFOWs44EsPLeSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: object_list in html

2018-02-22 Thread Costja Covtushenko
Hi Alan,

How did you receive that `object_list`?
You should filter it based on you user and ‘Running’ inside the view. And then 
just check if it has count > 0.

I hope that does have sense to you.

Regards,
Constantine C.

> On Feb 22, 2018, at 7:34 PM, Alan  wrote:
> 
> Hi there,
> 
> I am using Django 2 with Python 3.5
> 
> I have this query, simple, in mysql:
> 
> select * from submit_submission where jstatus = 'Running' and juser = 
> 'jonhdoe';
> 
> Basically, I have a table that tracks the jobs I am running.
> 
> In my html, I'd like to replace this part (in red):
> 
> {% if object_list.last.jstatus == 'Running' %}
>  Page automatically 
> refreshed every 5 seconds | {% now "jS M y H:i" %}
> {% else %}No running jobs.
> {% endif %}
> 
> ​with something equivalent to my query above where I need to know if there's 
> at least one job running for a given user.
> 
> I've been looking at 
> https://docs.djangoproject.com/en/2.0/ref/models/querysets 
>  ​but I couldn't 
> work out a solution.
> 
> ​Many thanks in advance,
> 
> Alan​
> 
> -- 
> I'll cycle across Britain in 2018 for a charity, would you consider
> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva 
> 
> Many thanks!
> --
> Alan Wilter SOUSA da SILVA, DSc
> Senior Bioinformatician, UniProt
> European Bioinformatics Institute (EMBL-EBI)
> European Molecular Biology Laboratory
> Wellcome Trust Genome Campus
> Hinxton
> Cambridge CB10 1SD
> United Kingdom
> Tel: +44 (0)1223 494588
> 
> -- 
> 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/CAEznbznNwJW4omM%3DMncj8aoBcg3AW8r-yFTMMkb5ZBiB%3Dsv96Q%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/7E9B0630-E1A7-4759-B082-998273D6B330%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


object_list in html

2018-02-22 Thread Alan
Hi there,

I am using Django 2 with Python 3.5

I have this query, simple, in mysql:

select * from submit_submission where jstatus = 'Running' and juser =
'jonhdoe';

Basically, I have a table that tracks the jobs I am running.

In my html, I'd like to replace this part (in red):

{% if *object_list.last.jstatus* == 'Running' %}

 Page automatically
refreshed every 5 seconds | {% now "jS M y H:i" %}

{% else %}No running jobs.

{% endif %}

​with something equivalent to my query above where I need to know if
there's at least one job running for a given user.

I've been looking at
https://docs.djangoproject.com/en/2.0/ref/models/querysets ​but I couldn't
work out a solution.

​Many thanks in advance,

Alan​

-- 
I'll cycle across Britain in 2018 for a charity, would you consider
supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
Many thanks!
--
Alan Wilter SOUSA da SILVA, DSc
Senior Bioinformatician, UniProt
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Trust Genome Campus
Hinxton
Cambridge CB10 1SD
United Kingdom
Tel: +44 (0)1223 494588

-- 
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/CAEznbznNwJW4omM%3DMncj8aoBcg3AW8r-yFTMMkb5ZBiB%3Dsv96Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.