Re: How to register EmployeeAdmin using atributes in Person class
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> 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 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 wrote: > > > > > > > > > > > > > > > > > On Fri, Apr 22, 2011 at 11:55 PM, Guevara > 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.
Re: How to register EmployeeAdmin using atributes in Person class
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, Guevarawrote: > 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 wrote: > > > > > > > > > On Fri, Apr 22, 2011 at 11:55 PM, Guevara 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.
Re: How to register EmployeeAdmin using atributes in Person class
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 Moraleswrote: > On Fri, Apr 22, 2011 at 11:55 PM, Guevara 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/#onetoonefieldhttp://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-in...http://docs.djangoproject.com/en/dev/topics/db/models/#specifying-the... > > -- > 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.
Re: How to register EmployeeAdmin using atributes in Person class
On Fri, Apr 22, 2011 at 11:55 PM, Guevarawrote: > [...] > > 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 doc http://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 http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance http://docs.djangoproject.com/en/dev/topics/db/models/#specifying-the-parent-link-field -- 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.
How to register EmployeeAdmin using atributes in Person class
Hello! I need register EmployeeAdmin using atributes in Person class: My admin.py: class EmployeeAdmin(admin.ModelAdmin): list_display = ("name","date_inclusion") ordering = ["-name"] search_fields = ("name",) list_filter = ("date_inclusion",) list_per_page = 10 admin.site.register(Employee,EmployeeAdmin) I got this exception: Exception Value is: EmployeeAdmin.list_display[0], 'name' is not a callable or an attribute of 'EmployeeAdmin' or found in the model 'Employee'. My models.py: 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 doc http://docs.djangoproject.com/en/dev/ref/contrib/admin/ but could not find this information. Thanks!! -- 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.