indeedeng / django-ptrack Goto Github PK
View Code? Open in Web Editor NEWTracking pixel library for Django
License: Apache License 2.0
Tracking pixel library for Django
License: Apache License 2.0
ptrack returns invalid tracking pixel on py3. Fixed by pr #6
I handle url normalization with a post processor. It would be handy if PTRACK_APP_URL could be an empty string.
Not a lot of work but I had to do this:
def rel_ptrack_tag(*args, **kwargs):
encoded_dict = {'ptrack_encoded_data': ptrack_encoder.encrypt(*args, **kwargs)}
url = reverse('ptrack', kwargs=encoded_dict)
return mark_safe("<img src='%s' width=1 height=1>" % (url,))
Will this library be updated for Django 2? I get the following exception when I try to use:
No module named 'django.core.urlresolvers'
/usr/local/lib/python3.5/dist-packages/ptrack/templatetags/ptrack.py in <module>
from django.core.urlresolvers import reverse
The default branch name for repositories created on GitHub is now main. See github guidance
Hi
Can you add some more information in the readme about how to use it for emails?
If I understand correctly, I can do something like:
from ptrack.templatetags.ptrack import ptrack
img_tag = ptrack(key1='aaa',key2='ccc')
and then I can add the img_tag to the email body.
Is there a different way to do that?
Using ptrack with Python 3 is giving the following error-
nacl.exceptions.TypeError: SecretBox must be created from 32 bytes
On debugging, the issue is with nacl/secret.py > SecretBox
def __init__(self, key, encoder=encoding.RawEncoder):
key = encoder.decode(key)
if not isinstance(key, bytes):
raise exc.TypeError("SecretBox must be created from 32 bytes")
The check for bytes for decoded key is evaluating to False in Python 3 (it evaluates to True in Python 2).
One way is to convert string to bytes before passing it to SecretBox constructor.
Any other idea?
It would be helpful if the default encoder used the DjangoJsonEncoder class for the JSON conversion to automatically handle types like uuid.
This is what happens when you pass a UUID pk through ptrack:
File "/home/vagrant/.tox/py/lib/python3.7/site-packages/ptrack/templatetags/ptrack.py", line 20, in ptrack
encoded_dict = {'ptrack_encoded_data': ptrack_encoder.encrypt(*args, **kwargs)}
File "/home/vagrant/.tox/py/lib/python3.7/site-packages/ptrack/encoder.py", line 46, in encrypt
data = json.dumps((args, kwargs))
File "/usr/local/lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/local/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/local/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type UUID is not JSON serializable
It would be a small change to this line:
django-ptrack/ptrack/encoder.py
Line 46 in c3b164b
Python 3 is not indicated anywhere in the README. But I see typing
being used and get syntax errors in python 2.7.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.