[+] Python - Django - nie mog

Potrzebujesz pomocy z C, C++, perl, python, itp.
modry
Posty: 6
Rejestracja: 20 lipca 2009, 10:11

[+] Python - Django - nie mogę znaleźć na to odpowiedzi

Post autor: modry »

Witam. Ostatnio uczę się Pythona. Chciałem przetestować Django. Robiłem wszystko według poradnika Riklaunima (Wprowadzenie do Django 1.0 - Tworzymy prostego bloga). Jednak od razu napotkałem na problem. Po uruchomieniu skryptu poprzez:

Kod: Zaznacz cały

python manage.py runserver
pojawia się:

Kod: Zaznacz cały

modry:/home/modry/django/blog1# python manage.py runserver
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.
Próbowałem uruchomić to jako root i jako zwykły użytkownik i nic. Co może powodować ten błąd?
W Google nie mogę odnaleźć niczego o tym.

Ktoś się z tym spotkał?

Pozdrawiam - Modry.
Czocher
Beginner
Posty: 140
Rejestracja: 26 maja 2007, 23:19

Post autor: Czocher »

Spróbuj wywołać runserver z innym adresem ip, to znaczy nie z localhostem/loopbackiem tylko np. z twoim adresem zewnętrznym (np. 10.0.0.1 jeżeli jesteś w sieci wewnętrznej) i potem spróbuj połączyć się do tego adresu zewnętrznego na port 8000 ;) .
Taki problem może być spowodowany błędnie skonfigurowanym interfejsem loopback, złymi uprawnieniami dostępu do niego lub złymi regułkami firewalla.
modry
Posty: 6
Rejestracja: 20 lipca 2009, 10:11

Post autor: modry »

Szukałem, jak się zmienia ip i port, na którym pracuje Django. I nic.

Kod: Zaznacz cały

modry@modry:~$ cd ./django/blog1
modry@modry:~/django/blog1$ python manage.py runserver
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ python manage.py runserver 127.0.0.1:8080
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.0.1:8080/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ python manage.py runserver localhost:8080
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://localhost:8080/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ python manage.py runserver localhost:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://localhost:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ python manage.py runserver 10.0.0.1:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://10.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ python manage.py runserver 10.0.0.1
[color=red]Error: '10.0.0.1' is not a valid port number.[/color]
modry@modry:~/django/blog1$ python manage.py runserver 10.0.0.1:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://10.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ python manage.py runserver 127.0.1.1:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.1.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry@modry:~/django/blog1$ su
Hasło:
modry:/home/modry/django/blog1# python manage.py runserver
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry:/home/modry/django/blog1# python manage.py runserver localhost
[color=red]Error: 'localhost' is not a valid port number.[/color]
modry:/home/modry/django/blog1# python manage.py runserver localhost:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://localhost:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry:/home/modry/django/blog1# python manage.py runserver localhost:8080
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://localhost:8080/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry:/home/modry/django/blog1# python manage.py runserver 127.0.0.1:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry:/home/modry/django/blog1# python manage.py runserver 127.0.1.1:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://127.0.1.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry:/home/modry/django/blog1# python manage.py runserver 10.0.0.1:8000
Validating models...
0 errors found

Django version 1.1, using settings 'blog1.settings'
Development server is running at [url]http://10.0.0.1:8000/[/url]
Quit the server with CONTROL-C.
[color=red]Error: That IP address can't be assigned-to.[/color]
modry:/home/modry/django/blog1#
Zauważyłem też, że serwer OTS też nie chce działać (nie nasłuchuje) - łączę się z localhost albo z 127.0.0.1 albo nawet 127.0.1.1 i nic. Co może blokować?
Czocher
Beginner
Posty: 140
Rejestracja: 26 maja 2007, 23:19

Post autor: Czocher »

zrób tak:

Kod: Zaznacz cały

/sbin/ifconfig
Skopiuj wartość po "inet addr:". W moim przypadku wygląda to tak:

Kod: Zaznacz cały

czocher@laptop:~/django/mysite$ /sbin/ifconfig 
eth0   Link encap:Ethernet  HWaddr 00:00:00:00:00:00 
          inet addr:10.0.0.2  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:33ff:fe4a:8c3c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24796 errors:0 dropped:1399095752 overruns:0 frame:0
          TX packets:27158 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:24391590 (23.2 MiB)  TX bytes:3448829 (3.2 MiB)
          Interrupt:219 Base address:0x6000
Więc kopiuję "10.0.0.2". A następnie:

Kod: Zaznacz cały

python manage.py runserver 10.0.0.2:8000
I komenda działa :P. A potem tylko wchodzę przeglądarką na 10.0.0.2 i wyświetla mi informacje o tym, że django działa.
modry
Posty: 6
Rejestracja: 20 lipca 2009, 10:11

Post autor: modry »

Dziękuję, Czocher. Jestem Ci bardzo wdzięczny. Działa. No, koniec problemów.
Awatar użytkownika
lexom
Beginner
Posty: 236
Rejestracja: 03 marca 2007, 18:38
Lokalizacja: wlkp

Post autor: lexom »

Witam. Mam podobny problem.

Kod: Zaznacz cały

debian:/home/pawel# /sbin/ifconfig
wlan0     Link encap:Ethernet  HWaddr 00:1e:4c:64:b7:41  
          inet addr:192.168.1.102  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:4cff:fe64:b741/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1768 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2333 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:986971 (963.8 KiB)  TX bytes:472118 (461.0 KiB)

wmaster0  Link encap:UNSPEC  HWaddr 00-1E-4C-64-B7-41-77-6C-00-00-00-00-00-00-00-00  
          UP RUNNING  MTU:0  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Kod: Zaznacz cały

debian:/home/pawel/mojprojekt# ./manage.py runserver 192.168.1.102:8000
Validating models...
0 errors found

Django version 1.1.1, using settings 'mojprojekt.settings'
Development server is running at [url]http://192.168.1.102:8000/[/url]
Quit the server with CONTROL-C.

Serwer niby jest odpalony ale w przeglądarce nie wyświetla się żadna strona. O co może chodzić?
salmon
Beginner
Posty: 296
Rejestracja: 12 października 2007, 23:28
Lokalizacja: Gliwice/Bielsko-Biała

Post autor: salmon »

A jaki adres wpisujesz?
Awatar użytkownika
lexom
Beginner
Posty: 236
Rejestracja: 03 marca 2007, 18:38
Lokalizacja: wlkp

Post autor: lexom »

salmon pisze:A jaki adres wpisujesz?
http://192.168.1.102:8000/
salmon
Beginner
Posty: 296
Rejestracja: 12 października 2007, 23:28
Lokalizacja: Gliwice/Bielsko-Biała

Post autor: salmon »

Wygląda dobrze :)

To jeszcze napisz co pisze w przeglądarce i czy pojawiło się coś w konsoli gdzie masz odpalone django, jeżeli tak, to wklej tu.
Awatar użytkownika
lexom
Beginner
Posty: 236
Rejestracja: 03 marca 2007, 18:38
Lokalizacja: wlkp

Post autor: lexom »

W przeglądarce pojawia się:

Kod: Zaznacz cały

The connection has timed out
The server at 192.168.1.102 is taking too long to respond.
W konsoli mam cały czas to samo czyli:

Kod: Zaznacz cały

debian:/home/pawel/mojprojekt# ./manage.py runserver 192.168.1.102:8000
Validating models...
0 errors found

Django version 1.1.1, using settings 'mojprojekt.settings'
Development server is running at [url]http://192.168.1.102:8000/[/url]
Quit the server with CONTROL-C.
ODPOWIEDZ