class Listing_channels(models.Model):
  list_parent_id = models.IntegerField(blank = True)
  list_channel = models.CharField(max_length = 20)
  visibility = models.BooleanField()
  index = djangosearch.ModelIndex(text=['list_channel'], additional=
[])

  def __unicode__(self):
    return self.list_channel

  def get_absolute_url(self):
    return u'%s' % self.list_channel

these are the records of list_channel

id   list_parent_id   list_channel
1       0     Top Menu
2       1     Sight Seeing
3       1     Real Estate
4       1     Shopping
5       1     Restaurants
6       2     Activities
7       2     Amusement park 1
8       2     Art Galleries
9       2     Museums
10       2     Parks
11       2     Tour operators
12       6     Bowling
13       6     Dinner Cruises
14       6     Diving
15       3     Developers
16       3     Orientation
17       3     Real Estate Agents
18       3     Relocation

I wanted to print like this for Sight Seeing see here
http://explocity.in/Dubai/sightseeing/activites/diving-sightseeing.html

i wrote in views.py

def latest_listing(request):
  listing_result = Listing_channels.objects.all().filter
(list_channel='Sight Seeing')
  for n in listing_result:
         print "N1.id : ", n.id
               if n.list_channel:
                       qset=(
                               Q(list_parent_id = n.id)
                       )
        level2 = Listing_channels.objects.filter(qset).distinct()
        for n in level2:
               print "N2.id : ", n.id
               if n.list_channel:
                       qset=(
                               Q(list_parent_id = n.id)
                       )
        print "QSET : ", qset
        level3 = Listing_channels.objects.filter(qset).distinct()
        for n in level3:
               print "N3.id : ", n.id
               if n.list_channel:
                       qset=(
                               Q(list_parent_id = n.id)
                       )
        level4 = Listing_channels.objects.filter(qset).distinct()
  #sight_result = Listing_channels.objects.all().filter
(list_parent_id=6)
  print "Listing Result : ", listing_result
  print "Level2 : ", level2
  print "Level3 : ", level3
  print "Level4 : ", level4
  #print "Sight Result : ", sight_result
  return render_to_response('sight_seeing.html',
{'listing_result':listing_result,'level2':level2,'level3':level3})

its printing me well up to level2
Sight Seeing
  Activities
     ---
     ---
  Amusement park
  Art Galleries
  Museums
  Parks
  Tour operators

but for Activities(Level3) it returns me blank list.
I know what is the problem in level3 iteration it goes to last id and
there is no parent_id. but for 6,7,8 there is parent id.

my output is

N1.id :  2
N2.id :  6
N2.id :  7
N2.id :  8
N2.id :  9
N2.id :  10
N2.id :  11
QSET :  (AND: ('list_parent_id', 11L))
Listing Result :  [<Listing_channels: Sight Seeing>]
Level2 :  [<Listing_channels: Activities>, <Listing_channels:
Amusement park>, <Listing_channels: Art Galleries>, <Listing_channels:
Museums>, <Listing_channels: Parks>, <Listing_channels: Tour
operators>]
Level3 :  []
Level4 :  []


my query is how may i get the value for Level3.

Please do not suggest me to use django-tree or mptt.

some one told me to use recursion i do not know how to do?

if you look for a while you will come to know where i hang up.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to