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

Python recipe.foreign_key函数代码示例

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

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



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

示例1: setUpClass

    def setUpClass(cls):
        # clear db
        models.User.objects.all().delete()
        models.Activity.objects.all().delete()

        cls.assertStrEqual = lambda cls, x, y: cls.assertEqual(str(x), str(y))

        employee = recipe.Recipe(models.Employee,
                                 id=1,
                                 first_name='Jan',
                                 last_name='Wójt')
        company = recipe.Recipe(models.CoffeeCompany,
                                id=2,
                                full_name='Kawa')
        activity1 = recipe.Recipe(models.Activity,
                                  id=1,
                                  creator=recipe.foreign_key(employee),
                                  target=recipe.foreign_key(company),
                                  content='Jan Wójt drinked coffee from Kawa')
        activity2 = recipe.Recipe(models.Activity,
                                  id=2,
                                  creator=recipe.foreign_key(company),
                                  target=recipe.foreign_key(employee),
                                  content='Kawa delivered product to Jan Wójt')

        employee.make()
        company.make()
        activity1.make()
        activity2.make()
开发者ID:macie,项目名称:coffee,代码行数:29,代码来源:test_models.py


示例2: test_returns_a_callable

 def test_returns_a_callable(self):
     number_recipe = Recipe(DummyNumbersModel,
         float_field = 1.6
     )
     method = foreign_key(number_recipe)
     self.assertTrue(callable(method))
     self.assertTrue(method.im_self, number_recipe)
开发者ID:willemallan,项目名称:model_mommy,代码行数:7,代码来源:test_recipes.py


示例3: test_prepare_recipe_with_foreign_key

    def test_prepare_recipe_with_foreign_key(self):
        person_recipe = Recipe(Person, name='John Doe')
        dog_recipe = Recipe(Dog,
            owner=foreign_key(person_recipe),
        )
        dog = dog_recipe.prepare()

        self.assertIsNone(dog.id)
        self.assertIsNone(dog.owner.id)
开发者ID:berinhard,项目名称:model_mommy,代码行数:9,代码来源:test_recipes.py


示例4: Recipe

    pension=MoneyInterval('per_month', pennies=0),
    other_income=MoneyInterval('per_week', pennies=2200)
)
savings = Recipe(Savings)
deductions = Recipe(Deductions,
                    income_tax = MoneyInterval('per_week', pennies=2200),
                    national_insurance = MoneyInterval('per_4week', pennies=2200),
                    maintenance = MoneyInterval('per_year', pennies=2200),
                    childcare = MoneyInterval('per_week', pennies=2200),
                    mortgage = MoneyInterval('per_week', pennies=2200),
                    rent = MoneyInterval('per_week', pennies=2200)
                    )

person = Recipe(Person)
full_person = Recipe(Person,
    income=foreign_key(income),
    savings=foreign_key(savings),
    deductions=foreign_key(deductions)
)

eligibility_check = Recipe(EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5, dependants_old=6,
    you=foreign_key(person),
    partner=foreign_key(person)
)

eligibility_check_yes = Recipe(EligibilityCheck,
    category=foreign_key(category),
    dependants_young=5, dependants_old=6,
    you=foreign_key(person),
开发者ID:doismellburning,项目名称:cla_backend,代码行数:31,代码来源:mommy_recipes.py


示例5: Recipe

    os.path.join(CUR_DIR, 'kenya_boundary.geojson'))


country_boundary_recipe = Recipe(
    WorldBorder,
    mpoly=_get_mpoly_from_geom(KENYA_BORDER[0].get_geoms()[0])
)


county_recipe = Recipe(
    County
)

county_boundary_recipe = Recipe(
    CountyBoundary,
    area=foreign_key(county_recipe),
    mpoly=_get_mpoly_from_geom(COUNTY_BORDER[0].get_geoms()[0])
)

constituency_recipe = Recipe(
    Constituency,
    county=foreign_key(county_recipe),
)

constituency_boundary_recipe = Recipe(
    ConstituencyBoundary,
    area=foreign_key(constituency_recipe),
    mpoly=_get_mpoly_from_geom(CONSTITUENCY_BORDER[0].get_geoms()[0])
)

开发者ID:FelixOngati,项目名称:mfl_api,代码行数:29,代码来源:mommy_recipes.py


示例6: Recipe

an **object-oriented** computer programming language commonly used to
create interactive effects within *web browsers*.''',
    ''''# Python

a *high-level* **general-purpose** _programming language_.''',
]

user = Recipe(
    User,
    email="[email protected]",
    is_active=True
)

category = Recipe(
    Category,
    title=seq('Category'),
    author=foreign_key(user),
    description=cycle('description'),
    _quantity=3
)

article = Recipe(
    Article,
    title=seq('Article'),
    author=foreign_key(user),
    category=foreign_key(category),
    content=cycle(definitions),
    _quantity=5
)
开发者ID:bazzite,项目名称:django-knowledgebase,代码行数:29,代码来源:mommy_recipes.py


示例7: Recipe

serial_numbers_by = Recipe(DummyDefaultFieldsModel,
    default_decimal_field = seq(Decimal('20.1'), increment_by=Decimal('2.4')),
    default_int_field = seq(10, increment_by=3),
    default_float_field = seq(1.23, increment_by=1.8)
)

serial_datetime = Recipe(DummyDefaultFieldsModel,
    default_date_field = seq(TEST_TIME.date(), timedelta(days=1)),
    default_date_time_field = seq(TEST_TIME, timedelta(hours=3)),
    default_time_field = seq(TEST_TIME.time(), timedelta(seconds=15))
)

dog = Recipe(Dog,
    breed = 'Pug',
    owner = foreign_key(person)
)

other_dog = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key('person')
)

other_dog_unicode = Recipe(Dog,
    breed = 'Basset',
    owner = foreign_key(u('person'))
)

dummy_unique_field = Recipe(DummyUniqueIntegerFieldModel,
    value = seq(10),
)
开发者ID:bruth,项目名称:model_mommy,代码行数:30,代码来源:mommy_recipes.py


示例8: Recipe

    name = 'San Francisco',
    slug = 'san-francisco',
    description = 'San Francisco',
    timezone = '-8.0',
    city = 'San Francisco',
    country = 'US',
    continent = 'NA',
    lat = '0',
    lon = '0',
    private = True
    )

location_mars = Recipe(
    Location,
    name = 'Mars',
    slug = 'mars',
    description = 'Mars',
    timezone = '-8.0',
    city = 'Mars',
    country = 'US',
    continent = 'NA',
    lat = '0',
    lon = '0',
    capacity = '100'
    )

registration = Recipe(
    Registration,
    location = foreign_key(location),
    # user = foreign_key(user),
    )
开发者ID:E-LLP,项目名称:39A,代码行数:31,代码来源:mommy_recipes.py


示例9: Recipe

REPORTER_NAME = 'rep'

public_ci = Recipe(CriticalIncident,
    incident = seq('Critical Incident '),
    public = True
)

published_incident = Recipe(PublishableIncident,
    publish = True,
    critical_incident__public = True,
    critical_incident__department__label = seq('Dept_'),
    critical_incident__department__reporter__user__username = seq(REPORTER_NAME),
)

translated_pi = Recipe(PublishableIncidentTranslation, 
    incident = seq('Published Incident '),
    master = foreign_key(published_incident)
)

reviewer = Recipe(Reviewer,
    user__username = seq('rev'),
    user__email = seq('[email protected]'),
)

reporter = Recipe(Reporter,
    user__username = seq(REPORTER_NAME))

department = Recipe(Department,
    label = seq('Dept_'),
    reporter__user__username = seq(REPORTER_NAME)
)
开发者ID:major-s,项目名称:labcirs,代码行数:31,代码来源:mommy_recipes.py


示例10: test_foreign_key_method_returns_a_recipe_foreign_key_object

 def test_foreign_key_method_returns_a_recipe_foreign_key_object(self):
     number_recipe = Recipe(DummyNumbersModel,
         float_field = 1.6
     )
     obj = foreign_key(number_recipe)
     self.assertIsInstance(obj, RecipeForeignKey)
开发者ID:lucassimon,项目名称:model_mommy,代码行数:6,代码来源:test_recipes.py


示例11: Recipe

from model_mommy.recipe import Recipe, seq, foreign_key
from ..models import Provider, ProviderAllocation, OutOfHoursRota, Staff, \
    Feedback, CSVUpload


provider = Recipe(Provider,
    name=seq('Name'),
)

staff = Recipe(Staff)

outofhoursrota = Recipe(OutOfHoursRota)

provider_allocation = Recipe(ProviderAllocation)

feedback = Recipe(Feedback, created_by=foreign_key(staff))

csvupload_determination = Recipe(CSVUpload,
                   body=[
                       u'2222222', u'0000', u'1A111A', u'A', u'Corgi',
                       u'01/01/1901', u'D', u'F', u'1', u'', u'', u'SW1A 1AA',
                       u'', u'SWAG', u'YOLO', u'', u'', u'', u'', u'', u'18',
                       u'99.5', u'', u'MOB', u'', u'', u'AAAA', u'', u'', u'',
                       u'NAR', u'', u'', u'TA'
                   ]
)


csvupload_case = \
    Recipe(CSVUpload,
           body=[
开发者ID:doismellburning,项目名称:cla_backend,代码行数:31,代码来源:mommy_recipes.py


示例12: Recipe

              email="[email protected]",
              )

# events; use defaults apart from dates
# override when using recipes, eg. mommy.make_recipe('future_event', cost=10)

event_type_PC = Recipe(EventType, event_type="CL", subtype=seq("Pole level class"))
event_type_PP = Recipe(EventType, event_type="CL", subtype=seq("Pole practice"))
event_type_WS = Recipe(EventType, event_type="EV", subtype=seq("Workshop"))
event_type_OE = Recipe(EventType, event_type="EV", subtype=seq("Other event"))
event_type_OC = Recipe(EventType, event_type="CL", subtype=seq("Other class"))
event_type_RH = Recipe(EventType, event_type="RH", subtype=seq("Room hire"))

future_EV = Recipe(Event,
                      date=future,
                      event_type=foreign_key(event_type_OE))

future_WS = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_WS))

future_PC = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_PC))
future_PP = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_PP))
future_CL = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_OC))
future_RH = Recipe(Event,
开发者ID:judy2k,项目名称:pipsevents,代码行数:31,代码来源:mommy_recipes.py


示例13: Recipe

from model_mommy.recipe import Recipe, foreign_key

from ..models import ReasonForContacting, ReasonForContactingCategory

reasonforcontacting = Recipe(ReasonForContacting, _fill_optional=["user_agent", "referrer"])
reasonforcontacting_category = Recipe(
    ReasonForContactingCategory, reason_for_contacting=foreign_key(reasonforcontacting)
)
开发者ID:ministryofjustice,项目名称:cla_backend,代码行数:8,代码来源:mommy_recipes.py


示例14: Recipe

from django.contrib.auth.models import User

from kb.base import choices
from kb.models import Article, Category, Vote
from model_mommy.recipe import foreign_key, Recipe, related

person = Recipe(User)

draft_article = Recipe(Article,
                       title='Draft Article Title',
                       content='Draft Article Content',
                       publish_state=choices.PublishChoice.Draft,
                       created_by=foreign_key(person))

published_article = Recipe(Article,
                           title='Published Article Title',
                           content='Published Article Content',
                           publish_state=choices.PublishChoice.Published,
                           created_by=foreign_key(person))

category_without_articles = Recipe(Category,
                                   name='Category Without Articles Title',
                                   description='Category Without Articles Description')

category_with_articles = Recipe(Category,
                                name='Category With Articles Title',
                                description='Category With Articles Description',
                                articles=related('draft_article',
                                                 'published_article'))

vote = Recipe(Vote, article__content='Markdown')
开发者ID:eliostvs,项目名称:django-kb,代码行数:31,代码来源:mommy_recipes.py


示例15: Recipe

from model_mommy.recipe import Recipe, foreign_key, seq

from project.account.mommy_recipes import domain
from .models import EmailDomain, EmailUser, EmailForward, EmailAlias, CatchAll

email_domain = Recipe(EmailDomain,
                      domain=foreign_key(domain),
                      )

email_user = Recipe(EmailUser,
                    domain=foreign_key(email_domain),
                    )

email_forward = Recipe(EmailForward,
                       user=foreign_key(email_user),
                       )

email_alias = Recipe(EmailAlias,
                     user=foreign_key(email_user),
                     )

catch_all = Recipe(CatchAll,
                   domain=foreign_key(email_domain),
                   user=foreign_key(email_user),
                   )
开发者ID:voltgrid,项目名称:mailmanager,代码行数:25,代码来源:mommy_recipes.py


示例16: Recipe

user = Recipe(User,
              username=seq("test_user"),
              password="password",
              email="[email protected]",
              )

# events; use defaults apart from dates
# override when using recipes, eg. mommy.make_recipe('future_event', cost=10)

event_type_YC = Recipe(EventType, event_type="CL", subtype=seq("Yoga class"))
event_type_WS = Recipe(EventType, event_type="EV", subtype=seq("Workshop"))

future_EV = Recipe(Event,
                      date=future,
                      event_type=foreign_key(event_type_YC))

future_WS = Recipe(Event,
                   date=future,
                   event_type=foreign_key(event_type_WS))

# past event
past_event = Recipe(Event,
                    date=past,
                    event_type=foreign_key(event_type_WS),
                    advance_payment_required=True,
                    cost=10,
                    payment_due_date=past-timedelta(10)
                    )

block = Recipe(Block)
开发者ID:rebkwok,项目名称:flexibeast,代码行数:30,代码来源:mommy_recipes.py


示例17: Recipe

belzonte = Recipe(
    Destino,
    titulo="Belo Horizonte"
)

rondonia = Recipe(
    Destino,
    titulo="Rondonia"
)

city_tour_bh = Recipe(
    Pacote,
    texto="Aproveite!",
    publicado=True,
    destaque=True,
    destino=foreign_key(belzonte),
    preco_por=100.40
)

city_tour_bh_despublicado = Recipe(
    Pacote,
    texto="Aproveite!",
    publicado=False,
    destaque=True,
)

city_tour_bh_sem_destaque = Recipe(
    Pacote,
    texto="Aproveite!",
    publicado=True,
    destaque=False,
开发者ID:intip,项目名称:protour,代码行数:31,代码来源:mommy_recipes.py


示例18: Path

from unipath import Path

from django.conf import settings
from django.core.files import File

from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models


django_file_path = Path(settings.APP_DIR, "grunt/tests/media/test-audio.wav")
assert django_file_path.exists()
django_file = File(open(django_file_path, "rb"))

chain = Recipe(grunt_models.Chain, name="mommy_chain")

seed = Recipe(grunt_models.Message, chain=foreign_key(chain), audio=django_file)

recording = Recipe(grunt_models.Message, chain=foreign_key(chain), parent=foreign_key(seed), audio=django_file)

survey = Recipe(ratings_models.Survey)

empty_question = Recipe(
    ratings_models.Question, survey=foreign_key(survey), given=foreign_key(recording), answer=foreign_key(seed)
)

response = Recipe(ratings_models.Response, question=foreign_key(empty_question), selection=foreign_key(seed))
开发者ID:lupyanlab,项目名称:telephone,代码行数:28,代码来源:mommy_recipes.py


示例19: Path

from model_mommy.recipe import Recipe, foreign_key, related

import grunt.models as grunt_models
import ratings.models as ratings_models


django_file_path = Path(settings.APP_DIR, 'grunt/tests/media/test-audio.wav')
assert django_file_path.exists()
django_file = File(open(django_file_path, 'rb'))

chain = Recipe(grunt_models.Chain,
    name = 'mommy_chain')

seed = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    audio = django_file)

recording = Recipe(grunt_models.Message,
    chain = foreign_key(chain),
    parent = foreign_key(seed),
    audio = django_file)

question = Recipe(ratings_models.Question,
    # Needs to be a valid recording
    choices = related('seed', 'seed'),
    answer = foreign_key(seed))

response = Recipe(ratings_models.Response,
    question = foreign_key(question),
    selection = foreign_key(seed))
开发者ID:Ingwar,项目名称:telephone,代码行数:30,代码来源:mommy_recipes.py


示例20: test_not_accept_other_type

 def test_not_accept_other_type(self):
     with self.assertRaises(TypeError) as c:
         foreign_key(2)
     exception = c.exception
     self.assertEqual(str(exception), 'Not a recipe')
开发者ID:lucassimon,项目名称:model_mommy,代码行数:5,代码来源:test_recipes.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python recipe.seq函数代码示例发布时间:2022-05-27
下一篇:
Python mommy.prepare_recipe函数代码示例发布时间: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