Foros del Web » Programando para Internet » Python »

[SOLUCIONADO] He creado mi servidor

Estas en el tema de He creado mi servidor en el foro de Python en Foros del Web. Al crear mi servidor y mi pagina se an creado la carpeta "PaginaWeb" dentro estan los archivos __init__.py settings.py urls.py views.py wsgi.py He visto este ...
  #1 (permalink)  
Antiguo 18/11/2013, 12:35
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
He creado mi servidor

Al crear mi servidor y mi pagina se an creado la carpeta "PaginaWeb" dentro estan los archivos

__init__.py
settings.py
urls.py
views.py
wsgi.py

He visto este http://www.forosdelweb.com/3894825-post5.html tutorial para crear mi primer Hola Mundo donde tengo que crear mis archivos

views.py
urls.py

He seguido manteniendo el codigo que tenia en urls.py, solo he añadido el que estaba en el tutorial.

Pero me sale el siguiente error,
Código PHP:
ImportError at /
No module named defaults
Request Method
:    GET
Request URL
:    http://localhost:8000/
Django Version:    1.6
Exception Type
:    ImportError
Exception Value
:    
No module named defaults
Exception Location
:    C:PythonPaginaWebPaginaWeburls.py in <module>, line 14
Python Executable
:    C:PythonPython27python.exe
Python Version
:    2.7.6
Python Path
:    
[
'C:\\Python\\PaginaWeb',
 
'C:\\Windows\\SYSTEM32\\python27.zip',
 
'C:\\Python\\Python27\\DLLs',
 
'C:\\Python\\Python27\\lib',
 
'C:\\Python\\Python27\\lib\\plat-win',
 
'C:\\Python\\Python27\\lib\\lib-tk',
 
'C:\\Python\\Python27',
 
'C:\\Python\\Python27\\lib\\site-packages']
Server time:    Mon18 Nov 2013 19:36:49 +0100 
El codigo del urls.py quedaria asin:
Código Python:
Ver original
  1. from django.conf.urls import patterns, include, url
  2.  
  3. from django.contrib import admin
  4. admin.autodiscover()
  5.  
  6. urlpatterns = patterns('',
  7.     # Examples:
  8.     # url(r'^$', 'PaginaWeb.views.home', name='home'),
  9.     # url(r'^blog/', include('blog.urls')),
  10.  
  11.     url(r'^admin/', include(admin.site.urls)),
  12. )
  13.  
  14. from django.conf.urls.defaults import *
  15. from mysite.views import hello
  16.  
  17. urlpatterns = patterns('',
  18.     ('^hello/$', hello),
  19. )
  #2 (permalink)  
Antiguo 18/11/2013, 13:30
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

Por favor no repitas mensajes.

Hace algunos años que cree ese tutorial incompleto. Creo que debería de poner una advertencia que ya no es usable con versiones recientes de django.

(Así debería de funcionar).
Código Python:
Ver original
  1. from django.conf.urls import patterns, include, url
  2. from mysite.views import hello
  3.  
  4. urlpatterns = patterns('',
  5.     url(r'^hello/$', hello),
  6. )

En todo caso tu error era muy claro. Decía que no podía importar defaults de urls y es porque eso cambio en versiones recientes.
  #3 (permalink)  
Antiguo 18/11/2013, 13:40
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

views.py
Código Python:
Ver original
  1. from django.http import HttpResponse
  2.  
  3. def hello(request):
  4.     return HttpResponse("Hola mundo")

urls.py
Código Python:
Ver original
  1. from django.conf.urls import patterns, include, url
  2. from mysite.views import hello
  3.  
  4. urlpatterns = patterns('',
  5.     url(r'^hello/$', hello),
  6. )

Y me sigue dando error, perdon por las molestias pero esque soy nuevo y no consigo ni hacer un "Hola Mundo"
  #4 (permalink)  
Antiguo 18/11/2013, 13:52
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

En otra pagina vi esto:

views.py
Código Python:
Ver original
  1. from django.http import HttpResponse
  2.  
  3.  def holaMundo(request):
  4.          html = "<html><body>Hola Mundo desde DJANGO</body></html>"
  5.          return HttpResponse(html)

