Redirectview error

My site keeps changing 127.0.0.1:8000 into 127.0.0.1:8000/%5Ecatalog/%5Ecatalog/%5Ecatalog/%5Ecatalog/ (and going on) instead of 127.0.0.1:8000/catalog/
Does someone now the problem? I sent my code in an image below
if not works:
url(‘catalog/‘, include(‘catalog.urls’))
url(r’^’, RedirectView.as_view(url=r’^127.0.0.1:8000/catalog/)),

I have tried everything but nothing works, please help :slight_smile:

Couple of meta-suggestions here:

  • When you’re posting code, post it as preformatted text. Some of the characters get swallowed up by the formatting of the site, which makes the code you post different from what you actually have in your code.

  • When you’re posting code, please copy/paste the text. Images are extremely difficult to read depending upon the device being used. It also makes it more difficult to quote the text to show the errors and corrections.

Now to get to the core of the issue you’re posting about.
First review the docs on RedirectView, specifically the url parameter.

Also note that “internal urls” don’t specify the host name.

Finally, just to avoid some confusion in the future, I would recommend that you change from using the ‘url’ specification to using the new-style ‘path’ specifications. You’ll have many fewer problems that way.

Ken

I’ve used the newer path specification, but it gives multiple massages that it doesn’t work - only the url works…
And I’ve looked at the RedirectView docs, but I could not find the answer I’m looking for - nothing worked for me
Is there any way I could fix this that you know of?

Regarding path vs url, I’d need to see what you tried and what the error messages are that you’re receiving.

Regarding the redirect, the url parameter is a string, not a regex. Also, you don’t want to specify the host ip address when the target of the redirect is the same server.

Ken