I'm working on a project in which I need to make some changes in django-paypal package. I have cloned the package's GitHub repo and make a very simple change (Just change a form submit type=image source) and then install it via python setup.py install
but now I couldn't find any path to import this package.
For example when I install it by using pip install django-paypal
i was able to import it like from paypal.standard.forms import PayPalPaymentsForm
but after installing it via python setup.py install
from my local changed source then it couldn't find any paypal
package.
How can i fix this issue?
Help me, please!
Thanks in advance!
You usually want to avoid modifying the source code of modules directly. This will make upgrading difficult and will require you to somehow bundle those modified packages along with your own code, which makes distributing your code difficult.
Instead of changing the string returned by PayPalPaymentsForm.render
, just subclass it and modify the render
method to return the HTML you want:
your_app/forms.py
from django.utils.html import format_html
from paypal.standard.forms import PayPalPaymentsForm
class CustomPayPalPaymentsForm(PayPalPaymentsForm):
def render(self):
return format_html(u"""<form action="{0}" method="post">
{1}
<input type="image" src="{2}" border="0" name="submit" alt="Buy it Now" />
</form>""", self.get_endpoint(), self.as_p(), self.get_image())
Then you just import it:
from your_app.forms import CustomPayPalPaymentsForm