django-urls

How can I delete the answers (code in body)?

寵の児 提交于 2020-07-23 06:45:18
问题 I am creating a Q&A website for practice, I created the answer and the question model and linked them together, however I can not access the template that I set for the deletion of the answer model, I created a DeleteView to delete the question. Here is the code: views.py : class Politics_post_details(DeleteView): model = PoliticsPost context_object_name = 'politicsposts' pk_url_kwarg = 'qid' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # now you can get

How can I delete the answers (code in body)?

人走茶凉 提交于 2020-07-23 06:43:38
问题 I am creating a Q&A website for practice, I created the answer and the question model and linked them together, however I can not access the template that I set for the deletion of the answer model, I created a DeleteView to delete the question. Here is the code: views.py : class Politics_post_details(DeleteView): model = PoliticsPost context_object_name = 'politicsposts' pk_url_kwarg = 'qid' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # now you can get

Django view function not being called on click of submit

不想你离开。 提交于 2020-07-22 09:26:12
问题 I have two view functions in my views.py. The first one renders the index.html Second is created for the form action on index.html (update_db). When I click on submit on the index.html file, it changes url to /update1, but the function call has print('HI') and I cannot see that on console. Neither are any new files created after it runs. Intially I had return render(request, 'index.html', {} ) but I am not sure if that should be returned. Is there some problem with my urls.py? views.py from

problem in loading media files into templates

巧了我就是萌 提交于 2020-07-10 07:07:31
问题 My django project is searching for images in /profile/<pk>/myapp/profile_pics/images.jpg instead of myapp/profile_pics/images.jpg similar to this question image isn't uploaded to media root using Django settings.py - MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' urls.py - urlpatterns = [ path('profile/<int:pk>/', views.profile, name='profile'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) views.py - def profile(request,

Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/contacts/contact.html

倾然丶 夕夏残阳落幕 提交于 2020-06-29 04:40:10
问题 I fails to connect my index.html page with contact.html page it shows this above error when i tried Using the URLconf defined in Website.urls, Django tried these URL patterns, in this order: admin/ [name='home-page'] Contact/ The current path, contacts/contact.html, didn't match any of these. This my contacts.urls.py from django.urls import path from . import views urlpatterns = [ path('Contact', views.contacts, name='contact-us') ] my contacts.views.py from django.shortcuts import render #

Django - include app urls

孤街浪徒 提交于 2020-06-10 08:46:31
问题 I have the following structure (Django 1.4): containing_dir/ myproject/ myapp1/ myapp2/ myapp3/ myproject, myapp1, myapp2, and myapp3 all have init .py, so they're all modules. In manage.py (under containing_dir) I have os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") in myproject.settings i define: [..] ROOT_URLCONF = 'myproject.urls' INSTALLED_APPS = ( [..] 'myproject.myapp1', 'myproject.myapp2', 'myproject.myapp3', ) [..] In myapp1.urls.py I define: urlpatterns =

Django - include app urls

旧巷老猫 提交于 2020-06-10 08:44:10
问题 I have the following structure (Django 1.4): containing_dir/ myproject/ myapp1/ myapp2/ myapp3/ myproject, myapp1, myapp2, and myapp3 all have init .py, so they're all modules. In manage.py (under containing_dir) I have os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") in myproject.settings i define: [..] ROOT_URLCONF = 'myproject.urls' INSTALLED_APPS = ( [..] 'myproject.myapp1', 'myproject.myapp2', 'myproject.myapp3', ) [..] In myapp1.urls.py I define: urlpatterns =