Please help

Question

This is a copy of my question in stackoverflow, please help. http://stackoverflow.com/questions/44001085/how-to-get-request-metahttp-host-in-settings-py

 

I am making a django application where it will have 2 apps. When you open www.webName.co.id it will use urls.py from app A, but when you open webName.co.uk it will use urls.py from app B

This is the urls.py from the main project:
    
    urlpatterns = [
    url(r'^tinymce/', include('tinymce.urls')),
    url(r'^filer/', include('filer.urls')),
    url(r'^ckeditor/', include('ckeditor_uploader.urls')),
    url(r'^admin/', admin.site.urls),
    ]

I was planning to add something like this to that file:

    if settings.CURRENT_HOST_IP == 'www.webname.co.id':
        urlpatterns += url(r'^', include('webname_id.urls')),
    else:
        urlpatterns += url(r'^', include('webname_uk.urls')),

That way, it will simply use the urls from the app that is being used, depending on the current www you are entering the site with.

So my project have 1 backend admin, but multiple front-end templates and urls. The problem is i can't figure out how to set CURRENT_HOST_IP in the settings.py,

Usually i use this to get the current IP / host the user is using:
    
     request.META['HTTP_HOST']

But i can't access the request object in settings.py

Guest May 16, 2017, 8:35 a.m. 1 Answer

Answers ( 1 )

  1. May 19, 2017, 1:09 p.m.

    try 

    from django.conf.urls import include, url

    url valueshould be stored inside url 

    try 

    print url to see what you will get

Warning! You are not logged in.
Your answer will be published as Guest user.

Post your Answer

 Prev question