Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/05/2014, 00:08
andy2507
 
Fecha de Ingreso: julio-2011
Ubicación: Peru
Mensajes: 92
Antigüedad: 13 años, 5 meses
Puntos: 1
no carga mi CRUD

Hola e echo mi CRUD y no entiendo porque no me carga
esto es mi codigo

models.py

from django.db import models

class Dist(models.Model):
id_distrito = models.CharField(primary_key=True, max_length=2)
nom_distrito = models.CharField(max_length=50)
class Meta: db_table = 'distrito'

def __unicode__(self):
return u'%s' % self.nom_distrito


forms.py

#encoding:utf-8
from django.forms import ModelForm
from django import forms
from app.models import Dist

class DistForm(ModelForm):
class Meta:
model = Dist



views.py

from app.models import Dist
from app.forms import forms
from django.contrib.auth.models import User
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
#from django.core.

# Create your views here.

def Dist(request):
if request.method=='POST':
formulario = distritoForm(request.POST)
if formulario.is_valid():
codigo = request.POST.get('codigo')
nombre = request.POST.get('nombre')
distrito = Dist()
distrito.id_distrito = codigo
distrito.nom_distrito = nombre
distrito.save()
return HttpResponseRedirect('/')
else:
formulario = distritoForm()
return render_to_response('distritoform.html',{'formulari o':formulario}, context_instance=RequestContext(request))

urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns(
# Examples:
# url(r'^$', 'CRUD.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

#url(r'^admin/', include(admin.site.urls)),
url(r'^Dist/$', 'app.views.Dist'),
)

distritoForm.py

class Dist(forms.Form):
codigo = forms.CharField(max_length=2)
nombre = forms.CharField(max_length=50)

distritoform.html

{% extends 'base.html' %}
{% block contenido %}
<form id='formulario' method='post' enctype='multipart/form-data' action=''>
{% csrf_token %}
{{formulario.as_p}}
<p><input type='submit' value='Guardar'/></p>
</form>
{% endblock %}

base.html

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<nav>
<ul>
<li><a href='/Dist'>DISTRITO</a></li>
</ul>

</nav>
</body>
</html>


y me carga la ventana del django, cuando yo quisiera que me cargue mi ventana de mi CRUD




espero su pronta ayuda gracias