Please give the exception traceback.

On Tuesday, July 25, 2017 at 3:35:41 PM UTC-4, Elias Coutinho wrote:
>
> Hello guys!
>
> I'm trying to recreate a form with Inline using django and django-stuff. I 
> already got it once, but this is not being easy!
>
> I want to create a form that can register a Client and its addresses, or 
> something similar to this link here.
>
> Example 1: Adding contacts.
>
> Example 2: Adding addresses.
>
> I'm trying like this:
>
> *Forms.py*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *from django import formsfrom material import Layout, Row, Fieldsetfrom 
> .models import Clientclass Address(forms.Form):# TA FEITO    public_place = 
> forms.CharField(label='Logradouro')    number = 
> forms.CharField(label='Número')    city = forms.CharField(label='Cidade')  
>   state = forms.CharField(label='Estado')    zipcode = 
> forms.CharField(label='Cep')    country = forms.CharField(label='País')    
> phone = forms.CharField(label='Fone')    class Meta:        
> verbose_name_plural = 'endereços'        verbose_name = 'endereço'    def 
> __str__(self):        return self.profissaoclass 
> ClientModelForm(forms.ModelForm):    class Meta:        model = Client      
>   fields = '__all__'    layout = Layout(        Fieldset("Client",          
>        Row('name', ),                 Row('birthday','purchase_limit'),    
>              Row('address1', ),                 Row('compra_sempre', ),    
>              ),    )*
> *views.py*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *import extra_viewsfrom braces.views import LoginRequiredMixinfrom 
> extra_views import CreateWithInlinesView, NamedFormsetsMixinfrom material 
> import LayoutMixin, Fieldsetfrom material.admin.base import Inlinefrom 
> danibraz.persons.forms import *from .models import Addressclass 
> ItemInline(extra_views.InlineFormSet):    model = Address    fields = 
> ['kynd',         
> 'public_place','number','city','state','zipcode','country','phone']#campos 
> do endereço    extra = 1# Define aquantidade de linhas a apresentar.class 
> NewClientsView(LoginRequiredMixin,LayoutMixin,                    
>  NamedFormsetsMixin,                     CreateWithInlinesView):    title = 
> "Inclua um cliente"    model = Client    #print('Chegou na linha 334')    
> layout = Layout(        Fieldset("Inclua um cliente",                
>  Row('name', ),                 Row('birthday','purchase_limit'),          
>        Row('address1', ),                 Row('compra_sempre', ),          
>        ),        Inline('Endereços', ItemInline),    )    #print('Chegou na 
> linha 340')    def forms_valid(self, form, inlines):        new = 
> form.save(commit=False)        new.save()        form.save_m2m()        
> return super(NewClientsView, self).forms_valid(form, inlines)    def 
> get_success_url(self):        return 
> self.object.get_absolute_url()models.py*
>
> # from django.contrib.auth.models import User
> from django.db import models
>
>
> class Person(models.Model):
>     # class Meta:
>     #     abstract = True
>
>     name = models.CharField('Nome',max_length=100)
>     birthday = models.DateField('Aniversário')
>     address1 = models.CharField('Endereço 1',max_length=100)
>     purchase_limit = models.DecimalField('Limite de compra',max_digits=15, 
> decimal_places=2)
>
>
>     class Meta:
>         verbose_name_plural = 'pessoas'
>         verbose_name = 'pessoa'
>
>     def __str__(self):
>         return self.name
>
>     def get_child(self):
>         if hasattr(self, 'client'):
>             return self.client
>         elif hasattr(self, 'employee'):
>             return self.employee
>         else:
>             return None
>
> def get_type(self):
>     if hasattr(self, 'client'):
>         return 'client'
>     elif hasattr(self, 'employee'):
>         return 'employee'
>     else:
>         return None
>
>
> class Address(models.Model):
>     KINDS_CHOICES = (
>         ('P', 'PRINCIPAL'),
>         ('C', 'COBRANÇA'),
>         ('E', 'ENTREGA'),
>     )
>
> person = models.ForeignKey('Person')
> kynd = models.CharField('Tipo', max_length=1, choices=KINDS_CHOICES)
> public_place = models.CharField('Logradouro',max_length=150)
> number = models.CharField('Número',max_length=150)
> city = models.CharField('Cidade',max_length=150)
> state = models.CharField('Estado',max_length=150)
> zipcode = models.CharField('Cep',max_length=10)
> country = models.CharField('País',max_length=150, choices=COUNTRY_CHOICES)
> phone = models.CharField('Fone',max_length=50)
>
> class Meta:
>     verbose_name_plural = 'endereços'
>     verbose_name = 'endereço'
>
> def __str__(self):
>     return self.public_place
>
>
>
> class Client(Person):
>     compra_sempre = models.BooleanField('Compra Sempre',default=False)
>
>         def save(self, *args, **kwargs):
>         super(Client, self).save(*args, **kwargs)
>
>     class Meta:
>         verbose_name = 'Cliente'
>         verbose_name_plural = 'Clientes'
>
>
>
> class Employee(Person):
>     ctps = models.CharField('Carteira de Trabalho',max_length=25)
>     salary = models.DecimalField('Salário',max_digits=15, decimal_places=2)
>
>
>     def save(self, *args, **kwargs):
>         # self.operacao = CONTA_OPERACAO_DEBITO
>         super(Employee, self).save(*args, **kwargs)
>
>     class Meta:
>         verbose_name = 'Funcionário'
>         verbose_name_plural = 'Funcionários'
>
>
>
> But django always returns the error quoted in the title of the post
>
> Believe me, I was able to simulate this in another project, and this one I 
> can not replicate.
>
> This is the link that works: https://github.com/CoutinhoElias/sosmypc
>
> The URL is http://127.0.0.1:8000/site/profissoes/
>
> And this is my project that I can not replicate: 
> Https://github.com/CoutinhoElias/danibraz
>
> All I want is something similar to the link below: 
> http://demo.viewflow.io/materialforms/pro/signup/#python
> My frustration is that I got involved in a project, but I can not do it 
> now in the danibraz!
> I do not know what I did differently!
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ddb835d-5442-4dc6-8722-47028433d420%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to