hello all....
I am doing a project in Django.
I want to create a list by clicking upon a link, it will open up a new
window using javascript window.open() method.
I have two tables for list.
class Saved_list(models.Model):
        description=models.CharField(max_length=100)
        number_entries=models.IntegerField()
        date_created=models.DateTimeField(auto_now_add=True)
        date_modified=models.DateTimeField(auto_now=True)

class Saved_list_entry(models.Model):
        saved_list=models.ForeignKey(Saved_list)
        date_created=models.DateTimeField(auto_now_add=True)

Onload all entries in the Saved_list is listed with description and
number entries with a check box in front of it.
I want to create new Saved_list. I have done it with a a link.
When any one of the Checkbox is checked I want to increment the
number_entries field and insert a new row in Saved_list_entry.

my view is :
def add_to_list(request):
        saved_list=Saved_list.objects.all()
        lists=saved_list.values()
        if request.method=='POST':
                name=''
                for lst in lists:
                        if request.POST[lst['description']]=='On':
                                name=lst['description']
                                break
                if name!='':
                        try:
                                slist1=Saved_list.objects.get
(description=name)
                        except KeyError:
                                pass
                        slist_entry=Saved_list_entry
(saved_list_id=slist1.id)
                        slist1.number_entries=slist1.number_entries+1;
                        slist1.save()
                else:
                        slist=Saved_list(description=request.POST
['listname'],number_entries=0)
                        slist.save()
        else:
                pass
        return render_to_response('candidates/add_to_list.html',
{'list':lists})


and my template is:
        <form action="" method="POST" name="list">
        {% for l in list %}
                <input type="checkbox" name="{{ l.description }}">
                {{ l.description }} ({{ l.number_entries }})
        {% endfor %}
                <td><input type="text" name="listname">
                <a href="javascript:document.list.submit()">Save</a>
                <input type="submit" class="button1" value="Add To List" 
name="Add
To List">
                <input type="button" class="button1" value="cancel" 
name="cancel"
onClick="window.close();">
        </form>

But i can't retrieve the unchecked checkboxes
please help me......
thanks in advance....
Lima
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to