For loop did not working ...

26 views
Skip to first unread message

Asad ur Rehman

unread,
Jul 20, 2016, 6:41:20 AM7/20/16
to Django users
In image tou can see Pending Box. i want to generate loop and want to get result against values in loop.in image 668 is the value of first Column.i want to give different values to column by loop
 
    Pending = pending(8)

pending(8) give first column result that is 668.


Id = [2,3,4,5,6,7,8]
        for w in Id:
        A = w
  Pending = pending(A)

How to give different value of A ? 
aa.PNG

Mandeep Tondak

unread,
Jul 20, 2016, 6:50:43 AM7/20/16
to django...@googlegroups.com
Hey


Id = [2,3,4,5,6,7,8]
        for w in Id:
             A = w
            Pending = pending(A)

indent error. i hope.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a450edf-7ed2-4924-a923-2b51e7049167%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Warm Regard:-
Mandeep Kumar
     



Asad ur Rehman

unread,
Jul 20, 2016, 6:55:21 AM7/20/16
to Django users
No module name urls error is showing.

Mandeep Tondak

unread,
Jul 20, 2016, 7:06:02 AM7/20/16
to django...@googlegroups.com
use custom template tag / or use class function

in html:-
 use {{ id|pending }}

pending is your custom template tag
_____________________________________
Class Abc():
     pending = model()

 def pendinf(self):
       return self.pending


Thank
Mandeep

On Wed, Jul 20, 2016 at 4:25 PM, Asad ur Rehman <asadurr...@gmail.com> wrote:
No module name urls error is showing.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.

Asad ur Rehman

unread,
Jul 20, 2016, 7:14:25 AM7/20/16
to Django users
def campaign_list(request):
    """List all campaigns for the logged in user

    **Attributes**:

        * ``template`` - dialer_campaign/campaign/list.html

    **Logic Description**:

        * List all campaigns belonging to the logged in user
    """
    form = CampaignSearchForm(request.user, request.POST or None)
    request.session['pagination_path'] = request.META['PATH_INFO'] + '?' + request.META['QUERY_STRING']
    sort_col_field_list = ['id', 'name', 'startingdate', 'status', 'totalcontact']
    pag_vars = get_pagination_vars(request, sort_col_field_list, default_sort_field='id')
    phonebook_id = ''
    status = 'all'
    post_var_with_page = 0

    if form.is_valid():
        field_list = ['phonebook_id', 'status']
        unset_session_var(request, field_list)
        phonebook_id = getvar(request, 'phonebook_id', setsession=True)
        status = getvar(request, 'status', setsession=True)
        post_var_with_page = 1

    # This logic to retain searched result set while accessing pagination or sorting on column
    # post_var_with_page will check following thing
    # 1) if page has previously searched value, then post_var_with_page become 1
    # 2) if not then post_var_with_page remain 0 & flush the session variables' value
    if request.GET.get('page') or request.GET.get('sort_by'):
        post_var_with_page = 1
        phonebook_id = request.session.get('session_phonebook_id')
        status = request.session.get('session_status')
        form = CampaignSearchForm(request.user, initial={'status': status, 'phonebook_id': phonebook_id})

    if post_var_with_page == 0:
        # default / unset session var
        field_list = ['status', 'phonebook_id']
        unset_session_var(request, field_list)

    # Set search on user as default
    kwargs = {'user': request.user}
    if phonebook_id and phonebook_id != '0':
        kwargs['phonebook__id__in'] = [int(phonebook_id)]
    if status and status != 'all':
        kwargs['status'] = status

    all_campaign_list = Campaign.objects.filter(**kwargs).order_by(pag_vars['sort_order'])
    campaign_list = all_campaign_list[pag_vars['start_page']:pag_vars['end_page']]
    campaign_count = all_campaign_list.count()

    Id = [2,3,4,5,6,7,8]
        for w in Id:
        A = w
        

    Pending = pending(A)


    data = {
        'form': form,
        'all_campaign_list': all_campaign_list,
        'campaign_list': campaign_list,
        'total_campaign': campaign_count,
        'CAMPAIGN_COLUMN_NAME': CAMPAIGN_COLUMN_NAME,
        'col_name_with_order': pag_vars['col_name_with_order'],
        'msg': request.session.get('msg'),
        'error_msg': request.session.get('error_msg'),
        'info_msg': request.session.get('info_msg'),
        'Pending': Pending,
        
    }
    request.session['msg'] = ''
    request.session['error_msg'] = ''
    request.session['info_msg'] = ''
    return render_to_response('dialer_campaign/campaign/list.html', data, context_instance=RequestContext(request))

def pending(campaign_id):

    A = Campaign_phonebook.objects.values_list('phonebook_id').filter(campaign_id = campaign_id)


   ## getting all contact_id of campaign_id = campaign_id in phonebook
    B = Contact.objects.filter(phonebook_id__in=A).count()
 

    ## Check How many Contacts in Subscriber of "campaign_id = campaign_id"
    C = Subscriber.objects.filter(campaign_id = campaign_id).exclude(status = 1).count()

    Result = B - C

    return Result


Sir Mandeep This is my full code When i give specific value instead of A it works,but when i give value through loop it did't Work
Reply all
Reply to author
Forward
0 new messages