Wednesday, December 14, 2016

Re: Problem with views when I try to move urls to a new app (folder)

Hi,

I found the problem, I had a problem with the local database. Now it works.

Thanks,
Uri.


Uri Even-Chen  
photo Phone: +972-54-3995700
Email: uri@speedy.net
Website: http://www.speedysoftware.com/uri/en/
    

On Wed, Dec 14, 2016 at 4:31 PM, Uri Even-Chen <uri@speedy.net> wrote:
Dear Django Users,

I'm trying to move the main view into a new main app (folder) inside speedy/mail. Currently the file urls.py is like this:

from django.conf import settings
from django.conf.urls import url, include
from . import views
from django.conf.urls.static import static
urlpatterns = [
url(r'^feedback/', include('speedy.net.feedback.urls', namespace='feedback')),
url(r'^', views.MainPageView.as_view(), name='main_page_view'),
]
if settings.DEBUG:
urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns
try:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
except ImportError:
pass

Now I want to move the main page url & view to speedy/mail/main/urls.py and views.py. Now the urls.py is like this:

from django.conf import settings
from django.conf.urls import url, include
from django.conf.urls.static import static

urlpatterns = [
url(r'^feedback/', include('speedy.net.feedback.urls', namespace='feedback')),
url(r'', include('speedy.mail.main.urls', namespace='main')),
]

if settings.DEBUG:
urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns

try:
import debug_toolbar
urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)),
]
except ImportError:
pass

And speedy/mail/main/urls.py is like this:

from django.conf.urls import url

from . import views

urlpatterns = [
url(r'', views.MainPageView.as_view(), name='main_page_view'),
]

But the problem is it doesn't work, I get this error message:

DoesNotExist at /

Site matching query does not exist.
I also tried with r'^' instead of r'' but it still doesn't work. What did I do wrong?

Thanks,
Uri.

Uri Even-Chen  
photo Phone: +972-54-3995700
Email: uri@speedy.net
Website: http://www.speedysoftware.com/uri/en/
    

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMQ2MsFwDWd%3DgeOLC%2Bm8hjgvM%3Dfoq39uoOrBZ%3DGmPiJmF5ouow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment