English 中文(简体)
Why an extra slash is getting added to urls?
原标题:

I ve created a blog using django and hosted it on dotcloud http://www.honeybunny.dotcloud.com/blog/ its working fine on the localhost but when i try to access it online an extra slash is added to the urls what could be the reason ?

www.sitename.com/admin/

becomes

www.sitename.com//admin/

my urls.py is as following

from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
import blog
admin.autodiscover()

urlpatterns = patterns(  ,
    url(r ^$ ,redirect_to,{ url : /blog }),
    url(r ^admin/ , include(admin.site.urls)),
    url(r ^blog/ ,include( blog.urls )),
)

Also submitting the login form on the admin redirects me to http://admin/ while in the local environment it works perfectly fine .

UPDATE : My problem seems remarkably similar to the one described here .

最佳回答

It seemed to be a problem with dotcloud the same code worked without any errors when i uploaded it to epio

问题回答

From django tutorials the url file should look like the one below.

from django.conf.urls.defaults import *

urlpatterns = patterns( , (r ^articles/2003/$ , news.views.special_case_2003 ),
(r ^articles/(d{4})/$ , news.views.year_archive ),
(r ^articles/(d{4})/(d{2})/$ , news.views.month_archive ),
(r ^articles/(d{4})/(d{2})/(d+)/$ , news.views.article_detail ), )

from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns(  ,
# Examples:
    # url(r ^$ ,  honeybunny.views.home , name= home ),
        # url(r ^honeybunny/ , include( honeybunny.foo.urls )),

            # Uncomment the admin/doc line below to enable admin documentation:
                # url(r ^admin/doc/ , include( django.contrib.admindocs.urls )),

                    # Uncomment the next line to enable the admin:
                        url(r ^$ ,redirect_to,{ url : /blog }),
                            url(r ^admin/$ , include(admin.site.urls)),
                                )

Is my urls.py file
Django Admin

I have deleted import blog line because I don t have blog module.





相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签