I still having a little problem using OneToOne relationship and Edit form. The forms are created with combobox and get all address in database, i need the address of the specific Employee only.
Anybody know fix this problem? Thanks! 2011/4/23 Guevara <eguevara2...@gmail.com> > I got put in the form of employee the form of Houses using > StackedInline: > > > class HouseInline(admin.StackedInline): > model = House > max_num = 1 > > class EmployeeAdmin(admin.ModelAdmin): > search_fields = ['person__name','person__cpf'] > list_display = ("name","cpf","date_born","date_inclusion") > ordering = ["-name"] > list_filter = ("date_inclusion",) > list_per_page = 10 > inlines = [HouseInline] > > admin.site.register(Employee, EmployeeAdmin) > > Now I need collapse the forms of Houses in edit form of Employee, if I > register mora than 2 houses, I have two forms of Houses in edit form > employee. =/ > And the address combobox still showing all address register in > database, i need show olnly adress of employee or adress of the house. > > Thanks. > > > > > On 23 abr, 12:46, Guevara <eguevara2...@gmail.com> wrote: > > Thank you Ramiro! > > > > Now i have the atributes Person in form Employee. =) > > > > I added the attribute address and house in Employee class: > > > > models.py > > > > class Employee(Person): > > person = models.OneToOneField(Person, parent_link=True) > > # Relationship OneToOne with Address > > address = models.OneToOneField(Address) > > # Relationship with Houses > > house = models.ForeignKey(Houses) > > > > def __unicode__(self): > > if self.person: > > return "%s %s (%s)" % (self.name, self.tel, self.address) > > else: > > return "%s (%s)" % (self.name, self.address) > > > > admin.py > > > > from django.contrib import admin > > from imobiliaria.employee.models import Employee > > admin.site.register(Employee) > > > > But when registering a new Employee, the form show in the combobox > > others addresses and other houses of other entries, you know how I can > > fix? > > > > Thanks!! > > > > On 23 abr, 00:22, Ramiro Morales <cra...@gmail.com> wrote: > > > > > > > > > > > > > > > > > On Fri, Apr 22, 2011 at 11:55 PM, Guevara <eguevara2...@gmail.com> > wrote: > > > > [...] > > > > > > class Person(models.Model): > > > > name = models.CharField(max_length=50) > > > > date_inclusion = models.DateField() > > > > > > class Employee(models.Model): > > > > person = models.OneToOneField(Pessoa) > > > > > > I reed this dochttp:// > docs.djangoproject.com/en/dev/ref/contrib/admin/ > > > > but could not find this information. > > > > > Try with > > > > > class Employee(Person): > > > person = models.OneToOneField(Person, parent_link=True) > > > > > or simply with > > > > > class Employee(Person): > > > pass > > > > > It you don't want/need control of the name of the 1to1 relationship > > > between Employee and Person. > > > > > Also, see > > > > > > http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield.... > .. > > > > > -- > > > Ramiro Morales > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.