Use of Stripe payment gateway in django - python

I have installed dj-strpe module and register one user without any difficulty i.e., by submitting the form at /payments/ and here dj-stripe register the current user to stripe.com . But what if I want to send card information with the user and want to use it later , However I register the card by following instructions https://stripe.com/docs/tutorials/forms .
But I think this module must contain all this forms already but I don't found any thing in documentation to use them (how ever I find out urls and forms in this module) . So please tell me how I can use those forms in my project , is there any specific tags or urls to submit the forms.
For one instance I used this url /payments/history/ but I didn't show any thing in browser however I have checked the browser console and in response there is some html but browser is blank.
I hope I have explained my question. Any help will be appreciated.

Related

Show private content to specific users in Django

I'm building a very simple website where a user authenticates and accesses a personal page from where they can download their paychecks. I've already implemented the login view, that redirects the user to the profile page. Now in the profile page, I need to add a list of paychecks to download. In order to do that, I need to take them from a static sub-directory with the same name as the user:
static/paychecks/username
I've been reading about serving static files, but I can't figure out how to do this specifically. Any help will be much appreciated.

Redirects in Django

I'm working on the Helpdesk module from Django.
I want people who try to access 192.168.x.xxx:8000/helpdesk/ are redirected to the login page: 192.168.x.xxx:8000/helpdesk/login/?next=/helpdesk/
I also want people who try to access an nonexistant page to be redirected to:
the homepage if connected, or
the login page if not connected.
I find an answer for the first part of my question. I just used the import login_required. Just before the function homepage in /helpdesk/public.py and the function index in /helpdesk/kb.py, I put #login_required(login_url='/helpdesk/login/?next=/helpdesk/) and it worked !
Now I try to find the answer of the second part (redirection).

How to add facebook login to Python Django Project?

I want to build a Django application where I have a simple button "login using Facebook" and it redirects you to the Facebook page allowing to log in with facebook username and password . When user clicks "login" . It should redirect me to my already defined url where i can display the user's public information from his profile. How this can be achieved ??
Just like 4shared.com allows to login with Facebook . I want something like that but i only want to display its public information of the user.
You should take a look at some of the existing OAuth libraries for django. I'm using allauth, and I can definitely recommend it, even though the documentation is a bit lacking.
Here's a tutorial that helped me a lot when I was starting out:
http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
As to how to display the Facebook user's public information, you should consult the Facebook Graph API

Determine if website developed with Django [duplicate]

This question already has answers here:
How can you tell if a site has been made with Django?
(7 answers)
Closed last year.
I actually have some questions (real childish).
1) If I know that a website has been developed using django , can we determine from the html source code (by right clicking and choosing "view page source ") , if that website has been developed using django?
2) If I have an HTML code for website written in HTML , and I just want to present it like that using django , how can present this HTML code using django?
3) For what kind of websites , should django be used or are used for ? I mean pure static page , blogs , or a simple google like .
Thanks in advance
Here are a few things you could use to determine if a web app was written in Django. None of these are foolproof by any means, but they could be indicators.
Try http://site.com/admin/ and see if it says "Django site admin" at the top.
Inspect all of the HTML source code of every form you can find on the site, and see if any contain an input tag with name='csrfmiddlewaretoken'. csrfmiddlewaretoken is Django's CSRF token identifier. Other web frameworks may use this same name, but Django is the predominant user of it.
Find information about the site owner and/or developer from a "Contact" page, Google their usernames/emails as well as the word "Django," such as "emailname#gmail.com django". If you see posts or questions about Django, this could possibly mean they use it often.
If all else fails, simply contact the site owner and ask them.
No, the source depends completely on the person who developed it, and there are no necessary "hints" that it was written in Django.
You should at least try the Django tutorial at https://www.djangoproject.com/, you'll learn the basics of setting up a Django application, and you'll answer your own question.
Django is pretty general purpose, a bit overkill for static pages. Anything else can be done in Django, the same way it can be done in Ruby on Rails or other Web frameworks.
Well, what you should do is to test the website behaviour in an unusal stiatuation, for example forcing it to return 404 or 500 error message, which developers often forget to customize.
If you for example go to http://www.galaxyzoo.org/ and then try to determine backend just by looking at HTML, you'll fail.
If, however, you try to access a page 'blablablabla' i.e. http://www.galaxyzoo.org/blablablabla then you'll see 404 message. If you paste the entrie text into google, you'll most likely get hits to Ruby On Rails... :)
Django leaves no trace on the html source unless you specifically do. If you only want a static site, django is overkill. Though if you really want to, have a look at django flatpages.
You could possibly try www.domainname.com/admin. Some people leave their admin at that url and you can see the login page.
If they left the login page as default, the title tag will say Login | Django site admin or something like that.
For example: http://www.snowbird.com/admin/ (no affiliation)
No.
Yes. See direct_to_template
See djangosites.org

Accessing Facebook Profile URLs

The goal here, given a user facebook profile url, access and open the profile page. Some simple python code:
from urllib2 import urlopen
url = "http://www.facebook.com/username"
page = urlopen(url)
The problem is that for some "username" this causes HTTP ERROR 404. I noticed this error only happening when the path includes a name rather than the "profile.php?id=XXX" format.
Notice that we only have the url here and not the user id.
UPDATE:
This turned out to happen also for some of the "profile.php?id=XXX" and other username formats.
This is a privacy feature of Facebook. Users have the ability to hide their profile page so that only logged in users can view their page. Accessing the page with /profile.php?id=XXX or with /username makes no difference. You must be logged-in in order to view the HTML page.
In your context, you'd have to first log in to a valid Facebook account before requesting the page and you should no longer receive the 404's.
One way to check this is on the graph API, graph.facebook.com/USERNAME will return a link property in the resulting JSON if they have a public page, and it will be omitted on private pages.
Not every Facebook account is accessible as FIRST.LAST, so you won't be able to reliably do this.
There is currently no guarantee that an account is accessible with a vanity name.
Works perfectly fine as long as the username exists.
Are you trying to open the page in a Web Browser or access the HTML source generated by the page?
If the latter, have you thought of using the Facebook Graph API to achieve whatever it is that you are doing? This will be much faster and the API is all documented. Plus the page's HTML source could change at any point in time, whereas the Graph API will not.
Edit
You could use the Graph API without having to even create an application to get the user ID, but going to http://graph.facebook.com/username and parsing the JSON response. You can then access the profile HTML using http://www.facebook.com/profile.php?id=userId

Categories