title: Adding django admin permissions in a migration: Permission matching query does not exist
body: <p>I wanted to add some groups and assign permissions to them in a manually written migration but if I run it on a clean DB it creates permissions only after running all migrations.</p>
  
  <p>I've found this ticket: <a href="https://code.djangoproject.com/ticket/23422" rel="noreferrer">https://code.djangoproject.com/ticket/23422</a>
  but I cannot comment there (it's possible I was banned after expressing some discontent with GeoDjango docs), so I'll share an improvement over the solution there below.</p>