FactoryBoy & ManyToManyField
Hi Guys, I'm using FactoryBoy in my tests, but I have a model which has a ManyToManyField to another model. Does anyone know if it's possible to make factoryboy use a factory to represent this relationship? For reference, here are a sample model and factory: --models.py from django.contrib.auth.models import User from django.db.models import ManyToManyField class Workplace(models.Model): employees = ManyToManyField(User) --tests.py import factory from models import Workplace # This will set the default strategy for all factories that don't define a default build strategy factory.Factory.default_strategy = factory.BUILD_STRATEGY class WorkplaceFactory(factory.Factory): FACTORY_FOR = Workplace class UserFactory(factory.Factory): FACTORY_FOR = User class ATestCase(TestCase): def setUp(self): super(ATestCase, self).setUp() self.user = UserFactory.build() self.workplace = WorkplaceFactory.build() def test_foobar(self): # how do I add self.user to self.workplace ? self.assertEqual(self.workplace.employees_set.all(), 1) --Craig -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Aubjg6DsgoYJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
https://code.djangoproject.com/ticket/16909
Hi All, I need the bugfix from this ticket. This ticket is assigned to Version 1.3, and was closed as fixed 5 months ago. This was fixed after the 1.3.1 release. Is there going to be a 1.3.2 release which includes this fix? Cheers, --Craig Blaszczyk -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/MifZKL58YukJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Min/Max value on FloatField
Hi, I'm wondering if there's a recommended solution for a FloatField which requires a minimum value? IMHO the best solution would be a ModelField implementation which provides this functionality. Can anybody recommend one, as I prefer not to implement it myself? Cheers, --Craig Blaszczyk -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/0sctiY8sCF0J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to add CSRF to context when using test client???
csrf_token is a proxy object not a string. Try doing: csrf_token = '%s' % response.context['csrf_token'] -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/DtPU80g0avcJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.