download ubuntu image for orangepi zero LTS: http://www.orangepi.org/downloadresources/flash with etcherfiddle with USB to TTL, gave up on trying to get that to workplug ethernet into switchssh orangepi@password orangepicouldn't successfully apt-get update upgrade, getting E: Unable to acquire the dpkg frontend lock- download armbian image for orangepi zero LTS: http://www.orangepi.org/downloadresources/
- flash with etcher
- armbian-config
This file contains hidden or 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
| # See full example: https://github.com/pawl/django_modelchoicefield_caching/blob/master/myapp/views.py#L31-L51 | |
| for song in playlist: | |
| form_data = {'title': song["title"], 'artist': song["artist"]} | |
| song_form = forms.SongFormWithModelChoiceField(data=form_data) | |
| song_form.is_valid() # runs a query to get the ModelChoiceField queryset each time | |
| print('ModelChoiceField - query count AFTER validating all songs:', | |
| len(connection.queries)) # 5 queries | |
| # query for choices outside of the loop to prevent unnecessary queries |
In my opinion, one of django's biggest gotchas is using RelatedManager.set with models that have non-nullable ForeignKey fields.
Models.py (with a one-to-many relationship and a non-nullable ForeignKey):
class Reporter(models.Model):
name = models.CharField(max_length=255)
class Article(models.Model):
This file contains hidden or 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
| cd ~ | |
| mkdir mysite | |
| virtualenv .venv -p `which python3` | |
| source .venv/bin/activate | |
| pip install django | |
| django-admin startproject mysite | |
| cd mysite | |
| python manage.py startapp myapp |
This file contains hidden or 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
| server { | |
| listen 80; | |
| listen [::]:80; | |
| root /var/dav/webdav_root; | |
| # dav allowed method | |
| dav_methods PUT DELETE MKCOL COPY MOVE; | |
| # Allow current scope perform specified DAV method | |
| dav_ext_methods PROPFIND OPTIONS; |
This file contains hidden or 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
| service PingPong { | |
| string ping(), | |
| } |
This file contains hidden or 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
| # demonstrates the issue fixed in: https://bitbucket.org/zzzeek/sqlalchemy/issues/3907 | |
| from sqlalchemy import create_engine, Column, Integer | |
| from sqlalchemy.orm import scoped_session, sessionmaker | |
| from sqlalchemy.ext.declarative import declarative_base | |
| engine = create_engine('mysql://root@localhost/test?charset=utf8mb4', | |
| convert_unicode=True, | |
| echo=True) | |
| session = scoped_session(sessionmaker(autocommit=False, |
This file contains hidden or 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 collections import defaultdict | |
| from sqlalchemy import create_engine, Column, ForeignKey, Integer | |
| from sqlalchemy.orm import relationship, scoped_session, sessionmaker | |
| from sqlalchemy.orm.attributes import set_committed_value | |
| from sqlalchemy.ext.declarative import declarative_base | |
| engine = create_engine('mysql://root@localhost/test?charset=utf8mb4', | |
| convert_unicode=True, | |
| echo=True) |