Re: passing an argument to ListView class and accessing using kwargs

2019-12-11 Thread Patrick Carra
Thank you Dominick your second suggestion worked beautifully!  I appreciate 
your time and expertise!

-- 
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/fe6e98de-a0c3-42e4-ab36-d439243faf29%40googlegroups.com.


Re: passing an argument to ListView class and accessing using kwargs

2019-12-10 Thread Dominick Del Ponte
I think you need to add ** to kwargs.
like: qs = Utilizationtable.objects.filter(pathname=**kwargs)

alternatively, this may also work,
def get_queryset(self):
return self.model.objects.filter(pathname=self.kwargs['pathname'])



Dominick
delponte.d...@gmail.com



On Wed, Dec 11, 2019 at 8:33 AM Patrick Carra  wrote:

> Hello I am attempting to pass an argument to a Class(ListView) and then
> perform a filter using a kwarg that contains the argument passed in the
> url.  I am having a problem because I cannot access the variable in the url
> using kwargs.  I am not sure what I'm doing wrong below is the link that
> I'm using to pass this value:
>  ="edit-item" title="ViewUtilization">Click to View Utilization
>
> my viewLit/urls.py is:
> urlpatterns= [
>  path('/', views.viewLit, name='viewLit'),
>  path('/edit', views.editLit.as_view(),
> name='editLit'),
>  path('/editXC', views.editXC.as_view(),
> name='editXC'),
>  path('/viewutilization',
> views.viewUtilization.as_view(), name='viewUtilization'),
> ]
>
> my views.py is:
> class viewUtilization(ListView):
> pk_url_kwarg = 'pathname'
> model=Utilizationtable
>
> def get_queryset(self, **kwargs):
> qs = Utilizationtable.objects.filter(pathname=kwargs)
> return qs
>
>
> and my template is:
> 
> 
> 
> 
> You have made it to the utilization page
> {% block content %}
>   Utilization
> {% for object in object_list %}
>   {{ object.reportdate }} {{ object.utilization }}
> {% endfor %}
> {% endblock %}
> 
> 
>
> My query comes back as this:
> *SELECT* ••• *FROM* "utilizationtable" *WHERE* "utilizationtable"."pathname"
> = '{}'
>
> I know I'm missing something simple but I'm not sure what?!?!?!?!??!!
>
> --
> 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/663edf79-246c-47d5-abb5-d9cb0e6ae718%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/CALLhV5SogU8SkJ27FEz9C2VO%2BL9-dau_eTCfnFJeAvOZrYDQPw%40mail.gmail.com.


Re: passing an argument to ListView class and accessing using kwargs

2019-12-10 Thread Patrick Carra
One more additional note this is the url that gets access when the link is 
clicked

http://98.8.61.133:8080/viewLit/St.%20Louis%20to%20Mt.%20Vernon/viewutilization

-- 
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/5bf13205-e8e7-41c9-9c65-dc513e2dc50f%40googlegroups.com.