Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3444932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:58:40+00:00 2026-05-18T08:58:40+00:00

In my page I have a voting possibility. Each object can be liked with

  • 0

In my page I have a voting possibility. Each object can be liked with facebook ‘Like’ button. If item is already liked, I would like to hide the button. So I’ve wrote a method for liked object’s to check if user with given ip already voted. IP is stored in context variable.

def check_vote(self, ip):
    id = self.id
    logging.debug("id: %s, ip: %s" % (id, ip))
    try:
        voted = Vote.objects.get(uid=id, ip=ip)
        return False
    except:
        logging.debug("returning True")
        return True 

Here’s my view:

def artifact_finalists(request):           
    submissions = ArtifactSubmission.objects.filter(resized=True, final=True)
    template_name = 'rte/artifact_finalists.html'
    return render_to_response(template_name, {"submissions": submissions, 'voting': voting,}, context_instance=RequestContext(request))

And template:

    {% for submission in submissions %}
        <li style="float:left, width:400px, margin-right:20px">
            <div class="single-submission">
                <div style="float:left, margin-right:10px">
                    <img src="{{ submission.url100 }}" width="100px" />
                </div>
                <div style="float:left">
                    <span style="float:left">{{ submission.name }}</span>
                    <span style="float:left">{{ submission.description }}</span>
                </div>
                <div class="vote">
                    {% if submission.get_vote IP_ADDRESS %}
                        <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="button_count" href="http://ntt.vipserv.org{{submission.get_absolute_url}}"></fb:like>
                    {% endif %}                    </div>
            </div>
        </li>
    {% endfor %}

But it raises : Expected 'not' in if statement . Any ideas why ? Adding ‘not’ in ‘if’ tag raises improperly formatted :/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:58:41+00:00Added an answer on May 18, 2026 at 8:58 am

    Your if statement in the template seems to be missing an operator.

    {% if submission.get_vote IP_ADDRESS %}
    

    if submission.get_vote (is what to the) IP_ADDRESS? == perhaps?

    See the Django template docs for a list of what if accepts in a template.

    Also, it’s not clear what IP_ADDRESS is. Do you mean REMOTE_ADDR, or to somehow refer to the ip address you have already?

    Also, I’d suggest not using a bare except:. Limit it to the exceptions you are thinking of specifically. Not specifying the exception can hide other errors. I suggest adding

    from django.core.exceptions import ObjectDoesNotExist
    

    and then

    except ObjectDoesNotExist:
    

    in the check_vote method.

    Where is check_vote called?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple poll site. I would like to disallow possibility of voting
I have a voting thing on my site. I also attach the facebook like
I have a page full of text boxes (Fields). Each containing data. I would
I have page which is redirected from htaccess. now I can pass the German
I have page, i can contact directly without any problems. http://www.mysite.com/app_dev.php/comments/22 the page shows
I have a listview that contains values from webservice.Each page contains only 10 listitems
So I have a simple voting feature on my asp.net mvc page. My index
I am working on a comment voting system. I have a page profile_new.php?id=194 That
I have a viewController, in that i have used Page control. and each page
I have a voting system. When a user clicks Vote button, the vote value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.