Skip to content

Instantly share code, notes, and snippets.

import pdb; pdb.set_trace()
# You can put it anywhere in a function
python -m pdb manage.py runserver
  • c = continue
@hminnovation
hminnovation / virtualenv_stuff.md
Last active November 10, 2016 21:03
Virtualenv memory jog
@hminnovation
hminnovation / scemo.py
Created October 5, 2016 16:26
Minimum Wagtail Heroku things
# Put this in your .env file #
DATABASE_URL # auto-generated by build-pack
DJANGO_SETTINGS_MODULE # e.g. your-app.settings.production
SECRET_KEY # looooooooooots of chars
ALLOWED_HOSTS # ".domain.com" or ["domain.com", "otherdomain.com", "someotherdomain.com"]
@hminnovation
hminnovation / User on homepage?
Created September 5, 2016 17:13
User on homepage?
`{% if request.path == '/' %}`
If you want to be able to make queries like "which myapp.FooPage pages use this image?",
then you can deal with that by setting an explicit `related_name`.
Usually we don't care about doing that, so we set `related_name='+'`
to disable that reverse relation completely.
Posted in #wagtail
The main reason for using it is to avoid name collisions.
If, say, you have two FooPage models in two different apps,
and they both have a FK to image, they'll both try to create a
reverse relation on `Image` called something like `foopage_objects`.
In short these are the commands you need to run
first time:
```pip install twine```
package/upload:
```python setup.py bdist_wheel
twine register dist/{{the file that we just made with the command above}}.whl
@hminnovation
hminnovation / models.py
Last active July 6, 2016 21:50
Album model -> ModelAdmin error
from django.db import models
from wagtail.wagtailcore.models import Page, Orderable
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
from wagtail.wagtailsearch import index
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.wagtailsnippets.models import register_snippet
from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from datetime import datetime
sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions
Use manage.py dumpdata to dump the data into a JSON fixture file. Read "django-admin.py and manage.py".
Couldn't find this documented in the docs or elsewhere...
Using the following in a model:
`download = DocumentChooserBlock(icon='fa-download', template='blocks/download.html')`
You'd need to use something along the lines of:
`<div class="download"><a href="{{ self.url }}">{{ self.title }}</a></div>`
note: title isn't the uploaded document's title (e.g. filename) but rather the title added at the point of uploading.