Coder Social home page Coder Social logo

Comments (5)

alaindomissy avatar alaindomissy commented on June 18, 2024

Prompt:

(tddd)alain@alain-thinkpadw530:~/tddd/myblog$ python manage.py convert_to_south blog
Creating migrations directory at '/home/alain/tddd/myblog/blog/migrations'...
Creating __init__.py in '/home/alain/tddd/myblog/blog/migrations'...
 + Added model blog.Entry
 + Added model blog.Comment
Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate blog
 - Soft matched migration 0001 to 0001_initial.
Running migrations for blog:
 - Migrating forwards to 0001_initial.
 > blog:0001_initial
   (faked)

App 'blog' converted. Note that South assumed the application's models matched the database
(i.e. you haven't changed it since last syncdb); if you have, you should delete the blog/migrations
directory, revert models.py so it matches the database, and try again.
(tddd)alain@alain-thinkpadw530:~/tddd/myblog$ python manage.py migrate --list

 blog
  (*) 0001_initial

(tddd)alain@alain-thinkpadw530:~/tddd/myblog$ python manage.py schemamigration --auto blog
Nothing seems to have changed.
(tddd)alain@alain-thinkpadw530:~/tddd/myblog$ python manage.py schemamigration --auto blog
 ? The field 'Entry.slug' does not have a default specified, yet is NOT NULL.
 ? Since you are adding this field, you MUST specify a default
 ? value to use for existing rows. Would you like to:
 ?  1. Quit now, and add a default to the field in models.py
 ?  2. Specify a one-off value to use for existing columns now
 ? Please select a choice: 

from test-driven-django-development.

treyhunner avatar treyhunner commented on June 18, 2024

We should select option 2 and then use an empty string for a default.

from test-driven-django-development.

treyhunner avatar treyhunner commented on June 18, 2024

We might want to note that to add slugs to existing entries (if this was a live blog with existing entries) we could make a South data migration. We should link to data migrations in the documentation.

from test-driven-django-development.

alaindomissy avatar alaindomissy commented on June 18, 2024
 >>> ""
 + Added field slug on blog.Entry
Created 0002_auto__add_field_entry_slug.py. You can now apply this migration with: ./manage.py migrate blog
(tddd)alain@alain-thinkpadw530:~/tddd/myblog$ 

from test-driven-django-development.

macro1 avatar macro1 commented on June 18, 2024

In the interest of keeping the migrations portion brief, I added a default to the slug field to avoid the prompt all together in #139.

from test-driven-django-development.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.