informatica:linux:django
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:linux:django [2015/04/13 20:19] – external edit 127.0.0.1 | informatica:linux:django [2019/05/19 16:55] (current) – [Activar la interfaz administrativa en app1 y tabla 'Tabla1'] javi | ||
---|---|---|---|
Line 2: | Line 2: | ||
django python framework | django python framework | ||
+ | |||
+ | ===== Instalacion ===== | ||
+ | |||
+ | 1. Instalar pip | ||
+ | |||
+ | sudo aptitude update; sudo aptitude install python-pip | ||
+ | | ||
+ | 2. Instalar ultima version de django: | ||
+ | |||
+ | sudo pip install Django==1.8 | ||
===== Primeros pasos ===== | ===== Primeros pasos ===== | ||
Line 91: | Line 101: | ||
python manage.py runserver 0.0.0.0: | python manage.py runserver 0.0.0.0: | ||
- | ===== Activar la interfaz administrativa ===== | + | ===== Interfaz administrativa ===== |
+ | |||
+ | Ahora la interfaz administrativa se activa por defecto | ||
+ | |||
+ | ==== Crear superusuario ==== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | ==== (Deprecated) | ||
1 | 1 | ||
Line 117: | Line 135: | ||
- | ===== Activar la interfaz administrativa en app1 y tabla ' | + | ==== (Deprecated) |
2.1 Crear: | 2.1 Crear: | ||
Line 332: | Line 350: | ||
Tabla1.objects.filter(pub_date__year=2006) | Tabla1.objects.filter(pub_date__year=2006) | ||
| | ||
- | ===== Instalacion manual ===== | ||
- | |||
- | 1. Download the latest release from our download page. | ||
- | |||
- | 2. Untar the downloaded file (e.g. tar xzvf Django-X.Y.tar.gz, | ||
- | |||
- | 3. Change into the directory created in step 2 (e.g. cd Django-X.Y). | ||
- | |||
- | 4. If you're using Linux, Mac OS X or some other flavor of Unix, enter the command sudo python setup.py install at the shell prompt. If you're using Windows, start a command shell with administrator privileges and run the command python setup.py install. This will install Django in your Python installation' | ||
- | |||
- | python setup.py install | ||
- | |||
===== Ejemplo aplicacion sin BBDD ===== | ===== Ejemplo aplicacion sin BBDD ===== | ||
Line 509: | Line 515: | ||
} | } | ||
... | ... | ||
+ | </ | ||
+ | |||
+ | Flujo habitual para mantener el modelo: | ||
+ | |||
+ | < | ||
+ | 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. | ||
</ | </ | ||
Line 842: | 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:// | ||
+ | |||
+ | 1. Crear el usuario desde el admin: | ||
+ | |||
+ | http:// | ||
+ | |||
+ | 2. Iniciar shell | ||
+ | |||
+ | cd / | ||
+ | | ||
+ | 3. Cambiar la contraseña de ese usuario, en este ejemplo " | ||
+ | |||
+ | < | ||
+ | from django.contrib.auth.models import User | ||
+ | user = User.objects.get(username=' | ||
+ | user.set_password(' | ||
+ | user.save() | ||
+ | </ | ||
+ | |||
+ | ==== Error al crear app ==== | ||
+ | |||
+ | Comando: | ||
+ | |||
+ | < | ||
+ | python manage.py startapp app1 | ||
+ | </ | ||
+ | |||
+ | Error: | ||
+ | |||
+ | < | ||
+ | File " | ||
+ | ) from exc | ||
+ | ^ | ||
+ | SyntaxError: | ||
+ | </ | ||
+ | |||
+ | Solución: | ||
+ | |||
+ | < | ||
+ | python3 manage.py startapp app1 | ||
+ | </ |
informatica/linux/django.txt · Last modified: 2019/05/19 16:55 by javi