urls.py
Código Python:
Ver original
  1. from django.conf.urls.defaults import patterns, include, url
  2. from tutorial.firstView import holaMundo, suma
  3.  
  4. urlpatterns = patterns('',
  5.          (r'^hola$',holaMundo),
  6. )

Y me sigue dando error.
  #5 (permalink)  
Antiguo 18/11/2013, 13:58
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

¿Podrías poner que error te manda?
  #6 (permalink)  
Antiguo 18/11/2013, 14:04
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Código Python:
Ver original
  1. ImportError at /
  2. No module named defaults
  3. Request Method: GET
  4. Request URL:    http://localhost:8000/
  5. Django Version: 1.6
  6. Exception Type: ImportError
  7. Exception Value:   
  8. No module named defaults
  9. Exception Location: C:\Python\PaginaWeb\PaginaWeb\urls.py in <module>, line 1
  10. Python Executable:  C:\Python\Python27\python.exe
  11. Python Version: 2.7.6
  12. Python Path:   
  13. ['C:\\Python\\PaginaWeb',
  14.  'C:\\Windows\\SYSTEM32\\python27.zip',
  15.  'C:\\Python\\Python27\\DLLs',
  16.  'C:\\Python\\Python27\\lib',
  17.  'C:\\Python\\Python27\\lib\\plat-win',
  18.  'C:\\Python\\Python27\\lib\\lib-tk',
  19.  'C:\\Python\\Python27',
  20.  'C:\\Python\\Python27\\lib\\site-packages']
  21. Server time:    Mon, 18 Nov 2013 21:06:46 +0100

No se porque no me funciona ninguno, tengo Python 2.7 y Django 1.6
  #7 (permalink)  
Antiguo 18/11/2013, 14:38
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

Es el mismo error.

Donde dice
Código Python:
Ver original
  1. from django.conf.urls.defaults import patterns, include, url

lo cambias por
Código Python:
Ver original
  1. from django.conf.urls import patterns, url, include

Lo que pasa es que en django 1.6 eliminaron defaults.

Si te sigue arrojando error, detén el proceso y vuelvo a iniciar.
  #8 (permalink)  
Antiguo 18/11/2013, 14:45
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Quedaria asin:
Código Python:
Ver original
  1. from django.conf.urls import patterns, url, include
  2. from tutorial.firstView import holaMundo, suma
  3.  
  4. urlpatterns = patterns('',
  5.          (r'^hola$',holaMundo),
  6. )

Y he cerrado el proceso (la consola) y me sigue saliendo el mismo error.

Me recomiendas otro Django?
  #9 (permalink)  
Antiguo 18/11/2013, 15:07
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

Puedes usar la versión anterior la 1.5

Pero si te da el mismo error es porque no lo haz cambiado.

El archivo es este: C:\Python\PaginaWeb\PaginaWeb\urls.py recuerda salvarlo.
  #10 (permalink)  
Antiguo 18/11/2013, 15:24
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Lo he comprobado unas cuantas veces y si lo cambié. Voy a descargarme la versión 1.5
  #11 (permalink)  
Antiguo 18/11/2013, 15:57
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Sigue sin funcionar, tienes skype haber si me podrias ayudar por ahí?
  #12 (permalink)  
Antiguo 18/11/2013, 19:18
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

Lo siento, pero no doy asesoría privada. Al menos no gratis.
  #13 (permalink)  
Antiguo 19/11/2013, 00:44
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

He desistalado todo, el python mysql Django, pidrias decirme lad versiones que ytilisas para descargarlo
  #14 (permalink)  
Antiguo 19/11/2013, 01:44
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: He creado mi servidor

Python 2.7
Django 1.6

Revisa la documentación de la página oficial de django, ahí puedes obtener los comandos vigentes, y tutorial completo.


Saludos
__________________
Grupo Telegram Docker en Español
  #15 (permalink)  
Antiguo 19/11/2013, 09:20
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Tengo esas versiones instaladas.
  #16 (permalink)  
Antiguo 19/11/2013, 10:18
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

He visto este tutorial http://www.desarrollaraplicaciones.c...do-primer.html

He creado mi django-admin.py startproject proyecto1 y python manage.py startapp aplicacion1

