• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python db.mock_model函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中south.db.db.mock_model函数的典型用法代码示例。如果您正苦于以下问题:Python mock_model函数的具体用法?Python mock_model怎么用?Python mock_model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mock_model函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: forwards

 def forwards(self):
     
     
     # Mock Models
     User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField)
     
     # Model 'Email'
     db.create_table('emails_email', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('subject', models.CharField(max_length=255)),
         ('attachment', models.FileField(upload_to="attachments/%Y/%m/%d", blank=True)),
         ('message', models.TextField(blank=True)),
         ('status', models.CharField(choices=(('draft', 'draft'),('template','template'),('sent','sent mail')), max_length=9)),
         ('user', models.ForeignKey(User, related_name="whocaresthiswillneverbereferenced")),
         ('last_edited', models.DateField(auto_now = True)),
     ))
     # Mock Models
     Email = db.mock_model(model_name='Email', db_table='emails_email', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField)
     Contact = db.mock_model(model_name='Contact', db_table='contacts_contact', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField)
     
     # M2M field 'Email.recipients'
     db.create_table('emails_email_recipients', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('email', models.ForeignKey(Email, null=False)),
         ('contact', models.ForeignKey(Contact, null=False))
     )) 
     
     db.send_create_signal('emails', ['Email'])
开发者ID:emperorcezar,项目名称:OpenConnect,代码行数:28,代码来源:0001_initial.py


示例2: test_change_foreign_key_target

    def test_change_foreign_key_target(self):
        # Tables for FK to target
        User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
        db.create_table("test_fk_changed_target", [
            ('eggs', models.IntegerField(primary_key=True)),
        ])
        Egg = db.mock_model(model_name='Egg', db_table='test_fk_changed_target', db_tablespace='', pk_field_name='eggs', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
        # Table with a foreign key to the wrong table
        db.create_table("test_fk_changing", [
            ('egg', models.ForeignKey(User, null=True)),
        ])
        db.execute_deferred_sql()

        # Change foreign key pointing
        db.alter_column("test_fk_changing", "egg_id", models.ForeignKey(Egg, null=True))
        db.execute_deferred_sql()

        # Test that it is pointing at the right table now
        try:
            non_user_id = db.execute("SELECT MAX(id) FROM auth_user")[0][0] + 1
        except (TypeError, IndexError):
            # Got a "None" or no records, treat as 0
            non_user_id = 17
        db.execute("INSERT INTO test_fk_changed_target (eggs) VALUES (%s)", [non_user_id])
        db.execute("INSERT INTO test_fk_changing (egg_id) VALUES (%s)", [non_user_id])
        db.commit_transaction()
        db.start_transaction()  # The test framework expects tests to end in transaction
开发者ID:10sr,项目名称:hue,代码行数:27,代码来源:db.py


示例3: forwards

 def forwards(self):
     
     # Model 'Event'
     db.create_table('events_event', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('title', models.CharField(max_length=255)),
         ('description', models.TextField()),
         ('start', models.DateField()),
         ('end', models.DateField()),
         ('location', models.CharField(max_length=255)),
         ('allowed_attendies', models.IntegerField(null=True, blank=True)),
         ('last_edited', models.DateField(auto_now = True)),
     ))
     # Mock Models
     Event = db.mock_model(model_name='Event', db_table='events_event', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[])
     Contact = db.mock_model(model_name='Contact', db_table='contacts_contact', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[])
     
     # M2M field 'Event.registrants'
     db.create_table('events_event_registrants', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('event', models.ForeignKey(Event, null=False)),
         ('contact', models.ForeignKey(Contact, null=False))
     )) 
     
     db.send_create_signal('events', ['Event'])
开发者ID:emperorcezar,项目名称:OpenConnect,代码行数:25,代码来源:0001_initial.py


