Re: Division with Python/Django

2010-01-29 Thread Mike Ramirez
On Friday 29 January 2010 12:28:37 Chris McComas wrote:
> Hey everyone, here's all of the information:
> 
> Here's the models:
> http://dpaste.com/152277/
> 
> Here's my view:
> http://dpaste.com/152061/
> 
> Here's the full error message:
> http://dpaste.com/152060/
> 

All your fields in the models are DecimalFields 

in your view you have:

cogability.pcatessay_conv = int(cogability.pcatessay_rawscore) / 5 
cogability.pcat_conv = int(cogability.pcat_rawscore) / 100

These are Type Int when saved, not Decimal, you should convert them somewhere 
along the lines or change the fields to be IntegerField

Mike


-- 
Let not the sands of time get in your lunch.


signature.asc
Description: This is a digitally signed message part.


Re: Division with Python/Django

2010-01-29 Thread Chris McComas
Hey everyone, here's all of the information:

Here's the models:
http://dpaste.com/152277/

Here's my view:
http://dpaste.com/152061/

Here's the full error message:
http://dpaste.com/152060/


On Jan 29, 9:13 am, Chris McComas  wrote:
> The form is a ModelForm, where the fields involved, all of them are
> DecimalField()
>
> On Jan 29, 9:03 am, Chris McComas  wrote:
>
>
>
> > Changed my view to this:
>
> >http://dpaste.com/152061/
>
> > This is the full error message:
>
> >http://dpaste.com/152060/
>
> > The first three numbers, math_rawscore, science_rawscore, and
> > socsci_rawscore are GPAs, like 4.0, 3.47, etc. The second two numbers
> > pcat_rawscore and pcatessay_rawscore are whole numbers like 40 or 4
>
> > On Jan 29, 8:43 am, rebus_  wrote:
>
> > > On 29 January 2010 14:40, Chris McComas  wrote:> 
> > > I have this view with my form:http://dpaste.com/152046/whenItry to
> > > > submit the form I'm getting this error: unsupported operand type(s)
> > > > for //: 'unicode' and 'int' what did I do wrong?
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups "Django users" group.
> > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > To unsubscribe from this group, send email to 
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group 
> > > > athttp://groups.google.com/group/django-users?hl=en.
>
> > > Are you sure cogability.* attributes are integers?
>
> > > Full error message would also be helpfull.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Division with Python/Django

2010-01-29 Thread Chris McComas
The form is a ModelForm, where the fields involved, all of them are
DecimalField()


On Jan 29, 9:03 am, Chris McComas  wrote:
> Changed my view to this:
>
> http://dpaste.com/152061/
>
> This is the full error message:
>
> http://dpaste.com/152060/
>
> The first three numbers, math_rawscore, science_rawscore, and
> socsci_rawscore are GPAs, like 4.0, 3.47, etc. The second two numbers
> pcat_rawscore and pcatessay_rawscore are whole numbers like 40 or 4
>
> On Jan 29, 8:43 am, rebus_  wrote:
>
>
>
> > On 29 January 2010 14:40, Chris McComas  wrote:> I 
> > have this view with my form:http://dpaste.com/152046/whenI try to
> > > submit the form I'm getting this error: unsupported operand type(s)
> > > for //: 'unicode' and 'int' what did I do wrong?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > Are you sure cogability.* attributes are integers?
>
> > Full error message would also be helpfull.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Division with Python/Django

2010-01-29 Thread Chris McComas
Changed my view to this:

http://dpaste.com/152061/

This is the full error message:

http://dpaste.com/152060/

The first three numbers, math_rawscore, science_rawscore, and
socsci_rawscore are GPAs, like 4.0, 3.47, etc. The second two numbers
pcat_rawscore and pcatessay_rawscore are whole numbers like 40 or 4



On Jan 29, 8:43 am, rebus_  wrote:
> On 29 January 2010 14:40, Chris McComas  wrote:> I 
> have this view with my form:http://dpaste.com/152046/when I try to
> > submit the form I'm getting this error: unsupported operand type(s)
> > for //: 'unicode' and 'int' what did I do wrong?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> Are you sure cogability.* attributes are integers?
>
> Full error message would also be helpfull.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Division with Python/Django

2010-01-29 Thread Mike Ramirez
On Friday 29 January 2010 05:40:19 Chris McComas wrote:
> I have this view with my form: http://dpaste.com/152046/ when I try to
> submit the form I'm getting this error: unsupported operand type(s)
> for //: 'unicode' and 'int' what did I do wrong?
> 

A full traceback would be helpful, along with your form code.

I suspect that your form isreturning unicode strings (which it gets from the 
POST of your form). If that's the case, you might want to try int(), float(), 
long(), (which ever floats your boat [pun intended]) and convert them from 
unicode strings to int's. -- if your strings aren't integers and you try to 
convert it, it will throw a ValueError at you

In [6]: x = u'123'

In [7]: int(x)/4
Out[7]: 30  

In [8]: x/4
---
TypeError Traceback (most recent call last)

/home/gufymike/Projects/goproject/ego_examples/src/ in 
()

TypeError: unsupported operand type(s) for /: 'unicode' and 'int'

In [9]: int(u"1x")
---
ValueErrorTraceback (most recent call last)

/home/gufymike/Projects/goproject/ego_examples/src/ in 
()

ValueError: invalid literal for int() with base 10: '1x'

  

Mike




-- 
We are MicroSoft.  You will be assimilated.  Resistance is futile.
-- Attributed to B.G., Gill Bates


signature.asc
Description: This is a digitally signed message part.


Re: Division with Python/Django

2010-01-29 Thread rebus_
On 29 January 2010 14:40, Chris McComas  wrote:
> I have this view with my form: http://dpaste.com/152046/ when I try to
> submit the form I'm getting this error: unsupported operand type(s)
> for //: 'unicode' and 'int' what did I do wrong?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>
Are you sure cogability.* attributes are integers?

Full error message would also be helpfull.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Division with Python/Django

2010-01-29 Thread Chris McComas
I have this view with my form: http://dpaste.com/152046/ when I try to
submit the form I'm getting this error: unsupported operand type(s)
for //: 'unicode' and 'int' what did I do wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.