Re: Decimal value allowed for auto primary key

2014-10-26 Thread Kafex
Ok, that makes sense, thanks for the reply!

On Sunday, October 26, 2014 7:34:06 PM UTC-4, Tom Evans wrote:
>
> On Sun, Oct 26, 2014 at 12:37 AM, Kafex  
> wrote: 
> > If I have the following model... 
> > class FruitType(models.Model): 
> >   name = models.CharField(max_length=255) 
> > 
> > And I insert some records... 
> > FruitType.objects.create(name="Apple") 
> > FruitType.objects.create(name="Orange") 
> > 
> > Why is this valid? 
> > FruitType.objects.get(id=1.2) # Gets me the apple 
> > FruitType.objects.get(id=2.9) # Gets me the apple 
> > 
> > 
> > Django seems to truncate the id to just the integer part. 
>
> Yes. The value is coerced to int, that is int(value) will be run on 
> it. If you pass a type that can be coerced to an int, no error will be 
> raised, so be aware of that. 
>
> > This also applies to form validation: 
> > class FruitForm(forms.Form): 
> >   type = forms.ModelChoiceField(queryset=FruitType.objects.all()) 
> > 
> > form = FruitForm(data={'type': 1.5}) 
> > form.is_valid() # returns True 
> > 
> > Is there any way to prevent this? I.e., I want my form to treat 1.5 as 
> > invalid input and raise a ValidationError. 
>
> This one is less obviously a problem, a typical form would actually be 
> passed the string '1.5' (not the float 1.5), which would in fact raise 
> a ValidationError. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ed2ab1b6-0e39-4be7-ac6f-9c3f0a74fd24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Decimal value allowed for auto primary key

2014-10-26 Thread Tom Evans
On Sun, Oct 26, 2014 at 12:37 AM, Kafex  wrote:
> If I have the following model...
> class FruitType(models.Model):
>   name = models.CharField(max_length=255)
>
> And I insert some records...
> FruitType.objects.create(name="Apple")
> FruitType.objects.create(name="Orange")
>
> Why is this valid?
> FruitType.objects.get(id=1.2) # Gets me the apple
> FruitType.objects.get(id=2.9) # Gets me the apple
>
>
> Django seems to truncate the id to just the integer part.

Yes. The value is coerced to int, that is int(value) will be run on
it. If you pass a type that can be coerced to an int, no error will be
raised, so be aware of that.

> This also applies to form validation:
> class FruitForm(forms.Form):
>   type = forms.ModelChoiceField(queryset=FruitType.objects.all())
>
> form = FruitForm(data={'type': 1.5})
> form.is_valid() # returns True
>
> Is there any way to prevent this? I.e., I want my form to treat 1.5 as
> invalid input and raise a ValidationError.

This one is less obviously a problem, a typical form would actually be
passed the string '1.5' (not the float 1.5), which would in fact raise
a ValidationError.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1KQHqEcKMY_iMk-Aeb7z%3D6TYWYXv1kWPCWg%3DrSMHmEsrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: TEST_MIRROR not working?

2014-10-26 Thread Ilya Baryshev
>Ilya: Can you test if using TEST_MIRROR fixes the issue you are seeing?
Both settings have same effect.

I've slightly modified testcase to demonstrate replica queries are not the 
same as master queries (no fixtures):

def test_fixture(self):
MyModel.objects.using('default').create(name=1)
MyModel.objects.using('slave').create(name=2)
MyModel.objects.using('slave').create(name=3)
self.assertEqual(MyModel.objects.using('default').count(),
 MyModel.objects.using('slave').count())


==
FAIL: test_fixture (testapp.tests.TestMirror)
--
Traceback (most recent call last):
  File "/Users/prophet/work/forks/test_mirror/testmirror/testapp/tests.py", 
line 13, in test_fixture
MyModel.objects.using('slave').count())
AssertionError: 3 != 2


