Daniel thank you but I'm not sure what you mean. The a href link works for everything so far except in the case that the circuitid contains a //. So I don't think its that my url's are not routing properly it seems to me like a // is being interpreted as an escape character. I looked over my code again and could not understand what you intended to point out.
On Thursday, November 14, 2019 at 11:06:09 AM UTC-6, DANIEL URBANO DE LA RUA wrote:
-- On Thursday, November 14, 2019 at 11:06:09 AM UTC-6, DANIEL URBANO DE LA RUA wrote:
a href="/viewLit/{{ circuit.circuitid }}" tand in your urls.pypath(r'<path:circuitid>/', views.viewLit, name='viewLit'),El jue., 14 nov. 2019 a las 18:04, DANIEL URBANO DE LA RUA (<dannybo...@gmail.com>) escribió:check on your a link you are including vieset/ and there is not on your urlEl jue., 14 nov. 2019 a las 17:17, Integr@te System (<datacen...@gmail.com>) escribió:--Hi Informer,check you model Circuitinfotable,Method call must include object instance as argument.On Thu, Nov 14, 2019, 21:42 Patrick Carra <pcar...@gmail.com> wrote: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:--<html>
<head>
<meta charset="UTF-8">
<title>Circuits</title>
<style>
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;
}
</style>
{% block content %}
<h1 align="center">Search Lit Circuits</h1>
<h6 align="center">Enter your search criteria below:</h6>
<form method="get">
<table class="form" style="width:100%">
<tr>
<th align="right">Circuit ID:</th><td><input type="text" name="circuitid" maxlength="100"></td>
<th align="right">Bandwidth:</th><td><input type="text" name="bandwidth" maxlength="100"></td>
<th align="right">Region:</th><td><input type="text" name="region" maxlength="100"></td>
</tr>
<tr>
<th align="right">Carrier:</th><td><input type="text" name="carrier" maxlength="100"></td>
<th align="right">Status:</th><td><input type="text" name="status" maxlength="100"></td>
<th align="right">Segmentname:</th><td><input type="text" name="segmentname" maxlength="100"></td>
</tr>
<tr>
<th align="right">MRC:</th><td><input type="text" name="mrcnew" maxlength="100"></td>
</tr>
</table>
<button type="submit">Search</button>
<a href="/searchlit/customsearch">
<input type="button" value="Clear" /></a>
</form>
<body>
<p>{{ filter.qs.count }} circuits returned</p>
<div>
<table style="width:100%">
<thead class="tabledata">
<tr>
<th>
{% if user.is_authenticated %}
Edit/
{% endif %}
View
</th>
<th>CircuitID</th>
<th>Bandwidth</th>
<th>Region</th>
<th>Carrier</th><th>Status</th> <th>Segmentname</th> <th>MRC</th> </tr> </thead> <tbody> {% for circuit in filter.qs %} <tr class="tablerow"> <td class="actions"> {% if user.is_authenticated %} <a href="/editLit/{{ circuit.circuitid }}" target="_blank" class="edit-item" title="Edit">Edit</a> {% endif %} <a href="/viewLit/{{ circuit.circuitid }}" target="_blank" class="view-item" title="View">View</a> </td> <td>{{ circuit.circuitid }}</td> <td>{{ circuit.bandwidth }}</td> <td>{{ circuit.region }}</td> <td>{{ circuit.carrier }}</td> <td>{{ circuit.status }}</td> <td>{{ circuit.segmentname }}</td> <td>{{ circuit.mrcnew }}</td> </tr> {% endfor %} </tbody> </table> </div> </body> {% endblock %} </html>My project level urls.py file:"""ciopsdb URL ConfigurationThe `urlpatterns` list routes URLs to views. For more information please see:Examples:Function views1. Add an import: from my_app import views2. Add a URL to urlpatterns: path('', views.home, name='home')Class-based views1. Add an import: from other_app.views import Home2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')Including another URLconf1. Import the include() function: from django.urls import include, path2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))"""from django.contrib import adminfrom django.urls import path, includefrom django.conf.urls import urlurlpatterns = [path('admin/', admin.site.urls),path('', include('homepage.urls')),path('searchlit/', include('searchLit.urls')),path('viewLit/', include('viewLit.urls')),]My viewLit app's urls.pyfrom django.urls import path, includefrom django.conf.urls import urlfrom . import viewsurlpatterns= [path(r'<path:circuitid>/', views.viewLit, name='viewLit'),]
My viewLit app's views.pyfrom django.shortcuts import renderfrom django.http import HttpResponsefrom django.views.generic import TemplateViewfrom . 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/ 34. response = get_response(request) File "/home/db_user/ciopsdb/venv/django/core/handlers/ exception.py" in inner lib64/python3.6/site-packages/ 115. response = self.process_exception_by_django/core/handlers/base.py" in _get_response middleware(e, request) File "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/ 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/db_user/ciopsdb/django/core/handlers/base.py" in _get_response viewLit/views.py" in viewLit 9. record = Circuitinfotable.objects.get(circuitid=circuitid) File "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/ 82. return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/db_user/ciopsdb/venv/django/db/models/manager.py" in manager_method lib64/python3.6/site-packages/ 408. self.model._meta.object_name Exception Type: DoesNotExist at /viewLit/OQYX/173774/ZYO/ Exception Value: Circuitinfotable matching query does not exist.django/db/models/query.py" in get 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
You received this message because you are 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/ .CAP5HUWqOnTrZvzArw77fnyDRHP4BA 9QmoUEdR4a9boMFVxggRg%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+unsubscribe@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.
No comments:
Post a Comment