Skip to content

Instantly share code, notes, and snippets.

@hcosta
hcosta / login.html
Last active October 27, 2023 18:38
Revisión del template para identificarse en el curso Django 2
{% extends 'core/base.html' %}
{% load static %}
{% block title %}Iniciar sesión{% endblock %}
{% block content %}
<style>.errorlist{color:red;}</style>
<main role="main">
<div class="container">
<div class="row mt-3">
<div class="col-md-9 mx-auto mb-5">
<form action="" method="post">{% csrf_token %}
@hcosta
hcosta / profile_form.html
Last active June 10, 2023 17:35
Revisión del formulario de perfil con avatar
{% extends 'core/base.html' %}
{% load static %}
{% block title %}Perfil{% endblock %}
{% block content %}
<style>.errorlist{color:red;} label{display:none}</style>
<main role="main">
<div class="container">
<div class="row mt-3">
<div class="col-md-9 mx-auto mb-5">
<form action="" method="post" enctype="multipart/form-data">{% csrf_token %}
class Producto:
def __init__(self, nombre, descripcion, precio):
self.nombre = nombre
self.descripcion = descripcion
self.precio = precio
class Subproducto(Producto):
def __init__(self, nombre, descripcion, precio, marca):
super().__init__(nombre, descripcion, precio)
self.marca = marca
def division(numero1, numero2):
resultado = numero1 / numero_2
return resultado
numero1 = input("Ingresa un número: "
numero2 = input("Ingresa otro número: ")
resultado = dividir_dos_numeros(numero1, numero2)
print("El resultado es: ", resultado)
@hcosta
hcosta / custom_ckeditor.md
Last active March 31, 2023 17:22
Código para conseguir ancho adaptativo en django-ckeditor

static/pages/css/custom_ckeditor.css

.django-ckeditor-widget, .cke_editor_id_content {
    width: 100% !important;
    max-width: 821px !important;
}

Inyectar en pages_menu.html

@hcosta
hcosta / script.py
Created July 9, 2022 22:03
Pyinstaller resources loading
import sys
import os
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
@hcosta
hcosta / manual.md
Last active August 18, 2022 17:31
Desplegar Django en doplet Ubuntu 16.04 de Digital Ocean

Actualizamos el repositorio como root (lo indico con $)

$ add-apt-repository universe
$ apt-get update
$ apt-get upgrade

Instalamos las dependencias y python, que por defecto viene en la versión 2.7

$ apt-get install python3 nginx supervisor # postgresql postgresql-contrib (si no se quiere sqlite)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hcosta
hcosta / command.txt
Created February 15, 2022 11:46
Fix Jupyter Notebook kernel error after update Python
python -m ipykernel install --user
@hcosta
hcosta / enumerate.ipynb
Created January 27, 2022 02:19
enumerate.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.