I've gone through the process, which is seemingly fairly straightforward of setting up an sitemap.xml file..
I'm getting 404 page when I go to www.example.com/sitemap.xml 'page not found' and a message (I've still got debug settings turned on..) along the lines of:
" Django tried these URL patterns, in this order:
^admin/
^nday/
^ ^$ [name='index']
^ ^tomorrow/$ [name='tomorrow']
^ ^day/(?P<day_name_url>\w+)/$ [name='day']
The current URL, sitemap.xml, didn't match any of these."
This is my urls.py file
from django.conf.urls import patterns, url
from django.contrib.sitemaps.views import sitemap
from nday import views
from nday import sitemap
from nday.sitemap import ndaySitemap
sitemaps = {
'posts': ndaySitemap,
}
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^tomorrow/$', views.tomorrow, name='tomorrow'),
url(r'^day/(?P<day_name_url>\w+)/$', views.day, name='day'),
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),)
and my sitemap.py file..
from django.contrib.sitemaps import Sitemap
from nday import models
from nday.models import nationalday
class ndaySitemap(Sitemap):
changefreq = "daily"
priority = 0.5
def items(self):
return nationalday.objects.all()
I've installed sitemaps as per the settings.py file..
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.sitemaps',
'nday',
)
Thank you so much in advance
If you are using the Django development server, it should reload when you make any code changes.
However in production (e.g. Apache or Nginx) you have to reload the server after making any changes to .py files.
Related
DoesNotExist at /admin/
URL matching query does not exist.
I copy code form old study-project and i haven't similar problem in old project.
settings.py INSTALLED_APPS:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'cutter',
]
admin.py:
from .models import URL
from django.contrib import admin
admin.site.register(URL)
urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('cutter.urls')),
path('admin/', admin.site.urls),
]
All another functions work.
I have developed oscar /django applications before but I am completely stumped by this issue:
I can see the dashboard url in the supported urls list but I am not able to access it.
404 Page
I have forked a few apps from oscar like voucher, shipping, checkout, reviews and customized them in various ways(None of these are dashboard related) . This is my INSTALLED_APPS:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'oscar.config.Shop',
'oscar.apps.analytics.apps.AnalyticsConfig',
'iirns.checkout.apps.CheckoutConfig',
'oscar.apps.address.apps.AddressConfig',
'iirns.shipping.apps.ShippingConfig',
'oscar.apps.catalogue.apps.CatalogueConfig',
'iirns.catalogue.reviews.apps.CatalogueReviewsConfig',
'oscar.apps.communication.apps.CommunicationConfig',
'oscar.apps.partner.apps.PartnerConfig',
'oscar.apps.basket.apps.BasketConfig',
'iirns.payment.apps.PaymentConfig',
'oscar.apps.offer.apps.OfferConfig',
'oscar.apps.order.apps.OrderConfig',
'oscar.apps.customer.apps.CustomerConfig',
'oscar.apps.search.apps.SearchConfig',
'iirns.voucher.apps.VoucherConfig',
'oscar.apps.wishlists.apps.WishlistsConfig',
'oscar.apps.dashboard.apps.DashboardConfig',
'oscar.apps.dashboard.reports.apps.ReportsDashboardConfig',
'oscar.apps.dashboard.users.apps.UsersDashboardConfig',
'oscar.apps.dashboard.orders.apps.OrdersDashboardConfig',
'oscar.apps.dashboard.catalogue.apps.CatalogueDashboardConfig',
'oscar.apps.dashboard.offers.apps.OffersDashboardConfig',
'oscar.apps.dashboard.partners.apps.PartnersDashboardConfig',
'oscar.apps.dashboard.pages.apps.PagesDashboardConfig',
'oscar.apps.dashboard.ranges.apps.RangesDashboardConfig',
'oscar.apps.dashboard.reviews.apps.ReviewsDashboardConfig',
'oscar.apps.dashboard.vouchers.apps.VouchersDashboardConfig',
'oscar.apps.dashboard.communications.apps.CommunicationsDashboardConfig',
'oscar.apps.dashboard.shipping.apps.ShippingDashboardConfig',
# 3rd-party apps that oscar depends on
'widget_tweaks',
'haystack',
'treebeard',
'sorl.thumbnail',
'django_tables2',
'mailer',
'extra',
]
and this is my root url file:
from django.conf.urls import url
from django.contrib import admin
from django.apps import apps
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('extra.urls')),
path('', include(apps.get_app_config('oscar').urls[0])),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
I use Pycharm,django2.0.4
I started Django yesterday.
I faced one error.
Using the URLconf defined in chatbottest.urls, Django tried these URL patterns, in this order:
1. admin/
2. globalHaksik/
The empty path didn't match any of these.
enter image description here
setting.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'globalHaksik',
]
chatbottest\urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('globalHaksik/', include('globalHaksik.urls')),
]
globalHaksik\urls.py
from django.urls import path
from . import views
urlpatterns = [
path('keyboard/', views.keyboard),
]
views.py
from django.http import JsonResponse
def keyboard(request):
return JsonResponse({
'type': 'buttons',
'buttons': ['학식', '배달음식']
})
I do not know the correct answer if I look for the same error on this site.
Please kindly answer me.
Update: Looks like you are just trying to access the URL leading to views.keyboard. So the url that you need to access is /globalHaksik/keyboard/ (and not just /keyboard) since the path defined in chatbottest\urls.py has globalHaksik/ in it:
path('globalHaksik/', include('globalHaksik.urls')),
If you are trying to access /, then you need to add the empty pattern as follows:
chatbottest\urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', views.your_view_name),
path('admin/', admin.site.urls),
path('globalHaksik/', include('globalHaksik.urls')),
]
If you are trying to access /globalHaksik/, then you you need to add the empty pattern to globalHaksik\urls.py:
globalHaksik\urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.your_view_name),
path('keyboard/', views.keyboard),
]
I've reviewed other posts related to my question, but I'm unable to find an answer for my question.
When I try to access "http://127.0.0.1:8000/TEST_PAGE" I get the following error:
"Using the URLconf defined in TEST_PAGE, Django tried these URL patterns, in this order:
^admin/
^$
^TEST_PAGE/
The current URL, TEST_PAGE, didn't match any of these."
Here is what I have for Mysite/Mysite/urls.py:
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', include('Main_Page.urls')),
url(r'^TEST_PAGE/', include('TEST_PAGE')),
]
I have the APP installed in Mysite/Mysite/settings.py:
INSTALLED_APPS = [
'TEST_PAGE',
'Main_Page',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
Here is what I have for Mysite/TEST_PAGE/urls.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^TEST_PAGE', views.index, name='TEST_PAGE'),
]
And here is what I have for Mysite/TEST_PAGE/views.py:
from django.shortcuts import render
def index(request):
return render(request, 'TEST_PAGE/TEST_PAGE.html')
The main/index/home app works fine, I'm just trying to access the second app.
I'm new to this, so any help would be appreciated.
By including 'TEST_PAGE' twice(in both urls.py), you have defined a url:
/TEST_PAGE/TEST_PAGE
So
django can find url /TEST_PAGE/TEST_PAGE but not /TEST_PAGE
Your Mysite/TEST_PAGE/urls.py should be:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='TEST_PAGE'), # maps to /TEST_PAGE/
]
I made a fresh install of django 1.6.2 in it's own virtualenv. No syncdb, no other configs. The only other apps installed are pip, setuptools and dojango. I followed the instructions in this wiki page https://github.com/klipstein/dojango/wiki/Gettingstarted
when I try 127.0.o.1:8000/dojango/test/ or localhost:8000/dojango/test I get
Page not found (404)
Request Method: GET
Request URL: http://127.0.o.1:8000/dojango/test/
Using the URLconf defined in dojango.urls, Django tried these URL patterns, in this order:
^dojango/ ^dojango/
The current URL, dojango/test/, didn't match any of these.
this is my INSTALLED_APPS
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dojo_tutor',
'dojango',)
and this is my urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^dojango/', include('dojango.urls')),
# url(r'^admin/', include(admin.site.urls)),
)
The wiki page says to use (r'^dojango/', include('dojango.urls')), but I tried both like that and url(r'^dojango/', include('dojango.urls')),. I still get 404
Ok, it was a silly mistake. Foolishly I had named my project dojango so naturally there was a naming conflict. Deleted the project and recreated it with another name. Now it works.