oh my god ,I begin studying django by using 1.02 ....
On Tue, Jul 21, 2009 at 6:06 PM, Harish <harish.bha...@gmail.com> wrote: > > The Django Version I am using is > '0.97-pre-SVN-7049' > > > On Jul 21, 2:56 pm, PanFei <cnwe...@gmail.com> wrote: > > may I have your version of django ? > > > > On Tue, Jul 21, 2009 at 4:49 PM, Harish <harish.bha...@gmail.com> wrote: > > > > > Hi Friends, > > > > > Just refer the sample code below. > > > > > My problem is I am referring a Dependant models field in > > > 'search_field' > > > it is working correctly but when i delete a record from 'Dept' name > > > from Dept Model > > > the Search for the firstname is not working.. > > > For example > > > > > The following data is displayed in the Employee Model > > > > > Employee > > > FirstName | Last Name | Dept | > > > ------------------------------------- > > > AAA BBB Sales > > > BBB CCC | Purchase > > > > > Dept > > > DeptName | Employee Name | Other Detail > > > ------------------------------------------------ > > > Sales AAA None > > > Purchase BBB None > > > > > In the above example (data) if I Search for Employee 'AAA' > > > It produces the result. But When I delete the 'Purchase' record > > > from 'Dept' Table, and then Search 'AAA' in 'Employee' Table > > > It is not displaying the Record. (The record exists in the list) > > > > > I want to display the records of Employee when there is no record > > > exist in the Dept Model with Dept as None > > > > > # Code Snippet > > > class Employee(models.Model): > > > firstname = models.CharField(maxlength=80) > > > last_name = models.CharField(maxlength=80) > > > salary = models.DecimalField() > > > > > def __str__ (self): > > > return self.firstname > > > > > def getdept(self): > > > try: > > > dept = Dept.objects.get(pk=self.pk) > > > except Dept.DoesNotExist: > > > dept = Dept() > > > return dept.dept_name > > > > > list_display = ('firstname ','lastname','getdept') > > > search_fields = ['firstname','lastname','Dept__dept_name'] > > > > > class Dept(models.Model): > > > dept_name = models.CharField(maxlength=80) > > > empName = models.OneToOneField(Employee, ) > > > otherDetails = models.TextField() > > > > > def __str__ (self): > > > return self.dept_name > > > > > list_display = ('dept_name') > > > search_fields = ['dept_name'] > > > > > Kindly reply if anyone has solution to this?? > > > > > Regards > > > Harish Bhat > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---