On Sunday, October 26, 2014 4:21:06 PM UTC+3, Ramiro Morales wrote:
>
> Actually, in 1.7.x both should work.
>
> Ilya: Can you test if using TEST_MIRROR fixes the issue you are seeing?
> On Oct 26, 2014 9:19 AM, "Tom Evans"  
> wrote:
>
>> On Sat, Oct 25, 2014 at 5:21 PM, Ilya Baryshev > > wrote:
>> > Hey all!
>> >
>> > I was writing tests for queries that use replica database, so I tried 
>> using
>> > TEST_MIRROR setting.
>> > TEST_MIRROR promises "connection to slave will be redirected to point at
>> > default.
>> > As a result, writes to default will appear on slave". Which happens not 
>> to
>> > be the case for me,
>> > replica queries are not returning expected results.
>> >
>> > Is this a bug, or am I missing something?
>> >
>> > Here is my example settings:
>> >
>> > DATABASES = {
>> > 'default': {
>> > 'ENGINE': 'django.db.backends.postgresql_psycopg2',
>> > 'NAME': 'testmirror',
>> > 'HOST': '127.0.0.1',
>> > 'PORT': 5432,
>> > },
>> > 'slave': {
>> > 'ENGINE': 'django.db.backends.postgresql_psycopg2',
>> > 'NAME': 'testmirror2',
>> > 'HOST': '127.0.0.1',
>> > 'PORT': 5432,
>> > 'TEST': {
>> > 'MIRROR': 'default'
>>
>> This should be 'TEST_MIRROR': 'default'
>>
>> Cheers
>>
>> Tom
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAFHbX1L%3DU95K4_XreTm%3D2aET3JRPCCeQL1773wgRZ_25eJX7gQ%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/47557c28-3ab7-4e03-9152-beacd9b55359%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TEST_MIRROR not working?

2014-10-26 Thread Ramiro Morales
Actually, in 1.7.x both should work.

Ilya: Can you test if using TEST_MIRROR fixes the issue you are seeing?
On Oct 26, 2014 9:19 AM, "Tom Evans"  wrote:

> On Sat, Oct 25, 2014 at 5:21 PM, Ilya Baryshev  wrote:
> > Hey all!
> >
> > I was writing tests for queries that use replica database, so I tried
> using
> > TEST_MIRROR setting.
> > TEST_MIRROR promises "connection to slave will be redirected to point at
> > default.
> > As a result, writes to default will appear on slave". Which happens not
> to
> > be the case for me,
> > replica queries are not returning expected results.
> >
> > Is this a bug, or am I missing something?
> >
> > Here is my example settings:
> >
> > DATABASES = {
> > 'default': {
> > 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> > 'NAME': 'testmirror',
> > 'HOST': '127.0.0.1',
> > 'PORT': 5432,
> > },
> > 'slave': {
> > 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> > 'NAME': 'testmirror2',
> > 'HOST': '127.0.0.1',
> > 'PORT': 5432,
> > 'TEST': {
> > 'MIRROR': 'default'
>
> This should be 'TEST_MIRROR': 'default'
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1L%3DU95K4_XreTm%3D2aET3JRPCCeQL1773wgRZ_25eJX7gQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO7PdF8F6d3rqYHJ5hj7Rfkom8%3DeHv7h1TTbpkSack1ATjg8Lg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dutch translation of Django Tutorial

2014-10-26 Thread Tomáš Ehrlich
HI Erwin,
It won't be more than 8 pages of documentation: Overview, Installation and 
six parts of tutorial. I don't think it's possible to finish more in three 
weeks from now.

Right now is being translated the 1st part of tutorial. I'll publish it 
somewhere for review once it's ready.

Thank you in advance!

Cheers,
   Tom


Dne neděle, 26. října 2014 13:23:43 UTC+1 Erwin Sprengers napsal(a):
>
> Hi,
>
> Depending on the size, I can help to review.
>
> Erwin
>
> Op zaterdag 25 oktober 2014 13:36:11 UTC+2 schreef Tomáš Ehrlich:
>>
>> Hello everyone,
>> there are two things that going to happen in next month:
>>
>> 1. Django Under the Hood conference in Amsterdam
>> 2. (Hopefully) I’ll finish SaaS for managing translations. The first 
>> frontend build on top of gettext message catalogues will be for Sphinx 
>> documentation.
>>
>> As a result, I would like make dutch translation of django documentation. 
>> Unfortunately, as Django docs are pretty comprehensive, I don’t think it’s 
>> possible to translate everything in three weeks. Therefore, I want to focus 
>> on tutorial which is a the best starting point for beginners.
>>
>> I’ve already found a English->Dutch translator who is available.
>>
>>
>> The questions are:
>>
>> 1. Is there any Dutch translation already available? I’m aware of French 
>> and Czech translation, there are few more in transifex 
>> https://www.transifex.com/projects/p/django-docs/, but I haven’t found 
>> any references about Dutch one.
>> 2. Are there any Dutch developers willing to review the translation?
>>
>>
>> Thank you in advance,
>>Tom
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb74e125-c504-49d2-ae63-e903b32aff8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dutch translation of Django Tutorial

2014-10-26 Thread Erwin Sprengers
Hi,

Depending on the size, I can help to review.

Erwin

Op zaterdag 25 oktober 2014 13:36:11 UTC+2 schreef Tomáš Ehrlich:
>
> Hello everyone,
> there are two things that going to happen in next month:
>
> 1. Django Under the Hood conference in Amsterdam
> 2. (Hopefully) I’ll finish SaaS for managing translations. The first 
> frontend build on top of gettext message catalogues will be for Sphinx 
> documentation.
>
> As a result, I would like make dutch translation of django documentation. 
> Unfortunately, as Django docs are pretty comprehensive, I don’t think it’s 
> possible to translate everything in three weeks. Therefore, I want to focus 
> on tutorial which is a the best starting point for beginners.
>
> I’ve already found a English->Dutch translator who is available.
>
>
> The questions are:
>
> 1. Is there any Dutch translation already available? I’m aware of French 
> and Czech translation, there are few more in transifex 
> https://www.transifex.com/projects/p/django-docs/, but I haven’t found 
> any references about Dutch one.
> 2. Are there any Dutch developers willing to review the translation?
>
>
> Thank you in advance,
>Tom
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57adb311-3109-48cb-a665-0a05f648ba99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TEST_MIRROR not working?

2014-10-26 Thread Tom Evans
On Sat, Oct 25, 2014 at 5:21 PM, Ilya Baryshev  wrote:
> Hey all!
>
> I was writing tests for queries that use replica database, so I tried using
> TEST_MIRROR setting.
> TEST_MIRROR promises "connection to slave will be redirected to point at
> default.
> As a result, writes to default will appear on slave". Which happens not to
> be the case for me,
> replica queries are not returning expected results.
>
> Is this a bug, or am I missing something?
>
> Here is my example settings:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> 'NAME': 'testmirror',
> 'HOST': '127.0.0.1',
> 'PORT': 5432,
> },
> 'slave': {
> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
> 'NAME': 'testmirror2',
> 'HOST': '127.0.0.1',
> 'PORT': 5432,
> 'TEST': {
> 'MIRROR': 'default'

This should be 'TEST_MIRROR': 'default'

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1L%3DU95K4_XreTm%3D2aET3JRPCCeQL1773wgRZ_25eJX7gQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.