示例4: forwards

 def forwards(self):
     
     # Model 'Platform'
     db.create_table('downloads_platform', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('name', models.CharField(_('name'), max_length=255)),
         ('slug', models.SlugField(_('slug'), max_length=255, unique=True)),
     ))
     # Model 'Release'
     db.create_table('downloads_release', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('version', models.CharField(_('version'), max_length=64, help_text=_("The version string used in the URL and on the download page. Please don't use spaces here."))),
         ('description', models.TextField(_('description'), blank=True)),
         ('changelog', models.TextField(_('changelog'), blank=True, help_text=_("The changelog displayed at http://fritzing.org/downloads/history-changes/. HTML is allowed."))),
         ('known_issues', models.TextField(_('known issues'), blank=True, help_text=_("The known issues displayed at http://fritzing.org/downloads/known-issues/. HTML is allowed."))),
         ('release_date', models.DateTimeField(_('date released'), default=datetime.now)),
         ('active', models.BooleanField(_('active'), default=True)),
     ))
     
     # Mock Models
     Release = db.mock_model(model_name='Release', db_table='downloads_release', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     Platform = db.mock_model(model_name='Platform', db_table='downloads_platform', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Model 'Download'
     db.create_table('downloads_download', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('release', models.ForeignKey(Release, verbose_name=_('release'))),
         ('platform', models.ForeignKey(Platform, verbose_name=_('platform'))),
         ('filename', models.FileField(_('file'), upload_to='downloads', blank=True, null=True)),
         ('mime_type', models.CharField(_('mime type'), max_length=255, blank=True, null=True)),
         ('counter', models.IntegerField(_('counter'), default=0)),
     ))
     
     db.send_create_signal('downloads', ['Platform','Release','Download'])
开发者ID:bacchante95,项目名称:fritzing,代码行数:34,代码来源:0001_initial.py


示例5: forwards

 def forwards(self):
     
     # Model 'Client'
     db.create_table('project_client', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('name', models.CharField(max_length=128, verbose_name=_('name'))),
     ))
     
     # Mock Models
     Team = db.mock_model(model_name='Team', db_table='teams_team', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     Client = db.mock_model(model_name='Client', db_table='project_client', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Model 'Project'
     db.create_table('project_project', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('name', models.CharField(max_length=128, verbose_name=_('name'))),
         ('team', models.ForeignKey(Team, null=True, blank = True, verbose_name=_('team'))),
         ('client', models.ForeignKey(Client, null=True, blank=True, verbose_name=_('client'))),
         ('deadline', models.DateField(null=True, blank=True, verbose_name=_('deadline'))),
     ))
     # Mock Models
     Project = db.mock_model(model_name='Project', db_table='project_project', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # M2M field 'Project.members'
     db.create_table('project_project_members', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('project', models.ForeignKey(Project, null=False)),
         ('user', models.ForeignKey(User, null=False))
     )) 
     
     db.send_create_signal('project', ['Client','Project'])
开发者ID:areski,项目名称:djime,代码行数:32,代码来源:0001_initial.py


示例6: test_add_unique_fk

 def test_add_unique_fk(self):
     """
     Test adding a ForeignKey with unique=True or a OneToOneField
     """
     db.create_table("test_add_unique_fk", [
         ('spam', models.BooleanField(default=False))
     ])
     
     db.add_column("test_add_unique_fk", "mock1", models.ForeignKey(db.mock_model('Mock', 'mock'), null=True, unique=True))
     db.add_column("test_add_unique_fk", "mock2", models.OneToOneField(db.mock_model('Mock', 'mock'), null=True))
     
     db.delete_table("test_add_unique_fk")
开发者ID:TradeHill2011,项目名称:south,代码行数:12,代码来源:db.py


示例7: test_add_unique_fk

    def test_add_unique_fk(self):
        """
        Test adding a ForeignKey with unique=True or a OneToOneField
        """
        db.create_table("test_add_unique_fk", [("spam", models.BooleanField(default=False))])
        db.start_transaction()

        db.add_column(
            "test_add_unique_fk", "mock1", models.ForeignKey(db.mock_model("Mock", "mock"), null=True, unique=True)
        )
        db.add_column("test_add_unique_fk", "mock2", models.OneToOneField(db.mock_model("Mock", "mock"), null=True))

        db.rollback_transaction()
        db.delete_table("test_add_unique_fk")
开发者ID:qiwihui,项目名称:johan-doc,代码行数:14,代码来源:db.py


示例8: forwards

    def forwards(self):

        # Mock Models
        ContentType = db.mock_model(
            model_name="ContentType",
            db_table="django_content_type",
            db_tablespace="",
            pk_field_name="id",
            pk_field_type=models.AutoField,
            pk_field_args=[],
        )

        # Model 'AttachedFile'
        db.create_table(
            "attachments_attachedfile",
            (
                ("id", models.AutoField(verbose_name="ID", primary_key=True, auto_created=True)),
                ("name", models.CharField(max_length=255)),
                ("file", models.FileField(upload_to="attachments/files/%Y/%m")),
                ("content_type", models.ForeignKey(ContentType)),
                ("object_id", models.PositiveIntegerField()),
            ),
        )

        # Mock Models
        ContentType = db.mock_model(
            model_name="ContentType",
            db_table="django_content_type",
            db_tablespace="",
            pk_field_name="id",
            pk_field_type=models.AutoField,
            pk_field_args=[],
        )

        # Model 'AttachedImage'
        db.create_table(
            "attachments_attachedimage",
            (
                ("id", models.AutoField(verbose_name="ID", primary_key=True, auto_created=True)),
                ("name", models.CharField(max_length=255)),
                ("link_to", models.URLField(blank=True)),
                ("display", models.PositiveIntegerField(default=1)),
                ("image", models.ImageField(upload_to="attachments/images/%Y/%m")),
                ("content_type", models.ForeignKey(ContentType)),
                ("object_id", models.PositiveIntegerField()),
            ),
        )

        db.send_create_signal("attachments", ["AttachedFile", "AttachedImage"])
开发者ID:pombredanne,项目名称:django-rst-attachments,代码行数:49,代码来源:0001_initial.py


示例9: forwards

 def forwards(self):
     
     # Mock model
     ArticleCategory = db.mock_model(model_name='ArticleCategory', db_table='articles_articlecategory', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Adding field 'ArticleCategory.parent'
     db.add_column('articles_articlecategory', 'parent', models.ForeignKey(ArticleCategory, verbose_name=_("Parent Category"), limit_choices_to={ "parent__isnull": True, }, blank=True, null=True, related_name="sub_categories"))
开发者ID:taylanpince,项目名称:alghalia,代码行数:7,代码来源:0004_add_parent_category.py


示例10: forwards

 def forwards(self):
     
     
     # Mock Models
     Event = db.mock_model(model_name='Event', db_table='events_event', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[])
     Contact = db.mock_model(model_name='Contact', db_table='contacts_contact', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[])
     
     # Model 'Registrant'
     db.create_table('events_registrant', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('event', models.ForeignKey(Event)),
         ('contact', models.ForeignKey(Contact)),
         ('pending', models.BooleanField(default=True)),
     ))
     
     db.send_create_signal('events', ['Registrant'])
开发者ID:emperorcezar,项目名称:OpenConnect,代码行数:16,代码来源:0002_create_registrants.py


示例11: forwards

    def forwards(self):
        # Mock Models
        User = db.mock_model(
            model_name="User",
            db_table="auth_user",
            db_tablespace="",
            pk_field_name="id",
            pk_field_type=models.AutoField,
            pk_field_args=[],
            pk_field_kwargs={},
        )

        # Model 'Staffer'
        db.create_table(
            "staff_staffer",
            (
                ("id", models.AutoField(verbose_name="ID", primary_key=True, auto_created=True)),
                ("user", models.OneToOneField(User, blank=True, null=True, help_text="Optional, but recommended.")),
                ("slug", models.SlugField()),
                ("position", models.CharField(max_length=50)),
                ("first_name", models.CharField(max_length=30, blank=True)),
                ("last_name", models.CharField(max_length=30, blank=True)),
            ),
        )
        db.create_index("staff_staffer", ["first_name", "last_name"], unique=True, db_tablespace="")

        db.send_create_signal("staff", ["Staffer"])
开发者ID:maxcutler,项目名称:Courant-News,代码行数:27,代码来源:0001_initial.py


示例12: forwards

 def forwards(self):
     
     # Mock model
     User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Adding field 'Article.author'
     db.add_column('articles_article', 'author', models.ForeignKey(User, related_name=_("Author"), blank=True, null=True))
开发者ID:taylanpince,项目名称:alghalia,代码行数:7,代码来源:0003_add_author.py


示例13: forwards

 def forwards(self):
     
     # Model 'ArticleCategory'
     db.create_table('articles_articlecategory', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('name', models.CharField(_("Name"), max_length=255)),
         ('slug', models.SlugField(_("Slug"), max_length=255, unique=True)),
         ('theme', models.CharField(_("Colour Theme"), max_length=10, choices=THEME_CHOICES)),
         ('featured', models.BooleanField(_("Featured"), default=False)),
     ))
     
     # Mock Models
     ArticleCategory = db.mock_model(model_name='ArticleCategory', db_table='articles_articlecategory', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Model 'Article'
     db.create_table('articles_article', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('title', models.CharField(_("Title"), max_length=255)),
         ('slug', models.SlugField(_("Slug"), max_length=255)),
         ('summary', models.TextField(_("Summary"), blank=True)),
         ('body', models.TextField(_("Body"), blank=True)),
         ('category', models.ForeignKey(ArticleCategory, verbose_name=_("Category"))),
         ('tags', TagField(_("Tags"))),
         ('featured', models.BooleanField(_("Featured"), default=False)),
         ('published', models.BooleanField(_("Published"), default=True)),
         ('publication_date', models.DateTimeField(_("Publication Date"), default=datetime.now)),
         ('expiration_date', models.DateTimeField(_("Expiration Date"), blank=True, null=True)),
         ('creation_date', models.DateTimeField(_("Creation Date"), editable=False, auto_now_add=True)),
         ('modification_date', models.DateTimeField(_("Modification Date"), editable=False, auto_now=True)),
         ('view_count', models.PositiveIntegerField(_("View Count"), editable=False, default=0)),
     ))
     db.create_index('articles_article', ['slug','publication_date','category_id'], unique=True, db_tablespace='')
     
     
     db.send_create_signal('articles', ['ArticleCategory','Article'])
