Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
and the actual value is OQYX/173774//ZYO but Django is interpreting it as 
OQYX/173774/ZYO/

On Thursday, November 14, 2019 at 1:41:35 PM UTC-6, Patrick Carra wrote:
>
> That is a value from the table in models called Circuitinfotable and the 
> field it is pulled from is called circuitid.
>

-- 
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/55203f72-f8fb-48d9-8ace-09aa652e1721%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread DANIEL URBANO DE LA RUA
mrcnew" maxlength="100">
>>>>>>>   
>>>>>>> 
>>>>>>> Search
>>>>>>> 
>>>>>>> 
>>>>>>>   
>>>>>>> 
>>>>>>> {{ filter.qs.count }} circuits returned
>>>>>>> 
>>>>>>>   
>>>>>>> 
>>>>>>>   
>>>>>>> 
>>>>>>>   {% if user.is_authenticated %}
>>>>>>> Edit/
>>>>>>>   {% endif %}
>>>>>>> View
>>>>>>> 
>>>>>>> CircuitID
>>>>>>> Bandwidth
>>>>>>> Region
>>>>>>> Carrier
>>>>>>> Status Segmentname MRC  
>>>>>>>  {% for circuit in filter.qs %}  >>>>>> class="actions"> {% if user.is_authenticated %} >>>>>> title="Edit">Edit {% endif %} >>>>>> title="View">View  {{ circuit.circuitid }} {{
>>>>>>> circuit.bandwidth }} {{ circuit.region }} {{
>>>>>>> circuit.carrier }} {{ circuit.status }} {{
>>>>>>> circuit.segmentname }} {{ circuit.mrcnew }}  {% 
>>>>>>> endfor
>>>>>>> %} {% endblock %} 
>>>>>>>
>>>>>>>
>>>>>>> My project level urls.py file:
>>>>>>> """ciopsdb URL Configuration
>>>>>>>
>>>>>>> The `urlpatterns` list routes URLs to views. For more information
>>>>>>> please see:
>>>>>>> https://docs.djangoproject.com/en/2.2/topics/http/urls/
>>>>>>> Examples:
>>>>>>> Function views
>>>>>>> 1. Add an import:  from my_app import views
>>>>>>> 2. Add a URL to urlpatterns:  path('', views.home, name='home')
>>>>>>> Class-based views
>>>>>>> 1. Add an import:  from other_app.views import Home
>>>>>>> 2. Add a URL to urlpatterns:  path('', Home.as_view(),
>>>>>>> name='home')
>>>>>>> Including another URLconf
>>>>>>> 1. Import the include() function: from django.urls import
>>>>>>> include, path
>>>>>>> 2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
>>>>>>> """
>>>>>>> from django.contrib import admin
>>>>>>> from django.urls import path, include
>>>>>>> from django.conf.urls import url
>>>>>>>
>>>>>>> urlpatterns = [
>>>>>>> path('admin/', admin.site.urls),
>>>>>>> path('', include('homepage.urls')),
>>>>>>> path('searchlit/', include('searchLit.urls')),
>>>>>>> path('viewLit/', include('viewLit.urls')),
>>>>>>> ]
>>>>>>>
>>>>>>>
>>>>>>> My viewLit app's urls.py
>>>>>>>
>>>>>>> from django.urls import path, include
>>>>>>> from django.conf.urls import  url
>>>>>>> from . import views
>>>>>>>
>>>>>>> urlpatterns= [
>>>>>>>  path(r'/', views.viewLit, name='viewLit'),
>>>>>>> ]
>>>>>>>
>>>>>>>
>>>>>>> My viewLit app's views.py
>>>>>>>
>>>>>>> from django.shortcuts import render
>>>>>>> from django.http import HttpResponse
>>>>>>> from django.views.generic import TemplateView
>>>>>>>
>>>>>>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>>>>>>
>>>>>>> # Create your views here.
>>>>>>> def viewLit(request, circuitid):
>>>>>>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>>>>>>> template = 'viewLit/viewCircuit.html'
>>>>>>> context = {'record':record}
>>>>>>> return render(request, template, context)
>>>>>>>
>>>>>>>
>>>>>>> The traceback that I receive as an error:
>>>>>>>
>>>>>>> Traceback:File 
>>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>>>>>>  in inner  34. response = get_response(request)File 
>>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>>>>  in _get_response  115. response = 
>>>>>>> self.process_exception_by_middleware(e, request)File 
>>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>>>>  in _get_response  113. response = 
>>>>>>> wrapped_callback(request, *callback_args, **callback_kwargs)File 
>>>>>>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>>>>>>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>>>>>>  in manager_method  82. return 
>>>>>>> getattr(self.get_queryset(), name)(*args, **kwargs)File 
>>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>>>>>>  in get  408. self.model._meta.object_nameException 
>>>>>>> Type: DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: 
>>>>>>> Circuitinfotable matching query does not exist.
>>>>>>>
>>>>>>>
>>>>>>> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>>>>>>> .
>>>>>>>
>>>>>> --
>>>>>> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
>>>>>> .
>>>>>>
>>>>>

-- 
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/CAO_yRT36AtOUN3NAC%2BYZ%3DqizTMZAASuZOqQO15asEaDNnQYS_Q%40mail.gmail.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread DANIEL URBANO DE LA RUA
t;>> 
>>>>>> CircuitID
>>>>>> Bandwidth
>>>>>> Region
>>>>>> Carrier
>>>>>> Status Segmentname MRC  
>>>>>>  {% for circuit in filter.qs %}  >>>>> class="actions"> {% if user.is_authenticated %} >>>>> title="Edit">Edit {% endif %} >>>>> title="View">View  {{ circuit.circuitid }} {{
>>>>>> circuit.bandwidth }} {{ circuit.region }} {{
>>>>>> circuit.carrier }} {{ circuit.status }} {{
>>>>>> circuit.segmentname }} {{ circuit.mrcnew }}  {% endfor
>>>>>> %} {% endblock %} 
>>>>>>
>>>>>>
>>>>>> My project level urls.py file:
>>>>>> """ciopsdb URL Configuration
>>>>>>
>>>>>> The `urlpatterns` list routes URLs to views. For more information
>>>>>> please see:
>>>>>> https://docs.djangoproject.com/en/2.2/topics/http/urls/
>>>>>> Examples:
>>>>>> Function views
>>>>>> 1. Add an import:  from my_app import views
>>>>>> 2. Add a URL to urlpatterns:  path('', views.home, name='home')
>>>>>> Class-based views
>>>>>> 1. Add an import:  from other_app.views import Home
>>>>>> 2. Add a URL to urlpatterns:  path('', Home.as_view(),
>>>>>> name='home')
>>>>>> Including another URLconf
>>>>>> 1. Import the include() function: from django.urls import
>>>>>> include, path
>>>>>> 2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
>>>>>> """
>>>>>> from django.contrib import admin
>>>>>> from django.urls import path, include
>>>>>> from django.conf.urls import url
>>>>>>
>>>>>> urlpatterns = [
>>>>>> path('admin/', admin.site.urls),
>>>>>> path('', include('homepage.urls')),
>>>>>> path('searchlit/', include('searchLit.urls')),
>>>>>> path('viewLit/', include('viewLit.urls')),
>>>>>> ]
>>>>>>
>>>>>>
>>>>>> My viewLit app's urls.py
>>>>>>
>>>>>> from django.urls import path, include
>>>>>> from django.conf.urls import  url
>>>>>> from . import views
>>>>>>
>>>>>> urlpatterns= [
>>>>>>  path(r'/', views.viewLit, name='viewLit'),
>>>>>> ]
>>>>>>
>>>>>>
>>>>>> My viewLit app's views.py
>>>>>>
>>>>>> from django.shortcuts import render
>>>>>> from django.http import HttpResponse
>>>>>> from django.views.generic import TemplateView
>>>>>>
>>>>>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>>>>>
>>>>>> # Create your views here.
>>>>>> def viewLit(request, circuitid):
>>>>>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>>>>>> template = 'viewLit/viewCircuit.html'
>>>>>> context = {'record':record}
>>>>>> return render(request, template, context)
>>>>>>
>>>>>>
>>>>>> The traceback that I receive as an error:
>>>>>>
>>>>>> Traceback:File 
>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>>>>>  in inner  34. response = get_response(request)File 
>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>>>  in _get_response  115. response = 
>>>>>> self.process_exception_by_middleware(e, request)File 
>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>>>  in _get_response  113. response = 
>>>>>> wrapped_callback(request, *callback_args, **callback_kwargs)File 
>>>>>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>>>>>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>>>>>  in manager_method  82. return 
>>>>>> getattr(self.get_queryset(), name)(*args, **kwargs)File 
>>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>>>>>  in get  408. self.model._meta.object_nameException 
>>>>>> Type: DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: 
>>>>>> Circuitinfotable matching query does not exist.
>>>>>>
>>>>>>
>>>>>> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>>>>>> .
>>>>>>
>>>>> --
>>>>> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>

-- 
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/CAO_yRT33QibaVifcukK%2BHhDJ3VBbzPaE%3DgJiMVGFaGM4YxcC7A%40mail.gmail.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread DANIEL URBANO DE LA RUA
;>> circuit.segmentname }} {{ circuit.mrcnew }}  {% endfor
>>>>> %} {% endblock %} 
>>>>>
>>>>>
>>>>> My project level urls.py file:
>>>>> """ciopsdb URL Configuration
>>>>>
>>>>> The `urlpatterns` list routes URLs to views. For more information
>>>>> please see:
>>>>> https://docs.djangoproject.com/en/2.2/topics/http/urls/
>>>>> Examples:
>>>>> Function views
>>>>> 1. Add an import:  from my_app import views
>>>>> 2. Add a URL to urlpatterns:  path('', views.home, name='home')
>>>>> Class-based views
>>>>> 1. Add an import:  from other_app.views import Home
>>>>> 2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
>>>>> Including another URLconf
>>>>> 1. Import the include() function: from django.urls import include,
>>>>> path
>>>>> 2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
>>>>> """
>>>>> from django.contrib import admin
>>>>> from django.urls import path, include
>>>>> from django.conf.urls import url
>>>>>
>>>>> urlpatterns = [
>>>>> path('admin/', admin.site.urls),
>>>>> path('', include('homepage.urls')),
>>>>> path('searchlit/', include('searchLit.urls')),
>>>>> path('viewLit/', include('viewLit.urls')),
>>>>> ]
>>>>>
>>>>>
>>>>> My viewLit app's urls.py
>>>>>
>>>>> from django.urls import path, include
>>>>> from django.conf.urls import  url
>>>>> from . import views
>>>>>
>>>>> urlpatterns= [
>>>>>  path(r'/', views.viewLit, name='viewLit'),
>>>>> ]
>>>>>
>>>>>
>>>>> My viewLit app's views.py
>>>>>
>>>>> from django.shortcuts import render
>>>>> from django.http import HttpResponse
>>>>> from django.views.generic import TemplateView
>>>>>
>>>>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>>>>
>>>>> # Create your views here.
>>>>> def viewLit(request, circuitid):
>>>>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>>>>> template = 'viewLit/viewCircuit.html'
>>>>> context = {'record':record}
>>>>> return render(request, template, context)
>>>>>
>>>>>
>>>>> The traceback that I receive as an error:
>>>>>
>>>>> Traceback:File 
>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>>>>  in inner  34. response = get_response(request)File 
>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>>  in _get_response  115. response = 
>>>>> self.process_exception_by_middleware(e, request)File 
>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>>  in _get_response  113. response = 
>>>>> wrapped_callback(request, *callback_args, **callback_kwargs)File 
>>>>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>>>>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>>>>  in manager_method  82. return 
>>>>> getattr(self.get_queryset(), name)(*args, **kwargs)File 
>>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>>>>  in get  408. self.model._meta.object_nameException Type: 
>>>>> DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: 
>>>>> Circuitinfotable matching query does not exist.
>>>>>
>>>>>
>>>>> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>

-- 
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/CAO_yRT2SfDJX2DDdJxRjaDZmuYY_3SubZbw4R-WsUxtHKrYw8w%40mail.gmail.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread DANIEL URBANO DE LA RUA
t; 1. Add an import:  from other_app.views import Home
>>>> 2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
>>>> Including another URLconf
>>>> 1. Import the include() function: from django.urls import include,
>>>> path
>>>> 2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
>>>> """
>>>> from django.contrib import admin
>>>> from django.urls import path, include
>>>> from django.conf.urls import url
>>>>
>>>> urlpatterns = [
>>>> path('admin/', admin.site.urls),
>>>> path('', include('homepage.urls')),
>>>> path('searchlit/', include('searchLit.urls')),
>>>> path('viewLit/', include('viewLit.urls')),
>>>> ]
>>>>
>>>>
>>>> My viewLit app's urls.py
>>>>
>>>> from django.urls import path, include
>>>> from django.conf.urls import  url
>>>> from . import views
>>>>
>>>> urlpatterns= [
>>>>  path(r'/', views.viewLit, name='viewLit'),
>>>> ]
>>>>
>>>>
>>>> My viewLit app's views.py
>>>>
>>>> from django.shortcuts import render
>>>> from django.http import HttpResponse
>>>> from django.views.generic import TemplateView
>>>>
>>>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>>>
>>>> # Create your views here.
>>>> def viewLit(request, circuitid):
>>>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>>>> template = 'viewLit/viewCircuit.html'
>>>> context = {'record':record}
>>>> return render(request, template, context)
>>>>
>>>>
>>>> The traceback that I receive as an error:
>>>>
>>>> Traceback:File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>>>  in inner  34. response = get_response(request)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>  in _get_response  115. response = 
>>>> self.process_exception_by_middleware(e, request)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>  in _get_response  113. response = 
>>>> wrapped_callback(request, *callback_args, **callback_kwargs)File 
>>>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>>>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>>>  in manager_method  82. return 
>>>> getattr(self.get_queryset(), name)(*args, **kwargs)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>>>  in get  408. self.model._meta.object_nameException Type: 
>>>> DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
>>>> matching query does not exist.
>>>>
>>>>
>>>> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>>> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>

-- 
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/CAO_yRT2hy0ejy_UkeMXfmECGggGJ4BfZ_OxOmRPpAimGtWzf5Q%40mail.gmail.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
Could you provide an example of what you mean?  I'm not sure what you mean 
by method call must include an object instance as argument.  This code 
works for other values of circuitid but does not work for one that contains 
a //.  This tells me, along with the traceback code, that django at some 
point drops one of the /'s and the result is it cannot find a matching 
circuitid in the Circuitinfotable during the query.

-- 
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/62a01aa1-3686-4451-adcb-48a78f6e98d1%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
gt;>> please see:
>>>> https://docs.djangoproject.com/en/2.2/topics/http/urls/
>>>> Examples:
>>>> Function views
>>>> 1. Add an import:  from my_app import views
>>>> 2. Add a URL to urlpatterns:  path('', views.home, name='home')
>>>> Class-based views
>>>> 1. Add an import:  from other_app.views import Home
>>>> 2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
>>>> Including another URLconf
>>>> 1. Import the include() function: from django.urls import include, 
>>>> path
>>>> 2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
>>>> """
>>>> from django.contrib import admin
>>>> from django.urls import path, include
>>>> from django.conf.urls import url
>>>>
>>>> urlpatterns = [
>>>> path('admin/', admin.site.urls),
>>>> path('', include('homepage.urls')),
>>>> path('searchlit/', include('searchLit.urls')),
>>>> path('viewLit/', include('viewLit.urls')),
>>>> ]
>>>>
>>>>
>>>> My viewLit app's urls.py
>>>>
>>>> from django.urls import path, include
>>>> from django.conf.urls import  url
>>>> from . import views
>>>>
>>>> urlpatterns= [
>>>>  path(r'/', views.viewLit, name='viewLit'),
>>>> ]
>>>>
>>>>
>>>> My viewLit app's views.py
>>>>
>>>> from django.shortcuts import render
>>>> from django.http import HttpResponse
>>>> from django.views.generic import TemplateView
>>>>
>>>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>>>
>>>> # Create your views here.
>>>> def viewLit(request, circuitid):
>>>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>>>> template = 'viewLit/viewCircuit.html'
>>>> context = {'record':record}
>>>> return render(request, template, context)
>>>>
>>>>
>>>> The traceback that I receive as an error:
>>>>
>>>> Traceback:File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>>>  in inner  34. response = get_response(request)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>  in _get_response  115. response = 
>>>> self.process_exception_by_middleware(e, request)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>>  in _get_response  113. response = 
>>>> wrapped_callback(request, *callback_args, **callback_kwargs)File 
>>>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>>>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>>>  in manager_method  82. return 
>>>> getattr(self.get_queryset(), name)(*args, **kwargs)File 
>>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>>>  in get  408. self.model._meta.object_nameException Type: 
>>>> DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
>>>> matching query does not exist.
>>>>
>>>>
>>>> Any suggestions are 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...@googlegroups.com .
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> -- 
>>> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>

-- 
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/9c405720-183f-4467-bcde-4ef4a7367d04%40googlegroups.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread DANIEL URBANO DE LA RUA
;> from django.conf.urls import url
>>>
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> path('', include('homepage.urls')),
>>> path('searchlit/', include('searchLit.urls')),
>>> path('viewLit/', include('viewLit.urls')),
>>> ]
>>>
>>>
>>> My viewLit app's urls.py
>>>
>>> from django.urls import path, include
>>> from django.conf.urls import  url
>>> from . import views
>>>
>>> urlpatterns= [
>>>  path(r'/', views.viewLit, name='viewLit'),
>>> ]
>>>
>>>
>>> My viewLit app's views.py
>>>
>>> from django.shortcuts import render
>>> from django.http import HttpResponse
>>> from django.views.generic import TemplateView
>>>
>>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>>
>>> # Create your views here.
>>> def viewLit(request, circuitid):
>>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>>> template = 'viewLit/viewCircuit.html'
>>> context = {'record':record}
>>> return render(request, template, context)
>>>
>>>
>>> The traceback that I receive as an error:
>>>
>>> Traceback:File 
>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>>  in inner  34. response = get_response(request)File 
>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>  in _get_response  115. response = 
>>> self.process_exception_by_middleware(e, request)File 
>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>>  in _get_response  113. response = 
>>> wrapped_callback(request, *callback_args, **callback_kwargs)File 
>>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>>  in manager_method  82. return getattr(self.get_queryset(), 
>>> name)(*args, **kwargs)File 
>>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>>  in get  408. self.model._meta.object_nameException Type: 
>>> DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
>>> matching query does not exist.
>>>
>>>
>>> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/CAO_yRT0N74sYAcDhcZGKT56%3D387-kx8QcnViKvyvJ23tfcWROA%40mail.gmail.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread DANIEL URBANO DE LA RUA
e
>> from django.views.generic import TemplateView
>>
>> from . models import Circuitinfotable, Budgettable, Xcinventorytable
>>
>> # Create your views here.
>> def viewLit(request, circuitid):
>> record = Circuitinfotable.objects.get(circuitid=circuitid)
>> template = 'viewLit/viewCircuit.html'
>> context = {'record':record}
>> return render(request, template, context)
>>
>>
>> The traceback that I receive as an error:
>>
>> Traceback:File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
>>  in inner  34. response = get_response(request)File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>  in _get_response  115. response = 
>> self.process_exception_by_middleware(e, request)File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>>  in _get_response  113. response = wrapped_callback(request, 
>> *callback_args, **callback_kwargs)File 
>> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
>> Circuitinfotable.objects.get(circuitid=circuitid)File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>>  in manager_method  82. return getattr(self.get_queryset(), 
>> name)(*args, **kwargs)File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>>  in get  408. self.model._meta.object_nameException Type: 
>> DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
>> matching query does not exist.
>>
>>
>> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAO_yRT33eVfpa4eSacGdQKD7cZr_rEO%3DLBiWuaMQauaWSXpw2w%40mail.gmail.com.


Re: django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Integr@te System
rs/base.py"
>  in _get_response  115. response = 
> self.process_exception_by_middleware(e, request)File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
>  in _get_response  113. response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)File 
> "/home/db_user/ciopsdb/viewLit/views.py" in viewLit  9. record = 
> Circuitinfotable.objects.get(circuitid=circuitid)File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
>  in manager_method  82. return getattr(self.get_queryset(), 
> name)(*args, **kwargs)File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
>  in get  408. self.model._meta.object_nameException Type: 
> DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
> matching query does not exist.
>
>
> Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAP5HUWqOnTrZvzArw77fnyDRHP4BA9QmoUEdR4a9boMFVxggRg%40mail.gmail.com.


Re: Django GIS query on annotated spatial field

2019-11-14 Thread Simon Charette
Hello Bill,

Could you give us more details about which version of Django you are using?