Pero me da este error en la pagina cuando accedo a http://localhost:8000/mensaje:
Código Python:
Ver original
  1. ImportError at /mensaje
  2. No module named aplicacion1
  3. Request Method: GET
  4. Request URL:    http://localhost:8000/mensaje
  5. Django Version: 1.6
  6. Exception Type: ImportError
  7. Exception Value:   
  8. No module named aplicacion1
  9. Exception Location: C:\Python\Python27\lib\site-packages\django\utils\importlib.py in import_module, line 40
  10. Python Executable:  C:\Python\Python27\python.exe
  11. Python Version: 2.7.6
  12. Python Path:   
  13. ['C:\\Python\\Proyectos',
  14.  'C:\\Windows\\SYSTEM32\\python27.zip',
  15.  'C:\\Python\\Python27\\DLLs',
  16.  'C:\\Python\\Python27\\lib',
  17.  'C:\\Python\\Python27\\lib\\plat-win',
  18.  'C:\\Python\\Python27\\lib\\lib-tk',
  19.  'C:\\Python\\Python27',
  20.  'C:\\Python\\Python27\\lib\\site-packages']
  21. Server time:    Tue, 19 Nov 2013 17:20:48 +0100

Al acceder a http://localhost:8000/ me sale: A server error occurred. Please contact the administrator.
  #17 (permalink)  
Antiguo 19/11/2013, 11:58
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

El error es muy claro. (Donde dice Exception Type y Exception Value)

Tienes un error al importar el modulo aplicacion1.

Por favor si escoges un tutorial sigue la versión que están usando en el tutorial. Para django 1.6 aquí esta el tutorial oficial. https://docs.djangoproject.com/en/1.6/intro/tutorial01/
  #18 (permalink)  
Antiguo 19/11/2013, 12:10
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Esque esta en ingles y no lo entiendo y con el traductor tampoco esque se entienda muy bien porque lo traduce fatal.

No hay ningun tutorial en español?
  #19 (permalink)  
Antiguo 19/11/2013, 15:13
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: He creado mi servidor

Creo que te podría servir la de la 1.5: http://tutorialdjango.com.ar/

¿Hiciste python manage.py startapp aplicacion1 dentro de la carpeta que te creo el anterior comando?


PD: te recomiendo que vayas apriendiendo inglés, si no vas a tener más limitaciones en el futuro.
__________________
Grupo Telegram Docker en Español
  #20 (permalink)  
Antiguo 19/11/2013, 15:17
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

Estoy totalmente de acuerdo con Carlangueitor, si no aprendes Ingles eventualmente es lo que te va detener como programador.
  #21 (permalink)  
Antiguo 19/11/2013, 15:23
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Si, si lo quiero aprender y lo necesitare.
Con el tema de python si lo cree, pero en el settings.py no lo puse, ya me funciona Gracias a todos.

Sabeis como puedo modificar el mensaje de inicio, me sale A server error occurred. Please contact the administrator. al acceder a localhost
  #22 (permalink)  
Antiguo 19/11/2013, 15:28
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: He creado mi servidor



No es un mensaje de Inicio, es un error. ¿Estás usando algo como apache o tienes el debug desactivado? Normalmente no te debería dar eso.

Saludos
__________________
Grupo Telegram Docker en Español
  #23 (permalink)  
Antiguo 19/11/2013, 15:30
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Tengo Python + Django + MySQl + MySQl Python.

El server lo inicie con un comando de python: python manage.py runserver
  #24 (permalink)  
Antiguo 19/11/2013, 15:31
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: He creado mi servidor

Parece que alguien mezclo versiones y settings de django.

http://stackoverflow.com/questions/1...-administrator
http://stackoverflow.com/questions/8...oes-not-define
  #25 (permalink)  
Antiguo 19/11/2013, 15:32
 
Fecha de Ingreso: septiembre-2013
Mensajes: 125
Antigüedad: 10 años, 7 meses
Puntos: 3
Respuesta: He creado mi servidor

Me falto, ya lo solucione
url(r'^$', 'Login.views.Inicio'),

Gracias a todos de verdad.

Etiquetas: 2013, creado, django, gui, ip, servidor
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:08.