开发者ID:taylanpince,项目名称:alghalia,代码行数:35,代码来源:0001_initial.py


示例14: forwards

 def forwards(self):
     
     
     # Mock Models
     User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     Syllabus = db.mock_model(model_name='Syllabus', db_table='user_model_syllabus', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Model 'UserProfile'
     db.create_table('user_profile_userprofile', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('user', models.ForeignKey(User, unique=True)),
         ('syllabus', models.ForeignKey(Syllabus)),
         ('first_language', models.CharField(max_length=100)),
         ('second_languages', models.CharField(max_length=200, null=True, blank=True)),
     ))
     
     db.send_create_signal('user_profile', ['UserProfile'])
开发者ID:larsyencken,项目名称:kanjitester,代码行数:17,代码来源:0001_initial.py


示例15: test_unique

 def test_unique(self):
     """
     Tests creating/deleting unique constraints.
     """
     db.create_table("test_unique2", [("id", models.AutoField(primary_key=True))])
     db.create_table(
         "test_unique",
         [
             ("spam", models.BooleanField(default=False)),
             ("eggs", models.IntegerField()),
             ("ham", models.ForeignKey(db.mock_model("Unique2", "test_unique2"))),
         ],
     )
     # Add a constraint
     db.create_unique("test_unique", ["spam"])
     # Shouldn't do anything during dry-run
     db.dry_run = True
     db.delete_unique("test_unique", ["spam"])
     db.dry_run = False
     db.delete_unique("test_unique", ["spam"])
     db.create_unique("test_unique", ["spam"])
     db.start_transaction()
     # Test it works
     db.execute("INSERT INTO test_unique2 (id) VALUES (1), (2)")
     db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (true, 0, 1), (false, 1, 2)")
     try:
         db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (true, 2, 1)")
     except:
         db.rollback_transaction()
     else:
         self.fail("Could insert non-unique item.")
     # Drop that, add one only on eggs
     db.delete_unique("test_unique", ["spam"])
     db.execute("DELETE FROM test_unique")
     db.create_unique("test_unique", ["eggs"])
     db.start_transaction()
     # Test similarly
     db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (true, 0, 1), (false, 1, 2)")
     try:
         db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (true, 1, 1)")
     except:
         db.rollback_transaction()
     else:
         self.fail("Could insert non-unique item.")
     # Drop those, test combined constraints
     db.delete_unique("test_unique", ["eggs"])
     db.execute("DELETE FROM test_unique")
     db.create_unique("test_unique", ["spam", "eggs", "ham_id"])
     db.start_transaction()
     # Test similarly
     db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (true, 0, 1), (false, 1, 1)")
     try:
         db.execute("INSERT INTO test_unique (spam, eggs, ham_id) VALUES (true, 0, 1)")
     except:
         db.rollback_transaction()
     else:
         self.fail("Could insert non-unique pair.")
     db.delete_unique("test_unique", ["spam", "eggs", "ham_id"])
