Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Django trouble

Django trouble

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helppythondatabasecomsysadmin
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rastaVnuce
    wrote on last edited by
    #1

    So, a while ago I wrote here about starting to experiment with Django, and now I have come to a stop... I usually map my Django projects on the root, but this time I tried something different and failed very badly... I tried to map it to http://foo.com/django and encountered two problems, I hope you guys can help me with... Problem 1: If I go to address http://foo.com/django (without trailing slash) I get an Internal Server Error. Log shows this info:

    File "/var/lib/python-support/python2.5/django/middleware/common.py", line 41, in process_request
    if settings.APPEND_SLASH and (old_url1-1 != '/') and ('.' not in old_url1.split('/')-1):
    IndexError: string index out of range

    If I include the trailing slash it works (at least it seems to). APPEND_SLASH is (obviously) set to True. Problem 2: Let's go with urls.py that looks like this:

    from django.conf.urls.defaults import *
    from djangobook.views import hello

    urlpatterns = patterns('',
    (r'^hello/$', hello),
    )

    Instead of going to http://foo.com/django/hello I get redirected to http://foo.com/hello. I presume I'm missing a setting or something to make it relative to the project's starting URL?

    We are using Linux daily to UP our productivity - so UP yours!

    C 1 Reply Last reply
    0
    • R rastaVnuce

      So, a while ago I wrote here about starting to experiment with Django, and now I have come to a stop... I usually map my Django projects on the root, but this time I tried something different and failed very badly... I tried to map it to http://foo.com/django and encountered two problems, I hope you guys can help me with... Problem 1: If I go to address http://foo.com/django (without trailing slash) I get an Internal Server Error. Log shows this info:

      File "/var/lib/python-support/python2.5/django/middleware/common.py", line 41, in process_request
      if settings.APPEND_SLASH and (old_url1-1 != '/') and ('.' not in old_url1.split('/')-1):
      IndexError: string index out of range

      If I include the trailing slash it works (at least it seems to). APPEND_SLASH is (obviously) set to True. Problem 2: Let's go with urls.py that looks like this:

      from django.conf.urls.defaults import *
      from djangobook.views import hello

      urlpatterns = patterns('',
      (r'^hello/$', hello),
      )

      Instead of going to http://foo.com/django/hello I get redirected to http://foo.com/hello. I presume I'm missing a setting or something to make it relative to the project's starting URL?

      We are using Linux daily to UP our productivity - so UP yours!

      C Offline
      C Offline
      Chris Austin
      wrote on last edited by
      #2

      When you deploy on a subdirectory you will need to make sure you account for that in your url patterns. Take a look here.[^]

      And above all things, never think that you're not good enough yourself. A man should never think that. My belief is that in life people will take you at your own reckoning. --Isaac Asimov Avoid the crowd. Do your own thinking independently. Be the chess player, not the chess piece. --Ralph Charell

      R 1 Reply Last reply
      0
      • C Chris Austin

        When you deploy on a subdirectory you will need to make sure you account for that in your url patterns. Take a look here.[^]

        And above all things, never think that you're not good enough yourself. A man should never think that. My belief is that in life people will take you at your own reckoning. --Isaac Asimov Avoid the crowd. Do your own thinking independently. Be the chess player, not the chess piece. --Ralph Charell

        R Offline
        R Offline
        rastaVnuce
        wrote on last edited by
        #3

        So, all the url patterns have to start with '/django/ ' ? Besides, there are no instructions for mod_wsgi, or I can't see them?

        We are using Linux daily to UP our productivity - so UP yours!

        C 1 Reply Last reply
        0
        • R rastaVnuce

          So, all the url patterns have to start with '/django/ ' ? Besides, there are no instructions for mod_wsgi, or I can't see them?

          We are using Linux daily to UP our productivity - so UP yours!

          C Offline
          C Offline
          Chris Austin
          wrote on last edited by
          #4

          You shouldn't need to make any mod_wsgi changes. And don't copy the apache config on the link, it looks like it would kill you app :) since it seems to be a mod_python set-up. So, try to leave you apache config alone and start with your patterns.

          And above all things, never think that you're not good enough yourself. A man should never think that. My belief is that in life people will take you at your own reckoning. --Isaac Asimov Avoid the crowd. Do your own thinking independently. Be the chess player, not the chess piece. --Ralph Charell

          R 1 Reply Last reply
          0
          • C Chris Austin

            You shouldn't need to make any mod_wsgi changes. And don't copy the apache config on the link, it looks like it would kill you app :) since it seems to be a mod_python set-up. So, try to leave you apache config alone and start with your patterns.

            And above all things, never think that you're not good enough yourself. A man should never think that. My belief is that in life people will take you at your own reckoning. --Isaac Asimov Avoid the crowd. Do your own thinking independently. Be the chess player, not the chess piece. --Ralph Charell

            R Offline
            R Offline
            rastaVnuce
            wrote on last edited by
            #5

            Ok, so what I just figured is that I get redirected from foo.com/django/hello to coo.com/hello only if I leave the trailing slash. How can I make django append the trailing slash in the URL? APPEND_SLASH is set to true.

            We are using Linux daily to UP our productivity - so UP yours!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups