User Tools

Site Tools


informatica:linux:django

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
informatica:linux:django [2015/04/18 18:24] javiinformatica:linux:django [2019/05/19 16:55] (current) – [Activar la interfaz administrativa en app1 y tabla 'Tabla1'] javi
Line 101: Line 101:
   python manage.py runserver 0.0.0.0:8080   python manage.py runserver 0.0.0.0:8080
  
-===== Activar la interfaz administrativa =====+===== Interfaz administrativa ===== 
 + 
 +Ahora la interfaz administrativa se activa por defecto 
 + 
 +==== Crear superusuario ==== 
 + 
 +https://docs.djangoproject.com/en/2.2/ref/django-admin/#django-admin-createsuperuser 
 + 
 +==== (Deprecated) Activar la interfaz administrativa =====
  
 1 1
Line 127: Line 135:
  
  
-====Activar la interfaz administrativa en app1 y tabla 'Tabla1' =====+==== (Deprecated) Activar la interfaz administrativa en app1 y tabla 'Tabla1' ====
  
 2.1 Crear: 2.1 Crear:
Line 507: Line 515:
 } }
 ... ...
 +</code>
 +
 +Flujo habitual para mantener el modelo:
 +
 +<code>
 +1. Change your models (in **models.py**).
 +2. Run **python manage.py makemigrations** to create migrations for those changes
 +3. Run **python manage.py migrate** to apply those changes to the database.
 </code> </code>
  
Line 840: Line 856:
  
 Falta el template y el resto de la vista. Es solo un ejemplo Falta el template y el resto de la vista. Es solo un ejemplo
 +
 +===== Errores =====
 +
 +==== The password is too similar to the username. ====
 +
 +En realidad no es un error, es solo para documentar un atajo para evitar esta restricción a la hora de especificar una contraseña para un nuevo usuario desde la interfaz gráfica del módulo admin.
 +
 +https://stackoverflow.com/a/35330167
 +
 +1. Crear el usuario desde el admin:
 +
 +http://localhost:8000/admin/auth/user/add/
 +
 +2. Iniciar shell
 +
 +  cd /path/django && python manage.py shell
 +  
 +3. Cambiar la contraseña de ese usuario, en este ejemplo "your_user":
 +
 +<code>
 +from django.contrib.auth.models import User
 +user = User.objects.get(username='your_user')
 +user.set_password('simple')
 +user.save()
 +</code>
 +
 +====  Error al crear app ====
 +
 +Comando:
 +
 +<code>
 +python manage.py startapp app1
 +</code>
 +
 +Error:
 +
 +<code>
 +  File "manage.py", line 16
 +    ) from exc
 +         ^
 +SyntaxError: invalid syntax
 +</code>
 +
 +Solución:
 +
 +<code>
 +python3 manage.py startapp app1
 +</code>
informatica/linux/django.1429381464.txt.gz · Last modified: 2015/04/18 18:24 by javi