0

I want to create custom url like this http://admin:testserver.com/login/

I've been trying different ways to to achieve this but all of my efforts were in vain. After reading Django document i'm able to create a custom url where i can add a certain prefix after the domain name which look like this

"http://127.0.0.1:8000/mod:add_product/"

with this line of code

url(r'^mod:', include('moderator.urls')),

My friend was suggesting to use django_subdomains to get a somewhat similar url which would look like this "http://admin.xyz.com/loign" i was considering that as an option but django_subdomains has been abandoned since July 2019 is there any other options to create such urls?

  • 1
    Whats wrong with paths such as ```/mod/``` and ```/admin/```? – Robert Kearns Jun 11 '21 at 10:10
  • Domains shall be registered on your DNS, Django won’t manage that part. – Mohamed ElKalioby Jun 11 '21 at 10:21
  • Try to avoid using reserved characters in your url's path, like ":" "/" "?" "#" "[" "]" "@" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" as they have some special meaning defined in [RFC 3986](https://www.ietf.org/rfc/rfc3986.txt). More in this thread: https://stackoverflow.com/questions/1856785/characters-allowed-in-a-url – twk Jun 11 '21 at 10:24
  • This is not compliant with how a URL should look like. The hostname can not contain a colon. You can percentage encode it, but that is often ugly. – Willem Van Onsem Jun 11 '21 at 10:28
  • actually it was included in the requirements of the client i'm working for. – Muhammad Asad Waseem Jun 11 '21 at 12:08
  • Can you explain how each part of the URL is meant to be interpreted with this `prefix` that you want to put before the domain? – Chris Doyle Jun 11 '21 at 12:21
  • yes there are 3 main players for this project the customer, moderators and super admin. the client himself is familiar with django. He wants two of there players to have their own prefixes like moderators will have mod. and super admin will have su. as a prefix in the url and then these prefix added urls are later bind with the actual urls of their respected apps. – Muhammad Asad Waseem Jun 11 '21 at 22:27
  • I've successfully attained that by using django-hosts and it was a little bit tricky but i found the solution and is working fine so far. can you please guide me like is there a way to extend admin panel with some custom views ? – Muhammad Asad Waseem Jun 11 '21 at 22:30

0 Answers0