22👍
Use python manage.py runserver <ip>:<port>
For example,my IP is 192.168.0.100 and I want to run django app on port 80,I have to do
[sudo] python manage.py runserver 192.168.0.100:80
My port 80 needed root permissions,maybe because I have other applications accessing it.
You also have to add the IP address to ALLOWED_HOSTS
list in settings.py
By doing this all clients in the 192.168.0 network will be able to access the site at 192.168.0.100
4👍
You’re starting Django as needed – it will accept connections from anywhere as soon as the connections get to it.
Check your firewall and make sure it’s allowing 8000 port connections. Something like this should work:
iptables -I INPUT -p tcp -m tcp --dport 8000 -j ACCEPT
Optionally you will need to extend the INTERNAL_IPS
variable in the setting to allow remote debugging: https://docs.djangoproject.com/en/dev/ref/settings/#internal-ips .
- What is the different between the get logger functions from celery.utils.log and logging?
- Make a Django model read-only?
- Efficient function to retrieve a queryset of ancestors of an mptt queryset
- Custom unique_together key name
- TypeError: __call__() missing 1 required positional argument: 'send' Django
4👍
skarap is correct. If your network is configured correctly and your django application with pytho9n manage.py runserver 0.0.0.0:8000 and you still can’t access your django app from the VM host there is almost certainly a firewall issue. The illustration above is good if you are running iptables.
I deployed CentOS 7 on a virtualbox VM from a Windows 7 host. I didn’t know that this distribution uses firewalld, not iptables to control access.
if
ps -ae | grep firewall
returns something like
602 ? 00:00:00 firewalld
your system is running firewalld, not iptables. They do not run together.
To correct you VM so you can access your django site from the host use the commands:
firewall-cmd –zone=public –add-port=8000/tcp –permanent
firewall-cmd –reload
Many thanks to pablo v on the http://www.scriptscoop.net site for pointing this out.
- Django.core.exceptions.FieldDoesNotExist: model has no field named <function SET_NULL at 0x7fc5ae8836e0>
- Why swagger raises unclear error – Django
- Django m2m form save " through " table
- Best way to reference the User model in Django >= 1.5
0👍
set firewall rules with
$ sudo ufw enable
$ sudo ufw allow 8000
type ipconfig
copy addr under inet
do python3 manage.py runserver your_inet_addr:8000
- How to disable request logging in Django and uWSGI?
- Adding prefix path to static files in Angular using angular-cli
- Retrieving the 'many' end of a Generic Foreign Key relationship in Django
- Access Apache SetEnv variable from Django wsgi.py file
- Raw_id_fields for modelforms