Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6737419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:14:48+00:00 2026-05-26T11:14:48+00:00

I currently have a structure that needs to be rewritten in order to cope

  • 0

I currently have a structure that needs to be rewritten in order to cope with Django-CMS

Currently the setup is as follows

class Video(models.Model):        
    #embed_code_or_url = models.CharField(max_length=2000)
    permalink = models.URLField(verify_exists=True, unique=True, max_length=255, default="http://", validators=[validate_youtube_address])
    thumbnail = models.CharField(max_length=500, blank=True, null=True)
    # Data
    title = models.CharField(max_length=255, blank=True)
    ...

class VideoPlugin(CMSPlugin):
    video = models.ForeignKey(Video)

when I now transfer all my fields from Video to VideoPlugin, run my schemamigration, I’d also like to transfer ALL the info from Video to VideoPlugin when I run the migration.

Does anyone have an example on how this can be achieved?

Here is the beginnig of the migration to be run

class Migration(SchemaMigration):

    def forwards(self, orm):

        # Adding field 'VideoPlugin.permalink'
        db.add_column('cmsplugin_videoplugin', 'permalink', self.gf('django.db.models.fields.URLField')(default='http://', unique=True, max_length=255), keep_default=False)

        # Adding field 'VideoPlugin.thumbnail'
        db.add_column('cmsplugin_videoplugin', 'thumbnail', self.gf('django.db.models.fields.CharField')(max_length=500, null=True, blank=True), keep_default=False)

        # Adding field 'VideoPlugin.title'
        db.add_column('cmsplugin_videoplugin', 'title', self.gf('django.db.models.fields.CharField')(default='', max_length=255, blank=True), keep_default=False)

        ...

Your help is much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:14:49+00:00Added an answer on May 26, 2026 at 11:14 am

    You create a datamigration:

    $ python manage.py datamigration yourapp name_of_this_migration
    

    This freezes the models in your app. If another app(s) is/are involved in the migration, you’ll need to add --freeze app1 --freeze app2, etc., to that line to include those in your migration as well.

    This sets up the basic migration file structure for you, but the forwards and backwards migrations are empty. It’s up to your to determine the logic that will migrate data from one to the other. But this works like anything else in Django, except you use the South ORM. For any model in your app in which this migration resides, you use orm.MyModel.objects for any other app that your added with the --freeze parameters, you use orm['someapp.SomeModel'].objects.

    Other than that, you just get/filter/create, etc., the objects as normal moving the data from one to the other. Obviously, your forwards migration needs the logic that moves the data where you want it now, and your backwards migration should have the logic required to restore the data to where it was originally.

    You can then migrate forwards and backwards in your dev environment to ensure it works properly. One important note: this is only for moving data around. DO NOT alter or delete any table structures in your datamigration. If you need to delete tables after the data has been moved. Create a schemamigration after the datamigration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a broken site structure that needs repair and I want to
I currently have a table structure that looks something like this(some details omitted): ColumnName
In the data structures class that I am currently taking, we have been tasked
I have a C# application that needs to be run several thousand times. Currently
i'm currently working on a wordpress site that needs to have the option to
I have the current basic structure for each domain object that I need to
Currently I have a structure like this: A | +--B | +--C It's mapped
Currently I have an xml structure in an app. I needed to convert it
Hi currently I have a nested XMl , having the following Structure : <?xml
I currently have an MS Access application that connects to a PostgreSQL database via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.