开发者ID:qiwihui,项目名称:johan-doc,代码行数:58,代码来源:db.py


示例16: forwards

 def forwards(self):
     
     # Model 'Report'
     db.create_table('reports_report', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('name', models.CharField("Name of this report", max_length=255)),
         ('page_size', models.CharField(default="Portrait", choices=(("Portrait", "Portrait"),("Landscape","Landscape")), max_length=8)),
         ('first_name', models.BooleanField("First Name")),
         ('middle_initial', models.BooleanField("Middle Initial")),
         ('last_name', models.BooleanField("Last Name")),
         ('title', models.BooleanField("Title")),
         ('email', models.BooleanField("Email")),
         ('phone1', models.BooleanField("Primary Phone Number")),
         ('phone2', models.BooleanField("Secondary Phone Number")),
         ('fax1', models.BooleanField("Primary Fax")),
         ('fax2', models.BooleanField("Secondary Fax")),
         ('employer', models.BooleanField("Employer")),
         ('position', models.BooleanField("Position")),
         ('addr1_row1', models.BooleanField("Row 1")),
         ('addr1_row2', models.BooleanField("Row 2")),
         ('addr1_city', models.BooleanField("City")),
         ('addr1_state', models.BooleanField("State")),
         ('addr1_zip', models.BooleanField("Zip Code")),
         ('addr2_row1', models.BooleanField("Row 1")),
         ('addr2_row2', models.BooleanField("Row 2")),
         ('addr2_city', models.BooleanField("City")),
         ('addr2_state', models.BooleanField("State")),
         ('addr2_zip', models.BooleanField("Zip Code")),
         ('degree1', models.BooleanField("Degree")),
         ('major1', models.BooleanField("Major")),
         ('year1', models.BooleanField("Year")),
         ('degree2', models.BooleanField("Degree")),
         ('major2', models.BooleanField("Major")),
         ('year2', models.BooleanField("Year")),
         ('tag_list', models.BooleanField("Tags")),
         ('do_not_email', models.BooleanField("Do Not Email")),
         ('preferred_comm', models.BooleanField("Preferred Comm")),
         ('notes', models.BooleanField("Notes")),
     ))
     
     # Mock Models
     Report = db.mock_model(model_name='Report', db_table='reports_report', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField)
     
     # Model 'SearchTerms'
     db.create_table('reports_searchterms', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('field', models.CharField(max_length=255)),
         ('condition', models.CharField(max_length=255)),
         ('query', models.CharField(max_length=255)),
         ('operator', models.CharField(max_length=255, blank=True)),
         ('order', models.IntegerField()),
         ('report', models.ForeignKey(Report, related_name="searchterms")),
     ))
     db.create_index('reports_searchterms', ['report_id','order'], unique=True, db_tablespace='')
     
     
     db.send_create_signal('reports', ['Report','SearchTerms'])
开发者ID:emperorcezar,项目名称:OpenConnect,代码行数:57,代码来源:0001_initial.py


示例17: forwards

 def forwards(self):
     # Model 'Category'
     db.create_table('portfolio_category', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('title', models.CharField(_("Title"), max_length=255)),
         ('slug', AutoSlugField(_("Slug"), populate_from="title")),
     ))
     
     # Mock Models
     Piece = db.mock_model(model_name='Piece', db_table='portfolio_piece', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # Model 'Photo'
     db.create_table('portfolio_photo', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('title', models.CharField(_("Title"), max_length=255)),
         ('image', models.ImageField(_("Image"), upload_to="files/portfolio")),
         ('piece', models.ForeignKey(Piece, verbose_name=_("Piece"))),
     ))
     
     # Model 'Piece'
     db.create_table('portfolio_piece', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('title', models.CharField(_("Title"), max_length=255)),
         ('teaser', models.TextField(_("Teaser"), blank=True)),
         ('body', models.TextField(_("Body"), blank=True)),
         ('link', models.URLField(_("Link"), blank=True, null=True, verify_exists=True)),
         ('slug', AutoSlugField(_("Slug"), populate_from="title")),
         ('published', models.BooleanField(_("Published"), default=True)),
         ('creation_date', CreateDateTimeField(_("Creation Date"), editable=True)),
     ))
     
     # Mock Models
     Piece = db.mock_model(model_name='Piece', db_table='portfolio_piece', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     Category = db.mock_model(model_name='Category', db_table='portfolio_category', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     
     # M2M field 'Piece.categories'
     db.create_table('portfolio_piece_categories', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('piece', models.ForeignKey(Piece, null=False)),
         ('category', models.ForeignKey(Category, null=False))
     )) 
     
     db.send_create_signal('portfolio', ['Category','Photo','Piece'])
开发者ID:taylanpince,项目名称:taylanpince,代码行数:43,代码来源:0001_initial.py


示例18: forwards

 def forwards(self):
     
     Spam = db.mock_model(model_name='Spam', db_table='southtest_spam', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField)
     
     db.create_table("southtest_eggs", (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('size', models.FloatField()),
         ('quantity', models.IntegerField()),
         ('spam', models.ForeignKey(Spam)),
     ))
开发者ID:takeiteasyguy,项目名称:django-project,代码行数:10,代码来源:0002_eggs.py


示例19: forwards

 def forwards(self):
     Event = db.mock_model(
         model_name="Event",
         db_table="events_event",
         db_tablespace="",
         pk_field_name="id",
         pk_field_type=models.AutoField,
         pk_field_args=[],
     )
     db.add_column("emails_email", "event", models.ForeignKey(Event, blank=True, null=True))
开发者ID:emperorcezar,项目名称:OpenConnect,代码行数:10,代码来源:0003_add_event.py


示例20: forwards

 def forwards(self, orm):
     Menu = db.mock_model(model_name='Menu', db_table='wizardcms_menu', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
     db.create_table('wizardcms_menuitem', (
         ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
         ('menu', models.ForeignKey(Menu)),
         ('display_order', models.PositiveIntegerField()),
         ('type', models.CharField(max_length=32)),
         ('value', models.CharField(max_length=255)),
         ('is_published', models.BooleanField(default=False)),
     ))
开发者ID:marcinn,项目名称:wizardcms,代码行数:10,代码来源:0007_naprawa_menu_item_1.py



注:本文中的south.db.db.mock_model函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.rename_column函数代码示例发布时间:2022-05-27
下一篇:
Python db.execute_many函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap