{"id":1458,"date":"2016-05-10T09:22:26","date_gmt":"2016-05-10T16:22:26","guid":{"rendered":"http:\/\/www.laurenwood.org\/anyway\/?p=1458"},"modified":"2016-05-10T09:22:26","modified_gmt":"2016-05-10T16:22:26","slug":"django-migrate-tips","status":"publish","type":"post","link":"https:\/\/www.laurenwood.org\/anyway\/2016\/05\/django-migrate-tips\/","title":{"rendered":"Django migrate tips"},"content":{"rendered":"<p>If you read the <a href=\"https:\/\/docs.djangoproject.com\/en\/stable\/ref\/django-admin\/#django-admin-migrate\">doc\u00adu\u00adment\u00ada\u00adtion<\/a> closely enough, of course all the inform\u00ada\u00adtion is there. Get\u00adting the order of oper\u00ada\u00adtions right, how\u00adever, can cause the odd&nbsp;issue.<\/p>\n<p>Devel\u00adop\u00ading Django apps means apply\u00ading migra\u00adtions, and those don\u2019t always do what\u2019s expec\u00adted. In that case, you can roll back to the n\u20111 migra\u00adtion by using <code>.\/manage.py migrate [app_label] {n-1_migration_label}<\/code>, then delete the nth migra\u00adtion, then edit the models.py to try&nbsp;again.<\/p>\n<p>To clean up the data\u00adbase from some third-party app you decide you don\u2019t want after all, you use <code>.\/manage.py migrate [app_label] zero<\/code> to get rid of the migra\u00adtions from that app. You have to run this <strong>before<\/strong> delet\u00ading the app from your settings.py file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you read the doc\u00adu\u00adment\u00ada\u00adtion closely enough, of course all the inform\u00ada\u00adtion is there. Get\u00adting the order of oper\u00ada\u00adtions right, how\u00adever, can cause the odd&nbsp;issue. Devel\u00adop\u00ading Django apps means apply\u00ading migra\u00adtions, and those don\u2019t always do what\u2019s expec\u00adted. In that case, you can roll back to the n\u20111 migra\u00adtion by using .\/manage.py migrate [app_label] {n\u20111_migration_label}, \u2026 <a href=\"https:\/\/www.laurenwood.org\/anyway\/2016\/05\/django-migrate-tips\/\" class=\"more-link\">Con\u00adtin\u00adue read\u00ading<span class=\"screen-reader-text\"> \u201cDjango migrate tips\u201d<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":""},"categories":[112,6],"tags":[],"class_list":["post-1458","post","type-post","status-publish","format-standard","hentry","category-django","category-technology"],"_links":{"self":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts\/1458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/comments?post=1458"}],"version-history":[{"count":1,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts\/1458\/revisions"}],"predecessor-version":[{"id":1459,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/posts\/1458\/revisions\/1459"}],"wp:attachment":[{"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/media?parent=1458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/categories?post=1458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laurenwood.org\/anyway\/wp-json\/wp\/v2\/tags?post=1458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}