-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to test sub-domains in my localhost? #61
Comments
I came accross the same issue, and easily bypass it by modifying my hosts file (
|
I'm having trouble getting mine configured correctly. Have sites enabled and site domain for "SITE_ID = 1" (db object 1 domain) set too "mysite.app" I have these subdomains setup
etc/hosts file
api/urls.py
api/views.py
The frontend app urls and views is identical except for returning string "FRONTEND" in the HttpResponse object. I can tell django-subdomains is working becuase it does go to the frontend app when I hit "mysite.app:8000" vs the mysite.urls as seen in the root_url_conf. It displays "FRONTEND" But no matter what I do I can't get "api.mysite.app:8000" to hit the api urls file to display "API" Am I missing something? I'm very new to django. Any help is appreciated. Thanks. |
Hi @james-hoegerl , I'm having the exact same problem that you are having. Have you had any luck resolving it? Thanks |
I did. Make sure you follow the directions on the docs. Adding the middleware before common. Then you must include Django.contrib.sites in your apps and then do run Python manage.py migrate. Finally the after adding the settings they provide in the docs to your settings file you'll need to access the database and change the value of entry 1 in the "django_sites" table to reflect what local domain you have set up. So change "example.com" to "mysite.app" or whatever you use. This is the ticket. The subdomains will not recognize if you don't have this site set and SITE = 1 in your settings. I set this up like 4 times correctly since I posted this. So message me if you have any other problems. |
then you need to modify /etc/hosts file
it should work Note: django-subdomains doesn't has support for django1.10. for that I have made a pull request... |
I set up django-subdomains following this [guide][1].
I set my subdomain urlconfs as follows:
Everything works nicely, but I can't really test it cause when I run my app on my local host using
python manage.py runserver
, I can't really add the subdomains. If go to http://blog.127.0.0.1:8000, then the browser says a server cannot be found. Is there any way to set my server in such a way that allows for testing?I also have this following line in my console:
No handlers could be found for logger "subdomains.middleware"
How can I get this working? If anyone wants, my settings.py file can be found here:
Pastebin Link
The text was updated successfully, but these errors were encountered: