Hi Guys
I am learning Django and trying to use Bootstrap, I already download
bootstrap and put it under 'D:\django14\projects\nomina\nom_mex\static', I
have Django 1.4 and use the developer server "runserver". According
Django's documentation says referent it I need to use STATICFILES_DIRS and
STATIC_URL parameters in my settings.py what else do I have to take in
count to run bootstrap ?, It seems I have something wrong in my settings.py
or may be in my urls.py, I left my project's files hoping somebody can
help me, the template I am testing is the index.html.
I will appreciate any observations or suggestions...
Thanks in advance.
Jose Galvan
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
{% extends "D:/django14/projects/nomina/nom_mex/templates/nom_mex/base.html" %}
{% block content %}
Lista de empleados
{{ static_url }}
{% if lista_empleados %}
{% for empleado in lista_empleados %}
{{empleado.nombre}} {{empleado.ap_paterno}} {{empleado.ap_materno}}
{% endfor%}
{% else %}
No hay empleados registrados !.
{% endif %}
Crear empleado
{% endblock %}
# Create your views here.
from django.shortcuts import render_to_response, get_object_or_404
from nom_mex.forms import EmpleadoForm
from nom_mex.models import Empleado
from django.template import RequestContext
from django.http import HttpResponse
def index(request):
lista_empleados = Empleado.objects.all().order_by('ap_materno')
return render_to_response('nom_mex/index.html',{'lista_empleados':lista_empleados})
def crea_empleado(request):
if request.method=='POST': # if method is post then catch the info from the form, validate it and do commit
form = EmpleadoForm(request.POST)
if form.is_valid():
nombre=form.cleaned_data['nombre']
ap_paterno=form.cleaned_data['ap_paterno']
ap_materno=form.cleaned_data['ap_materno']
sexo=form.cleaned_data['sexo']
fecha_nacimiento=form.cleaned_data['fecha_nacimiento']
estatura=form.cleaned_data['estatura']
peso=form.cleaned_data['peso']
domicilio=form.cleaned_data['domicilio']
colonia=form.cleaned_data['colonia']
cod_postal=form.cleaned_data['cod_postal']
estado=form.cleaned_data['estado']
pais=form.cleaned_data['pais']
telefono_1=form.cleaned_data['telefono_1']
telefono_2=form.cleaned_data['telefono_2']
buzon_electronico=form.cleaned_data['buzon_electronico']
rfc=form.cleaned_data['rfc']
no_seg_social=form.cleaned_data['no_seg_social']
curp=form.cleaned_data['curp']
cartilla_militar=form.cleaned_data['cartilla_militar']
activo=form.cleaned_data['activo']
e=Empleado()
e.nombre=nombre
e.ap_paterno=ap_paterno
e.ap_materno=ap_materno
e.sexo=sexo
e.fecha_nacimiento=fecha_nacimiento
e.estatura=estatura
e.peso=peso
e.domicilio=domicilio
e.colonia=colonia
e.cod_postal=cod_postal
e.estado=estado
e.pais=pais
e.telefono_1=telefono_1
e.telefono_2=telefono_2
e.buzon_electronico=buzon_electronico
e.rfc=rfc
e.no_seg_social=no_seg_social
e.curp=curp
e.cartilla_militar=cartilla_militar
e.activo=activo
e.save() # Commit to database
mensaje='Registro Gravado correctamente'
form=EmpleadoForm()
lista_empleados = Empleado.objects.all().order_by('ap_materno')
return render_to_response('nom_mex/index.html',{'lista_empleados':lista_empleados})
else:
mensaje="Error en los datos de entrada caray, el registro no fue grabado"
#form=EmpleadoForm()
return render_to_response('nom_mex/crea_empleado.html',{'empleado_form':form,'mensaje':mensaje},context_instance=RequestContext(request))
else:
form=EmpleadoForm()
mensaje='Em metodo no fue post'
return render_to_response('nom_mex/crea_empleado.html', {'empleado_form': form,'mensaje':mensaje},context_instance=RequestContext(request))
def edita_empleado(request, empleado_id):
empleado = get_object_or_404(Empleado,pk=empleado_id)
form = EmpleadoForm(request.POST or None,instance=empleado)
if form.is_valid():
form.cleaned_data['nombre']
form.cleaned_data['ap_paterno']
form.cleaned_data['ap_materno']
form.cleaned_data['sexo']
form.cleaned_data['fecha_nacimiento']
form.cleaned_data['estatura']
form.cleaned_data['peso']
form.cleaned_data['domicilio']
form.cleaned_data['colonia']
form.cleaned_data['cod_postal']
form.cleaned_data['estado']
form.cleaned_data['pais']
form.cleaned_data['telefono_1']
form.cleaned_data['telefono_2']
form.cleaned_data['buzon_electronico']
form.cleaned_data['rfc']
form.cleaned_data['no_seg_social']
form.cleaned_data['curp']