Django 1.4.1. I have a form which appears to have all proper values present in the html yet the POST dict appears empty.
views.py (relevant portion):
#login_required
def event(request, event_id):
event = Event.objects.get(pk=event_id)
crew = event.userprofile_set.all()
current_user = request.user.get_profile()
if current_user in crew:
current_user_is_not_crew = False
elif request.user == event.host:
current_user_is_not_crew = False
else:
current_user_is_not_crew = True
if event.date > datetime.now():
future_event = True
else:
future_event = False
context = RequestContext(request)
context['event'] = event
context['crew'] = crew
context['current_user_is_not_crew'] = current_user_is_not_crew
context['future_event'] = future_event
return render_to_response('event.html', context)
def commit(request):
"""
Commit user to event. Check if enough members
(2 including event creator) are taking part to
publish the event. If there are, mark
sufficient_participants Boolean and publish the
event to Facebook.
clashing_commitment checks that request user is not
already committed to an event on this day. If she is
they will not be allowed to commit to this.
"""
member = request.user.get_profile()
event_id = request.POST.get('event_id','')
print event_id
event = Event.objects.get(pk=event_id)
event_less_3_hours = event.date - timedelta(hours=3)
event_plus_3_hours = event.date + timedelta(hours=3)
clashing_commitment = Event.objects.filter(userprofile__exact=member).\
filter(date__range=(event_less_3_hours, event_plus_3_hours))
crew = event.userprofile_set.all()
print crew
context = RequestContext(request)
if clashing_commitment:
context['event'] = event
context['crew'] = crew
messages.add_message(request, messages.INFO,
'You are already committed to another event at this time. \
You cannot commit to two simultaneous events. Sorry! \
Ask admin to remove you from other event if necessary.')
return render_to_response('event.html', context)
try:
# cronix test page token:
graph = GraphAPI("CAAk6zW7VBJL9eUZD")
# Publish Facebook event on page
eventdate = event.date
date_iso = eventdate.isoformat()
date_iso += '+0100'
graph.post(
path = '/449/events',
retry=1,
name = event.name,
description = event.description,
location = event.location,
start_time = date_iso,
)
# To post event image, retrieve all Page events and identify current event
# by its precise date in ISO format as captured above.
# TODO This is a hacky, error-prone means of identifying
# events and needs to be fixed.
fb_events = graph.get('/449/events')
fb_events = fb_events['data']
for item in fb_events:
if item["start_time"] == date_iso:
fb_event = item
fb_event_id = fb_event.values()[0]
fb_event_path = fb_event_id + '/picture'
# Get appropriate, environment-specific root url for urllib call below.
# TODO Set two img_url variables and wrap urllib2.urlopen call
# in try/except as it is error prone
try:
if os.environ['ENV'] == 'staging':
img_url = 'http://www.mysite.org.uk//img/logo-fb.jpg'
except:
img_url = 'http://localhost:8000/static/img/logo.png'
print img_url
graph.post(
path = fb_event_path,
source = urllib2.urlopen(img_url))
except GraphAPI.OAuthError, e:
print e.message
return redirect('commit')
member.event_commitments.add(event)
crew = event.userprofile_set.all()
if crew.count() > settings.EVENT_PUB_COMMITTED_CRITICAL_MASS and event.sufficient_participants == 0:
event.sufficient_participants = 1
event.save()
publish_event = True
context['event'] = event
context['crew'] = crew
messages.add_message(request, messages.SUCCESS, 'You have committed to this event.')
return render_to_response('event.html', context)
urls.py (as requested by commenter):
from crewcal.views import user, log_in
from django.conf.urls import patterns, include, url
from django.contrib.auth.views import login, logout
from crewcal import models, views
from crewcal.forms import CustomRegistrationForm
# from crewcal.forms import RegistrationFormUniqueEmail
urlpatterns = patterns('',
# Examples:
url(r'^$', 'crewcal.views.index', name='home'),
# url(r'^ssc/', include('ssc.foo.urls')),
url(r'^events/(?P<event_id>\d+)/$', 'crewcal.views.event', name='events'),
url(r'^events/new/$', 'crewcal.views.new_event', name='new_event'),
url(r'^commit/$', 'crewcal.views.commit', name='commit'),
url(r'^users/(?P<user_name>[A-Za-z]+)/$', 'crewcal.views.user', name="user-profile"),
url(r'^users/(?P<user_name>\d+)/$', 'crewcal.views.user', name="user-profile"),
url(r'^', include('registration.backends.default.urls')),
url(r'^register/$', 'RegistrationView',
{'form_class':CustomRegistrationForm,
'backend':'registration.backends.default.DefaultBackend' }, name='registration_register'),
# For Registration simple, one-step login
# url(r'^', include('registration.backends.simple.urls')),
url(r'^facebook/', include('django_facebook.urls')),
# (r'^$', include('django_facebook.auth_urls')),
url(r'^messages/', include('postman.urls')),
# url(r'^event/$', views.object_list, {'model': models.Event}),
url(r'^accounts/', include('registration.urls')),
# url(r'^register/$', register, name='join'),
url(r'^login/$', 'django.contrib.auth.views.login'),
url(r'^logout/$', logout, {'next_page': '/'}, name='logout'),
url(r'^log_in/$', log_in, name='log_in'),
Here's the form rendered in the page:
<p>
<form action="/commit/" method="post" id="event-commit">
<input type="hidden" name="event_id" id="event_id" value="4">
<input type="submit" value="Commit to this event »" class="btn")">
<div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='XXOqtkkxYQ0zAN1sv3KYxVD8ljhjMpit' /></div>
</form>
</p>
But the consequent page breaks because the event_id (or anything else) is present in the POST dictionary:
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: ''
...
request
"<WSGIRequest\npath:/commit/,\nGET:<QueryDict: {}>,\nPOST:<QueryDict: {}>,\nCOOKIES:
...
This is happening in my Heroku staging environment but not locally. Any ideas? Thanks.
Hmm maybe this line caused the error:
event_id = request.POST.get('event_id','')
event = Event.objects.get(pk=event_id)
You need to pass int instead of string to pk, so change it to something like:
event_id = request.POST.get('event_id', 0)
event = Event.objects.get(pk=int(event_id))
EDIT:
You also have this part of code:
except GraphAPI.OAuthError, e:
print e.message
return redirect('commit')
So if there is an exception, it's automatically redirect to this same view with an empty querydict. I think that could be the source of the problem, could you remove that redirection and try again?
Related
I am building a web app that makes use of the HackerNews API and I keep running into the same error.
I am trying to Output the 10 requested result from API but everytime i use the return response it only outputs the first result.
I want it to output 10 articles from the API instead of just the One.
This is my code:
from operator import itemgetter
import requests
from django.shortcuts import render
# Make an API call and store the response.
def home(request):
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
r = requests.get(url)
print(f"Status code: {r.status_code}")
# Process information about each submission.
submission_ids = r.json()
submission_dicts = []
for submission_id in submission_ids[:10]:
# Make a separate API call for each submission.
url = f"https://hacker-news.firebaseio.com/v0/item/{submission_id}.json"
r = requests.get(url)
print(f"id: {submission_id}\tstatus: {r.status_code}")
response_dict = r.json()
# Build a dictionary for each article.
submission_dict = {
'title': response_dict['title'],
'hn_link': f"http://news.ycombinator.com/item?id={submission_id}",
# 'comments': response_dict['descendants'],
}
submission_dicts.append(submission_dict)
# submission_dicts = sorted(submission_dicts, key=itemgetter('comments'),
# reverse=True)
for submission_dict in submission_dicts:
print(f"\nTitle: {submission_dict['title']}")
print(f"Discussion link: {submission_dict['hn_link']}")
# print(f"Comments: {submission_dict['comments']}")
count = 0
if count < 10:
return render(request, "news_api/home.html", submission_dict)
You're only getting one result because your return statement is calling "submission_dict". You probably wanted to call "submission_dict(s)" or something similar but it's hard to tell based on what has been commented out in your code. I think that's your primary problem. Without seeing your template, I don't know what your context object is supposed to look like.
But try this:
# views.py
def hacker_news_api_selector():
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
r = requests.get(url)
submission_list = r.json()
context = {}
context['objects'] = []
# Process information about each submission.
for submission_id in submission_list[:10]:
# Make a separate API call for each submission.
url = f"https://hacker-news.firebaseio.com/v0/item/{submission_id}.json"
r = requests.get(url)
response_dict = r.json()
context['objects'].append(response_dict)
return context
def home(request):
context = hacker_news_api_selector()
return render(request, "news_api/home.html", context)
And in the template...
# news_api/home.html
<html>
...
{% for x in objects %}
<li>{{ x.title }}</li>
{% endfor %}
</html>
I am working on ticketing system in Flask Admin. The Flask Admin enviroment will be the main one for all the users. For creating or editing tickets I go out from Flask-Admin and use wtforms to implement backend logic. After creation or editing the ticket (validate_on_submit) I want to redirect back to Flask Admin, so I use redirect(url_for(ticket.index_view)). It works fine.
Is there a way to redirect to flask admin, but also with specific filters which were applied before user left Flask admin enviroment? (it is basiccaly GET parameters of url - but in FLASK)
I was trying to use:
referrer = request.referrer
get_url()
But I am probably missing something crucial and don´t know how to implement it (where to put it so I can call the arguments)
Thank you so much.
EDIT : adding more context:
I have a flask admin customized to different roles of users. The main ModelView is the one showing the TICKETS : the specifics of the Class are not vital to my current problem but here its how it looks:
class TicketModelView(ModelView):
column_list = ['id', 'title', 'osoba', 'content', 'povod_vmc_kom', 'dateVMC','zodpovedni', 'deadline', 'odpoved', 'solution', 'is_finished']
column_searchable_list = ['osoba']
column_filters = [ 'povod_vmc_kom', 'dateVMC', 'osoba', 'zodpovedni']
column_labels = dict(povod_vmc_kom='VMČ / Komisia', dateVMC='Dátum VMČ / komisie', zodpovedni = "Zodpovední")
column_display_actions = True
column_filters = [
FilterEqual(column=Ticket.povod_vmc_kom, name='Výbor/komisia', options=(('VMČ Juh','VMČ Juh'), ('UM','UM'), ('Kom dopravy','Kom dopravy'))),
'zodpovedni', 'is_finished',
'dateVMC', 'osoba'
]
def is_accessible(self):
#práva pre vedenie mesta - môže len nazerať
if current_user.is_authenticated and current_user.role == 0:
self.can_export=True
self.can_delete = False
self.can_edit = False
self.can_create = False
self._refresh_form_rules_cache()
self._refresh_forms_cache()
return True
#práva pre super admina (ostatné práva sú defaultne zapnuté)
if current_user.is_authenticated and current_user.role == 1:
self.can_export=True
self.can_delete=True
self.form_edit_rules = ('zodpovedni', 'is_finished' )
self.column_editable_list = ['is_finished']
self._refresh_form_rules_cache()
self._refresh_forms_cache()
return True
#práva pre garantov
if current_user.is_authenticated and current_user.role == 2:
self.can_delete = False
self.can_create = False
self.can_edit = False
self.can_export=True
self.column_searchable_list = ['title']
self._refresh_form_rules_cache()
self._refresh_forms_cache()
return True
#práva pre veducich utvarov
if current_user.is_authenticated and current_user.role == 3:
self.can_create = False
self.can_delete = False
self.can_export=True
self.column_searchable_list = ['title']
self.column_editable_list = ['odpoved', 'date_odpoved', 'solution', 'date_solution' ]
self.form_edit_rules = ('odpoved', 'date_odpoved', 'solution', 'date_solution')
self._refresh_form_rules_cache()
self._refresh_forms_cache()
return True
return False
def _solution_formatter(view, context, model, name):
# Format your string here e.g show first 20 characters
# can return any valid HTML e.g. a link to another view to show the detail or a popup window
if model.solution:
return model.solution[:50]
pass
def _content_formatter(view, context, model, name):
# Format your string here e.g show first 20 characters
# can return any valid HTML e.g. a link to another view to show the detail or a popup window
if len(model.content) > 100:
markupstring = "<a href= '%s'>%s</a>" % (url_for('ticket', ticket_id=model.id), "...")
return model.content[:100] + Markup(markupstring)
return model.content
def _user_formatter(view, context, model, name):
if model.id:
markupstring = "<a href= '%s'>%s</a>" % (url_for('ticket', ticket_id=model.id), model.id)
return Markup(markupstring)
else:
return ""
column_formatters = {
'content': _content_formatter,
'solution': _solution_formatter,
'id': _user_formatter
}
When user viewing the TicketView in Flask Admin, he can apply various filters which is vital to the user experience of the whole web app. The filters work fine and they are stored in URL as GET arguments. When he wants to create or edit a ticket, I am not allowing him to do it in Flask Admin (I edited Flask-Admin layout.html template and added a button to navbar which redirects to my new_ticket url with wtforms.) because of backend logic I want to be applied. For example when he edits field "solution" : I want the value in field "date_of_solution" be generated automatically (date.today()). So I am using wtforms and flask routing : example is bellow:
#app.route("/ticket/<int:ticket_id>/solution", methods = ['GET', 'POST'])
#login_required
def solution(ticket_id):
if current_user.role != 3:
flash("Pre zadanie riešenia alebo odpovede musíte byť prihlásený ako vedúci útvaru", "danger")
return redirect(url_for('ticket', ticket_id=ticket_id))
ticket = Ticket.query.get_or_404(ticket_id)
form = AdminPanelForm()
if form.validate_on_submit():
print("1")
if not ticket.date_solution:
print("2")
ticket.date_solution= datetime.now()
if not ticket.date_odpoved:
print("3")
if form.odpoved.data != ticket.odpoved:
print("4")
ticket.date_odpoved= datetime.now()
ticket.solution = form.solution.data
ticket.odpoved = form.odpoved.data
ticket.is_finished = True
db.session.commit()
flash("Ticket bol updatenutý", "success")
**return redirect(url_for('ticketmod.index_view'))**
elif request.method == 'GET':
form.solution.data = ticket.solution
form.odpoved.data = ticket.odpoved
return render_template("admin_ticket.html", form=form, ticket = ticket)
Now you can see that after succesful updating the ticket, user is redirected to Ticket model View where he came from, return redirect(url_for('ticketmod.index_view')) but without filters applied. I am looking for the solution, how can you store the url GET parameters (the filters) and then use them when redirecting back to ModelView. I tried function get_url() or request.referrer but I wasn´t succesful.
As I said in my original post, maybe I am missing something crucial in web architecture - if you have in mind some learning material I shoul be looking at : thanks for any advice.
Within the formatter method you can get a view's url including the applied filters/sorting criteria using the following:
_view_url = view.get_url('.index_view', **request.args)
Now pass this along to route request, either as a parameter or some other means. For example:
class TicketModelView(ModelView):
# blah blah
def _user_formatter(view, context, model, name):
if model.id:
# This is the current url of the view including filters
_view_url = view.get_url('.index_view', **request.args)
# Pass this as a parameter to your route
markupstring = "<a href= '%s'>%s</a>" % (url_for('ticket', ticket_id=model.id, return_url=_view_url), model.id)
return Markup(markupstring)
At the route you can now pull out the return_url from the request arg and add it as a hidden field in the form. Then in the post back retrieve the value from the form and redirect.
#app.route("/ticket/<int:ticket_id>/solution", methods = ['GET', 'POST'])
#login_required
def solution(ticket_id):
# Get the return_url from the request
_return_url = request.args.get('return_url'):
# Add the return_url to the form as a hidden field
form.return_url.data = _return_url
# blah blah
if form.validate_on_submit():
# get return value from form
_return_url = form.return_url.data
return redirect(_return_url) if _return_url else redirect(url_for('ticketmod.index_view'))
I'm new in Django ! I don't know how to send email in Django. I refer Django documentation but it didn't help me . I need to send email with html page to different users .In models.py i have two values Name and Email. When i click button ,the html page should be send to appropriate user's Email
There are a lot of different solutions how to send emails in django.
You can use even php, or any scripting language if you feel it's complicated to use only python/django code.
Just an example of email utility from custom email subscription:
email_utility.py:
import logging, traceback
from django.urls import reverse
import requests
from django.template.loader import get_template
from django.utils.html import strip_tags
from django.conf import settings
def send_email(data):
try:
url = "https://api.mailgun.net/v3/<domain-name>/messages"
status = requests.post(
url,
auth=("api", settings.MAILGUN_API_KEY),
data={"from": "YOUR NAME <admin#domain-name>",
"to": [data["email"]],
"subject": data["subject"],
"text": data["plain_text"],
"html": data["html_text"]}
)
logging.getLogger("info").info("Mail sent to " + data["email"] + ". status: " + str(status))
return status
except Exception as e:
logging.getLogger("error").error(traceback.format_exc())
return False
Don't forget to create a token which we will verify when user clicks the confirmation link. Token will be encrypted so that no one can tamper the data.
token = encrypt(email + constants.SEPARATOR + str(time.time()))
Also check this link and this.
Here is a naive exemple to leverage django send_mail:
import smtplib
from django.core.mail import send_mail
from django.utils.html import strip_tags
from django.template.loader import render_to_string
#user will be a queryset like:
users = User.objects.all() # or more specific query
subject = 'Subject'
from_email = 'from#xxx.com'
def send_email_to_users(users,subject,from_email):
full_traceback = []
for user in users:
to = [user.email] # list of people you want to sent mail to.
html_content = render_to_string('mail_template.html', {'title':'My Awesome email title', 'content' : 'Some email content', 'username':user.username}) # render with dynamic context you can retrieve in the html file
traceback = {}
try:
send_mail(subject,strip_tags(html_content),from_email, to, html_message=html_content, fail_silently=False)
traceback['status'] = True
except smtplib.SMTPException as e:
traceback['error'] = '%s (%s)' % (e.message, type(e))
traceback['status'] = False
full_traceback.append(traceback)
errors_to_return = []
error_not_found = []
for email in full_traceback:
if email['status']:
error_not_found.append(True)
else:
error_not_found.append(False)
errors_to_return.append(email['error'])
if False in error_not_found:
error_not_found = False
else:
error_not_found = True
return (error_not_found, errors_to_return)
#really naive view using the function on top
def my_email_view(request,user_id):
user = get_object_or_404(User, pk=user_id)
subject = 'Subject'
from_email = 'myemail#xxx.com'
email_sent, traceback = send_email_to_users(user, subject, from_email)
if email_sent:
return render(request,'sucess_template.html')
return render(request,'fail_template.html',{'email_errors' : traceback})
In your template mail_template.html:
<h1>{{title}}</h1>
<p>Dear {{username}},</p>
<p>{{content}}</p>
And don't forget to set the email settings in settings.py: https://docs.djangoproject.com/fr/2.2/ref/settings/#email-backend
Send_mail from docs :https://docs.djangoproject.com/fr/2.2/topics/email/#send-mail
Render_to_string from the doc: https://docs.djangoproject.com/fr/2.2/topics/templates/#django.template.loader.render_to_string
I'm trying to get session social variable from my template.
I have 2 separate buttons for Signup and Login using key login_type:
<img src='img.png'>
<img src='img2.png'>
In my settings:
SOCIAL_AUTH_FIELDS_STORED_IN_SESSION = ['login_type']
I tried also with:
FIELDS_STORED_IN_SESSION = ['login_type']
my custom pipeline:
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'FBAuth.facebook.check_if_exists',
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
)
facebook.py:
from django.conf import settings
from django.shortcuts import redirect, HttpResponse
def check_if_exists(strategy, request, *args, **kwargs):
login_type = strategy.request.GET.get('login_type')
#login_type = strategy.session_get('key') (I tried all cases)
#login_type = request['login_type']
#login_type = strategy.request['login_type']
logger.debug("is_new parameter is %s", kwargs['is_new'])
logger.debug("login_type is %s", login_type)
if kwargs['is_new']:
if login_type == 1:
return redirect('/', message ='Specified social account is not yet associate with any existent user, try to Sign up first')
else:
if login_type == 2:
return redirect('/', message = 'User for this account is already exist, try to login')
return None
but, in any cases in my logs I always see "login_type is None"
What's wrong?
It seems like form your GET params wrong. You should change
<code><pre>?next={{ request.path }}?login_type=1</pre></code>
to
<code><pre>?next={{ request.path }}&login_type=1</pre></code>
I did a pip install for django paypal. The button renders and the payment goes through. The return url works too but the notify_url part is not working. So I cannot update my database that a sale has gone through.
I don't get any errors either so I am stumped. If someone can help Id really appreciate it. Thanks
Edit: I added from paypal.standard.ipn.signals import payment_was_successful to the top of my views page. and changed the name of my notify_url to show_me_the_money (Not sure if that matters) I got it from a blog called http://djangodersleri.blogspot.ie/2013/11/paypal-ipn-with-django.html. But the good thing is now at least I seem to be getting my transactions recorded in the table paypal_ipn. But that's all! So still dont know if the show_me_the_money view is being executed.
Here is what I have..
Settings...
INSTALLED_APPS = (
...
'paypal.standard.ipn',
)
PAYPAL_RECEIVER_EMAIL = "my_sandbox_test_email_is_here#gmail.com"
PAYPAL_TEST = True
URLS...
(r'^show_me_the_money /', include('paypal.standard.ipn.urls')),
Views...
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
from paypal.standard.ipn.signals import payment_was_successful
def show_me_the_money (sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
doc_id=ipn_obj.item_number1 # :document_id,
us_id=ipn_obj.item_number2 #user.id,
obj_doc=Document.objects.get(id=doc_id)
my_user = User.objects.get(id=us_id)
obj_doc.users.add(my_user)
obj_doc.save()
try:
ipn_obj.verify(item_check_callable)
except:
import sys, traceback
traceback.print_exc(file=sys.stdout)
valid_ipn_received.connect(paid)
#csrf_exempt
def myvideos(request):
try:
my_vids=Document.objects.filter(users=request.user.id)#request.user.id
except:
return render_to_response(
'myvideos.html',
context_instance=RequestContext(request)
)
#my_vids= Document.objects.filter(users=request.user.id)
return render_to_response(
'myvideos.html',
{'my_vids': my_vids},
context_instance=RequestContext(request)
)
def video(request, document_id):
document = Document.objects.get(id=document_id)
if request.user.id:
d1 =datetime.datetime.now()
t=d1.strftime('%y%m%d%h%m%s')
pp_price = str(document.price)
# What you want the button to do.
paypal_dict = {
"business": settings.PAYPAL_RECEIVER_EMAIL,
"amount": pp_price + ".00",
"item_number1":document_id,
"item_number2":request.user.id,
"item_name": document.name,
"invoice": document.name+t,
"notify_url": "http://wackosmackosite.com/"+ reverse('paypal-ipn'),
"return_url": "http://wackosmackosite.com/myvideos/",
"cancel_return": "http://wackosmackosite.com/video/"+document_id+"/",
}
form = PayPalPaymentsForm(initial=paypal_dict)
context = {"form": form, "document":document }
return render(request, "video.html", context)
else:
return render_to_response('video.html',{'document': document},
context_instance=RequestContext(request))
Here is the The urls from paypal.standard.ipn
from django.conf.urls import url
from paypal.standard.ipn import views
urlpatterns = [
url(r'^$', views.ipn, name="paypal-ipn"),
]
First off #mcastle Thank you so much for your help. But I just couldn't figure out the Django signals.
Ok so what I had to do in the end is go to the paypal.standard.ipn.views file and import my app and call the show_me_the_money view from there at the very bottom of the view just before it returns the http response.
So the notify url in the paypal dict like this...
"notify_url": "http://wackosmackosite.com/show_me_the_money/",
And the url in my urls file is like this..
url(r'^show_me_the_money/', include('paypal.standard.ipn.urls')),
I was able to extract the info I needed to update my database from the arguments passed to show_me_the_money. like this...
def show_me_the_money(sender, **kwargs):
ipn_obj = sender
payStatus=ipn_obj.POST.get('payment_status','')
if payStatus=='Completed':
....
Then in the paypal ipn view
at the top...
from myApp.views import show_me_the_money
At the bottom...
s_m_t_m=show_me_the_money(request, item_check_callable=None)
return HttpResponse("OKAY")
I found this whole set-up very confusing and think the documentaion for me just leaves lots of important stuff out. Anyway This is working perfect now and I just got off the phone with pay pal and they are happy it is configured correctly.
Review Django's documentation on signals. show_me_the_money looks like it needs to be connected to a signal.