Raja that was a great suggestion thank you! Once a started playing around with the urls in the project level I found that it was still being routed to viewLit despite the edit/ in the url I was passing. I decided to put all these classes into the same app viewLit/views.py and now my parameter is correct.
The problem I am now having is that UpdateView cannot find the template circuitinfotable_form.html
My viewLit/models.py is:
My viewLit/views.py is now:
my viewLit.urls.py is now:
and my template is:
I understand this has kind of moved to a new topic and I can start a new post if that is more appropriate than answering here.
-- SELECT ••• FROM "circuitinfotable" WHERE "circuitinfotable"."circuitid" = 'STTK-100G-18040-01-WRBB'
The problem I am now having is that UpdateView cannot find the template circuitinfotable_form.html
Environment:
Request Method: GETRequest URL: http://98.8.61.133:8080/viewLit/STTK-100G-18040-01-WRBB/edit
Django Version: 2.2.4Python Version: 3.6.8Installed Applications:['editLit.apps.EditlitConfig', 'viewLit.apps.ViewlitConfig', 'searchLit.apps.SearchlitConfig', 'homepage.apps.HomepageConfig', 'base.apps.BaseConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'debug_toolbar']Installed Middleware:['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template loader postmortemDjango tried loading these templates, in this order:
Using engine django: * django.template.loaders.filesystem.Loader: /home/db_user/ciopsdb/base/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.filesystem.Loader: /home/db_user/ciopsdb/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/editLit/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/viewLit/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/searchLit/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/homepage/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/base/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/contrib/admin/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/contrib/auth/templates/viewLit/circuitinfotable_form.html (Source does not exist) * django.template.loaders.app_directories.Loader: /home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/debug_toolbar/templates/viewLit/circuitinfotable_form.html (Source does not exist)
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 145. 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 143. response = response.render()
File "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/response.py" in render 106. self.content = self.rendered_content
File "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/response.py" in rendered_content 81. template = self.resolve_template(self.template_name)
File "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/response.py" in resolve_template 63. return select_template(template, using=self.using)
File "/home/db_user/ciopsdb/venv/lib64/python3.6/site-packages/django/template/loader.py" in select_template 47. raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
Exception Type: TemplateDoesNotExist at /viewLit/STTK-100G-18040-01-WRBB/editException Value: viewLit/circuitinfotable_form.html
My viewLit/models.py is:
class Circuitinfotable(models.Model): id1 = models.IntegerField(blank=True,null=True) 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) bw = models.IntegerField(blank=True, null=True) tableaupathname = models.CharField(max_length=255, blank=True, null=True) handoffalocaddress = models.CharField(max_length=255, blank=True, null=True) handoffaloccity = models.CharField(max_length=255, blank=True, null=True) handoffalocst = models.CharField(max_length=255, blank=True, null=True) alocationaddress = models.CharField(max_length=255, blank=True, null=True) alocationcity = models.CharField(max_length=255, blank=True, null=True) alocst = models.CharField(max_length=255, blank=True, null=True) handoffzlocaddress = models.CharField(max_length=255, blank=True, null=True) carrier = models.CharField(max_length=255, blank=True, null=True) handoffzloccity = models.CharField(max_length=255, blank=True, null=True) handoffzlocst = models.CharField(max_length=255, blank=True, null=True) zlocationaddress = models.CharField(max_length=255, blank=True, null=True) zlocationcity = models.CharField(max_length=255, blank=True, null=True) zlocst = models.CharField(max_length=255, blank=True, null=True) segmentid = models.CharField(max_length=255, blank=True, null=True) segmenttype = models.CharField(max_length=255, blank=True, null=True) status = models.CharField(max_length=255, blank=True, null=True) purpose = models.CharField(max_length=255, blank=True, null=True) installdate = models.DateField(blank=True, null=True) termdate = models.DateField(blank=True, null=True) termlengthmos = models.IntegerField(blank=True, null=True) legacy = models.CharField(max_length=255, blank=True, null=True) installciopsticket = models.CharField(max_length=255, blank=True, null=True) retermciopsticket = models.CharField(max_length=255, blank=True, null=True) discociopsticket = models.CharField(max_length=255, blank=True, null=True) notes = models.CharField(max_length=255, blank=True, null=True) kma = models.CharField(max_length=255, blank=True, null=True) group = models.IntegerField(blank=True, null=True) cktidkey = models.IntegerField(blank=True, null=True) visiolink = models.CharField(max_length=255, blank=True, null=True) latestjiraticket = models.CharField(max_length=255, blank=True, null=True, unique=True) disconnectdate = models.DateField(blank=True, null=True) segmentname = models.CharField(max_length=255, blank=True, null=True) mrcnew = models.TextField(blank=True, null=True) # This field type is a guess. termyrs = models.IntegerField(blank=True, null=True) monthbudget = models.IntegerField(blank=True, null=True) monthdisco = models.IntegerField(blank=True, null=True) mrcold = models.TextField(blank=True, null=True) # This field type is a guess. kmz = models.CharField(max_length=255, blank=True, null=True)
class Meta: managed = False db_table = 'circuitinfotable'
def get_absolute_url(self): return reverse()
My viewLit/views.py is now:
import refrom django.shortcuts import renderfrom django.http import HttpResponsefrom django.views.generic import TemplateViewfrom django.views.generic.edit import UpdateViewfrom django.urls import reverse
from . models import Circuitinfotable, Budgettable, Xcinventorytable
# Create your views here.def viewLit(request, circuitid): ruleList=["/SB", "/ZYO", "/ZYO /", "/MS", "/CLVI", "ELG"] for rule in ruleList: if(len(re.findall(rule + "$", circuitid))>0): circuitid=re.sub(rule+"$","/"+rule, circuitid) record = Circuitinfotable.objects.get(circuitid=circuitid) template = 'viewLit/viewCircuit.html' context = {'record':record} return render(request, template, context)
class editLit(UpdateView): pk_url_kwarg = 'circuitid' model=Circuitinfotable template="/viewLit/editCircuit.html" fields='__all__'
my viewLit.urls.py is now:
from django.urls import path, includefrom django.conf.urls import urlfrom . import views
urlpatterns= [ path('<path:circuitid>/', views.viewLit, name='viewLit'), path('<path:circuitid>/edit', views.editLit.as_view(), name='editLit'),]
and my template is:
<html text/html>
<body>{% block content %}
<form action="" method="POST">{% csrf_token %}{{form.as_p}}
<input type="submit" value="Update">
</form>
{% endblock %}</body></html>
I understand this has kind of moved to a new topic and I can start a new post if that is more appropriate than answering here.
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/c300fd7c-1f8e-4efe-89d3-2eaa175e2100%40googlegroups.com.
No comments:
Post a Comment