Django Ignoring updates to urls.py - django

The urls.py file In My Dango Project Is being Ignored; for Example I Tried Commenting Out The Admin Urls From the Project, And I Could Still Use The Admin. I tried Adding A Name Space, And Django Says It Doesn't Exist.
mysite/urls.py:
"""mysite URL Configuration
The `urlpatterns` list routes URLs to views. For more information, please see:
https://docs.djangoproject.com/en/3.0/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.static import static
from . import settings
urlpatterns = [
path('admin/', admin.site.urls),
path('',include("Wallet.urls"),
path('',include("django.contrib.auth.urls"))
] + static(settings.STATIC_URL, document_root='/home/dh_hemuuv/minicoin.fztl.com/static')
Wallet/urls.py:
from django.urls import path
from .views import signup,viewWallet,transfer,userpage,collectgift
urlpatterns = [
path("signup/",signup,name="signup"),
path("",viewWallet,name="home"),
path("transfer/",transfer,name="transfer"),
path("account/<str:username>/",userpage),
path("collectgift/<int:id>/",collectgift,name="colgift"),
]
Please Help!

oops I Found My Problem I found a Pesky __pycache__ Folder Deleteing Solved my problems

Related

Using the URLconf defined in myapp.urls, Django tried these URL patterns, in this order

I think I went through every available answer to this error but they all reference some other tutorial and a views.py which I do not have. After running the tutorial from here I get this 404 error.
Using the URLconf defined in myapp.urls, Django tried these URL patterns, in this order:
admin/
^$ [name='home']
^media/(?P<path>.*)$
^static/(?P<path>.*)$
The current path, market_data/, didn’t match any of these.
The urls.py has the following code:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.urls import re_path as url
from django.views.generic.base import TemplateView
urlpatterns = [
path('admin/', admin.site.urls),
url(r'^$', TemplateView.as_view(template_name='templates/static_pages/index.html'), name='home'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
The root directory structure of this project is
~/market_data/myapp
~/market_data/myapp/static_media
~/market_data/myapp/static_files
~/market_data/myapp/static_files/admin
~/market_data/myapp/templates
~/market_data/myapp/templates/static_pages
Thank you for any tips!

Django not using updated urls.py - returning 404 on www.site.com/page with outdated list

I am very new to django and beginning to understand some of the framework however view-route binding is confusing me
There is a persistent issue that when I try to visit any url except for the homepage and /admin I receive a 404, including routes I have declared in my project's urls.py file
also i am following this mdn tutorial
project urls.py
"""trends 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.views.generic import RedirectView
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('articles/', include('articles.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
app named 'articles' urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
app named 'articles' views.py
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the articles index.")
and here is the 404 page I receive
I know this is becoming very long but there is one more odd thing, when I refresh the 404 page, it will toggle between showing me the above screenshot and sometimes show me an old route which is no longer in the urls.py like this
this is on an nginx server with gunicorn, and restarting the nginx service does not solve the issue
In your projects urls.py you have defined
path('articles/', include('articles.urls')),
So by going to YOUR_URL/articles will not give a valid response. Instead try going to YOUR_URL/articles/ or change your path to
path('articles', include('articles.urls')),
Stumbled upon this SO post which lead me to the idea to restart gunicorn and that solved my problem so try running
sudo service gunicorn restart
should fix your problems

The current path, index, didn't match any of these. http://127.0.0.1:8001/index

I setup webpage via cmd for Django.However, i had problem when accessing index page of 127.0.0.1:8001. I tried to update urls.py but still have problem.
Browser page error:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8001/index
Using the URLconf defined in barry.urls, Django tried these URL patterns, in this order:
admin/
The current path, index, didn't match any of these.
urls.py file:
"""{{ project_name }} URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/{{ docs_version }}/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
from django.conf.urls import url
from sign import views
urlpatterns = [
path('admin/', admin.site.urls),
path('index/', views.index),
]
views.py
from django.shortcuts import render
# Create your views here.
def index(request):
return HttpResponse("Hello Django!")
You are mistaking in path pattern. Confusing with path, re_path and url.
Have a look at documentation Django Urls - Path.
urlpatterns = [
path('admin/', admin.site.urls),
path('index/', views.index),
]

"how to fix "No module named 'core' in django"

ajax_pro1 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.conf.urls import url
from core import views
urlpatterns = [
url(r'^signup/$', views.SignUpView.as_view(), name='signup'),
]

urls.py django 2.0.2 need parameters

i'm learning django and i'm making a blog tutorial but it's from older version that i have, i have version 2.0.2 and i'm not understand documentation my problem is that i dont know how configure my urls.py
this is my three proyect:
i need to put archive.html in 127.0.0.1:8000/ and this is my urls code
codigofacilito/blog.urls.py :
"""codigofacilito URL Configuration
The urlpatterns list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/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<br/>
from django.urls import path<br/>
from . import views<br/>
urlpatterns = [
path('admin/', admin.site.urls),
]
and codigofacilito/codigofacilito.urls.py:
from django.contrib import admin
from django.urls import path
from . import views
enter code here`urlpatterns = [
path('admin/', admin.site.urls),
]
from django.views.generic import TemplateView
urlpatterns = [
path('', TemplateView.as_view(template_name = 'archive.html')),
path('admin/', admin.site.urls),
]
put this in your project's urls.py, this will directly render the archive.html when you visit 127.0.0.1:8000/ in your browser.
but if you want to render data from backend in this html page then i suggest you to use views (function based , class based, etc..)
then you just have to import the views in url file and specify path for that.
from your_app.views import your_view
urlpatterns = [
path('/', your_view),
]