I'm trying to use ModelForm ChainedForeignKey and use of my models... #30

gladson opened this Issue Jun 22, 2012 · 3 comments


None yet
3 participants

gladson commented Jun 22, 2012

This works in admin, but when I send to the template through the ModelForm in this way in the template:


# -*- coding: utf-8 -*-
from django import forms
from django.forms import ModelForm
from validoc.certificacao.models import *

class Cadastro_certificado_ecpfForm(forms.ModelForm):
    class Meta:
        model = Cadastro_certificado_ecpf


from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, get_object_or_404
from django.views.generic.simple import direct_to_template
from validoc.certificacao.forms  import Cadastro_certificado_ecpfForm as ECPFForm

def create_ecpf_post(request):
    if request.method == 'POST':
       form = ECPFForm(request.POST)
       if form.is_valid():
            return HttpResponseRedirect('/add_ecpf/')
        form = ECPFForm()

    return direct_to_template(request,
                              extra_context={'form':form} )


<form method='post' action='.'>{% csrf_token %}
       {{ form.as_p }}
<input type='submit'>

Does not work as the admin, what am I doing wrong?

Exit (by blag): Updated formatting to use GFM.

gladson commented Jun 22, 2012

I forgot too...
It makes the filter and does not bring the data as it does...


SalahAdDin commented May 22, 2015

Could you fix it?


blag commented Oct 13, 2016

Closing due to inactivity. Feel free to reopen if this is still an issue.

@blag blag closed this Oct 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment