This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnixTimestampField(serializers.FloatField): | |
""" | |
Stores Django datetimes as a Unix timestamp. | |
Thank you to Laur Ivan for the inspiration: | |
https://www.laurivan.com/timestamp-to-datetime-serializer-field-for-drf/ | |
""" | |
def to_internal_value(self, value): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Excerpt for https://github.com/etsy/open-api/issues/27 | |
# Untested, unproven, don't use this in production! | |
def _make_request(method, url, data=None): | |
with open("etsy_token.json", "r") as f: | |
token = json.loads(f.read()) | |
oauth = OAuth2Session(client_id, token=token) | |
oauth.refresh_token( | |
"https://api.etsy.com/v3/public/oauth/token", client_id=client_id | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib.parse import urlencode | |
from hypothesis import strategies | |
HTTP_METHODS = ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT'] | |
letters = strategies.characters(whitelist_categories=('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl')) | |
def http_method(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import TestCase | |
from hypothesis import given | |
from hypothesis import strategies | |
class TestFoo(TestCase): | |
def setUp(self): | |
self.foo = 'meow' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A basic Shopware 5 API client I threw together for a project. There's a few gotchas in here that | |
I thought are useful enough to others to publish it. But please take it as is - it works for my | |
purpose (processing Shopware articles daily), I make no claims beyond that. | |
""" | |
import logging | |
import os | |
import requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<00 twttor 2006 slide> | |
This might not be a popular opinion, and this talk isn't about this, but I think Django's days of glory are over. I have no doubts that in the near future, we will not be building traditional websites, we will be building Javascript applications for the web. And that's a shame really. I really like Python and Django, and I don't like Javascript all that much. But maybe there's a Pythonic way forward! | |
<10 maik slide > | |
Hi, I'm Maik -- and this is "Building websites like it's 2006" 2006 was the year of the dog, so this talk is mostly pictures of dogs. | |
I've been involved with Django in one way or another for five years now. I'm an django-oscar core contributor; if you're looking for a Python ecommerce solution, look no more! And at the moment I'm helping Aymeric Augustin at Oscaro sell car parts. They're using Oscar, but that's a non-issue, so they gave me frontend work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_no_pending_changes(self): | |
output = cStringIO() | |
call_command('makemigrations', dry_run=True, stdout=output) | |
val = output.getvalue() | |
has_changes = 'No changes detected' not in output.getvalue() | |
if has_changes: | |
self.fail("Some apps need migrations: %s" % val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shutil import move | |
from tempfile import mkstemp | |
import os | |
import re | |
def get_model_files(): | |
root_path = os.path.dirname(os.path.realpath(__file__)) | |
paths = [] | |
for path, subfolders, all_files in os.walk(root_path): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
tmux start-server | |
tmux new-session -d -s trent -n serv | |
tmux new-window -t trent:1 -n solr | |
tmux new-window -t trent:2 -n DI | |
tmux new-window -t trent:3 -n DII | |
tmux new-window -t trent:4 -n oscar | |
tmux new-window -t trent:5 -n venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(oscar)(master) T530i:django-oscar $ sites/sandbox/manage.py loaddata countries.json sites/_fixtures/p | |
ages.json sites/_fixtures/auth.json sites/_fixtures/ranges.json sites/_fixtures/offers.json | |
Problem installing fixture 'sites/_fixtures/offers.json': Traceback (most recent call last): | |
File "/home/m/.virtualenvs/oscar/local/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/cor | |
e/management/commands/loaddata.py", line 196, in handle | |
obj.save(using=using) | |
File "/home/m/.virtualenvs/oscar/local/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/cor | |
e/serializers/base.py", line 165, in save | |
models.Model.save_base(self.object, using=using, raw=True) | |
File "/home/m/.virtualenvs/oscar/local/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/db/ |
NewerOlder