Re: cannot access admin

20 views
Skip to first unread message

Melvyn Sopacua

unread,
Jul 4, 2012, 2:05:22 PM7/4/12
to django...@googlegroups.com
On 4-7-2012 19:18, Scott Somers wrote:

> My urls
>
> urlpatterns = patterns('',
> (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT }),
> )
>
> urlpatterns += patterns('',
> url(r'^$', 'tacobakedotnet.dotnet_forms.views.home'),
> url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'),

It looks like you have the project name in the view, which suggests the
current working directory of the project is one directory too high.
Could you show the directory layout, including the location of
settings.py, admin.py for the app and views.py.

--
Melvyn Sopacua


Scott Somers

unread,
Jul 4, 2012, 5:54:55 PM7/4/12
to django...@googlegroups.com
/Local Python Source Code/tacobakedotnet
manage.py
settings.py
urls.py
/Local Python Source Code/tacobakedotnet/media
JavaScript files
/Local Python Source Code/tacobakedotnet/dotnet_forms
models.py
tests.py
views.py
/Local Python Source Code/tacobakedotnet/dotnet_forms/static
CSS files

What it is having a hard time finding is 

So


and http://127.0.0.1:8000/admin/ actually works too

But when I try and access anything inside the admin I get article not found.

Now, and this might be interesting if I go http://127.0.0.1:8000/admin/sfsdfdsfsfd just doing gibberish it gives me the ArticleNotFound, as opposed to say 404, which it does if you do something that violates urlconf.  So basically the database got corrupted somehow is that what happened?

Tomas Neme

unread,
Jul 4, 2012, 6:33:44 PM7/4/12
to django...@googlegroups.com
ah, got it... your

url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'),

is too permisive
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Z5X0qegeC44J.
>
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

Tomas Neme

unread,
Jul 4, 2012, 6:34:10 PM7/4/12
to django...@googlegroups.com
On Wed, Jul 4, 2012 at 7:33 PM, Tomas Neme <lacry...@gmail.com> wrote:
> ah, got it... your
>
> url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'),
>
> is too permisive

...

maybe?

Nikolas Stevenson-Molnar

unread,
Jul 4, 2012, 6:40:33 PM7/4/12
to django...@googlegroups.com
Yes. \S+/\S+ will match <anything>/<anything>. Since /admin doesn't
contain a slash (other than the leading slash, which isn't considered),
it works fine. But /admin/whatever will get directed to your
tacobakedotnet.dotnet_forms.views.home view because it matches the URL
pattern. An easy fix would be to make sure your admin URL pattern comes
first in the list.

_Nik

Nikolas Stevenson-Molnar

unread,
Jul 4, 2012, 6:44:40 PM7/4/12
to django...@googlegroups.com
And actually, \S matches forward slashes, so even something like
/one/two/foo/bar would match.

_Nik

Scott Somers

unread,
Jul 4, 2012, 8:59:02 PM7/4/12
to django...@googlegroups.com
Yes, and this is a little embarrassing I was missing a line from the debugging output.

/home/tacobake/Source Code/Python (Komodo)/tacobakedotnet/../tacobakedotnet/dotnet_forms/views.py in home
  1.             article = Article.objects.get(menu__menu_title = menu, article_title__startswith=item)  

So that is where the word "Article" comes from in the earlier error message.

Now having said that I believe it is the permissiveness of the \S+ \S+ which may very well be what the problem is, I am going to change it but I need to learn a bit more first.  Basically I need the best way to pass a pair of options to the view function, which also just happen to be the URL, I was reading about it in the basic documentation for urls.  I do appreciate everyone's help.

Like if I set it to:

url(r'^source-code/(\S+)', ...) that is not dynamic enough for the view function, "Source Code" or source-code being the menu_title.

Scott Somers

unread,
Jul 4, 2012, 9:05:27 PM7/4/12
to django...@googlegroups.com
here we go I actually had a typo that slipped in, everything is working perfectly now thanks again to everyone.

urlpatterns = patterns('',
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT }),
)

urlpatterns += patterns('',
    url(r'^$', 'tacobakedotnet.dotnet_forms.views.home'),                        
    url(r'^admin/', include(admin.site.urls)),  <--- had a $ here
    url(r'^(\S+)/(\S+)', 'tacobakedotnet.dotnet_forms.views.home'),

Nikolas Stevenson-Molnar

unread,
Jul 4, 2012, 9:11:15 PM7/4/12
to django...@googlegroups.com
One thing you might consider is using a prefix for article URLs so that  you can more easily differentiate them from other URLs. For example: r'^articles/(\S+)/(\S+)' . Then, rather than a URL like /source-code/c++, you'd have /articles/source-code/c++.

_Nik
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/b8SobMx4jtkJ.
Reply all
Reply to author
Forward
0 new messages