There was a few Django bugs related to as_sql returning Union[list, tuple] 
as params that were
fixed in recent release but this one might not have been caught yet.

Cheers,
Simon

Le jeudi 14 novembre 2019 09:43:46 UTC-5, Bill Bouzas a écrit :
>
>
>
> I am currently building a web app based on GeoDjango and I want to check 
> if 
> a number of points lie within a multipolygon. To form the multipolygon, I 
> check which areas are selected and then aggregate them into one 
> multipolygon with the following query: 
>
> area = Area.objects.filter(id__in = 
> area_ids).aggregate(area=Union('geom'))['area']print(area) 
>
> SRID=4326;MULTIPOLYGON (((5.014146 52.371687, 5.013973 52.371632, 5.013238 
> 52.37166, 5.012505 52.372437, 5.01294 52.372787, 5.012977 52.373, 5.013142 
> 52.373072, 5.014488 52.373032, 5.014564 52.372957, 5.014701 52.37272, 
> 5.01461 52.372181, 5.014372 52.371786, 5.014146 52.371687)), ((5.014054 
> 52.367988, 5.014448 52.368027, 5.014532 52.367978, 5.014079 52.367899, 
> 5.014033 52.367822, 5.01398 52.367882, 5.012914 52.367781, 5.013032 
> 52.367372, 5.012751 52.367294, 5.00198 52.366278, 5.001809 52.366739, 
> 5.36 52.366614, 5.86 52.366682, 5.013941 52.367968, 5.013987 
> 52.36805, 5.014054 52.367988)), ((4.997837 52.350827, 4.997581 52.350302, 
> 4.996731 52.35072, 4.996493 52.350708, 4.991906 52.352949, 4.989279 
> 52.354708, 4.990234 52.354938, 4.993064 52.353655, 4.997837 52.350827)), 
> ((5.021518 52.384118, 5.018382 52.380388, 5.01628 52.377323, 5.014382 
> 52.37417, 5.014296 52.374171, 5.014094 52.37425, 5.014288 52.374504, 
> 5.014268 52.374785, 5.013763 52.374812, 5.013434 52.375018, 5.013673 
> 52.375082, 5.01377 52.375441, 5.014177 52.375737, 5.014467 52.375531, 
> 5.014801 52.375961, 5.014822 52.376498, 5.014295 52.376588, 5.014194 
> 52.376725, 5.014413 52.377446, 5.015047 52.378, 5.015372 52.378016, 
> 5.015413 52.377633, 5.01574 52.377412, 5.015965 52.377466, 5.015873 
> 52.378071, 5.016008 52.378355, 5.015993 52.378669, 5.016702 52.380502, 
> 5.016514 52.380922, 5.016989 52.381336, 5.017121 52.381644, 5.017756 
> 52.381984, 5.017666 52.382471, 5.018341 52.383453, 5.018662 52.383813, 
> 5.018769 52.383778, 5.019567 52.384011, 5.020317 52.383815, 5.02067 
> 52.38387, 5.022685 52.386085, 5.022946 52.386199, 5.023521 52.386835, 
> 5.023697 52.386851, 5.023905 52.386782, 5.021518 52.384118)), ((4.980684 
> 52.330761, 4.982519 52.330804, 4.983355 52.330747, 4.984946 52.330428, 
> 4.98604 52.329811, 4.987298 52.32893, 4.989045 52.327985, 4.989604 
> 52.327548, 4.990891 52.326142, 4.991615 52.324538, 4.992109 52.323766, 
> 4.995479 52.31931, 4.997103 52.317392, 4.997369 52.316672, 4.997147 
> 52.315905, 4.997091 52.314456, 4.997298 52.314196, 4.997456 52.314246, 
> 4.99786 52.313979, 5.001531 52.315911, 5.006523 52.319077, 5.016134 
> 52.324512, 5.016323 52.324237, 5.016653 52.322987, 5.017933 52.323192, 
> 5.018331 52.320249, 5.021543 52.302457, 5.019476 52.302498, 5.018104 
> 52.302624, 5.016685 52.302881, 5.014265 52.303677, 5.014229 52.30359, 
> 5.012989 52.303605, 5.012279 52.303522, 5.011623 52.303337, 5.011051 
> 52.303029, 5.009933 52.302103, 5.008961 52.301726, 5.007892 52.301522, 
> 5.007544 52.300868, 5.005265 52.298393, 5.003835 52.298509, 5.003233 
> 52.297389, 5.003227 52.296065, 5.002484 52.296035, 5.001851 52.295879, 
> 5.001789 52.292793, 4.998814 52.290239, 4.998551 52.290234, 4.998452 
> 52.289839, 4.998298 52.289815, 4.997475 52.289118, 4.994117 52.289288, 
> 4.990459 52.289603, 4.983506 52.290368, 4.982889 52.289642, 4.975148 
> 52.286342, 4.973249 52.285236, 4.973072 52.285022, 4.972611 52.284846, 
> 4.969726 52.283121, 4.969378 52.281789, 4.968815 52.280973, 4.968753 
> 52.280726, 4.968328 52.280412, 4.967674 52.279582, 4.967576 52.279561, 
> 4.966842 52.279878, 4.966491 52.280096, 4.966166 52.28098, 4.965709 
> 52.280578, 4.965316 52.280448, 4.962548 52.280285, 4.962244 52.280207, 
> 4.961054 52.278174, 4.959968 52.278346, 4.958664 52.278343, 4.957809 
> 52.278612, 4.957144 52.278671, 4.956564 52.278641, 4.955241 52.278305, 
> 4.95184 52.282443, 4.952091 52.282534, 4.946407 52.288562, 4.937142 
> 52.29947, 4.934869 52.301943, 4.934936 52.301969, 4.933217 52.303553, 
> 4.932721 52.304263, 4.931682 52.305025, 4.930256 52.30643, 4.929473 
> 52.307414, 4.929825 52.307515, 4.929416 52.307829, 4.929909 52.308104, 
> 4.929328 52.308532, 4.929615 52.308813, 4.930303 52.309182, 4.930065 
> 52.30934, 4.931656 52.310267, 4.934138 52.311903, 4.936352 52.312663, 
> 4.935229 52.313889, 4.938724 52.315091, 4.938738 52.315636, 4.938042 
> 52.316505, 4.93983 52.31712, 4.940332 52.318302, 4.939585 52.31912, 
> 4.941043 52.31962, 4.940205 52.320815, 4.939927 52.321936, 4.9

django passing a parameter for a view in a url produces Error: Circuitinfotable matching query does not exist.

2019-11-14 Thread Patrick Carra
I am passing a parameter in a url to another view and during the process it 
gets changed.  An original parameter example that produces the error 
is OQYX/173774//ZYO but gets changed to '/viewLit/OQYX/173774/ZYO/' It 
drops the second / between 173774 and ZYO. I assumed this was because it 
was treating it as an escape character? So I tried adding an r in the 
urls.py file but it did not have any effect. Here is my template code for 
the page that generates the hyperlink:




Circuits

h1 {
color:blue;
}
h4 {
color:red;
}
.tabledata {
  background: #395870; color:#fff;
}
.tablerow:nth-child(even) {
  background-color: #f2f2f2;
}
.form{
  width:100%;
}
.field {
  background: #white; float: left; margin: 1%; width: 200;
}

{% block content %}
  Search Lit Circuits
Enter your search criteria below:


  
Circuit ID:
Bandwidth:
Region:
  
  
Carrier:
Status:
Segmentname:
  
  
MRC:
  

Search


  

{{ filter.qs.count }} circuits returned

  

  

  {% if user.is_authenticated %}
Edit/
  {% endif %}
View

CircuitID
Bandwidth
Region
Carrier
Status Segmentname MRC{% 
for circuit in filter.qs %}   {% 
if user.is_authenticated %} Edit {% endif %} View  {{ circuit.circuitid }} {{ 
circuit.bandwidth }} {{ circuit.region }} {{ 
circuit.carrier }} {{ circuit.status }} {{ 
circuit.segmentname }} {{ circuit.mrcnew }}  {% endfor 
%} {% endblock %}  


My project level urls.py file:
"""ciopsdb URL Configuration

The `urlpatterns` list routes URLs to views. For more information please 
see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import:  from my_app import views
2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
1. Add an import:  from other_app.views import Home
2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('homepage.urls')),
path('searchlit/', include('searchLit.urls')),
path('viewLit/', include('viewLit.urls')),
]


My viewLit app's urls.py

from django.urls import path, include
from django.conf.urls import  url
from . import views

urlpatterns= [
 path(r'/', views.viewLit, name='viewLit'),
]


My viewLit app's views.py

from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import TemplateView

from . models import Circuitinfotable, Budgettable, Xcinventorytable

# Create your views here.
def viewLit(request, circuitid):
record = Circuitinfotable.objects.get(circuitid=circuitid)
template = 'viewLit/viewCircuit.html'
context = {'record':record}
return render(request, template, context)


The traceback that I receive as an error:

Traceback:File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py"
 in inner  34. response = get_response(request)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 in _get_response  115. response = 
self.process_exception_by_middleware(e, request)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/core/handlers/base.py"
 in _get_response  113. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)File "/home/db_user/ciopsdb/viewLit/views.py" 
in viewLit  9. record = 
Circuitinfotable.objects.get(circuitid=circuitid)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/manager.py"
 in manager_method  82. return getattr(self.get_queryset(), 
name)(*args, **kwargs)File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py"
 in get  408. self.model._meta.object_nameException Type: 
DoesNotExist at /viewLit/OQYX/173774/ZYO/Exception Value: Circuitinfotable 
matching query does not exist.


Any suggestions are 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/49da6357-27be-42fa-8b88-fc9c223654d8%40googlegroups.com.


Re: Performing a query returns an error

2019-11-13 Thread Patrick Carra
Simon thank you for that I had been playing around with db_column but did 
not realize the exact reference I should have been making.  Thank you for 
the quick reply!

On Wednesday, November 13, 2019 at 9:46:59 AM UTC-6, Simon Charette wrote:
>
> Hello Patrick,
>
> From what I understand you are relying on unmanaged (Meta.managed=False) 
> models
> to use the ORM to query an externally managed database.
>
> The part you missed here is that the ORM maps ForeignKey fields to 
> database columns with
> a "_id" suffix by default. In your case that means it expects a "pid_id" 
> column to exist for the
> Budgettable.pid field.
>
> If you column is actually named "pid" you'll want to use the "db_column" 
> option to let the ORM
> know about it[0]. That is `db_column=pid` in your `pid = ForeignKey` 
> definition.
>
> Cheers,
> Simon
>
> [0] 
> https://docs.djangoproject.com/en/2.2/ref/models/fields/#database-representation
>
> Le mercredi 13 novembre 2019 10:28:30 UTC-5, Patrick Carra a écrit :
>>
>> Hello all I am new to django and I am trying to do a query to that will 
>> provide me with information from multiple tables I have included my 
>> models.py file below:
>> Enter code hclass Circuitinfotable(models.Model):
>> pid = models.CharField(max_length=255, blank=True, null=True)
>> circuitid = models.CharField(primary_key=True, max_length=255, 
>> blank=True, null=False)
>> bandwidth = models.CharField(max_length=255, blank=True, null=True)
>> region = models.CharField(max_length=255, blank=True, null=True)
>> 
>>
>> class Meta:
>> managed = False
>> db_table = 'circuitinfotable'
>>
>>
>> class Budgettable(models.Model):
>> id = models.IntegerField(primary_key=True)
>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>> pid = models.ForeignKey('Circuitinfotable', on_delete=models.CASCADE)
>> monthnum = models.IntegerField(blank=True, null=True)
>> yearnum = models.IntegerField(blank=True, null=True)
>> budgetmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> actualmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> region = models.CharField(max_length=255, blank=True, null=True)
>>
>> class Meta:
>> managed = False
>> db_table = 'budgettable'
>>
>>
>> the code I was using to query this is below:
>> >>> from viewLit.models import Circuitinfotable, Budgettable
>> >>> btc = Circuitinfotable.objects.get(circuitid='ETH100GB-23349286')
>> >>> btc.budgettable_set.all()
>> Traceback (most recent call last):
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
>>  
>> line 84, in _execute
>> return self.cursor.execute(sql, params)
>> psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
>> LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
>>  ^
>> HINT:  Perhaps you meant to reference the column "budgettable.pid".
>>
>>
>> The above exception was the direct cause of the following exception:
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 250, in __repr__
>> data = list(self[:REPR_OUTPUT_SIZE + 1])
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 274, in __iter__
>> self._fetch_all()
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 1242, in _fetch_all
>> self._result_cache = list(self._iterable_class(self))
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>>  
>> line 55, in __iter__
>> results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
>> chunk_size=self.chunk_size)
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/sql/compiler.py",
>>  
>> line 1100, in execute_sql
>> cursor.execute(sql, params)
>>   File 
>> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-pa

Re: Performing a query returns an error

2019-11-13 Thread Simon Charette
Hello Patrick,

>From what I understand you are relying on unmanaged (Meta.managed=False) 
models
to use the ORM to query an externally managed database.

The part you missed here is that the ORM maps ForeignKey fields to database 
columns with
a "_id" suffix by default. In your case that means it expects a "pid_id" 
column to exist for the
Budgettable.pid field.

If you column is actually named "pid" you'll want to use the "db_column" 
option to let the ORM
know about it[0]. That is `db_column=pid` in your `pid = ForeignKey` 
definition.

Cheers,
Simon

[0] 
https://docs.djangoproject.com/en/2.2/ref/models/fields/#database-representation

Le mercredi 13 novembre 2019 10:28:30 UTC-5, Patrick Carra a écrit :
>
> Hello all I am new to django and I am trying to do a query to that will 
> provide me with information from multiple tables I have included my 
> models.py file below:
> Enter code hclass Circuitinfotable(models.Model):
> pid = models.CharField(max_length=255, blank=True, null=True)
> circuitid = models.CharField(primary_key=True, max_length=255, 
> blank=True, null=False)
> bandwidth = models.CharField(max_length=255, blank=True, null=True)
> region = models.CharField(max_length=255, blank=True, null=True)
> 
>
> class Meta:
> managed = False
> db_table = 'circuitinfotable'
>
>
> class Budgettable(models.Model):
> id = models.IntegerField(primary_key=True)
> circuitid = models.CharField(max_length=255, blank=True, null=True)
> pid = models.ForeignKey('Circuitinfotable', on_delete=models.CASCADE)
> monthnum = models.IntegerField(blank=True, null=True)
> yearnum = models.IntegerField(blank=True, null=True)
> budgetmrc = models.TextField(blank=True, null=True)  # This field type 
> is a guess.
> actualmrc = models.TextField(blank=True, null=True)  # This field type 
> is a guess.
> region = models.CharField(max_length=255, blank=True, null=True)
>
> class Meta:
> managed = False
> db_table = 'budgettable'
>
>
> the code I was using to query this is below:
> >>> from viewLit.models import Circuitinfotable, Budgettable
> >>> btc = Circuitinfotable.objects.get(circuitid='ETH100GB-23349286')
> >>> btc.budgettable_set.all()
> Traceback (most recent call last):
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
>  
> line 84, in _execute
> return self.cursor.execute(sql, params)
> psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
> LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
>  ^
> HINT:  Perhaps you meant to reference the column "budgettable.pid".
>
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>  
> line 250, in __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>  
> line 274, in __iter__
> self._fetch_all()
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>  
> line 1242, in _fetch_all
> self._result_cache = list(self._iterable_class(self))
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
>  
> line 55, in __iter__
> results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
> chunk_size=self.chunk_size)
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/sql/compiler.py",
>  
> line 1100, in execute_sql
> cursor.execute(sql, params)
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
>  
> line 99, in execute
> return super().execute(sql, params)
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
>  
> line 67, in execute
> return self._execute_with_wrappers(sql, params, many=False, 
> executor=self._execute)
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
>  
> line 76, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File 
> "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/ut

Performing a query returns an error

2019-11-13 Thread Patrick Carra
Hello all I am new to django and I am trying to do a query to that will 
provide me with information from multiple tables I have included my 
models.py file below:
Enter code hclass Circuitinfotable(models.Model):
pid = models.CharField(max_length=255, blank=True, null=True)
circuitid = models.CharField(primary_key=True, max_length=255, 
blank=True, null=False)
bandwidth = models.CharField(max_length=255, blank=True, null=True)
region = models.CharField(max_length=255, blank=True, null=True)


class Meta:
managed = False
db_table = 'circuitinfotable'


class Budgettable(models.Model):
id = models.IntegerField(primary_key=True)
circuitid = models.CharField(max_length=255, blank=True, null=True)
pid = models.ForeignKey('Circuitinfotable', on_delete=models.CASCADE)
monthnum = models.IntegerField(blank=True, null=True)
yearnum = models.IntegerField(blank=True, null=True)
budgetmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
actualmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
region = models.CharField(max_length=255, blank=True, null=True)

class Meta:
managed = False
db_table = 'budgettable'


the code I was using to query this is below:
>>> from viewLit.models import Circuitinfotable, Budgettable
>>> btc = Circuitinfotable.objects.get(circuitid='ETH100GB-23349286')
>>> btc.budgettable_set.all()
Traceback (most recent call last):
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
 ^
HINT:  Perhaps you meant to reference the column "budgettable.pid".


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 250, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 274, in __iter__
self._fetch_all()
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 1242, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/query.py",
 
line 55, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
chunk_size=self.chunk_size)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/models/sql/compiler.py",
 
line 1100, in execute_sql
cursor.execute(sql, params)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 99, in execute
return super().execute(sql, params)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, 
executor=self._execute)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/utils.py", 
line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column budgettable.pid_id does not exist
LINE 1: ...CT "budgettable"."id", "budgettable"."circuitid", "budgettab...
 ^
HINT:  Perhaps you meant to reference the column "budgettable.pid".


The next thing that I tried was to just get an object from the Budgettable 
directly code below:

>>> btcBud=Budgettable.objects.get(pid='ETH100GB-23349286')
Traceback (most recent call last):
  File 
"/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/db/backends/utils.py",
 
line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column budgettable.pid_id does not exist
LINE 1: ...CT "

Re: Django Query

2019-11-12 Thread Eng. Medson Naftal
Visit this link
https://simpleisbetterthancomplex.com/tutorial/2018/01/18/how-to-implement-multiple-user-types-with-django.html

On Tue, Nov 12, 2019, 18:20 Suraj Thapa FC  wrote:

> You can simply do this with a single login
>
> On Tue, 12 Nov 2019, 6:59 pm Deepak Singh, 
> wrote:
>
>> I have a survey form for students and teachers. Questions are different
>> for students and teachers, so I want to provide them with different login.
>> How do I create different login pages in Django that redirect to different
>> pages?
>> And how can I store the students and teachers username and password in
>> different databases?
>>
>> Regards
>>
>> --
>> 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/CAOjV4wHBnORvJNWnvxRtHVMEbbuyqApQJZo1XunomGLu-RbouA%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/CAPjsHcHPnz5duvtcwdPg0FhUogtivP%2BbGsiNVAtHN2X1v0qWyA%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/CAH7nK-A5Z3n4YkKruS34bd9fOhrppn-ViX%2BgPW7ZP8WT1f-FLA%40mail.gmail.com.


Re: Django Query

2019-11-12 Thread Suraj Thapa FC
You can simply do this with a single login

On Tue, 12 Nov 2019, 6:59 pm Deepak Singh, 
wrote:

> I have a survey form for students and teachers. Questions are different
> for students and teachers, so I want to provide them with different login.
> How do I create different login pages in Django that redirect to different
> pages?
> And how can I store the students and teachers username and password in
> different databases?
>
> Regards
>
> --
> 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/CAOjV4wHBnORvJNWnvxRtHVMEbbuyqApQJZo1XunomGLu-RbouA%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/CAPjsHcHPnz5duvtcwdPg0FhUogtivP%2BbGsiNVAtHN2X1v0qWyA%40mail.gmail.com.


Django Query

2019-11-12 Thread Deepak Singh
I have a survey form for students and teachers. Questions are different for
students and teachers, so I want to provide them with different login. How
do I create different login pages in Django that redirect to different
pages?
And how can I store the students and teachers username and password in
different databases?

Regards

-- 
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/CAOjV4wHBnORvJNWnvxRtHVMEbbuyqApQJZo1XunomGLu-RbouA%40mail.gmail.com.


Re: Query regarding Jija templates with django project

2019-10-30 Thread 'Amitesh Sahay' via Django users
Hey Red, 

Thank you for your reply.
Your suggestion did the trick. 
Now I am facing issues with static files, especially for CSS files. There were 
issues for images files, but I got that rectified. I know that the location 
that I have mentioned in the HTML pages has the CSS files. Still  I am getting 
the below error:

Not Found: /blog/contact/%{ static 'CSS/tooplate_style.css' %}
Not Found: /blog/contact/%{ static 'CSS/ddsmoothmenu.css' %}
[30/Oct/2019 10:41:07] "GET 
/blog/contact/%%7B%20static%20'CSS/tooplate_style.css'%20%%7D HTTP/1.1" 404 3124
[30/Oct/2019 10:41:07] "GET 
/blog/contact/%%7B%20static%20'CSS/ddsmoothmenu.css'%20%%7D HTTP/1.1" 404 3118
Not Found: /blog/contact/%{ static 'CSS/ddsmoothmenu.css' %}
[30/Oct/2019 10:41:07] "GET 
/blog/contact/%%7B%20static%20'CSS/ddsmoothmenu.css'%20%%7D HTTP/1.1" 404 3118

Below is the snippet of my static file settings:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = (
   os.path.join(BASE_DIR, 'static'),
   )Below is my static dir structure as seen in my pycharm.


I went through below stackoverflow web link, but the suggestion don't seem to 
be working for me.
Django - Static file not found

| 
| 
| 
|  |  |

 |

 |
| 
|  | 
Django - Static file not found

I've seen several posts for this issue but didn't found my solution. I'm trying 
to serve static files within my...
 |

 |

 |




It would great if you could suggest .



Regards,
Amitesh
 

On Saturday, 26 October, 2019, 4:42:05 AM IST, red  
wrote:  
 
  
Hello,
 
Your views have a 'name' attribute. You can also give a name to an app in the 
urls.py file of the app, right above your urlpatterns list:
 app_name = "myappname"

urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('blog', views.blog, name='blog'),

] 

 
 
Then, when you need to put a link to a another page in your template, use the 
following syntax:
 Home
About Us 
Regards,
 
 
Red
 On 25/10/2019 21:01, 'Amitesh Sahay' via Django users wrote:
  
 
  Hello Team, 
  
  I am kind of new to software development, and trying to find my feat. I have 
a queries which could be quite dumb to most of you, but I need to know.   As 
far as I know, we need Jija templates in the HTML files, so that we can assign 
correct path of the static files. 
  
  Its a general practice to create base.html and extend this in other HTML 
files. Since, I am new to development, so I want to do things in a stupid way, 
I have a HTML templates, and I do not wish to create base.html for now. 
Therefore, if I want to render the html page, I need to create views.py , 
urls.py, and modify the HTML pages to use 'static' any where required. Below 
are the snippet of my test environment. 
  views.py 
from django.shortcuts import render, get_object_or_404


def index(request):
return render(request, 'index.html')


def blog(request):
return render(request, 'blog.html')


def about(request):
return render(request, 'about.html')
  project/urls.py 
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('BLOG.urls'))
]

if settings.DEBUG:
   urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)  APP/urls.py 
from django.urls import path
from django.conf import settings
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('blog', views.blog, name='blog'),

]  below is the HTML(index.html) file, which I modified as per my limited 
understanding. 
{% load staticfiles %}
{% block content %}

http://www.w3.org/1999/xhtml;>


Orange Theme - Free Website Template







   var flashvars = {};
   flashvars.xml_file = "photo_list.xml";
   var params = {};
   params.wmode = "transparent";
   var attributes = {};
   attributes.id = "slider";
   swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "440", "220", 
"9.0.0", false, flashvars, params, attributes);







/***
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library 
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***/





ddsmoothmenu.init({
   mainmenuid: "tooplate_menu", //menu DIV id
   orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
   classname: 'ddsmoothmenu', //class added to menu's outer DIV
   //customtheme: ["#1c5a80", "#18374a"],
   contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})







   
   
   Orange HTML Template


  
   
   Home
   

RE: Database ORM query Help

2019-10-26 Thread dvdcedar
Thanks for the recommendation. The raw SQL method worked for me. Would be good 
to know how to accomplish this using the Django ORM query set.

 

Basically I have a list of games, the user may choose to update the name for 
example and instead of the object being updated a new object is created with 
the status set to PENDING.

The application should only display a single unique game (game_id) where the 
latest(created_at) record status is (APPROVED).

 

Example, I have cut out most of the bulk one to many links, fields etc. so it 
is easier to share:

 

My View:

class ViewGameList(ListView):

model = GameDetails

template_name = 'games/list_all_games.html'

paginate_by = 60  # if pagination is desired

 

def get(self, request, **kwargs):

 

self.object_list  = GameDetails.objects.raw("""

SELECT temp.*

FROM gamedetails temp

INNER JOIN

(SELECT game_id, MAX(created_at) AS MaxDateTime, MAX(id) AS MaxID

FROM gamedetails

WHERE status = ‘APRO’

GROUP BY game_id) grouped_join 

ON temp.game_id = grouped_join. game_id

AND temp.created_at = grouped_join.MaxDateTime

AND temp.id = grouped_join.MaxID

""")

 

return self.render_to_response(self.get_context_data())

 

 

My Model:

class GameDetails(models.Model):

name   = models.TextField(blank=False)

game= models.ForeignKey(Game, on_delete=models.CASCADE)

   created_at  = models.DateTimeField(auto_now_add=True) 

APPROVED = 'APRO'

PENDING  = 'PEND'

DECLINED = 'DECL'

STATUS_TYPES = (

(APPROVED, 'Approved'),

(PENDING, 'Pending Approval'),

(DECLINED, 'Declined'),

)

status  = models.CharField(max_length=25, choices=STATUS_TYPES, 
default=PENDING) 

 

 

From: django-users@googlegroups.com  On Behalf 
Of wd
Sent: Saturday, 26 October 2019 11:43 AM
To: django-users@googlegroups.com
Subject: Re: Database ORM query Help

 

I think you could consider using raw sql, 
https://docs.djangoproject.com/en/2.2/topics/db/sql/#executing-custom-sql-directly

 

On Fri, Oct 25, 2019 at 7:56 PM Cheda me mailto:dvdce...@gmail.com> > wrote:

Hey guys,

 

I have worked out the SQL query I would like to implement but am currently 
struggling to create the Django query. I have been attempting to use the 
.aggregate() & Max() methods but cant seem to get the right result. Any help is 
much appropriated.

 

SELECT temp.*
FROM item_detail temp
INNER JOIN
(SELECT item, MAX(created_date) AS MaxDateTime, MAX(id) AS MaxID
FROM item_detail
WHERE approved = true
GROUP BY item) grouped_join 
ON temp.item = grouped_join.item 
AND temp.created_date = grouped_join.MaxDateTime
AND temp.id <http://temp.id>  = grouped_join.MaxID

 

 

CREATE TABLE item_detail
(
id INT,
item INT,
created_date TIMESTAMP,
description VARCHAR(10),
approved BOOLEAN

);

INSERT INTO item_detail VALUES(1, 1, '2009-04-03', 'dk', true);
INSERT INTO item_detail VALUES(2, 1, '2009-04-03', 'dk mama', false);
INSERT INTO item_detail VALUES(3, 1, '2009-03-04', 'dk 2', true);
INSERT INTO item_detail VALUES(4, 2, '2009-03-04', 'botw', true);
INSERT INTO item_detail VALUES(5, 2, '2009-04-04', 'botw 2', true);
INSERT INTO item_detail VALUES(6, 3, '2009-03-05', 'cod mw', true);
INSERT INTO item_detail VALUES(7, 4, '2008-12-25', 'bf 4', true);
INSERT INTO item_detail VALUES(8, 4, '2009-01-05', 'bf mw', false);
INSERT INTO item_detail VALUES(9, 2, '2009-04-06', 'botw 4', false);
INSERT INTO item_detail VALUES(10, 3, '2009-04-06', 'cod newy', false);
INSERT INTO item_detail VALUES(12, 1, '2009-04-07', 'dk ea', false);
INSERT INTO item_detail VALUES(13, 1, '2009-05-08', 'dk 3', true);
INSERT INTO item_detail VALUES(14, 1, '2009-05-08', 'dk 3-3', true);

 

 

Here is the link to the SQL Fiffle: http://www.sqlfiddle.com/#!17/260b62/1

-- 
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 
<mailto:django-users+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com?utm_medium=email_source=footer>
 .

-- 
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 
<mailto:django-users+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABexzmgXY0XHjsLNe2%2BTwN1F8cJwX9%3DHYL2EoF56XzzD4M_xew%40mail.gmail.com

Re: Database ORM query Help

2019-10-25 Thread wd
I think you could consider using raw sql,
https://docs.djangoproject.com/en/2.2/topics/db/sql/#executing-custom-sql-directly

On Fri, Oct 25, 2019 at 7:56 PM Cheda me  wrote:

> Hey guys,
>
> I have worked out the SQL query I would like to implement but am currently
> struggling to create the Django query. I have been attempting to use the
> .aggregate() & Max() methods but cant seem to get the right result. Any
> help is much appropriated.
>
> SELECT temp.*
> FROM item_detail temp
> INNER JOIN
> (SELECT item, MAX(created_date) AS MaxDateTime, MAX(id) AS MaxID
> FROM item_detail
> WHERE approved = true
> GROUP BY item) grouped_join
> ON temp.item = grouped_join.item
> AND temp.created_date = grouped_join.MaxDateTime
> AND temp.id = grouped_join.MaxID
>
>
> CREATE TABLE item_detail
> (
> id INT,
> item INT,
> created_date TIMESTAMP,
> description VARCHAR(10),
> approved BOOLEAN
>
> );
>
> INSERT INTO item_detail VALUES(1, 1, '2009-04-03', 'dk', true);
> INSERT INTO item_detail VALUES(2, 1, '2009-04-03', 'dk mama', false);
> INSERT INTO item_detail VALUES(3, 1, '2009-03-04', 'dk 2', true);
> INSERT INTO item_detail VALUES(4, 2, '2009-03-04', 'botw', true);
> INSERT INTO item_detail VALUES(5, 2, '2009-04-04', 'botw 2', true);
> INSERT INTO item_detail VALUES(6, 3, '2009-03-05', 'cod mw', true);
> INSERT INTO item_detail VALUES(7, 4, '2008-12-25', 'bf 4', true);
> INSERT INTO item_detail VALUES(8, 4, '2009-01-05', 'bf mw', false);
> INSERT INTO item_detail VALUES(9, 2, '2009-04-06', 'botw 4', false);
> INSERT INTO item_detail VALUES(10, 3, '2009-04-06', 'cod newy', false);
> INSERT INTO item_detail VALUES(12, 1, '2009-04-07', 'dk ea', false);
> INSERT INTO item_detail VALUES(13, 1, '2009-05-08', 'dk 3', true);
> INSERT INTO item_detail VALUES(14, 1, '2009-05-08', 'dk 3-3', true);
>
>
> Here is the link to the SQL Fiffle: http://www.sqlfiddle.com/#!17/260b62/1
>
> --
> 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/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CABexzmgXY0XHjsLNe2%2BTwN1F8cJwX9%3DHYL2EoF56XzzD4M_xew%40mail.gmail.com.


Re: Query regarding Jija templates with django project

2019-10-25 Thread red
Hello,

Your views have a 'name' attribute. You can also give a name to an app
in the urls.py file of the app, right above your urlpatterns list:

app_name = "myappname"

urlpatterns = [
path('', views.index, name='index'), path('about', views.about, 
name='about'), path('blog', views.blog, name='blog'), ]


Then, when you need to put a link to a another page in your template,
use the following syntax:

Home About Us

Regards,

Red

On 25/10/2019 21:01, 'Amitesh Sahay' via Django users wrote:
> Hello Team,
>
> I am kind of new to software development, and trying to find my feat.
> I have a queries which could be quite dumb to most of you, but I need
> to know.
>  
> As far as I know, we need Jija templates in the HTML files, so that we
> can assign correct path of the static files.
>
> Its a general practice to create base.html and extend this in other
> HTML files. Since, I am new to development, so I want to do things in
> a stupid way, I have a HTML templates, and I do not wish to create
> base.html for now. Therefore, if I want to render the html page, I
> need to create views.py , urls.py, and modify the HTML pages to use
> 'static' any where required. Below are the snippet of my test environment.
>
> views.py
>
> from django.shortcuts import render, get_object_or_404
>
>
> def index(request):
> return render(request, 'index.html')
>
>
> def blog(request):
> return render(request, 'blog.html')
>
>
> def about(request):
> return render(request, 'about.html')
> project/urls.py
>
> from django.contrib import admin
> from django.urls import path, include
> from django.conf import settings
> from django.conf.urls.static import static
>
> urlpatterns = [
> path('admin/', admin.site.urls), path('blog/', include('BLOG.urls'))
> ]
>
> if settings.DEBUG:
>urlpatterns += static(settings.STATIC_URL, 
> document_root=settings.STATIC_ROOT)
> APP/urls.py
>
> from django.urls import path
> from django.conf import settings
> from . import views
>
> urlpatterns = [
> path('', views.index, name='index'), path('about', views.about, 
> name='about'), path('blog', views.blog, name='blog'), ]
> below is the HTML(index.html) file, which I modified as per my limited
> understanding.
>
> {% load staticfiles %}
> {% block content %}
>   xmlns="http://www.w3.org/1999/xhtml;>   http-equiv="Content-Type" content="text/html; charset=utf-8" /> Orange 
> Theme - Free Website Template  
>  content="" />  
>   var flashvars = {};
>flashvars.xml_file = "photo_list.xml";
>var params = {};
>params.wmode = "transparent";
>var attributes = {};
>attributes.id = "slider";
>swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "440", "220", 
> "9.0.0", false, flashvars, params, attributes);
> src="{% static 'js/ddsmoothmenu.js' %}"> 
> /***
> * Smooth Navigational Menu- (c) Dynamic Drive DHTML code library 
> (www.dynamicdrive.com)
> * This notice MUST stay intact for legal use
> * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
> ***/
>
>   ddsmoothmenu.init({
>mainmenuid: "tooplate_menu", //menu DIV id
>orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
>classname: 'ddsmoothmenu', //class added to menu's outer DIV
>//customtheme: ["#1c5a80", "#18374a"],
>contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
> })
>
>  id="tooplate_header"> Orange HTML 
> Template  
> Home  href="{% 'about.html' %}">About Us  History 
> Our Team Vision and Mission 
>   Portfolio   href="#">Website Templates Web Design 
> Free Templates HTML CSS 
> Layouts Web Developmenthref="{% 'blog.html' %}">Blog Contact   id="tooplate_social">href="#">  href="#"> /> id="flash_grid_slider">  href="http://www.adobe.com/go/getflashplayer;>  src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif;
> alt="Get Adobe Flash player" />
>  Website Template
>Aliquam in odio ut ipsum mollis facilisis. Integer est 
> sem, dignissim quis auctor vel, dapibus vel massa. Curabitur vulputate ligula 
> vel mi semper tempus.   
>  class="cleaner">id="tooplate_main_top">   class="col_fw">  New 
> Standard  
>  Vivamus a velit. Vivamus leo velit, convallis id, ultrices sit amet, 
> validate http://validator.w3.org/check?uri=referer;
> rel="nofollow">XHTML and  href="http://jigsaw.w3.org/css-validator/check/referer;
> rel="nofollow">CSS.   href="#">Detail   High 
> Quality  /> Donec pharetra orci id tortor cursus eu ultricies velit vehicula. 
> Phasellus eu ante tellus. Detail   class="col_allw270 fp_service_box col_last"> Solid Platform  src="{% static 'img/rosette-48px.png' %}" alt="Rosette" /> Curabitur sed 
> lectus id erat viverra consectetur nec in sapien. Etiam vitae tortor mi. 
> Detail
>  class="cleaner">  
>   Pages  

Query regarding Jija templates with django project

2019-10-25 Thread 'Amitesh Sahay' via Django users
Hello Team, 

I am kind of new to software development, and trying to find my feat. I have a 
queries which could be quite dumb to most of you, but I need to know. As far as 
I know, we need Jija templates in the HTML files, so that we can assign correct 
path of the static files. 

Its a general practice to create base.html and extend this in other HTML files. 
Since, I am new to development, so I want to do things in a stupid way, I have 
a HTML templates, and I do not wish to create base.html for now. Therefore, if 
I want to render the html page, I need to create views.py , urls.py, and modify 
the HTML pages to use 'static' any where required. Below are the snippet of my 
test environment.
views.py
from django.shortcuts import render, get_object_or_404


def index(request):
return render(request, 'index.html')


def blog(request):
return render(request, 'blog.html')


def about(request):
return render(request, 'about.html')
project/urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('blog/', include('BLOG.urls'))
]

if settings.DEBUG:
   urlpatterns += static(settings.STATIC_URL, 
document_root=settings.STATIC_ROOT)APP/urls.py
from django.urls import path
from django.conf import settings
from . import views

urlpatterns = [
path('', views.index, name='index'),
path('about', views.about, name='about'),
path('blog', views.blog, name='blog'),

]below is the HTML(index.html) file, which I modified as per my limited 
understanding.
{% load staticfiles %}
{% block content %}

http://www.w3.org/1999/xhtml;>


Orange Theme - Free Website Template







   var flashvars = {};
   flashvars.xml_file = "photo_list.xml";
   var params = {};
   params.wmode = "transparent";
   var attributes = {};
   attributes.id = "slider";
   swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "440", "220", 
"9.0.0", false, flashvars, params, attributes);







/***
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library 
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***/





ddsmoothmenu.init({
   mainmenuid: "tooplate_menu", //menu DIV id
   orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
   classname: 'ddsmoothmenu', //class added to menu's outer DIV
   //customtheme: ["#1c5a80", "#18374a"],
   contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})







   
   
   Orange HTML Template


  
   
   Home
   About Us

History
Our Team
Vision and Mission
   
   
Portfolio

Website Templates
Web Design
Free Templates
HTML CSS Layouts
Web Development
   
   
Blog
Contact

 

 













http://www.adobe.com/go/getflashplayer;>
http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif; 
alt="Get Adobe Flash player" />



  


Website Template
  
Aliquam in odio ut ipsum mollis facilisis. Integer est sem, 
dignissim quis auctor vel, dapibus vel massa. Curabitur vulputate ligula vel mi 
semper tempus.


  

 



   


New Standard

 Vivamus a velit. Vivamus leo velit, convallis id, ultrices 
sit amet, validate http://validator.w3.org/check?uri=referer; 
rel="nofollow">XHTML and http://jigsaw.w3.org/css-validator/check/referer; 
rel="nofollow">CSS. 
Detail

 

High Quality

Donec pharetra orci id tortor cursus eu ultricies velit 
vehicula. Phasellus eu ante tellus.
Detail

 

Solid Platform

Curabitur sed lectus id erat viverra consectetur nec in 
sapien. Etiam vitae tortor mi.
Detail

 


  
 

   



   
   Pages

Home
About Us
 

Re: Database ORM query Help

2019-10-25 Thread Samiul Sk
Please post the code of Model and explain what do you want as Queryset?


On Fri, 25 Oct 2019 at 17:26, Cheda me  wrote:

> Hey guys,
>
> I have worked out the SQL query I would like to implement but am currently
> struggling to create the Django query. I have been attempting to use the
> .aggregate() & Max() methods but cant seem to get the right result. Any
> help is much appropriated.
>
> SELECT temp.*
> FROM item_detail temp
> INNER JOIN
> (SELECT item, MAX(created_date) AS MaxDateTime, MAX(id) AS MaxID
> FROM item_detail
> WHERE approved = true
> GROUP BY item) grouped_join
> ON temp.item = grouped_join.item
> AND temp.created_date = grouped_join.MaxDateTime
> AND temp.id = grouped_join.MaxID
>
>
> CREATE TABLE item_detail
> (
> id INT,
> item INT,
> created_date TIMESTAMP,
> description VARCHAR(10),
> approved BOOLEAN
>
> );
>
> INSERT INTO item_detail VALUES(1, 1, '2009-04-03', 'dk', true);
> INSERT INTO item_detail VALUES(2, 1, '2009-04-03', 'dk mama', false);
> INSERT INTO item_detail VALUES(3, 1, '2009-03-04', 'dk 2', true);
> INSERT INTO item_detail VALUES(4, 2, '2009-03-04', 'botw', true);
> INSERT INTO item_detail VALUES(5, 2, '2009-04-04', 'botw 2', true);
> INSERT INTO item_detail VALUES(6, 3, '2009-03-05', 'cod mw', true);
> INSERT INTO item_detail VALUES(7, 4, '2008-12-25', 'bf 4', true);
> INSERT INTO item_detail VALUES(8, 4, '2009-01-05', 'bf mw', false);
> INSERT INTO item_detail VALUES(9, 2, '2009-04-06', 'botw 4', false);
> INSERT INTO item_detail VALUES(10, 3, '2009-04-06', 'cod newy', false);
> INSERT INTO item_detail VALUES(12, 1, '2009-04-07', 'dk ea', false);
> INSERT INTO item_detail VALUES(13, 1, '2009-05-08', 'dk 3', true);
> INSERT INTO item_detail VALUES(14, 1, '2009-05-08', 'dk 3-3', true);
>
>
> Here is the link to the SQL Fiffle: http://www.sqlfiddle.com/#!17/260b62/1
>
> --
> 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/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAPTaHEufZJ6Y1V4e4zYtKJbzJa3Q1aTQMxY6f1SJDCR6auBcNw%40mail.gmail.com.


Database ORM query Help

2019-10-25 Thread Cheda me
Hey guys,

I have worked out the SQL query I would like to implement but am currently 
struggling to create the Django query. I have been attempting to use the 
.aggregate() & Max() methods but cant seem to get the right result. Any 
help is much appropriated.

SELECT temp.*
FROM item_detail temp
INNER JOIN
(SELECT item, MAX(created_date) AS MaxDateTime, MAX(id) AS MaxID
FROM item_detail
WHERE approved = true
GROUP BY item) grouped_join 
ON temp.item = grouped_join.item 
AND temp.created_date = grouped_join.MaxDateTime
AND temp.id = grouped_join.MaxID


CREATE TABLE item_detail
(
id INT,
item INT,
created_date TIMESTAMP,
description VARCHAR(10),
approved BOOLEAN

);

INSERT INTO item_detail VALUES(1, 1, '2009-04-03', 'dk', true);
INSERT INTO item_detail VALUES(2, 1, '2009-04-03', 'dk mama', false);
INSERT INTO item_detail VALUES(3, 1, '2009-03-04', 'dk 2', true);
INSERT INTO item_detail VALUES(4, 2, '2009-03-04', 'botw', true);
INSERT INTO item_detail VALUES(5, 2, '2009-04-04', 'botw 2', true);
INSERT INTO item_detail VALUES(6, 3, '2009-03-05', 'cod mw', true);
INSERT INTO item_detail VALUES(7, 4, '2008-12-25', 'bf 4', true);
INSERT INTO item_detail VALUES(8, 4, '2009-01-05', 'bf mw', false);
INSERT INTO item_detail VALUES(9, 2, '2009-04-06', 'botw 4', false);
INSERT INTO item_detail VALUES(10, 3, '2009-04-06', 'cod newy', false);
INSERT INTO item_detail VALUES(12, 1, '2009-04-07', 'dk ea', false);
INSERT INTO item_detail VALUES(13, 1, '2009-05-08', 'dk 3', true);
INSERT INTO item_detail VALUES(14, 1, '2009-05-08', 'dk 3-3', true);


Here is the link to the SQL Fiffle: http://www.sqlfiddle.com/#!17/260b62/1

-- 
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/88f11149-eb65-4d0b-ad6e-729d9db6c6d2%40googlegroups.com.


Re: how to use django pagination with sql query and not ORM

2019-09-24 Thread Deep Sukhwani
Have you tried using the *.query* on Django's QuerySet (documentation: [1])

For example, if my QuerySet is:
*User.objects.filter(username__contains='alpha')*

I can obtain the underlying raw SQL Query using:
*print(User.objects.filter(username__contains='alpha').query)*
*>>> *print(User.objects.filter(username__contains='alpha').query)
SELECT `auth_user`.`id`, `auth_user`.`password`, `auth_user`.`last_login`,
`auth_user`.`is_superuser`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`, `auth_user`.`email`,
`auth_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`date_joined`
FROM `auth_user` WHERE `auth_user`.`username` LIKE BINARY %alpha%

1:
https://docs.djangoproject.com/en/2.2/topics/db/sql/#performing-raw-queries

--
Regards
Deep L Sukhwani


On Wed, 25 Sep 2019 at 00:47, leb dev  wrote:

> I now how to use django pagination with ORM django after filtering the
> required data and put in into *pagination div*
>
> *queryset_list = employee.objects.all()*
> *query=request.GET.get("q")*
> *if query:*
> *queryset_list=queryset_list.filter(*
> *  Q(name__icontains=query)|*
> *  Q(father_name__icontains=query)|*
> *  Q(mother_name__icontains=query)|*
> *  Q(content__icontains=query)|*
> *  Q(create_date__icontains=query)*
> *  # Q(user__first_name__contains=query)*
> *).distinct()*
>
>
> *paginator = Paginator(queryset_list, 5)*
> *page_request_var = "page"*
> *page = request.GET.get(page_request_var)*
> *queryset = paginator.get_page(page)*
>
> *context={*
> *"object_list":queryset,*
> *"title":"List Items",*
> *"page_request_var":page_request_var,*
> *}*
> *return render(request,"blog/list.html", context)*
>
>
> the above code is working
>
> my question is how to convert this ORM into raw SQL
>
> i know that i must use LIMIT and OFFSET  in raw SQL  to embedded into
> paginator.
>
>
>
> --
> 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/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAEMqiPc5zqcT%2BaPYSySLCJe22nPC-fCk_RkaTvWvRx5CSqkXQA%40mail.gmail.com.


how to use django pagination with sql query and not ORM

2019-09-24 Thread leb dev
I now how to use django pagination with ORM django after filtering the 
required data and put in into *pagination div*

*queryset_list = employee.objects.all()*
*query=request.GET.get("q")*
*    if query:*
*queryset_list=queryset_list.filter(*
*  Q(name__icontains=query)|*
*  Q(father_name__icontains=query)|*
*  Q(mother_name__icontains=query)|*
*  Q(content__icontains=query)|*
*  Q(create_date__icontains=query)*
*  # Q(user__first_name__contains=query)*
*).distinct()*


*paginator = Paginator(queryset_list, 5)*
*page_request_var = "page"*
*page = request.GET.get(page_request_var)*
*queryset = paginator.get_page(page)*

*context={*
*"object_list":queryset,*
*"title":"List Items",*
*"page_request_var":page_request_var,*
*}*
*return render(request,"blog/list.html", context)*


the above code is working 

my question is how to convert this ORM into raw SQL 

i know that i must use LIMIT and OFFSET  in raw SQL  to embedded into 
paginator.



-- 
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/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com.


Re: how to use sql select query with pyodbc and django ?

2019-09-18 Thread Cornelis Poppema
I am not using pyodbc, but I imagine you should %s instead of ? as 
parameter marker. mysql-python actually uses python interpolation to build 
the query instead of simply replacing the ? signs, so pyodbc might do the 
same. If that's the case, it makes sense the error says there are 0 
parameter markers. For reference, check the example from the docs: 
https://docs.djangoproject.com/en/2.2/topics/db/sql/#passing-parameters-into-raw

>>> lname = 'Doe'>>> Person.objects.raw('SELECT * FROM myapp_person WHERE 
>>> last_name = %s', [lname])



On Wednesday, 18 September 2019 08:36:59 UTC+2, leb dev wrote:
>
> i have a django code that connect to sql server database and i am trying 
> to select values using *like *but once i try it it crash and the system 
> display the below error:
>
> ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 
> 'HY000')
>
>
> views.py
>
> 
>
>
> from django.shortcuts import render
> import pyodbc
> # from .models import Artist
> # Create your views here.
>
>
> def connect(request):
>  
> conn = pyodbc.connect(
> 'Driver={ODBC Driver 17 for SQL Server};'
> 'Server=DESKTOP-LPD1575\\SQLEXPRESS;'
> 'Database=testDB;'
> 'UID=test;'
> 'PWD=*;'
>
> )
> query = 'jhon'
> cursor = conn.cursor()
>  
> c = cursor.execute('SELECT * FROM Artist where artistName like 
> "%?%"',query)
> print(c)
> return render (request,'connect.html',{"c":c})
>
>
>
> connect.html
> ==
> 
> 
> id
> FolderNumber
> Folderdate
>
> 
> {% for row in c %}
>  
> {{ row.0 }}
> {{ row.1 }}
> {{ row.2 }}
> 
> 
> {% endfor %}
> 
>
>

-- 
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/7c6435ab-0a86-4b4e-9af2-093d713c0502%40googlegroups.com.


how to use sql select query with pyodbc and django ?

2019-09-18 Thread leb dev
i have a django code that connect to sql server database and i am trying to 
select values using *like *but once i try it it crash and the system 
display the below error:

('The SQL contains 0 parameter markers, but 1 parameters were supplied', 
'HY000')


views.py




from django.shortcuts import render
import pyodbc
# from .models import Artist
# Create your views here.


def connect(request):
 
conn = pyodbc.connect(
'Driver={ODBC Driver 17 for SQL Server};'
'Server=DESKTOP-LPD1575\\SQLEXPRESS;'
'Database=testDB;'
'UID=test;'
'PWD=*;'

)
query = 'jhon'
cursor = conn.cursor()
 
c = cursor.execute('SELECT * FROM Artist where artistName like "%?%"',query)
print(c)
return render (request,'connect.html',{"c":c})



connect.html
==


id
FolderNumber
Folderdate
   

{% for row in c %}
 
{{ row.0 }}
{{ row.1 }}
{{ row.2 }}


{% endfor %}


-- 
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/485f0fc0-c340-460c-aef3-00177c8a2ef7%40googlegroups.com.


Django query set

2019-09-15 Thread Suraj Thapa FC
https://hastebin.com/powupucitu.sql

Can anyone convert this into queryset...

-- 
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/CAPjsHcExuHfUgmaDUPhz6SgGSi_1bvXw2KJNQS006nL7LOZ9JQ%40mail.gmail.com.


Merging or joining raw query set results.

2019-09-14 Thread ML
Hi,

I have a raw query which takes in 4 ids within a for loop. It therefore 
returns 4 query set results.

I put the result of each query set into a dictionary and append it to a 
list.
The result looks something like this:

[{'first_name': u'John'}, {'first_name': u'Jack'}, {'first_name': u'Jill'}]
[ ]
[{'first_name': u'James'}, {'first_name': u'Phil'}]
[{'first_name': u'Bill'}]

I'm trying to merge the query set results into one list to get something 
like
[{'first_name': u'John'}, {'first_name': u'Jack'}, {'first_name': u'Jill'}, 
{'first_name': u'James'}, {'first_name': u'Phil'}, {'first_name': u'Bill'}]

Any help will be 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/f2f82a83-ffc9-433b-af7a-eb2a513ce225%40googlegroups.com.


Re: Query help

2019-09-12 Thread Matt
Tosin,
Please refer below. This should help.
https://docs.djangoproject.com/en/2.2/topics/db/queries/


best,
matt

On Thu, Sep 12, 2019 at 10:01 AM Tosin Ayoola 
wrote:

> Halo guyz I actually need a little help, I'm working on a airline tickets
> reservations project using postman Api that requires making query for
> available flight going to a particular destination,  from a particular
> city, arrival date & departure  date & I got no idea on how to write the
> query,  Pls can anyone help out 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/CAHLKn70jgSAAHL9YtX5Y6-9BWNdx42i0-0LnVt%3DQCPB-Bgjwow%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHLKn70jgSAAHL9YtX5Y6-9BWNdx42i0-0LnVt%3DQCPB-Bgjwow%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CACZnaa%3Dg3HuiOUFidFB%2BJL7GSWvTZ2%2Bg-Ow%3D2dtxECnN%3DirBMQ%40mail.gmail.com.


Query help

2019-09-12 Thread Tosin Ayoola
Halo guyz I actually need a little help, I'm working on a airline tickets
reservations project using postman Api that requires making query for
available flight going to a particular destination,  from a particular
city, arrival date & departure  date & I got no idea on how to write the
query,  Pls can anyone help out 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/CAHLKn70jgSAAHL9YtX5Y6-9BWNdx42i0-0LnVt%3DQCPB-Bgjwow%40mail.gmail.com.


Re: Query into Django ORM

2019-09-10 Thread Ronit Mishra
Hi Amit,

Excuse me for my straight forwardness, but this not a challenge. From what
I can see is, you want someone to write you the complete code for your
models.

You didn't even write a single line of code, and you're expecting someone
to write the whole damn thing for you. Unless you're willing to pay for
this, I for sure wont help you.

Take this email as constructive criticism, and either start working on your
own or hire someone. Don't spam my inbox.

Regards,
Ronnie

On Tue, Sep 10, 2019 at 11:31 AM N'BE SORO  wrote:

> Hello please send your models example and.
>
> Le jeu. 5 sept. 2019 à 14:56, Amit Samanta  a
> écrit :
>
>> Hi,
>>
>> I am facing a challenge please help me.
>>
>> [image: Query.PNG]
>>
>>
>> output:
>>
>> [image: output.PNG]
>>
>> Here one env_name can have many comp name and one env with one comp_name
>> there will be many deploy_details which is in green colour (latest).
>>
>> in deploy_detail if there is two deploy in one component we will take the
>> latest deploy_date.
>>
>>
>> Now please can anyone help me in converting this query into Django ORM
>> and the models
>>
>> 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/db10af4c-ef4c-47cb-82fd-a442d3b381ab%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/db10af4c-ef4c-47cb-82fd-a442d3b381ab%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAOtSHp_5uVs1zmqDz%3DXNb%3DZJmB_yvL%3DNqBt0WPtDL0nbsez0yw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAOtSHp_5uVs1zmqDz%3DXNb%3DZJmB_yvL%3DNqBt0WPtDL0nbsez0yw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CACh0Ehwf70Ym%3DE9hUs%3Dw7LsAT6JKHZo%3DpK9mdZHYYKT7hztUmQ%40mail.gmail.com.


Re: Query into Django ORM

2019-09-10 Thread N'BE SORO
Hello please send your models example and.

Le jeu. 5 sept. 2019 à 14:56, Amit Samanta  a
écrit :

> Hi,
>
> I am facing a challenge please help me.
>
> [image: Query.PNG]
>
>
> output:
>
> [image: output.PNG]
>
> Here one env_name can have many comp name and one env with one comp_name
> there will be many deploy_details which is in green colour (latest).
>
> in deploy_detail if there is two deploy in one component we will take the
> latest deploy_date.
>
>
> Now please can anyone help me in converting this query into Django ORM and
> the models
>
> 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/db10af4c-ef4c-47cb-82fd-a442d3b381ab%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/db10af4c-ef4c-47cb-82fd-a442d3b381ab%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAOtSHp_5uVs1zmqDz%3DXNb%3DZJmB_yvL%3DNqBt0WPtDL0nbsez0yw%40mail.gmail.com.


Re: how to pass user input into raw sql query ?

2019-09-08 Thread testdevleb
Sent from my Samsung Galaxy smartphone.
I tried daniel solution and this was right.

-- 
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/5d751fca.1c69fb81.8be36.2078%40mx.google.com.


Re: Page 404 - No Job matches the given query.

2019-09-08 Thread Kean
access a given URL

On 7 Sep 2019, at 21:46, Mclaren Sunday  wrote:

> What are you trying to do?
> 
> On Sat, 7 Sep 2019 20:30 Kean,  wrote:
> Hi,
> 
> New to Django, Have an issue. the table exists and the view references the 
> table however, I still get 404 message.
> I have spent 8 hours trying to resolve, nothing seems to work, please help?
> 
> urls.py
> 
>  path('businesslogin/businessadmin/busproject',
>  views.project_detail, name='project_detail'),
> 
> models.py
> 
> class Job(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
> 
> def __str__(self):
> return(self.name)
> 
> 
> class Category(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
> 
> def __str__(self):
> return(self.project)
> 
> class Expense(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> 
> def __str__(self):
> return(self.project)
> 
> views.py
> 
> def project_detail(request):
> project = get_object_or_404(Job)
> return render(request, 'projectdetail.html', {'project': project, 
> 'expense_list': project.expenses.all()})
> 
> 
> Error message:
> 
> Page not found (404)
> Request Method:   GET
> Request URL:  http://127.0.0.1:8000/businesslogin/businessadmin/busproject
> Raised by:core.views.project_detail
> No Job matches the given query.
> 
> 
> 
> 
> 
> 
> 
> Please can anyone help, with getting the url to connect and resolving this 
> error?
> 
> 
> 
> Best 
> 
> 
> 
> Kean
> 
> 
> -- 
> 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/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%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/CAPm7yyWW0kecfF3Rfu8tYnwfR5FtStj%3D9FWHLfjXQUCVth9WPg%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/09347CDD-59ED-47AA-8729-F2839699BC68%40gmail.com.


Re: Page 404 - No Job matches the given query.

2019-09-07 Thread Mclaren Sunday
What are you trying to do?

On Sat, 7 Sep 2019 20:30 Kean,  wrote:

> Hi,
>
> New to Django, Have an issue. the table exists and the view references the
> table however, I still get 404 message.
> I have spent 8 hours trying to resolve, nothing seems to work, please help?
>
> urls.py
>
>  path('businesslogin/businessadmin/busproject',
>  views.project_detail, name='project_detail'),
>
> models.py
>
> class Job(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
>
> def __str__(self):
> return(self.name)
>
>
> class Category(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
>
> def __str__(self):
> return(self.project)
>
> class Expense(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>
> def __str__(self):
> return(self.project)
>
> views.py
>
> def project_detail(request):
> project = get_object_or_404(Job)
> return render(request, 'projectdetail.html', {'project': project,
> 'expense_list': project.expenses.all()})
>
>
> Error message:
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/businesslogin/businessadmin/busproject
> Raised by: core.views.project_detail
>
> No Job matches the given query.
>
>
>
>
> Please can anyone help, with getting the url to connect and resolving this
> error?
>
>
> Best
>
>
> Kean
>
> --
> 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/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAPm7yyWW0kecfF3Rfu8tYnwfR5FtStj%3D9FWHLfjXQUCVth9WPg%40mail.gmail.com.


Re: how to pass user input into raw sql query ?

2019-09-07 Thread Mario R. Osorio
*Do not use string interpolation* as proposed by Bhoopesh!!!

Take a look at:

   - SQL injection <https://en.wikipedia.org/wiki/SQL_injection>
   
   
<https://docs.djangoproject.com/en/2.2/topics/security/#sql-injection-protection>
   - SQL injection protection 
   
<https://docs.djangoproject.com/en/2.2/topics/security/#sql-injection-protection>
 
   and
   - Passing parameters into raw() 
   
<https://docs.djangoproject.com/en/2.2/topics/db/sql/#passing-parameters-into-raw>
   

On Friday, September 6, 2019 at 6:59:04 AM UTC-4, leb dev wrote:
>
> i have a django project that is connected to sql server  database i am 
> trying to write a *select query *  #convert the Django ORM into SQL query
> print("sql query  = ",FilterQuery.query)
>  
> *select * from table name where filed name = user input *
>
>
> *can anyone help me with 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/14d1748a-9b51-47b6-83ad-7a4235c0ec9b%40googlegroups.com.


Re: User matching query does not exist.

2019-09-07 Thread Gabriel Stone
Tamam all the best

On Sat, Sep 7, 2019 at 23:12 göktürk sığırtmaç 
wrote:

> I solved it!!! using ObjectDoesNotExist via javatpoint. (
> https://www.javatpoint.com/django-exceptions)
>
> try:
> user = User.objects.get(email=email)
> except ObjectDoesNotExist:
> user = None;
>
>
> 7 Eylül 2019 Cumartesi 23:36:00 UTC+3 tarihinde göktürk sığırtmaç yazdı:
>>
>> I'm trying get user according to email.
>>
>> user = User.objects.get(email=email)
>>
>>
>> if user is none, i will show message. I will check password after. But
>> when i trying login with wrong email address for test i have error "User
>> matching query does not exist.". How can i handle this error to convert
>> message. I have tried this
>>
>> try:
>> user = User.objects.get(email=email)
>> except:
>> user = None;
>>
>>
>> if user is None:
>> messages.warning(request, "Email hatalı")
>> print("email is wrong")
>> return render(request, "login.html", context)
>>
>>
>>  code but my each login attempt, i have message "e mail is wrong"
>>
>>
>> --
> 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/0b36cb1f-d42c-4783-86a7-fcfaf0cbfb99%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0b36cb1f-d42c-4783-86a7-fcfaf0cbfb99%40googlegroups.com?utm_medium=email_source=footer>
> .
>
-- 
Gabrielstone

-- 
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/CAL-5MpV8y_rfdDxDR7KsgCeD%3Dys3aQALvi_yOGeWOyYqtBrw_Q%40mail.gmail.com.


Re: User matching query does not exist.

2019-09-07 Thread göktürk sığırtmaç
I solved it!!! using ObjectDoesNotExist via javatpoint. (
https://www.javatpoint.com/django-exceptions) 

try:
user = User.objects.get(email=email)
except ObjectDoesNotExist:
user = None;


7 Eylül 2019 Cumartesi 23:36:00 UTC+3 tarihinde göktürk sığırtmaç yazdı:
>
> I'm trying get user according to email.
>
> user = User.objects.get(email=email)
>
>
> if user is none, i will show message. I will check password after. But 
> when i trying login with wrong email address for test i have error "User 
> matching query does not exist.". How can i handle this error to convert 
> message. I have tried this
>
> try:
> user = User.objects.get(email=email)
> except:
> user = None;
>
>
> if user is None:
> messages.warning(request, "Email hatalı")
> print("email is wrong")
> return render(request, "login.html", context)
>
>
>  code but my each login attempt, i have message "e mail is wrong"
>
>
>

-- 
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/0b36cb1f-d42c-4783-86a7-fcfaf0cbfb99%40googlegroups.com.


Re: User matching query does not exist.

2019-09-07 Thread göktürk sığırtmaç
Yes i get name email password in register, i get email and password in 
login 

7 Eylül 2019 Cumartesi 23:47:41 UTC+3 tarihinde Gabriel Stone yazdı:
>
> In your user creation form did you add an email field?if you did then only 
> can you query users by their email 
>
> On Sat, Sep 7, 2019 at 22:36 göktürk sığırtmaç  > wrote:
>
>> I'm trying get user according to email.
>>
>> user = User.objects.get(email=email)
>>
>>
>> if user is none, i will show message. I will check password after. But 
>> when i trying login with wrong email address for test i have error "User 
>> matching query does not exist.". How can i handle this error to convert 
>> message. I have tried this
>>
>> try:
>> user = User.objects.get(email=email)
>> except:
>> user = None;
>>
>>
>> if user is None:
>> messages.warning(request, "Email hatalı")
>> print("email is wrong")
>> return render(request, "login.html", context)
>>
>>
>>  code but my each login attempt, i have message "e mail is wrong"
>>
>>
>> -- 
>> 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/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> -- 
> Gabrielstone
>

-- 
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/449722c8-b307-4001-aac6-cf4102e30bb4%40googlegroups.com.


Re: User matching query does not exist.

2019-09-07 Thread Gabriel Stone
In your user creation form did you add an email field?if you did then only
can you query users by their email

On Sat, Sep 7, 2019 at 22:36 göktürk sığırtmaç 
wrote:

> I'm trying get user according to email.
>
> user = User.objects.get(email=email)
>
>
> if user is none, i will show message. I will check password after. But
> when i trying login with wrong email address for test i have error "User
> matching query does not exist.". How can i handle this error to convert
> message. I have tried this
>
> try:
> user = User.objects.get(email=email)
> except:
> user = None;
>
>
> if user is None:
> messages.warning(request, "Email hatalı")
> print("email is wrong")
> return render(request, "login.html", context)
>
>
>  code but my each login attempt, i have message "e mail is wrong"
>
>
> --
> 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/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com?utm_medium=email_source=footer>
> .
>
-- 
Gabrielstone

-- 
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/CAL-5MpWb6fpUZs%3Dvrztc%3DjN8RaUNYax1nwGXegR1J-cG0Mk2dA%40mail.gmail.com.


User matching query does not exist.

2019-09-07 Thread göktürk sığırtmaç
I'm trying get user according to email.

user = User.objects.get(email=email)


if user is none, i will show message. I will check password after. But when 
i trying login with wrong email address for test i have error "User 
matching query does not exist.". How can i handle this error to convert 
message. I have tried this

try:
user = User.objects.get(email=email)
except:
user = None;


if user is None:
messages.warning(request, "Email hatalı")
print("email is wrong")
return render(request, "login.html", context)


 code but my each login attempt, i have message "e mail is wrong"


-- 
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/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com.


Page 404 - No Job matches the given query.

2019-09-07 Thread Kean
Hi,

New to Django, Have an issue. the table exists and the view references the 
table however, I still get 404 message.
I have spent 8 hours trying to resolve, nothing seems to work, please help?

urls.py

 path('businesslogin/businessadmin/busproject',
 views.project_detail, name='project_detail'),

models.py

class Job(models.Model):
name = models.CharField(max_length=100)
budget = IntegerField()

def __str__(self):
return(self.name)


class Category(models.Model):
project = models.ForeignKey(
Job, on_delete=models.CASCADE)
name = models.CharField(max_length=150)

def __str__(self):
return(self.project)

class Expense(models.Model):
project = models.ForeignKey(
Job, on_delete=models.CASCADE, related_name='expenses')
title = models.CharField(max_length=100)
amount = models.DecimalField(max_digits=8, decimal_places=2)
category = models.ForeignKey(Category, on_delete=models.CASCADE)

def __str__(self):
return(self.project)

views.py

def project_detail(request):
project = get_object_or_404(Job)
return render(request, 'projectdetail.html', {'project': project, 
'expense_list': project.expenses.all()})


Error message:

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/businesslogin/businessadmin/busproject
Raised by: core.views.project_detail

No Job matches the given query.




Please can anyone help, with getting the url to connect and resolving this 
error?


Best 


Kean

-- 
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/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%40googlegroups.com.


Re: how to pass user input into raw sql query ?

2019-09-07 Thread David Grant
On Sat., Sep. 7, 2019, 8:21 a.m. Daniel Roseman, 
wrote:

> On Friday, 6 September 2019 20:39:58 UTC+1, Bhoopesh sisoudiya wrote:
>>
>> Hi Lev dev,
>>
>> Write your query like this
>>
>>
>> sqlRawQuery = "Your query ... Field name= {}".format (userInput)
>>
>> Thanks
>> Bhoopesh Kumar
>>
>>
>>>
>>>
> No. Do **not** do this, ever.
>
> Use SQL parameters:
>
> query = 'SELECT * FROM whatever WHERE name = %s'
> cursor.execute(query, (user_input,))
>
> Bhoopesh please stop giving bad unsafe advice like this.
> --
> Daniel.
>

Bhoopesh

The reason is that the user input could be used to do something
dangerous It's called SQL injection. The solution be Daniel prevents
this. Look it up...

Dave

-- 
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/CAJPFr9RNJp%3DgfKBOC3ApdHu8nbaRhazYNDG%2BzJ3V9-q9-xroQA%40mail.gmail.com.


Re: how to pass user input into raw sql query ?

2019-09-07 Thread Daniel Roseman
On Friday, 6 September 2019 20:39:58 UTC+1, Bhoopesh sisoudiya wrote:
>
> Hi Lev dev,
>
> Write your query like this 
>
>
> sqlRawQuery = "Your query ... Field name= {}".format (userInput)
>
> Thanks
> Bhoopesh Kumar
>  
>
>>
>>
No. Do **not** do this, ever. 

Use SQL parameters: 

query = 'SELECT * FROM whatever WHERE name = %s'
cursor.execute(query, (user_input,))

Bhoopesh please stop giving bad unsafe advice like this. 
--
Daniel. 

-- 
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/7bb94edb-c558-4dba-bb17-4e71e22b6685%40googlegroups.com.


Re: how to pass user input into raw sql query ?

2019-09-06 Thread Bhoopesh sisoudiya
Hi Lev dev,

Write your query like this


sqlRawQuery = "Your query ... Field name= {}".format (userInput)

Thanks
Bhoopesh Kumar



On Fri, Sep 6, 2019, 4:29 PM leb dev  wrote:

> i have a django project that is connected to sql server  database i am
> trying to write a *select query *  #convert the Django ORM into SQL query
>     print("sql query  = ",FilterQuery.query)
>
> *select * from table name where filed name = user input *
>
>
> *can anyone help me with 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/fa888770-2a9a-4ff6-951b-be085c15cda8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fa888770-2a9a-4ff6-951b-be085c15cda8%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAAk3c1OMymAb68VPSh%3DJjwhuM1Zx%2BoX9XJborLWYQiULD5BPZg%40mail.gmail.com.


how to pass user input into raw sql query ?

2019-09-06 Thread leb dev
i have a django project that is connected to sql server  database i am 
trying to write a *select query *  #convert the Django ORM into SQL query
print("sql query  = ",FilterQuery.query)
 
*select * from table name where filed name = user input *


*can anyone help me with 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/fa888770-2a9a-4ff6-951b-be085c15cda8%40googlegroups.com.


Query into Django ORM

2019-09-05 Thread Amit Samanta
Hi,

I am facing a challenge please help me.

[image: Query.PNG]


output:

[image: output.PNG]

Here one env_name can have many comp name and one env with one comp_name 
there will be many deploy_details which is in green colour (latest).

in deploy_detail if there is two deploy in one component we will take the 
latest deploy_date. 


Now please can anyone help me in converting this query into Django ORM and 
the models 

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/db10af4c-ef4c-47cb-82fd-a442d3b381ab%40googlegroups.com.


model object query

2019-09-04 Thread Dev Gis


Hi All,

How to get the ForeignKey value while querying the model object.


I was trying to query a model object "mla" to fetch a specific sets of columns 
and its working fine but the field ForeignKey "instuid" returning a numeric 
value instant of actual associated value.


Do I need to edit the query in views.py


def mlas_datasets(request):

 mlaAll = 
list(mla.objects.values('mla_name_short','mla_name_full','inst_acronym','mla_type','year_adopted',*'**instuid**'*,'mla_uid'))
 mlaAll = JsonResponse(mlaAll,safe=False)
 return HttpResponse(mlaAll,content_type='json')


Regards

Deb

-- 
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/71e89d44-8beb-4968-bd94-749b5878b43b%40googlegroups.com.


Re: ResultSet with query on multiple models

2019-08-24 Thread Catalina Popescu
Hey, Benoit

You could set up a filter on your admin.py file. Like writing:

class Immunization(admin.ModelAdmin):
list_filter = ('vaccine', 'recorded')

On Friday, August 23, 2019 at 2:19:35 PM UTC+3, Benoit Dupont wrote:
>
> Hello,
>
> I've played a lot of time with Django and it's a great tool for basic 
> query but I don't figure out how to play with Django to do a query spanning 
> between a lot of models.
>
> This is the query I do to display all Animals and their corresponding 
> Vaccines with Encounter.status 'in-progress' and the Immunization date is 
> in the futur.
>
>
> def current_with_futur_vaccines(self):
>
> return (
>
> Encounter.objects.filter(
>
> status="in-progress").filter(
>
> subject__immunizations__recorded__gte=datetime.now(),
>
> )
>
> .select_related("subject")
>
> .prefetch_related("subject__immunizations", "location")
>
> )
>
>
>  {% for immunization in object.subject.immunizations.all %}
>
>  {{ immunization }}
>
> {% endfor %}
>
>
> The things is when I want to list the Immunizations from the query I get 
> all the Immunizations for this animal and not only the Immunizations that 
> have to take place in the futur like I said in the query. I guess it's 
> because of the .all() and what I need is more something like 
> Encounter.subject.immunization_set()
>
>
> This is the model
>
>   
>
> class Animal(models.Model):
>
> name = models.CharField(max_length=250)
>
> 
>
> class Encounter(models.Model):
>
> subject = models.ForeignKey(Animal, on_delete=models.PROTECT)
>
> status = models.CharField(max_length=11)
>
> 
>
> class Vaccine(models.Model):
>
> name = models.CharField(max_length=250)
>
>
> class Immunization(models.Model):
>
> subject = models.ForeignKey(
>
> Animal, on_delete=models.PROTECT, related_name="immunizations"
>
> )
>
> recorded = models.DateTimeField(default=timezone.now)
>
> vaccine = models.ForeignKey(Vaccine, on_delete=models.PROTECT)
>
>
> Thanks for your 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/bd329d36-ce41-4a43-b5b1-d259a85d0759%40googlegroups.com.


Re: ResultSet with query on multiple models

2019-08-24 Thread Benoit Dupont
I think I have figured it out. 
I have to play with models.Prefetch() to restrict the results from the 
prefetch_related()

Can someone confirm this is the right way to do it ?

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/9825d4d1-165a-4347-96a5-7f96bb27bdbd%40googlegroups.com.


ResultSet with query on multiple models

2019-08-23 Thread Benoit Dupont


Hello,

I've played a lot of time with Django and it's a great tool for basic query 
but I don't figure out how to play with Django to do a query spanning 
between a lot of models.

This is the query I do to display all Animals and their corresponding 
Vaccines with Encounter.status 'in-progress' and the Immunization date is 
in the futur.


def current_with_futur_vaccines(self):

return (

Encounter.objects.filter(

status="in-progress").filter(

subject__immunizations__recorded__gte=datetime.now(),

)

.select_related("subject")

.prefetch_related("subject__immunizations", "location")

)


 {% for immunization in object.subject.immunizations.all %}

 {{ immunization }}

{% endfor %}


The things is when I want to list the Immunizations from the query I get 
all the Immunizations for this animal and not only the Immunizations that 
have to take place in the futur like I said in the query. I guess it's 
because of the .all() and what I need is more something like 
Encounter.subject.immunization_set()


This is the model

  

class Animal(models.Model):

name = models.CharField(max_length=250)



class Encounter(models.Model):

subject = models.ForeignKey(Animal, on_delete=models.PROTECT)

status = models.CharField(max_length=11)



class Vaccine(models.Model):

name = models.CharField(max_length=250)


class Immunization(models.Model):

subject = models.ForeignKey(

Animal, on_delete=models.PROTECT, related_name="immunizations"

)

recorded = models.DateTimeField(default=timezone.now)

vaccine = models.ForeignKey(Vaccine, on_delete=models.PROTECT)


Thanks for your 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/7ba3b500-1a6f-41ef-ad34-d35adfe1e7bb%40googlegroups.com.


Re: Django sql raw query to queryset

2019-08-23 Thread Suraj Thapa FC
Invalid field name error

On Fri, 23 Aug, 2019, 11:58 AM Sipum,  wrote:

> You can use Queryset like -
>
> course_review_report.objects.select_related('courses')
>
> On Fri, 23 Aug, 2019, 11:07 AM Suraj Thapa FC, 
> wrote:
>
>> SELECT *
>> FROM course_review_report LEFT JOIN courses ON course_review_report.cid =
>> courses.cid
>>
>>
>> Can anyone pls write the querryset for the above sql query
>>
>> --
>> 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/CAPjsHcFbqD%2BgX1NA8QLYFsJUkb9VydzzcBRrNO2FpCyAgS0nqw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAPjsHcFbqD%2BgX1NA8QLYFsJUkb9VydzzcBRrNO2FpCyAgS0nqw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAGHZBzyCMzkdjvjdAg4MbF0tQgotCZkorunJQbi4v1xEqsFsBw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGHZBzyCMzkdjvjdAg4MbF0tQgotCZkorunJQbi4v1xEqsFsBw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAPjsHcHZj1_ZgWOe2wZV784%2BaZ%2BT%2BySdLcJ3PmiU5BR0ANpB8g%40mail.gmail.com.


Re: Django sql raw query to queryset

2019-08-23 Thread Sipum
You can use Queryset like -

course_review_report.objects.select_related('courses')

On Fri, 23 Aug, 2019, 11:07 AM Suraj Thapa FC, 
wrote:

> SELECT *
> FROM course_review_report LEFT JOIN courses ON course_review_report.cid =
> courses.cid
>
>
> Can anyone pls write the querryset for the above sql query
>
> --
> 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/CAPjsHcFbqD%2BgX1NA8QLYFsJUkb9VydzzcBRrNO2FpCyAgS0nqw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPjsHcFbqD%2BgX1NA8QLYFsJUkb9VydzzcBRrNO2FpCyAgS0nqw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAGHZBzyCMzkdjvjdAg4MbF0tQgotCZkorunJQbi4v1xEqsFsBw%40mail.gmail.com.


Django sql raw query to queryset

2019-08-22 Thread Suraj Thapa FC
SELECT *
FROM course_review_report LEFT JOIN courses ON course_review_report.cid =
courses.cid


Can anyone pls write the querryset for the above sql query

-- 
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/CAPjsHcFbqD%2BgX1NA8QLYFsJUkb9VydzzcBRrNO2FpCyAgS0nqw%40mail.gmail.com.


Django db query

2019-08-22 Thread Suraj Thapa FC
class courses(models.Model):
level = (
('beginner', 'Beginner Level'),
('intermediate', 'Intermediate Level'),
('expert', 'Expert Level'),
('all level', 'All Level'),
 )
type = (
 ('live', 'LIVE'),
 ('on demand', 'On Demand'),
 )

ins_id = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
coursetype = models.CharField(max_length=50,choices=type, default="on
demand")
cid = models.UUIDField(default=uuid.uuid4, editable=True,
primary_key=True)# course id
course_title = models.CharField(max_length=255, default="")
course_sub_title = models.CharField(max_length=255,default="")
course_level = models.CharField(max_length=255, choices= level,
default="beginner")
course_main_cat = models.ForeignKey(courses_main_categories,
on_delete=models.CASCADE)
course_sub_cat = models.ForeignKey(courses_sub_categories,
on_delete=models.CASCADE)
course_permalink = models.SlugField(max_length=255,default="")
image_path = models.ImageField(upload_to="media",blank=True,default="")
is_published = models.BooleanField(default=False)
is_in_draft = models.BooleanField(default=True)
a_pending = models.BooleanField(default=False)
i_pending = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
live_course_start = models.DateTimeField(auto_now_add=True)
live_course_end = models.DateTimeField(auto_now_add=True)
course_desc = models.CharField(max_length=255, default="")
primarily_taught = models.CharField(max_length=255, default="")




class course_review_report(models.Model):
task_id = models.BigAutoField(primary_key = True)
expert_id = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
cid = models.ForeignKey(courses,on_delete = models.CASCADE)
is_completed = models.BooleanField(default=False)
is_pending = models.BooleanField(default=True)
assigned_date = models.DateTimeField(auto_now_add = True)
review_completion_date = models.DateTimeField(auto_now_add = True)


This is my project models
I want to get those cid from courses tables which have the is_published =
True and based on this I want to get the course_review_report data on the
basis of  distinct cid.


Can anyone write the querryset for the same..

-- 
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/CAPjsHcHWGKqn82oEz-So%3DKcoT3HKjD5DnHc86d4koBOGxXQnsA%40mail.gmail.com.


Re: Aggregating the results of a .union query without using .raw, is it possible?

2019-08-19 Thread Simon Charette
I'm afraid the ORM doesn't support aggregation over unions yet else I would
have expected the following to work.

objects = Model.objects
querysets = (
objects.filter(city=city).values(
'date', weighted_car_crashes=F('car_crashes') * weight
) for city, weight in weights
)
union = itertools.reduce(QuerySet.union, querysets, querysets[0])
queryset = union.annotate(cc=Sum('weighted_car_crashes')).values('date', 
'cc')

Best,
Simon

Le lundi 19 août 2019 17:10:47 UTC-4, Jo a écrit :
>
> I have a table that looks like this
>
> datecar_crashes city
> 01.01   1   Washington
> 01.02   4   Washington
> 01.03   0   Washington
> 01.04   2   Washington
> 01.05   0   Washington
> 01.06   3   Washington
> 01.07   4   Washington
> 01.08   1   Washington
> 01.01   0   Detroit
> 01.02   2   Detroit
> 01.03   4   Detroit
> 01.04   2   Detroit
> 01.05   0   Detroit
> 01.06   3   Detroit
> 01.07   1   Detroit
>
>
> I want to know how many car crashes for each day happened in the entire 
> nation, and I can do that with this:
>
>
> Model.values("date") \
> .annotate(car_crashes=Sum('car_crashes')) \
> .values("date", "car_crashes")
>
>
>
> Now, let's suppose I have an array like this:
>
> weights = [
> {
> "city": "Washington",
> "weight": 1,
> },
> {
> "city": "Detroit",
> "weight": 2,
> }
> ]
>
>
>
> This means that Detroit's car crashes should be multiplied by 2 before 
> being aggregated with Washington's.
>
> It can be done like this:
>
> from django.db.models import IntegerField
>
>
> when_list = [When(city=w['city'], then=w['weight']) for w in weights]
> case_params = {'default': 1, 'output_field': IntegerField()}
>
>
> Model.objects.values('date') \
> .annotate(
> weighted_car_crashes=Sum(
> F('car_crashes') * Case(*when_list, **case_params)
> ))
>
> However, this generates very slow SQL code, especially as more properties 
> and a larger array are introduced.
>
> Another solution which is way faster but still sub-optimal is using pandas 
> to :
>
> aggregated = false
> for weight in weights:
>
>  ag = Model.values("date") \
>  .annotate(car_crashes=Sum('car_crashes')) \
>  .values("date", "car_crashes")
>
>
>  if aggregated is False:
>  aggregated = ag
>  else:
>  aggregated = aggregated.union(ag)
>
>
> aggregated = pd.DataFrame(aggregated)
> if len(weights) > 1:
>  aggregated = aggregated.groupby("date", as_index=False).sum(level=[1])
>
>
> This is faster, but still not as fast as what happens if, before calling 
> pandas, I take the aggregated.query string and
> wrap it with a few lines of SQL.
>
>
> SELECT "date", sum("car_crashes") FROM (
>
>
> // String from Python
> str(aggregated.query)
>
>
> )
>
>
> This works perfectly when pasted into my database SQL. I could do this in 
> Python/Django using .raw() but the documentation says to ask here before 
> using .raw() as mostly anything could be acomplished with the ORM.
>
> Yet, I don't see how. Once I call .union on 2 querysets, I cannot 
> aggregate further.
>
> aggregated.union(ag).annotate(cc=Sum('car_crashes'))
>
> gives
>
> Cannot compute Sum('car_crashes'): 'car_crashes' is an aggregate
>
>
>
>
> Is this possible to do with the Django ORM or should I use .raw()?
>

-- 
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/3e1aedd7-8eb8-4fd6-9116-ed835719deb6%40googlegroups.com.


Re: Aggregating the results of a .union query without using .raw, is it possible?

2019-08-19 Thread Jo
My bad, the correct SQL query is this:

SELECT "date", sum("car_crashes") FROM (


// String from Python
str(aggregated.query)


) as "aggregated" GROUP BY "date"



Il giorno lunedì 19 agosto 2019 23:10:47 UTC+2, Jo ha scritto:
>
> I have a table that looks like this
>
> datecar_crashes city
> 01.01   1   Washington
> 01.02   4   Washington
> 01.03   0   Washington
> 01.04   2   Washington
> 01.05   0   Washington
> 01.06   3   Washington
> 01.07   4   Washington
> 01.08   1   Washington
> 01.01   0   Detroit
> 01.02   2   Detroit
> 01.03   4   Detroit
> 01.04   2   Detroit
> 01.05   0   Detroit
> 01.06   3   Detroit
> 01.07   1   Detroit
>
>
> I want to know how many car crashes for each day happened in the entire 
> nation, and I can do that with this:
>
>
> Model.values("date") \
> .annotate(car_crashes=Sum('car_crashes')) \
> .values("date", "car_crashes")
>
>
>
> Now, let's suppose I have an array like this:
>
> weights = [
> {
> "city": "Washington",
> "weight": 1,
> },
> {
> "city": "Detroit",
> "weight": 2,
> }
> ]
>
>
>
> This means that Detroit's car crashes should be multiplied by 2 before 
> being aggregated with Washington's.
>
> It can be done like this:
>
> from django.db.models import IntegerField
>
>
> when_list = [When(city=w['city'], then=w['weight']) for w in weights]
> case_params = {'default': 1, 'output_field': IntegerField()}
>
>
> Model.objects.values('date') \
> .annotate(
> weighted_car_crashes=Sum(
> F('car_crashes') * Case(*when_list, **case_params)
> ))
>
> However, this generates very slow SQL code, especially as more properties 
> and a larger array are introduced.
>
> Another solution which is way faster but still sub-optimal is using pandas 
> to :
>
> aggregated = false
> for weight in weights:
>
>  ag = Model.values("date") \
>  .annotate(car_crashes=Sum('car_crashes')) \
>  .values("date", "car_crashes")
>
>
>  if aggregated is False:
>  aggregated = ag
>  else:
>  aggregated = aggregated.union(ag)
>
>
> aggregated = pd.DataFrame(aggregated)
> if len(weights) > 1:
>  aggregated = aggregated.groupby("date", as_index=False).sum(level=[1])
>
>
> This is faster, but still not as fast as what happens if, before calling 
> pandas, I take the aggregated.query string and
> wrap it with a few lines of SQL.
>
>
> SELECT "date", sum("car_crashes") FROM (
>
>
> // String from Python
> str(aggregated.query)
>
>
> )
>
>
> This works perfectly when pasted into my database SQL. I could do this in 
> Python/Django using .raw() but the documentation says to ask here before 
> using .raw() as mostly anything could be acomplished with the ORM.
>
> Yet, I don't see how. Once I call .union on 2 querysets, I cannot 
> aggregate further.
>
> aggregated.union(ag).annotate(cc=Sum('car_crashes'))
>
> gives
>
> Cannot compute Sum('car_crashes'): 'car_crashes' is an aggregate
>
>
>
>
> Is this possible to do with the Django ORM or should I use .raw()?
>

-- 
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/7096fdff-ec55-4d1b-8110-9fd6bb70f9e1%40googlegroups.com.


Aggregating the results of a .union query without using .raw, is it possible?

2019-08-19 Thread Jo
I have a table that looks like this

datecar_crashes city
01.01   1   Washington
01.02   4   Washington
01.03   0   Washington
01.04   2   Washington
01.05   0   Washington
01.06   3   Washington
01.07   4   Washington
01.08   1   Washington
01.01   0   Detroit
01.02   2   Detroit
01.03   4   Detroit
01.04   2   Detroit
01.05   0   Detroit
01.06   3   Detroit
01.07   1   Detroit


I want to know how many car crashes for each day happened in the entire 
nation, and I can do that with this:


Model.values("date") \
.annotate(car_crashes=Sum('car_crashes')) \
.values("date", "car_crashes")



Now, let's suppose I have an array like this:

weights = [
{
"city": "Washington",
"weight": 1,
},
{
"city": "Detroit",
"weight": 2,
}
]



This means that Detroit's car crashes should be multiplied by 2 before 
being aggregated with Washington's.

It can be done like this:

from django.db.models import IntegerField


when_list = [When(city=w['city'], then=w['weight']) for w in weights]
case_params = {'default': 1, 'output_field': IntegerField()}


Model.objects.values('date') \
.annotate(
weighted_car_crashes=Sum(
F('car_crashes') * Case(*when_list, **case_params)
))

However, this generates very slow SQL code, especially as more properties 
and a larger array are introduced.

Another solution which is way faster but still sub-optimal is using pandas 
to :

aggregated = false
for weight in weights:

 ag = Model.values("date") \
 .annotate(car_crashes=Sum('car_crashes')) \
 .values("date", "car_crashes")


 if aggregated is False:
 aggregated = ag
 else:
 aggregated = aggregated.union(ag)


aggregated = pd.DataFrame(aggregated)
if len(weights) > 1:
 aggregated = aggregated.groupby("date", as_index=False).sum(level=[1])


This is faster, but still not as fast as what happens if, before calling 
pandas, I take the aggregated.query string and
wrap it with a few lines of SQL.


SELECT "date", sum("car_crashes") FROM (


// String from Python
str(aggregated.query)


)


This works perfectly when pasted into my database SQL. I could do this in 
Python/Django using .raw() but the documentation says to ask here before 
using .raw() as mostly anything could be acomplished with the ORM.

Yet, I don't see how. Once I call .union on 2 querysets, I cannot aggregate 
further.

aggregated.union(ag).annotate(cc=Sum('car_crashes'))

gives

Cannot compute Sum('car_crashes'): 'car_crashes' is an aggregate




Is this possible to do with the Django ORM or should I use .raw()?

-- 
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/3e3e80a1-29e4-47bd-8688-f826063d2b02%40googlegroups.com.


Re: Duplicated django_content_type Query

2019-08-16 Thread Simon Charette
Hello there,

These queries should be cached by ContentTypeManager[0] so something must 
be broken
in your Django install or monkey patching this method.

Simon

[0] 
https://github.com/django/django/blob/7da6a28a447dc0db2a2c6ef31894094eb968f408/django/contrib/contenttypes/models.py#L34-L44

Le vendredi 16 août 2019 07:18:08 UTC-4, Gaurav Ravindra Bole a écrit :
>
> [image: Screenshot from 2019-08-16 13-47-45.jpg]
>
>
>
> How we avoid this Duplicated django_content_type Query
>

-- 
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/3b549f51-94ed-4fc9-bdb1-72c166424f8e%40googlegroups.com.


Django 2.2 mongoengine query pagination performance

2019-08-07 Thread Felix Tillyard
Hi,

We are facing an issue while upgrading from Django 2.1.10 to 2.2.4. We are 
using mongoengine (http://mongoengine.org/) to pull some documents from a 
Mongo database. Following the upgrade performance of this is significantly 
worse.

We ran some profiling using pyspy (https://github.com/benfred/py-spy) which 
produced the attached charts.

Basically it seems like there are many extra function calls, seemingly 
related to pagination, and the control flow here is different following the 
upgrade.

Any ideas / help would be amazing!

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/76590bde-a7bb-4820-bacf-e1a8c3ec13c1%40googlegroups.com.


Re: Recreating SQL query in ORM

2019-08-01 Thread Jonathan Spicer
Thanks Simon, that's a great help.

On Wednesday, 31 July 2019 15:03:55 UTC+1, Simon Charette wrote:
>
> Hello,
>
> assuming you have a FullMatch model mapped to your FullMatches table
> the following should do.
>
> FullMatch.objects.filter(
> job_id=job_id,
> ).values(
> seq=Concat('loading_code', ...),
> ids=Concat('loading_id', ),
> ).annotate(
> total=Count('*'),
> ).order_by('-total')
>
> Using .values() before an annotation of an aggregate function uses the 
> provided columns
> from grouping.
>
> Cheers,
> Simon
>
> Le mardi 30 juillet 2019 12:56:56 UTC-4, Jonathan Spicer a écrit :
>>
>> Hello,
>>
>> I have an sql query that I would like to recreate using the ORM. Would it 
>> be possible for someone to give me some pointers.
>>
>> select count(*) as total,
>> 
>> concat(loading_code,code1_code,code2_code,code3_code,code4_code) as seq,
>> 
>> concat(loading_id,',',code1_id,',',code2_id,',',code3_id,',',code4_id) as 
>> ids
>> from FullMatches where job_id = %s group by seq, ids 
>> order by total desc
>>
>> Thanks in advance.
>>
>> Johnny
>>
>

-- 
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/5f6f271a-4d8d-4d02-80c3-9085f15f6ce4%40googlegroups.com.


Re: Recreating SQL query in ORM

2019-07-31 Thread Simon Charette
Hello,

assuming you have a FullMatch model mapped to your FullMatches table
the following should do.

FullMatch.objects.filter(
job_id=job_id,
).values(
seq=Concat('loading_code', ...),
ids=Concat('loading_id', ),
).annotate(
total=Count('*'),
).order_by('-total')

Using .values() before an annotation of an aggregate function uses the 
provided columns
from grouping.

Cheers,
Simon

Le mardi 30 juillet 2019 12:56:56 UTC-4, Jonathan Spicer a écrit :
>
> Hello,
>
> I have an sql query that I would like to recreate using the ORM. Would it 
> be possible for someone to give me some pointers.
>
> select count(*) as total,
> 
> concat(loading_code,code1_code,code2_code,code3_code,code4_code) as seq,
> 
> concat(loading_id,',',code1_id,',',code2_id,',',code3_id,',',code4_id) as 
> ids
> from FullMatches where job_id = %s group by seq, ids order 
> by total desc
>
> Thanks in advance.
>
> Johnny
>

-- 
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/276bf123-6990-4594-a9cf-8e9a8432d40e%40googlegroups.com.


Re: Recreating SQL query in ORM

2019-07-30 Thread Yogesh K SonI
yes

On Tuesday, July 30, 2019 at 10:26:56 PM UTC+5:30, Jonathan Spicer wrote:
>
> Hello,
>
> I have an sql query that I would like to recreate using the ORM. Would it 
> be possible for someone to give me some pointers.
>
> select count(*) as total,
> 
> concat(loading_code,code1_code,code2_code,code3_code,code4_code) as seq,
> 
> concat(loading_id,',',code1_id,',',code2_id,',',code3_id,',',code4_id) as 
> ids
> from FullMatches where job_id = %s group by seq, ids order 
> by total desc
>
> Thanks in advance.
>
> Johnny
>

-- 
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/a24d2cbe-1230-4ef5-813f-6cc6739ccd0f%40googlegroups.com.


Re: Recreating SQL query in ORM

2019-07-30 Thread Jonathan Spicer
Hello John,

I did try that but it complained about the query not containing the primary 
key.

I did wonder if there are methods within the ORM that can replicate it, the 
tricky part being creating a value to group by from concatenated rows.

On Tuesday, 30 July 2019 19:14:32 UTC+1, John Bagiliko wrote:
>
> Do you want to make this exact query in Django? 
> Then use Your_model.objects.raw("the query here except the last semi 
> colon")
>
> On Tue, Jul 30, 2019, 4:56 PM Jonathan Spicer <
> joh...@spicersolutions.co.uk > wrote:
>
>> Hello,
>>
>> I have an sql query that I would like to recreate using the ORM. Would it 
>> be possible for someone to give me some pointers.
>>
>> select count(*) as total,
>> 
>> concat(loading_code,code1_code,code2_code,code3_code,code4_code) as seq,
>> 
>> concat(loading_id,',',code1_id,',',code2_id,',',code3_id,',',code4_id) as 
>> ids
>> from FullMatches where job_id = %s group by seq, ids 
>> order by total desc
>>
>> Thanks in advance.
>>
>> Johnny
>>
>> -- 
>> 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/d91ae3ab-f111-4081-8a6e-26fad5a2f782%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/d91ae3ab-f111-4081-8a6e-26fad5a2f782%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/edd9244d-a320-4bfc-8859-b7aab1439c37%40googlegroups.com.


Re: Recreating SQL query in ORM

2019-07-30 Thread John Bagiliko
Do you want to make this exact query in Django?
Then use Your_model.objects.raw("the query here except the last semi colon")

On Tue, Jul 30, 2019, 4:56 PM Jonathan Spicer 
wrote:

> Hello,
>
> I have an sql query that I would like to recreate using the ORM. Would it
> be possible for someone to give me some pointers.
>
> select count(*) as total,
>
> concat(loading_code,code1_code,code2_code,code3_code,code4_code) as seq,
>
> concat(loading_id,',',code1_id,',',code2_id,',',code3_id,',',code4_id) as
> ids
> from FullMatches where job_id = %s group by seq, ids order
> by total desc
>
> Thanks in advance.
>
> Johnny
>
> --
> 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/d91ae3ab-f111-4081-8a6e-26fad5a2f782%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d91ae3ab-f111-4081-8a6e-26fad5a2f782%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAC26BE0cEq4c_UWcO9BKMThazgMEHOpLp3dXiU%2Bb_SNmPgU%2BSg%40mail.gmail.com.


Recreating SQL query in ORM

2019-07-30 Thread Jonathan Spicer
Hello,

I have an sql query that I would like to recreate using the ORM. Would it 
be possible for someone to give me some pointers.

select count(*) as total,

concat(loading_code,code1_code,code2_code,code3_code,code4_code) as seq,

concat(loading_id,',',code1_id,',',code2_id,',',code3_id,',',code4_id) as 
ids
from FullMatches where job_id = %s group by seq, ids order 
by total desc

Thanks in advance.

Johnny

-- 
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/d91ae3ab-f111-4081-8a6e-26fad5a2f782%40googlegroups.com.


Re: Query questions. Please help me.

2019-07-17 Thread 나르엔
I've solved it like this.
Thank you for your help.

def get_queryset(self):
context = super(SearchListView, self).get_queryset()
query = self.request.GET.get('q')
selectOptions = self.request.GET.getlist('selectoptions')
argument_list = []
for field in selectOptions:
argument_list.append( Q(**{field+'__icontains':query}))
context = assetsInfo.objects.filter( reduce(operator.or_, argument_list))
return context

2019년 7월 18일 목요일 오전 11시 31분 7초 UTC+9, Yoo 님의 말:
>
> Take a look at Q objects: 
> https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q-objects
>
> On Wednesday, July 17, 2019 at 4:04:16 PM UTC-4, 나르엔 wrote:
>>
>> Hello, I am studying django.
>>
>> When I use objects.filter, I want to search various columns. 
>>
>> Columns to search for are unknown and have been receiving columns to 
>> search through checkbox in html.
>>
>> What should I do? Please teach me.
>> It's blocked from below.
>> selectoptions is name in checkbox.
>>
>>
>> ---
>> def get_queryset(self):
>> context = super(SearchListView, self).get_queryset()
>> query = self.request.GET.get('q')
>> selectOptions = self.request.GET.getlist('selectoptions')
>>
>

-- 
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/7218b4c6-5734-4cca-9b1a-098f41899f39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query questions. Please help me.

2019-07-17 Thread Yoo
Take a look at Q objects: 
https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q-objects

On Wednesday, July 17, 2019 at 4:04:16 PM UTC-4, 나르엔 wrote:
>
> Hello, I am studying django.
>
> When I use objects.filter, I want to search various columns. 
>
> Columns to search for are unknown and have been receiving columns to 
> search through checkbox in html.
>
> What should I do? Please teach me.
> It's blocked from below.
> selectoptions is name in checkbox.
>
>
> ---
> def get_queryset(self):
> context = super(SearchListView, self).get_queryset()
> query = self.request.GET.get('q')
> selectOptions = self.request.GET.getlist('selectoptions')
>

-- 
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/bc0ae786-7b3c-49dd-80de-afa61fa7356f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query questions. Please help me.

2019-07-17 Thread 나르엔

Thank you!
That's working! But I think it's just a AND condition. It's embarrassing, 
but what should I do with the OR conditions?

def get_queryset(self):
context = super(SearchListView, self).get_queryset()
query = self.request.GET.get('q')
selectOptions = self.request.GET.getlist('selectoptions')
search_querys = dict((i,query) for i in selectOptions)
context = assetsInfo.objects.filter(**search_querys)
return context
2019년 7월 18일 목요일 오전 5시 42분 1초 UTC+9, Jani Tiainen 님의 말:
>
> Hi.
>
> You can use dictionary unpacking to kwargs.
>
> .filter(**{"name__contains": "foo", "somefield__gt": 123})
>
>
>
> ke 17. heinäk. 2019 klo 23.04 나르엔 > 
> kirjoitti:
>
>> Hello, I am studying django.
>>
>> When I use objects.filter, I want to search various columns. 
>>
>> Columns to search for are unknown and have been receiving columns to 
>> search through checkbox in html.
>>
>> What should I do? Please teach me.
>> It's blocked from below.
>> selectoptions is name in checkbox.
>>
>>
>> ---
>> def get_queryset(self):
>> context = super(SearchListView, self).get_queryset()
>> query = self.request.GET.get('q')
>> selectOptions = self.request.GET.getlist('selectoptions')
>>
>> -- 
>> 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 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/dbdb681d-e7ad-44db-a825-512cc9436575%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/dbdb681d-e7ad-44db-a825-512cc9436575%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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/d048c43d-cdfb-45d7-a978-40d41d996770%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query questions. Please help me.

2019-07-17 Thread Jani Tiainen
Hi.

You can use dictionary unpacking to kwargs.

.filter(**{"name__contains": "foo", "somefield__gt": 123})



ke 17. heinäk. 2019 klo 23.04 나르엔  kirjoitti:

> Hello, I am studying django.
>
> When I use objects.filter, I want to search various columns.
>
> Columns to search for are unknown and have been receiving columns to
> search through checkbox in html.
>
> What should I do? Please teach me.
> It's blocked from below.
> selectoptions is name in checkbox.
>
>
> ---
> def get_queryset(self):
>     context = super(SearchListView, self).get_queryset()
> query = self.request.GET.get('q')
> selectOptions = self.request.GET.getlist('selectoptions')
>
> --
> 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/dbdb681d-e7ad-44db-a825-512cc9436575%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/dbdb681d-e7ad-44db-a825-512cc9436575%40googlegroups.com?utm_medium=email_source=footer>
> .
> 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/CAHn91ofMwQCD_B3UH7Knb6TgvDtwa2A2YnA5OO3jBa7Vsr%2BH7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Query questions. Please help me.

2019-07-17 Thread 나르엔
Hello, I am studying django.

When I use objects.filter, I want to search various columns. 

Columns to search for are unknown and have been receiving columns to search 
through checkbox in html.

What should I do? Please teach me.
It's blocked from below.
selectoptions is name in checkbox.


---
def get_queryset(self):
context = super(SearchListView, self).get_queryset()
query = self.request.GET.get('q')
selectOptions = self.request.GET.getlist('selectoptions')

-- 
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/dbdb681d-e7ad-44db-a825-512cc9436575%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django ORM Left Join query

2019-07-01 Thread Razib Hossain Shuvo
HI all,

I have the follow models . I want to find all the categories from the 
UserCategory table along with the budget for each category from the 
UserBudget model. I tried with select_related and prefetch and filtered 
with user_id but then it only returns budget that has matched with user_id. 
But i want to retrieve all the categories whether user has budget or not.

class UserCategory(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
cat = models.ForeignKey('preference.Category', null=True, 
on_delete=models.CASCADE)
is_active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

class Category(models.Model):
name = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
is_active = models.BooleanField(default=True)

class UserBudget(models.Model):
cat = models.ForeignKey('preference.Category', on_delete=models.CASCADE)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
budget = models.DecimalField(default=0.00, decimal_places=2, max_digits=20)
is_active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)


I tried following approach :

user_cats = 
UserCategory.objects.prefetch_related('cat__userbudget_set__user').filter(user_id=user_id)

Enter code here...
But the above query only returns UserCategory that matched with the 
user_id. But i want the following result. 

select uc.id as cat_id, uc.user_id cat_user, ub.user_id as budget_user, 
ub.cat_id as budget_cat from user_categories as uc
left outer join user_budget as ub on uc.id = ub.cat_id 
where uc.user_id = 2




Please help. 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/99366754-8702-4939-adaa-e271ae3ed144%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Display ManyToManyField value or a select_related query in an html object list

2019-06-24 Thread Ricardo Daniel Quiroga
Hi,

model.many_to_many_atribute.all()
model.many_to_many_atribute.find(name="carl")


El lun., 24 jun. 2019 a las 19:18, Charlotte Wood (<
charlotte.w...@epiccharterschools.org>) escribió:

> HELP!
>
> Do ManyToManyFields just not print?
>
> I see them in my form selection.
>
> Everything works fine, but when I try to put the linked item on a list
> form, i get:  project.model.none for the value.  I cannot figure out how to
> make all the values print.  HELP!  PLEASE!!
>
> --
> 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/ec36b6b0-dc7a-4534-9af3-ae0a173fa493%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Ricardo Daniel Quiroga

-- 
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/CAO2-wHbGHpgzBdqzsvj%3DVuC-AF3%2BXKGkVpmnKhTtoV-5irSYjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Display ManyToManyField value or a select_related query in an html object list

2019-06-24 Thread Charlotte Wood
HELP!

Do ManyToManyFields just not print?

I see them in my form selection.

Everything works fine, but when I try to put the linked item on a list 
form, i get:  project.model.none for the value.  I cannot figure out how to 
make all the values print.  HELP!  PLEASE!!

-- 
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/ec36b6b0-dc7a-4534-9af3-ae0a173fa493%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DRF structure query

2019-06-11 Thread Andréas Kühne
Hi,

The way we have structured our application is that we have our models and
serializers in different apps, but have one app for the api itself. So all
of the urls are in the "api/urls.py" file.

We have found that this works great for us.

However we don't use routers - instead we just use DRF class based views
for our endpoints.

Regards,

Andréas


Den tis 11 juni 2019 kl 16:07 skrev Dave B :

> Hi,
>
> Being fairly new to DRF, I'm just wondering on the best ways of going
> about stucturing an api which has man endpoints.
>
> Basically is there a good reason not to put different categories of
> endpoints together in different apps, like the ones for user data, ones for
> app data etc.
>
> And then how does that work with the routers?
>
> --
> 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/20f43bb4-f73f-428a-8628-338e81b2da86%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/CAK4qSCdeD%3DkCwGXT3Vs8V2UFZdVE4Pro3nDmEcEdkaBjzR_%2BJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


DRF structure query

2019-06-11 Thread Dave B
Hi,

Being fairly new to DRF, I'm just wondering on the best ways of going about 
stucturing an api which has man endpoints.

Basically is there a good reason not to put different categories of 
endpoints together in different apps, like the ones for user data, ones for 
app data etc.

And then how does that work with the routers?

-- 
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/20f43bb4-f73f-428a-8628-338e81b2da86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Orm Query for this type of situation

2019-06-07 Thread Devender Kumar
Hi,
On this question only I took some step deep and able to find out one part
and need your help on the second half.
This requires a good understanding of Django annotation and subquery
features
If you have this thank for reading and helping me in advance
I am facing problem to filter calls on account.contact list which are
realted by contact phone no with and calls phone no
can any one help writing this query





On Thu, Jun 6, 2019 at 7:47 PM Devender Kumar 
wrote:

> Account /Lead Model
>  account_name
>  contact m2m realtion
>
> contact Model
> name
> phone No
>
> calls Model
> caller no # person phone no who is calling
> agent no #  person who is picking the call (CRM user)
> status 
> timestamp
> duration
>
> calls model is populated with some third party software and we are map its
> caller no and agent no their is no direct relationship
>
> I want to get the list of accounts in particular date range  with:
> total no of contact it have ,
> how many time its contact have called
> how many calls where missed inbound outbound etc
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Thu, Jun 6, 2019 at 4:49 PM Chetan Ganji 
> wrote:
>
>> Right now its an open ended question.
>>
>> If you post code for your models here, someone can help you.
>>
>> On Thu, Jun 6, 2019, 4:38 PM Devender Kumar  wrote:
>>
>>> Hi,
>>> I am working on CRM project and stuck with REPORTING part.
>>>
>>> I have Accounts , Lead , contact, Calls ,Concern modules
>>> account/Lead can have multiple contacts
>>> contacts have multiple calls and concerns
>>> calls have different status like Incoming outgoing missed call etc
>>>
>>> Question
>>> I need to create a reporting system
>>> In this I have to give a functionality like so
>>> list of accounts with counts of :
>>>  contacts, total calls,incoming, outgoing etc
>>>
>>>  how can list all this count for a given date ranges calls on all
>>> accounts
>>>
>>>
>>>
>>> --
>>> 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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/1cb5c003-7cbc-4d54-ae5b-21403e543b95%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> 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/CALmCJr7ApqHCCsm73t%3DiuvzOYwE44Vh7pcdpH2bNkb-aH015fw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALmCJr7ApqHCCsm73t%3DiuvzOYwE44Vh7pcdpH2bNkb-aH015fw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> 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/CALZ%3DbEL-FcgFqpjJtN9Up0JuOJ4WtO_fVKrPBERSYWKK%2B1r_gQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Orm Query for this type of situation

2019-06-06 Thread Devender Kumar
Account /Lead Model
 account_name
 contact m2m realtion

contact Model
name
phone No

calls Model
caller no # person phone no who is calling
agent no #  person who is picking the call (CRM user)
status 
timestamp
duration

calls model is populated with some third party software and we are map its
caller no and agent no their is no direct relationship

I want to get the list of accounts in particular date range  with:
total no of contact it have ,
how many time its contact have called
how many calls where missed inbound outbound etc














On Thu, Jun 6, 2019 at 4:49 PM Chetan Ganji  wrote:

> Right now its an open ended question.
>
> If you post code for your models here, someone can help you.
>
> On Thu, Jun 6, 2019, 4:38 PM Devender Kumar  wrote:
>
>> Hi,
>> I am working on CRM project and stuck with REPORTING part.
>>
>> I have Accounts , Lead , contact, Calls ,Concern modules
>> account/Lead can have multiple contacts
>> contacts have multiple calls and concerns
>> calls have different status like Incoming outgoing missed call etc
>>
>> Question
>> I need to create a reporting system
>> In this I have to give a functionality like so
>> list of accounts with counts of :
>>  contacts, total calls,incoming, outgoing etc
>>
>>  how can list all this count for a given date ranges calls on all
>> accounts
>>
>>
>>
>> --
>> 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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%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/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%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/CALmCJr7ApqHCCsm73t%3DiuvzOYwE44Vh7pcdpH2bNkb-aH015fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Orm Query for this type of situation

2019-06-06 Thread Chetan Ganji
Right now its an open ended question.

If you post code for your models here, someone can help you.

On Thu, Jun 6, 2019, 4:38 PM Devender Kumar  wrote:

> Hi,
> I am working on CRM project and stuck with REPORTING part.
>
> I have Accounts , Lead , contact, Calls ,Concern modules
> account/Lead can have multiple contacts
> contacts have multiple calls and concerns
> calls have different status like Incoming outgoing missed call etc
>
> Question
> I need to create a reporting system
> In this I have to give a functionality like so
> list of accounts with counts of :
>  contacts, total calls,incoming, outgoing etc
>
>  how can list all this count for a given date ranges calls on all accounts
>
>
>
> --
> 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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%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/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Orm Query for this type of situation

2019-06-06 Thread Devender Kumar
Hi,
I am working on CRM project and stuck with REPORTING part.

I have Accounts , Lead , contact, Calls ,Concern modules
account/Lead can have multiple contacts 
contacts have multiple calls and concerns 
calls have different status like Incoming outgoing missed call etc

Question 
I need to create a reporting system
In this I have to give a functionality like so
list of accounts with counts of :
 contacts, total calls,incoming, outgoing etc

 how can list all this count for a given date ranges calls on all accounts 



-- 
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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Error - Cannot query "dgp": Must be "Employee" instance. ( dgp is userName and Employee is Model Name )

2019-05-31 Thread Balaji Shetty
HI

I get the error when i enter the records of Profile Model and save it. i
get GUI for model.

I created group and given access of both model to dgp user.


ValueError at /admin/newapp/profile1/

  dgp is my user name and Employee is the model name.

Can anybody help me in this regards

Employee Refers to User Model ( Foreign Key Relation)
Profile Model Refers to Employee Model ( Foreign Key Relation)

Models.py



class Employee(models.Model):
   * user = models.OneToOneField(User,
on_delete=models.CASCADE,primary_key="True")*
department = models.CharField(max_length=100)
level = models.IntegerField()
parentlevel = models.IntegerField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)



def __str__(self):
return '%s' % (self.user)




class Profile(models.Model):

State = models.CharField(max_length=100,default="MH")
District = models.CharField(max_length=100,default="Parbhani")

  *  user = models.ForeignKey(Employee, on_delete=models.CASCADE)*
InwardNumber = models.CharField(max_length=100,default="2019/3")


admin.py

class Profile1Admin(admin.ModelAdmin):

  def get_form(self, request, obj=None, **kwargs):

username = request.user.username

print("- Inside get_exclude Method")
print (username)

if username == 'dgp': # if user is not a superuser

LOGIC 1 
elif username == 'inumber':

LOGIC 2 
print("-  ***  Inside DGP LOGIN ***---")
self.fields = self.inward_fields
else:
Logic 3 --

return super(Profile1Admin, self).get_form(request, obj, **kwargs)

Can Anyone please help me in this regards.


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

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


Re: Query on 2 non related models

2019-05-20 Thread Rafael E. Ferrero
Hello Ivan... you say Unrelated but I see you have a relation with
VendorGroup... why don't use a ForeignKey?... any way you can use the pipe
charater " | " to concatenate two querysets.

https://simpleisbetterthancomplex.com/tips/2016/06/20/django-tip-5-how-to-merge-querysets.html


Cheers!

Rafael E. Ferrero


El lun., 20 may. 2019 a las 9:12, Ivan Martić ()
escribió:

> Hi guys, hope you can help me.
> I have 2 models and i want to make a count query on them. I need a count
> on how many articles i have in every category.
>
> Models:
> class Vendors(models.Model):
> id = models.AutoField(db_column='id', primary_key=True, blank=False,
> unique=True)
> name = models.CharField(db_column='name', max_length=150, blank=True,
> null=True)
> groupid = models.IntegerField(db_column='groupid', blank=True,
> null=True)
>
>
> class VendorGroup(models.Model):
> id = models.AutoField(db_column='ID', primary_key=True, null=False,
> max_length=255, blank=True)
> vendor_group = models.CharField(db_column='Vendor Group',
> max_length=255, blank=True, null=True)
>
> view:
> def vendorsgrouping_view(request):
> list_vendor = VendorGroup.objects.all().order_by('vendor_group')
>
> context = {
> 'lista_vendora':lista_vendora,
> }
> return render(request, "templates/vendorgroup.html", context)
>
> I have list of vendors listed in template:
> {% for item in lista_vendora %}
> {{ item.vendor_group }}
> {% endfor %}
>
> Prefetch, annotate, select related dont work since they are not connected.
> I know it is easier to give foreign key to fields but what about this?
>
> 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/f0413341-91b2-4308-afd5-ae486b09a71e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f0413341-91b2-4308-afd5-ae486b09a71e%40googlegroups.com?utm_medium=email_source=footer>
> .
> 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/CAJJc_8XZ00Sw%2B-o%3D%2B7xY7cHP6wL_TqMMeHmR7RSC5k71hvvRfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Query on 2 non related models

2019-05-20 Thread Ivan Martić
Hi guys, hope you can help me. 
I have 2 models and i want to make a count query on them. I need a count on 
how many articles i have in every category.

Models:
class Vendors(models.Model):
id = models.AutoField(db_column='id', primary_key=True, blank=False, 
unique=True)
name = models.CharField(db_column='name', max_length=150, blank=True, 
null=True)
groupid = models.IntegerField(db_column='groupid', blank=True, 
null=True)


class VendorGroup(models.Model):
id = models.AutoField(db_column='ID', primary_key=True, null=False, 
max_length=255, blank=True)
vendor_group = models.CharField(db_column='Vendor Group', 
max_length=255, blank=True, null=True)

view:
def vendorsgrouping_view(request):
list_vendor = VendorGroup.objects.all().order_by('vendor_group')

context = {
'lista_vendora':lista_vendora, 
}
return render(request, "templates/vendorgroup.html", context)

I have list of vendors listed in template:
{% for item in lista_vendora %}
{{ item.vendor_group }}
{% endfor %}

Prefetch, annotate, select related dont work since they are not connected. 
I know it is easier to give foreign key to fields but what about this?

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/f0413341-91b2-4308-afd5-ae486b09a71e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to make the mock object iterable ['TypeError: 'Mock' object is not iterable'] Need to Mock the django query that is iterating through for loop

2019-05-08 Thread Shashank Gupta
I am trying to mock the below django query object : 
   
1.) if MyModel.objects.filter(data='some_data').exists():
then 2.) for row in MyModel.objects.filter(ListId=id):

I am trying to test below django query inside my method.

def my_method(some_parameter):
 if formsList.objects.filter(data=some_data).exists():
for item in formsList.objects.filter(data1='data1',data2='data2'):
formNameInDb = (item.fileId).formName
if formNameInDb == formName:
return True

Below is my approach:

@mock.patch('MyModel.objects')  
def test_checkCombinationOfStateAndProduct(self, formsList_mock):

formsList_mock_data = mock.MagicMock(spec=MyModel)
formsList_mock_data.fileId.formName ='test data'

formsList_queryset = Mock()
formsList_mock.filter.return_value = formsList_queryset

# formsList_mock.filter.return_value = [formsList_queryset] 

formsList_queryset.exists.return_value = True


For the query 1). 
It is working like I am able to mockupto  **if 
formsList.objects.filter(data=some_data).exists()**

but again for the query 
2) for item in formsList.objects.filter(data1='data1',data2='data2'):
I am getting **mock object(formsList_queryset) should be iterable**
so if I make it iterable like this **[formsList_queryset]**.

Then i am getting error **" AttributeError: 'list' object has no attribute 
'exists'**.

I guess it is because after making the mock object iterable it is behaving 
like list so it does not has the exists attribute.

My problem is I am not able to make the mock object(formsList_queryset) 
iterable so that it will work in the both above mentioned query.

Is there other way mock both query to handle this issue.

Can anyone help to solve the chain queries. Any help or lead, I will really 
appreciate.
Please let me know if any information required.

-- 
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/f5558d18-6872-4715-b5e2-8f2baa627478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


About query strings in urls

2019-05-04 Thread Surajeet Das
I am actually developing an android app which will fetch data using an api 
.  I am trying to pass multiple parameters in the url using query strings, 
but I am not able concatenate those parameters in the url. 
eg: U/userapi/?email=abc=bcd
I trying to achieve the above example.
How do I take email and password parameter together in the url ?
Help me out on that.

-- 
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/00b0c885-478b-4de0-befb-9d350dc67640%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-23 Thread Gourav Chawla
No sir please! Gourav is just fine.

Also, you would need to go edit/add code in the admin.py file for this to
work.

Try this part of the docs:

https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter

Hope, it helps.

On Mon, 22 Apr, 2019, 1:15 PM Balaji Shetty,  wrote:

> Dear Gaurav Sir
>
> I am very much thankful to you for your reply to my query.
>
> My questions is *How can i make  the customization in Django Admin Panel
> itself to implement necessary logic after user of particular department do
> the login.( How and where to embed proposed Logic
> T1.objects.filter(user=current_user, department=current_user.department)*
>
> If i design separate pages for login using templates and showing necessary
> content user-wise (Login wise),
> Your suggested logic will definitely work  (after making necessary changes
> in schema)
>
>
>
> On Sun, Apr 21, 2019 at 11:00 AM Gourav Chawla <
> gauravchawla.chawla...@gmail.com> wrote:
>
>> First of all, use appropriate model fields for linking objects. For
>> example users should be a foreign key to your(or Django's) user table.
>>
>> Then whenever you want to show data on any interface to any user, just
>> filter content/rows by user department.
>>
>> Something like:
>>
>> T1.objects.filter(user=current_user, department=current_user.department)
>>
>> --
>> 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/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
>

-- 
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/CAHkVAtuWq0CF2J4X%3DnckroOZZpEk%2B%2BzgT1r76%2Bd-7SeWTYU4QQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-22 Thread Balaji Shetty
Dear Gaurav Sir

I am very much thankful to you for your reply to my query.

My questions is *How can i make  the customization in Django Admin Panel
itself to implement necessary logic after user of particular department do
the login.( How and where to embed proposed Logic
T1.objects.filter(user=current_user, department=current_user.department)*

If i design separate pages for login using templates and showing necessary
content user-wise (Login wise),
Your suggested logic will definitely work  (after making necessary changes
in schema)



On Sun, Apr 21, 2019 at 11:00 AM Gourav Chawla <
gauravchawla.chawla...@gmail.com> wrote:

> First of all, use appropriate model fields for linking objects. For
> example users should be a foreign key to your(or Django's) user table.
>
> Then whenever you want to show data on any interface to any user, just
> filter content/rows by user department.
>
> Something like:
>
> T1.objects.filter(user=current_user, department=current_user.department)
>
> --
> 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/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

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


Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Sithembewena L. Dube
Your model fields are not cased correctly.

https://stackoverflow.com/questions/8908760/should-i-use-camel-case-or-underscores-in-python


Kind regards,
Sithu


*Sent with Shift
<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>*

On Fri, Apr 19, 2019 at 6:23 PM Balaji Shetty 
wrote:

> HI
>
> My models.py
>
>
> class T1(models.Model):
> CaseNumber = models.TextField(blank=True,null=True)
> UserCurrent = models.TextField(blank=True,null=True,default='user1')
> UserCurrentDepartment = models.TextField(blank=True,null=True)
>
> def __str__(self):
> return '%s %s' % (self.CaseNumber , self.UserCurrentDepartment )
>
> 
>  Assume Record in MODELS T1  to be entered by respectuve user are
> (
> *  I will create System User U1, U2 and U3 for IT,CS and MECH Department
> only. *
> *)*
> CaseNumber  -- UserCurrent  --UserCurrentDepartment
>  11 - U1 - *iT*
>
> * 12 - U1 - IT*
>
> *13 - U1 - IT*
>
>  21 - U2 - *CS*
> * 22 - U2 - CS*
>
> *23 - U2- CS*
>
>  31 - U3 - *MECH*
>
> * 32 - U3 - MECH *
> *33 - U3 - MECH*
> *--*
>
>
> *when I run the Project by creating One Superuser*
>
> *http://127.0.0.1:8000/admin/appname/t1/
> <http://127.0.0.1:8000/admin/appname/t1/>*
>
> * i get all records of all Users and all Departments.*
> *I will create three user of Name U1,U2 and U3 of IT,CS and MECH
> Department and ask them to do CRUD Operation. I want the output in
> following way use rwise.*
>
>
> *When User U1 do the login in Admin Panel, He should get only his
> Department Records -IT, not other department*
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  11 - U1 - *iT*
>
> * 12 - U1 - IT*
>
> *13 - U1 - IT*
> *--*
>
> *When User U2 do the login in Admin Panel, He should get only his
> Department Records - CS,, not other department*
>
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  21 - U2 - *CS*
> * 22 - U2 - CS*
>
> *23 - U2- CS*
> *--*
>
> *When User U3 do the login in Admin Panel, He should get only his
> Department Records - MECH, , not other department*
>
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  31 - U3 - *MECH*
>
> * 32 - U3 - MECH *
> *33 - U3 - MECH*
> *--*
>
> *When I create superuser, he has access to all user data.*
>
> *But other users U1, U2 and U3 have also access of other users Data.*
>
>
> *So My query is how can i accomplish this Constraint.*
>
> --.
>
> How can i write a customized query so that Admin panel should display only
> particular Department as per respective user Deparement.-
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> 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/CAECSbOtiHTPCprTj9w168rHksoUf2TKsju-yQHZvJLw14eZ9Ag%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAECSbOtiHTPCprTj9w168rHksoUf2TKsju-yQHZvJLw14eZ9Ag%40mail.gmail.com?utm_medium=email_source=footer>
> .
> 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/CAH-SnCCSuqweF_hfSCUXR6p3O3WsHrNEWLcShe%2BdQx6tkYEkmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Gourav Chawla
First of all, use appropriate model fields for linking objects. For example 
users should be a foreign key to your(or Django's) user table.

Then whenever you want to show data on any interface to any user, just filter 
content/rows by user department.

Something like:

T1.objects.filter(user=current_user, department=current_user.department)

-- 
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/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django How to write Customized Query ( Display Information Departmentwise)

2019-04-19 Thread Balaji Shetty
HI

My models.py


class T1(models.Model):
CaseNumber = models.TextField(blank=True,null=True)
UserCurrent = models.TextField(blank=True,null=True,default='user1')
UserCurrentDepartment = models.TextField(blank=True,null=True)

def __str__(self):
return '%s %s' % (self.CaseNumber , self.UserCurrentDepartment )


 Assume Record in MODELS T1  to be entered by respectuve user are
(
*  I will create System User U1, U2 and U3 for IT,CS and MECH Department
only. *
*)*
CaseNumber  -- UserCurrent  --UserCurrentDepartment
 11 - U1 - *iT*

* 12 - U1 - IT*

*13 - U1 - IT*

 21 - U2 - *CS*
* 22 - U2 - CS*

*23 - U2- CS*

 31 - U3 - *MECH*

* 32 - U3 - MECH *
*33 - U3 - MECH*
*--*


*when I run the Project by creating One Superuser*

*http://127.0.0.1:8000/admin/appname/t1/
<http://127.0.0.1:8000/admin/appname/t1/>*

* i get all records of all Users and all Departments.*
*I will create three user of Name U1,U2 and U3 of IT,CS and MECH Department
and ask them to do CRUD Operation. I want the output in following way use
rwise.*


*When User U1 do the login in Admin Panel, He should get only his
Department Records -IT, not other department*

CaseNumber--   UserCurrent  --  UserCurrentDepartment
 11 - U1 - *iT*

* 12 - U1 - IT*

*13 - U1 - IT*
*--*

*When User U2 do the login in Admin Panel, He should get only his
Department Records - CS,, not other department*


CaseNumber--   UserCurrent  --  UserCurrentDepartment
 21 - U2 - *CS*
* 22 - U2 - CS*

*23 - U2- CS*
*--*

*When User U3 do the login in Admin Panel, He should get only his
Department Records - MECH, , not other department*


CaseNumber--   UserCurrent  --  UserCurrentDepartment
 31 - U3 - *MECH*

* 32 - U3 - MECH *
*33 - U3 - MECH*
*--*

*When I create superuser, he has access to all user data.*

*But other users U1, U2 and U3 have also access of other users Data.*


*So My query is how can i accomplish this Constraint.*

--.

How can i write a customized query so that Admin panel should display only
particular Department as per respective user Deparement.-


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

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


Django model field and external SQL query

2019-04-18 Thread aardzhanov
Hello, my friends.

I need to connect SQL query and model field as ManyToManyField.

For example, models.py:

cursor = connections['req'].cursor()

query="""SELECT…."""

cursor.execute(query)

emps = cursor.fetchall()



class test(models.Model)
 name = models.CharField(...)
 ext_field=models.ManyToManyField('emps')


Is it possible?


-- 
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/e810044e-1058-46e5-a930-eb72d709ce91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django model field and external SQL query

2019-04-18 Thread aardzhanov
Hello, my friends.

I need to add in my model ManyToManyField connected to any sql query

For example, models.py:

cursor = connections['req'].cursor()
query="""SELECT…."""
cursor.execute(query)
emps = cursor.fetchall()



class test(models.Model)
  name = models.CharField(...)
  ext_field=models.ManyToManyField('emps')



Is it possible? 


-- 
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/cfbb6e80-50e3-41b0-96ba-1ae92a5def79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex query on inner join - case for __ne?

2019-04-15 Thread nm
I've only had a quick look at your problem, but looks like maybe this 
section of the Django documentation could be useful: 
https://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-valued-relationships


On Friday, 12 April 2019 15:10:59 UTC+2, Michael Thomas wrote:
>
> Hello everyone,
>
> I've run into what I believe is a limitation of the ORM that other people 
> must be dealing with somehow, but I can't seem to figure out a sensible 
> solution.
>
> I think it's easiest to describe the problem with code.
>
> For the following models:
>
> class Foo(models.Model):
> name = models.CharField(max_length=64)
>
>
> class Bar(models.Model):
> foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
> attribute_1 = models.IntegerField()
> attribute_2 = models.IntegerField()
>
> I want to select all Foo() that have 1 or more bar with attribute_1 not 
> equal to 1, and attribute_2 equal to 2.
>
> Eg. SQL something like this:
>
> SELECT 
> "app_foo"."id", 
> "app_foo"."name" 
> FROM "app_foo" 
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> ) 
> WHERE (
> "app_bar"."attribute_1" <> 1 
> AND "app_bar"."attribute_2" = 2
> )
>
> However, here's what I end up with...
>
>
> print(Foo.objects.exclude(bar__attribute_1=1).filter(bar__attribute_2=2).query)
> SELECT 
> "app_foo"."id", 
> "app_foo"."name" 
> FROM "app_foo" 
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> ) 
> WHERE (
> NOT (
> "app_foo"."id" IN (
> SELECT 
> U1."foo_id" 
> FROM "app_bar" U1 
> WHERE U1."attribute_1" = 1
> )
> ) 
> AND "app_bar"."attribute_2" = 2
> )
>
> print(Foo.objects.filter(~Q(bar__attribute_1=1), bar__attribute_2=2).query)
> Exact same SQL output as above 
>
> Interestingly enough, a simple query for attribute_1=1 and attribute_2=2 
> works as expected, so it would be trivial to do this with a __ne operator 
> (if it existed), without any other changes to the ORM:
>
> print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query)
> SELECT 
> "app_foo"."id", 
> "app_foo"."name" 
> FROM "app_foo" 
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> ) 
> WHERE (
> "app_bar"."attribute_1" = 1 
> AND "app_bar"."attribute_2" = 2
> )
>
> Am I missing something here? How are other people tackling this?
>
> Kind Regards,
> Michael Thomas
>
>

-- 
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/8142abe8-1d14-4eff-aa6b-0f281ce14181%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex query on inner join - case for __ne?

2019-04-12 Thread Michael Thomas
Naimur: I am - that SQL was in response to  Aldian's question :)

On Fri, Apr 12, 2019 at 8:23 PM naimur rahman 
wrote:

> use ORM istead of SQL
>
> On Fri, Apr 12, 2019, 7:42 PM Michael Thomas <
> michael.thomas.s...@gmail.com> wrote:
>
>> SELECT
>> "app_foo"."id",
>> "app_foo"."name"
>> FROM "app_foo"
>> INNER JOIN "app_bar" ON (
>> "app_foo"."id" = "app_bar"."foo_id"
>> )
>> WHERE (
>> NOT (
>> "app_foo"."id" IN (
>> SELECT
>> U1."foo_id"
>> FROM "app_bar" U1
>> WHERE U1."attribute_1" = 1
>> )
>> )
>> AND "app_bar"."attribute_2" = 2
>> )
>>
>> On Fri, Apr 12, 2019 at 6:59 PM Aldian Fazrihady 
>> wrote:
>>
>>> What's the result of
>>>
>>> print(Foo.objects.exclude(bar__attribute=1).filter(
>>> bar__attribute_2=2).query)
>>>
>>> On Fri, 12 Apr 2019, 20:10 Michael Thomas, <
>>> michael.thomas.s...@gmail.com> wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> I've run into what I believe is a limitation of the ORM that other
>>>> people must be dealing with somehow, but I can't seem to figure out a
>>>> sensible solution.
>>>>
>>>> I think it's easiest to describe the problem with code.
>>>>
>>>> For the following models:
>>>>
>>>> class Foo(models.Model):
>>>> name = models.CharField(max_length=64)
>>>>
>>>>
>>>> class Bar(models.Model):
>>>> foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
>>>> attribute_1 = models.IntegerField()
>>>> attribute_2 = models.IntegerField()
>>>>
>>>> I want to select all Foo() that have 1 or more bar with attribute_1 not
>>>> equal to 1, and attribute_2 equal to 2.
>>>>
>>>> Eg. SQL something like this:
>>>>
>>>> SELECT
>>>> "app_foo"."id",
>>>> "app_foo"."name"
>>>> FROM "app_foo"
>>>> INNER JOIN "app_bar" ON (
>>>> "app_foo"."id" = "app_bar"."foo_id"
>>>> )
>>>> WHERE (
>>>> "app_bar"."attribute_1" <> 1
>>>> AND "app_bar"."attribute_2" = 2
>>>> )
>>>>
>>>> However, here's what I end up with...
>>>>
>>>>
>>>> print(Foo.objects.exclude(bar__attribute_1=1).filter(bar__attribute_2=2).query)
>>>> SELECT
>>>> "app_foo"."id",
>>>> "app_foo"."name"
>>>> FROM "app_foo"
>>>> INNER JOIN "app_bar" ON (
>>>> "app_foo"."id" = "app_bar"."foo_id"
>>>> )
>>>> WHERE (
>>>> NOT (
>>>> "app_foo"."id" IN (
>>>> SELECT
>>>> U1."foo_id"
>>>> FROM "app_bar" U1
>>>> WHERE U1."attribute_1" = 1
>>>> )
>>>> )
>>>> AND "app_bar"."attribute_2" = 2
>>>> )
>>>>
>>>> print(Foo.objects.filter(~Q(bar__attribute_1=1),
>>>> bar__attribute_2=2).query)
>>>> Exact same SQL output as above
>>>>
>>>> Interestingly enough, a simple query for attribute_1=1 and
>>>> attribute_2=2 works as expected, so it would be trivial to do this with a
>>>> __ne operator (if it existed), without any other changes to the ORM:
>>>>
>>>> print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query)
>>>> SELECT
>>>> "app_foo"."id",
>>>> "app_foo"."name"
>>>> FROM "app_foo"
>>>> INNER JOIN "app_bar" ON (
>>>> "app_foo"."id" = "app_bar"."foo_id"
>>>> )
>>>> WHERE (
>>>> "app_bar"."attribute_1" = 1
>>>> AND "app_bar"."attribute_2&quo

Re: Complex query on inner join - case for __ne?

2019-04-12 Thread naimur rahman
use ORM istead of SQL

On Fri, Apr 12, 2019, 7:42 PM Michael Thomas 
wrote:

> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
> NOT (
> "app_foo"."id" IN (
> SELECT
> U1."foo_id"
> FROM "app_bar" U1
> WHERE U1."attribute_1" = 1
> )
> )
> AND "app_bar"."attribute_2" = 2
> )
>
> On Fri, Apr 12, 2019 at 6:59 PM Aldian Fazrihady 
> wrote:
>
>> What's the result of
>>
>> print(Foo.objects.exclude(bar__attribute=1).filter(
>> bar__attribute_2=2).query)
>>
>> On Fri, 12 Apr 2019, 20:10 Michael Thomas, 
>> wrote:
>>
>>> Hello everyone,
>>>
>>> I've run into what I believe is a limitation of the ORM that other
>>> people must be dealing with somehow, but I can't seem to figure out a
>>> sensible solution.
>>>
>>> I think it's easiest to describe the problem with code.
>>>
>>> For the following models:
>>>
>>> class Foo(models.Model):
>>> name = models.CharField(max_length=64)
>>>
>>>
>>> class Bar(models.Model):
>>> foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
>>> attribute_1 = models.IntegerField()
>>> attribute_2 = models.IntegerField()
>>>
>>> I want to select all Foo() that have 1 or more bar with attribute_1 not
>>> equal to 1, and attribute_2 equal to 2.
>>>
>>> Eg. SQL something like this:
>>>
>>> SELECT
>>> "app_foo"."id",
>>> "app_foo"."name"
>>> FROM "app_foo"
>>> INNER JOIN "app_bar" ON (
>>> "app_foo"."id" = "app_bar"."foo_id"
>>> )
>>> WHERE (
>>> "app_bar"."attribute_1" <> 1
>>> AND "app_bar"."attribute_2" = 2
>>> )
>>>
>>> However, here's what I end up with...
>>>
>>>
>>> print(Foo.objects.exclude(bar__attribute_1=1).filter(bar__attribute_2=2).query)
>>> SELECT
>>> "app_foo"."id",
>>> "app_foo"."name"
>>> FROM "app_foo"
>>> INNER JOIN "app_bar" ON (
>>> "app_foo"."id" = "app_bar"."foo_id"
>>> )
>>> WHERE (
>>> NOT (
>>> "app_foo"."id" IN (
>>> SELECT
>>> U1."foo_id"
>>> FROM "app_bar" U1
>>> WHERE U1."attribute_1" = 1
>>> )
>>> )
>>> AND "app_bar"."attribute_2" = 2
>>> )
>>>
>>> print(Foo.objects.filter(~Q(bar__attribute_1=1),
>>> bar__attribute_2=2).query)
>>> Exact same SQL output as above
>>>
>>> Interestingly enough, a simple query for attribute_1=1 and attribute_2=2
>>> works as expected, so it would be trivial to do this with a __ne operator
>>> (if it existed), without any other changes to the ORM:
>>>
>>> print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query)
>>> SELECT
>>> "app_foo"."id",
>>> "app_foo"."name"
>>> FROM "app_foo"
>>> INNER JOIN "app_bar" ON (
>>> "app_foo"."id" = "app_bar"."foo_id"
>>> )
>>> WHERE (
>>> "app_bar"."attribute_1" = 1
>>> AND "app_bar"."attribute_2" = 2
>>> )
>>>
>>> Am I missing something here? How are other people tackling this?
>>>
>>> Kind Regards,
>>> Michael Thomas
>>>
>>> --
>>> 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.
>

Re: Complex query on inner join - case for __ne?

2019-04-12 Thread Michael Thomas
SELECT
"app_foo"."id",
"app_foo"."name"
FROM "app_foo"
INNER JOIN "app_bar" ON (
"app_foo"."id" = "app_bar"."foo_id"
)
WHERE (
NOT (
"app_foo"."id" IN (
SELECT
U1."foo_id"
FROM "app_bar" U1
WHERE U1."attribute_1" = 1
)
)
AND "app_bar"."attribute_2" = 2
)

On Fri, Apr 12, 2019 at 6:59 PM Aldian Fazrihady  wrote:

> What's the result of
>
> print(Foo.objects.exclude(bar__attribute=1).filter(
> bar__attribute_2=2).query)
>
> On Fri, 12 Apr 2019, 20:10 Michael Thomas, 
> wrote:
>
>> Hello everyone,
>>
>> I've run into what I believe is a limitation of the ORM that other people
>> must be dealing with somehow, but I can't seem to figure out a sensible
>> solution.
>>
>> I think it's easiest to describe the problem with code.
>>
>> For the following models:
>>
>> class Foo(models.Model):
>> name = models.CharField(max_length=64)
>>
>>
>> class Bar(models.Model):
>> foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
>> attribute_1 = models.IntegerField()
>> attribute_2 = models.IntegerField()
>>
>> I want to select all Foo() that have 1 or more bar with attribute_1 not
>> equal to 1, and attribute_2 equal to 2.
>>
>> Eg. SQL something like this:
>>
>> SELECT
>> "app_foo"."id",
>> "app_foo"."name"
>> FROM "app_foo"
>> INNER JOIN "app_bar" ON (
>> "app_foo"."id" = "app_bar"."foo_id"
>> )
>> WHERE (
>> "app_bar"."attribute_1" <> 1
>> AND "app_bar"."attribute_2" = 2
>> )
>>
>> However, here's what I end up with...
>>
>>
>> print(Foo.objects.exclude(bar__attribute_1=1).filter(bar__attribute_2=2).query)
>> SELECT
>> "app_foo"."id",
>> "app_foo"."name"
>> FROM "app_foo"
>> INNER JOIN "app_bar" ON (
>> "app_foo"."id" = "app_bar"."foo_id"
>> )
>> WHERE (
>> NOT (
>> "app_foo"."id" IN (
>> SELECT
>> U1."foo_id"
>> FROM "app_bar" U1
>> WHERE U1."attribute_1" = 1
>> )
>> )
>> AND "app_bar"."attribute_2" = 2
>> )
>>
>> print(Foo.objects.filter(~Q(bar__attribute_1=1),
>> bar__attribute_2=2).query)
>> Exact same SQL output as above
>>
>> Interestingly enough, a simple query for attribute_1=1 and attribute_2=2
>> works as expected, so it would be trivial to do this with a __ne operator
>> (if it existed), without any other changes to the ORM:
>>
>> print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query)
>> SELECT
>> "app_foo"."id",
>> "app_foo"."name"
>> FROM "app_foo"
>> INNER JOIN "app_bar" ON (
>> "app_foo"."id" = "app_bar"."foo_id"
>> )
>> WHERE (
>> "app_bar"."attribute_1" = 1
>> AND "app_bar"."attribute_2" = 2
>> )
>>
>> Am I missing something here? How are other people tackling this?
>>
>> Kind Regards,
>> Michael Thomas
>>
>> --
>> 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/d852fc10-5f5a-43e8-8dab-c796404867a8%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/d852fc10-5f5a-43e8-8dab-c796404867a8%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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/CAN7EoAaXupYqNoPcHOcZ3OoA_07N--D4EPoEfZvkSWL%2BeLbD6A%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAN7EoAaXupYqNoPcHOcZ3OoA_07N--D4EPoEfZvkSWL%2BeLbD6A%40mail.gmail.com?utm_medium=email_source=footer>
> .
> 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/CAEdx1fpYmYHXX14iu3Enwc18Ojkk3%3DBfzTv3mGWVdf5BzZVv7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Complex query on inner join - case for __ne?

2019-04-12 Thread Aldian Fazrihady
What's the result of

print(Foo.objects.exclude(bar__attribute=1).filter(
bar__attribute_2=2).query)

On Fri, 12 Apr 2019, 20:10 Michael Thomas, 
wrote:

> Hello everyone,
>
> I've run into what I believe is a limitation of the ORM that other people
> must be dealing with somehow, but I can't seem to figure out a sensible
> solution.
>
> I think it's easiest to describe the problem with code.
>
> For the following models:
>
> class Foo(models.Model):
> name = models.CharField(max_length=64)
>
>
> class Bar(models.Model):
> foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
> attribute_1 = models.IntegerField()
> attribute_2 = models.IntegerField()
>
> I want to select all Foo() that have 1 or more bar with attribute_1 not
> equal to 1, and attribute_2 equal to 2.
>
> Eg. SQL something like this:
>
> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
>     "app_bar"."attribute_1" <> 1
> AND "app_bar"."attribute_2" = 2
> )
>
> However, here's what I end up with...
>
>
> print(Foo.objects.exclude(bar__attribute_1=1).filter(bar__attribute_2=2).query)
> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
> NOT (
> "app_foo"."id" IN (
> SELECT
> U1."foo_id"
> FROM "app_bar" U1
> WHERE U1."attribute_1" = 1
> )
> )
> AND "app_bar"."attribute_2" = 2
> )
>
> print(Foo.objects.filter(~Q(bar__attribute_1=1), bar__attribute_2=2).query)
> Exact same SQL output as above
>
> Interestingly enough, a simple query for attribute_1=1 and attribute_2=2
> works as expected, so it would be trivial to do this with a __ne operator
> (if it existed), without any other changes to the ORM:
>
> print(Foo.objects.filter(bar__attribute_1=1, bar__attribute_2=2).query)
> SELECT
> "app_foo"."id",
> "app_foo"."name"
> FROM "app_foo"
> INNER JOIN "app_bar" ON (
> "app_foo"."id" = "app_bar"."foo_id"
> )
> WHERE (
> "app_bar"."attribute_1" = 1
> AND "app_bar"."attribute_2" = 2
> )
>
> Am I missing something here? How are other people tackling this?
>
> Kind Regards,
> Michael Thomas
>
> --
> 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/d852fc10-5f5a-43e8-8dab-c796404867a8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d852fc10-5f5a-43e8-8dab-c796404867a8%40googlegroups.com?utm_medium=email_source=footer>
> .
> 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/CAN7EoAaXupYqNoPcHOcZ3OoA_07N--D4EPoEfZvkSWL%2BeLbD6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


<    1   2   3   4   5   6   7   8   9   10   >