Methods for sending dynamic content in Django apps - django

I'm quite new to all of this, so I apologize if the language I'm using isn't indicative of what I'm describing.
I am developing a Django app which my company will use to monitor bids at auctions which it sends out to various banks. I am at the stage now where the clients see the auction and its contents on one page, and we see pretty much the same thing on a different page. What I want to happen is for the clients to fill in their bids on all the things they want, hit "submit", whereupon on our (the admin) page, a new column pops into existence with the name of the bank and their bids on each item.
I don't think I can do this in jQuery. Do I have to use AJAX? PHP? Are all of these valid methods? I really don't know. Any help would be greatly appreciated.

I use PHP and Django. But the easiest way to build like that is with Django+Ajax.

Related

How do I not redirect to a success_url in Django after I make a post using a modal form and stay on the current page?

Here is my problem, I have a model medication that has a foreignkey field drug. In the create view of medication if a certain drug is not found in the record, I would like to create it on the go. So I tried using django-bootstrap-modal-forms from PyPi which basically does what it says. However, when I make a post to create a new drug, I get redirected to the DetailView of the drug even I did not explicitly specify success_url in the DrugCreateView.
I have tried searching for probable solutions on the internet and also some similar problems people have in stackoverflow. I have not found an answer to my question so far.
I do not want this behavior. What I want is to stay in the medication create view and reload the page if necessary to update the foreignkey drug field as I have just added it in the database. I would really appreciate if you can help or at least give me a clue on how am I going to accomplish this. Please tell what other information I have to give and I will gladly provide it immediately.
I had the same problem and when I googled it I found a solution and it was Ajax.
you can use ajax to post/get data with out refreshing the page.
here some advantage and disadvantages of Ajax:
Advantage :
Improved User Experience
Enhanced User Productivity
Reduced Bandwidth Usage and Increased speed
Increased Compatibility
Supports Asynchronous Processing
Reduced server hits and network load
Easier Navigation
Disadvantages :
Browser Incompatibility
Insecurity
Increased load on Web Server
you can use the link below yo how work with Ajax requests in Django: How to Work With AJAX Request With Django

How to develop a button for followers of a web site

I apologize for my English it is not very good.
I am developing a website that will have own followers.
I need to create a button by followers such as facebook, twitter or google plus buttons.
Thank you for any information that will allow me to begin to develop the button next to the platform.
Thank you
First, your English is fair enough. For creating your own follow button you will have to have an image that will be displayed on your website. When someone clicks on that button, your webapp should be able to know who clicked it and your should be able to remember that user in future as well. So first you will have users to register on your website (like facebook and twitter) for unique identification of each user.
Next, for remembering that a particular user is following your website you need to persist some information about that user. The obvious approach is having a database table to store the information. For instance you can have IS_FOLLOWING column in your USER table
But there are some considerations. First, the user must remain on the same page or be able to continue his activity even after cicking the follow button. For example, if the user is filling some form then his data should remain intact even after clicking the follow button. If the user is directed to some other page, he might lose information.
Second, database operations are costly. So you need to use them wisely.
One approach that I could think of is having AJAX do the work. If you want to learn AJAX you can visit this website and for AJAX database operations this one will be helpful.
Ajax will do all the work in background and both the problems mentioned above will be addressed. I hope this was helpful.

Django paypal checkout for WHOLE cart

I made a Django online-store site and I need to include paypal checkout system for the cart, but solutions I found online either just for one item only(Buy Now buttons) or something like django-paypal-cart, which is not well-documented and I can't figure out how to make it to the checkout.
Please, give me some hint, maybe good article about how to make your cart items go to the checkout, anything will be highly appreciated, I don't know what else to google now
There are numerous options for tying PayPal into your website or app. Depending on exactly what you're doing or how good you are with web service API's you may choose one or another.
If you want to keep things simple, you can stick with Payments Standard. This is basically what you're referring to about the one item only buy now button, but you can use the cart upload command method to build a form that includes multiple items and pass it all over to PayPal at once.
If you prefer web service API's I'd recommend using Express Checkout. This consists of SetExpressCheckout, GetExpressCheckoutDetails, and DoExpressCheckoutPayment. Read through that general EC documentation to get familiar with the calls and how it all flows.
Another thing I would highly recommend utilizing is Instant Payment Notification (IPN). This is a feature where PayPal will POST transaction data to a listener script that you have sitting on your server any time a transaction occurs on your PayPal account. This includes payments, refunds, disputes, cleared payments that were pending, etc. This allows you to automate tasks like updating your database, sending out custom email notifications, hitting 3rd party web services, etc. and it happens in real-time, so it's very powerful.

Sending Newsletters from Django

I am seeking advice from someone with experience integrating django and newsletters.
I need to send newsletters from my django app. I see that there are a couple of packages that already do this such as 'pennyblack' and 'emencia'. Does anyone have experience with these? Which of these is the most versatile and easy to use? My users want to add their own content to the news letters with topic, and article. News letters generally have 3 articles with a couple of photos. I also want the newsletter to print nicely as both html and pdf formats. Any working expamples I could toy with before I dive into the code?
Thanks!!
You can send html email messages directly from django with a few lines of python code, as in this snippet: http://www.djangofoo.com/250/sending-html-email. Or you can use an email sending module (I like django-messages - it allows for html and plaintext variants and gives you a message queue). Of course, that doesn't help you manage the newsletter, so you'd have to do that yourself and render an html template the same way you do with any webpage. I assume you've already checked google for newsletter-specific django modules with more features, but I don't know of any.
However, you probably don't want to send a newsletter yourself through django (more importantly, from your own production server). For one thing, if it's going to a lot of people, you don't want it to use all of your bandwidth and make your site sluggish while a huge queue of emails is sent. But more importantly, it's easy to get your server blacklisted by spam filters if you're not sending from a known, reputable domain (if you're paying for hosting it might be less of an issue, but you should check with your hosting provider).
IMO, your best bet is to use a stand-alone email newsletter service like MailChimp or Cheetah Mail. I've used and highly recommend MailChimp for a small to medium number of recipients, but I imagine there are a bunch of others that do that same thing. It makes organizing your message campaigns and recipient lists easy with hooks to do things like add a new user on your site to a recipient list. I'm sure you could also figure out a way to get your user-submitted content into the newsletter from django.
Hope that helps.
check this out. A better solution for you is django-newsletter

Best way Implement "referral links" in Django

Intro
I am working on an e-commerce website. And we want to add a feature where a user can refer others via a custom link e.g.:
http://example.com/a1t2312 or http://example.com/?ref=a1t2312 (a1t231 being the referral code).
A user following such a link, will navigate a few pages on the site. And if he reached the 'buy' page and purchases something - the original referrer will get a discount.
The question is:
What is the best method to track the referral code? Put it in the user's cookies? Stick it somehow into the session? Other method?
I would definitely use cookies, as it is the easiest (but not foolproof, though). Sessions are by site, so that won't work, unless the receiving site has some code to handle the user.
All methods mentioned by you are OK. If I were you I would consider using sessions because it is more natural to me.
disclaimer: session has some limitations when you want to build application ready for heavy-load. For complicated demployment scenarios avoiding sessions might be a good choice.