Get results from query depending on another query

2009-08-18 Thread Chris McComas
I have a model that has a FK to django.contrib.auth.models Group. I run a query that gets all the groups that a user is a member of: groups = Group.objects.filter(user=request.user) Then I want to run a query for that model that gets and entries in that model where the group FK is one of the gro

Help with schema

2009-05-05 Thread Chris McComas
I have a site/database that tracks baseball players and their agents. Players can have multiple agents at one time, they also can fire agents and hire new ones at anytime, and I'd like to track all of their agents, current, or previous. I was thinking of this schema for my models, but wasn't sure

IndexError: list index out of range

2009-09-21 Thread Chris McComas
I am trying to write to CSV, I was able to do so before, not sure what the problem is... When my query returns results, I get this error http://dpaste.com/96399/ Here's my view http://dpaste.com/96398/ If the query is empty it opens the CSV with only the header row... What am I doing wrong? --

Switching from MySQL to PostgreSQL

2009-10-06 Thread Chris McComas
We've been running our Django app with mod_python and Apache to serve static files, along with MySQL as the database of choice. We're in the process of making a few changes because we've had some stability and performance issues, so we're moving to mod_wsgi/nginx, but we also want to switch from M

Django and Authorize.net

2009-12-02 Thread Chris McComas
Greetings, We have an application for our school online, just recently the university controller and business office finally gave us clearance to accept our application fee online, and they setup an account with authorize.net. I'm trying to integrate the payment within our Application app, I was

Help Converting a Query getting one result using .filter() to .get()

2010-07-12 Thread Chris McComas
I have this query, trying to get the next game in the future. today = datetime.datetime.now() next_game = Game.objects.filter(date__gt=today).order_by('date')[:1] I need to use .get() if possible, instead of .filter() how can I do this? -- You received this message because you are subscribed to

Re: Help Converting a Query getting one result using .filter() to .get()

2010-07-13 Thread Chris McComas
database, in a separate query where sport=sport and opponent=opponent to figure out the historical Win/Loss record between the teams? On Jul 12, 8:15 pm, John M wrote: > Why does it matter? > > You could just say next_game[0] instead. > > J > > On Jul 12, 4:28 pm, Chris M

Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
This is my model, I'm trying to set it so that if the game is in the future, based on the field date, then to return True, if not return False. http://dpaste.com/218111/ I am importing datetime in my models.py but for some reason it's giving me nothing. I tried displaying future and nothing shows

Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
I'm using it in my template... Basically this http://dpaste.com/218114/ Mainly I want to use it for the {% if %} but I tried to just show it was well and still nothing... On Jul 14, 11:49 am, Daniel Roseman wrote: > On Jul 14, 4:43 pm, Chris McComas wrote: > > > This is my

Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
etime.datetime.now()' instead of 'datetime.now()' > > b> > from datetime import datetime > Then 'datetime.now()' should work correctly. > > Thanks, > Subhranath Chunder. > > On Wed, Jul 14, 2010 at 9:13 PM, Chris McComas wrote: > > >

Help Reading data from an uploaded CSV

2010-09-30 Thread Chris McComas
I have this code: http://dpaste.com/250981/ The file is uploading properly, but it is not creating any entries in my Pharmcas table, it's worked before, last spring when we used it last, but right now it's not working? It uploads and saves the file as it should, but then doesn't do any of the cre

Help with Django and Apache

2010-01-05 Thread Chris McComas
I have a site built with Django, we're switching things up and will be running ExpressionEngine as our main CMS for the "front-end" / marketing piece of our site. We will have two Django apps running elsewhere on the site, one is a Course Management Software we built in house, the other is an onlin

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 t

Re: Division with Python/Django

2010-01-29 Thread Chris McComas
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

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 t

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

help with Django model and 'choices'

2010-02-02 Thread Chris McComas
I have this model http://dpaste.com/153722/ and I have a ModelForm for it on my site. When I complete the form it saves everything as it should and displays just a detail page for each entry with all of the correct information from the Model. When I go back to edit the form, or I view it in the CR

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Here's my model form: http://dpaste.com/153728/ The info isn't being saved as an empty value. When I view my db with phpmyadmin, the correct values are in the ha_grade and hp_grade field in the db, the drop-down list on the forms is just not displaying them as being 'selected'. On Feb 2, 10:09

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Here's my view: http://dpaste.com/153735/ One thing I just thought of, is it a problem that the data for ha_grade and hp_grade are saved in the db as 4.3300 or 4. or 3.6700 but in the on my form they're like this: 4.33 or 4.0 or 3.67 ??? On Feb 2, 10:32 am, Shawn Milochik wrote: > Okay.

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Here's the view... http://dpaste.com/153735/ Could it possibly be that the grade is saved in the db as 4.3300 or 4. or 3.6700 but when I view source the select on the form looks like this: - A+ A A- B+ B B- C+ C C- CR On Feb 2, 10:32 am, Shawn Milochik wrote: > Okay. Sorry, I don

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
in my views that'd be fine as well... On Feb 2, 10:56 am, Shawn Milochik wrote: > On Feb 2, 2010, at 10:40 AM, Chris McComas wrote: > > > Here's my view: > > >http://dpaste.com/153735/ > > > One thing I just thought of, is it a problem that the data for >

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Shawn -> thnx for your help, that "hacky" fix isn't working tho... On Feb 2, 11:09 am, Chris McComas wrote: > Thnx. The reason the grade values are 4.33, 4. 3.67 etc is because > that value is multiplied by the value entered for ha_credithours and > hp_credithours. If

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Like this? http://dpaste.com/153790/ On Feb 2, 12:19 pm, Shawn Milochik wrote: > On Feb 2, 2010, at 11:49 AM, Chris McComas wrote: > > > Shawn -> thnx for your help, that "hacky" fix isn't working tho... > > Sorry 'bout that. I didn't really test

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
t the form and it's still not showing anything as for ha_grade or hp_grade. The drop-down for each still lists the value as 4.33 or 4.0 or 3.67 etc? On Feb 2, 12:51 pm, Shawn Milochik wrote: > On Feb 2, 2010, at 12:48 PM, Chris McComas wrote: > > > Like this? > > &g

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
h. Ha On Feb 2, 1:03 pm, Chris McComas wrote: > Nope. I dropped the table completely and started from scratch. I'm > still testing it out, so there hasn't been any real data entered so I > can play around with it. I dropped the table, uploaded my new models, > syncdb, and

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Again, this is my view: http://dpaste.com/153735/ I'm thinking the error is in someway related to this line: new_green.hp_coursepoints = new_green.hp_grade * hp_credithours The only thing I changed was changed hp_grade from a DecimalField to FloatField On Feb 2, 1:14 pm, Chris Mc

Re: help with Django model and 'choices'

2010-02-02 Thread Chris McComas
Gleber, I'll try that as well. If I can just figure out how to multiply total = = new_green.hp_grade * hp_credithours Where hp_grade is a FloatField (double in the MySQL db) with hp_credithours which is a DecimalField (decimal in the MySQL db) I think they'd solve the problem. On Feb 2, 2:25 pm

Re: help with Django model and 'choices'

2010-02-03 Thread Chris McComas
is a DecimalField hp_grade is a FloatField hp_credithours is a DecimalField I tried this, but no luck: new_green.hp_coursepoints = Decimal(new_green.hp_grade) * hp_credithours On Feb 2, 2:27 pm, Chris McComas wrote: > Gleber, > > I'll try that as well. If I can just figure out how to

Re: help with Django model and 'choices'

2010-02-03 Thread Chris McComas
Javier, WORKED PERFECT! THANK YOU ALL SO MUCH! :) On Feb 3, 9:50 am, Javier Rivera wrote: > Chris McComas wrote: > > I tried this, but no luck: > > > new_green.hp_coursepoints = Decimal(new_green.hp_grade) * > > hp_credithours > > Decimal can't directly

Help with math functions...

2010-02-03 Thread Chris McComas
This is kinda of a general and kind of a specific question. I have this in my view: http://dpaste.com/154208/ The first line adds up perfectly, but the second one doesn't and throws an index out of range error. What is the problem? cog.interview_score and cog.interview_score_conv are both Decim

If query field equals text...

2010-02-03 Thread Chris McComas
I'm trying to run this IF in my views, it's throwing an index out of range error. http://dpaste.com/154249/ What have I done 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.

Re: If query field equals text...

2010-02-03 Thread Chris McComas
not right and threw a bad syntax error. The field rating_recommendation is a CharField in my model/db. On Feb 3, 2:58 pm, Shawn Milochik wrote: > On Feb 3, 2010, at 2:52 PM, Chris McComas wrote: > > > I'm trying to run this IF in my views, it's throwing an index out of > > ran

Feedback on Models setup

2010-02-09 Thread Chris McComas
I have a Course Management System I've developed here at work. Faculty can login and upload lectures, course resources, etc to classes they teach, along with general course information. Students can login to view their courses, download lectures, resources, get announcements from their faculty memb

Index Error with empty queries

2010-02-18 Thread Chris McComas
I have this in my views, if there lor1 and lor2 are both there it works fine, but if one or two of them are missing then it gives me this error. views.py - http://dpaste.com/161124/ error - http://dpaste.com/161128/ Some applicants have two LORs, some have one LOR, and obviously some don't have

Help with Date Functions

2010-03-02 Thread Chris McComas
These are my models: http://dpaste.com/166906/ I have a ModelForm setup, nothing special, just excluding a couple fields: application, tuition_deadline, and deadline_passed What I'm trying to do in my view is if a value is entered in read_receipt then it automatically sets tuition_deadline to be

Re: Help with Date Functions

2010-03-02 Thread Chris McComas
I tried this: new_admit.read_receipt.datetime.timedelta(days=7) and I got this error: http://dpaste.com/166919/ On Mar 2, 9:51 am, Masklinn wrote: > On 2 Mar 2010, at 15:45 , Chris McComas wrote: > > > > > These are my models:http://dpaste.com/166906/ > > > I have

Re: Help with Date Functions

2010-03-02 Thread Chris McComas
Crap my bad, just under the gun to get this done and I overlook easy stuff. Sorry guys, thanks so much for your help! On Mar 2, 10:11 am, raj wrote: > Now that's a pure python typo. You must add(+) datetime.timedelta to > read_receipt. > > On Mar 2, 8:01 pm, Chris McComas w

Re: Help with Date Functions

2010-03-02 Thread Chris McComas
One more question...I'm trying in my view to say if the deadline has passed to make that field as True, if not False I have this view: http://dpaste.com/166951/ This is the error I get: http://dpaste.com/166952/ On Mar 2, 10:12 am, Chris McComas wrote: > Crap my bad, just under the gu

Uploading CSV file via ModelForm and then getting info and storing in a different model

2010-03-26 Thread Chris McComas
I have to models, one is just a timestamp field and a file, the other has some information. I need to create a view that'll allow our staff to upload a CSV and then it'll automatically take that info and save it into the second model. I found this http://blog.2theleft.la/2010/02/9/importing-csv-fil

Re: Uploading CSV file via ModelForm and then getting info and storing in a different model

2010-03-26 Thread Chris McComas
derek, thanks, that's a bit much for what we need. i setup this in my views: http://dpaste.com/176380/ I'm getting this error: http://dpaste.com/176382/ How can I get it to open the file that was just uploaded and saved? On Mar 26, 9:27 am, derek wrote: > On Mar 26, 1:54 pm,

Re: Uploading CSV file via ModelForm and then getting info and storing in a different model

2010-03-26 Thread Chris McComas
So I resolved the previous issue, not i'm getting this error, newline in string. http://dpaste.com/176429/ Any idea? I'm thinking for some reason I need to change something in reader = csv.reader(file, delimiter=',', quotechar='"') On Mar 26, 10:2

Running Shell script to run Django shell and then scp files to server...

2012-10-02 Thread Chris McComas
I have a script in Django that I run manually 'python manage.py shell' and then 'from sports import scores' and it goes out and pulls scores from a couple URLs, modifies the data, and saves it to a SQLite database. Once that process runs I manually scp my files to a server... What I'd like to d

Parsing feeds that are imported

2011-06-06 Thread Chris McComas
This could be the wrong place to ask (maybe a BeautifulSoup) question... I have a Django app that is based around the Django Community Aggregator, it gets feeds from various sites and displays them on my site. What I am wanting to do, if possible, is when it gets a feed if a certain zip code is th

Re: Parsing feeds that are imported

2011-06-06 Thread Chris McComas
e.com/551322/ Thanks, On Jun 6, 4:55 pm, Chris McComas wrote: > This could be the wrong place to ask (maybe a BeautifulSoup) > question... > > I have a Django app that is based around the Django Community > Aggregator, it gets feeds from various sites and displays them on my >

Re: Parsing feeds that are imported

2011-06-08 Thread Chris McComas
feed parsing, you might try using the > Universal Feed Parser python module:http://feedparser.org/. It's > specifically designed for parsing RSS / Atom feeds, and so may be > somewhat more useful than BeautifulSoup. > > On Jun 6, 10:59 pm, Chris McComas wrote: > > >

Help with custom model method for query

2011-06-09 Thread Chris McComas
I have this views.py and models.py: http://dpaste.com/552615/ On the view what I want to do is display a list of all the feed types (News, Sports, etc general categories), then then below each of those feed type headings display the FeedItems for each feed for that city. Prior to adding the City

Re: Help with custom model method for query

2011-06-10 Thread Chris McComas
.name }} {% for entry in feed.list %} {{ entry.title }} {% endfor %} {% endfor %} On Jun 10, 6:21 am, bruno desthuilliers wrote: > On Jun 10, 6:13 am, Chris McComas wrote: > > > I have this views.py and mod

Re: Help with custom model method for query

2011-06-10 Thread Chris McComas
%} it does the first {% for %} loop perfectly, the second {% for %} loop gets the Feed from the database for that FeedType, but I need it to get FeedItems for Feed in FeedType Thanks for any help On Jun 10, 8:54 am, Chris McComas wrote: > Thanks very much! > > The city is passed to th

Re: Help with custom model method for query

2011-06-10 Thread Chris McComas
un 10, 10:02 am, bruno desthuilliers wrote: > On Jun 10, 3:12 pm, Chris McComas wrote: > > > tethered my phone to my laptop to test it out...have this code in my > > template: > > > {% regroup feeds by feed_type as feed_list %} > > {% for feed_type

Re: Help with custom model method for query

2011-06-10 Thread Chris McComas
Bruno, Thanks. It wasn't exactly working properly, so I just had to add .order_by('feed__feed_type__order_by') and it seems to be working properly. On Jun 10, 3:33 pm, bruno desthuilliers wrote: > On 10 juin, 17:23, Chris McComas wrote: > > > Sorry for the c

Help with Multiple Databases Master/Slave

2011-06-11 Thread Chris McComas
I have this database setup: http://dpaste.com/553289/ This is my db router file: http://dpaste.com/553290/ When I try to run ./manage.py syncdb --database=slave1 it starts to create the tables, but when it gets to the auth_permission table I get this error: django.db.utils.IntegrityError: dupl

Feed Parser, Community Aggregator, Date and Time settings

2011-06-12 Thread Chris McComas
I'm using the Django community aggregator on my site, which uses the Universal Feed Parser to parse RSS feeds and save them in a database. I noticed that the date_modified for feeds were actually +5 of my timezone, which is set to America/Detroit in my Django settings. I'm on DotCloud and unfortun

Help with Templates and ljust

2011-06-17 Thread Chris McComas
I have this as my template code: http://dpaste.com/555651/ This is the HTML it is outputting, which makes sense. What I'm trying to do is make it so the closing tag is right after the team name and the whitespace from the ljust after it. http://dpaste.com/555649/ -- You received this message

Re: Help with Templates and ljust

2011-06-17 Thread Chris McComas
Figured it out. Added this to my Model: @property def spacer(self): return (25-len(str(self.team.name)))*' ' then in my template just added {{ team.spacer }} On Jun 17, 7:17 pm, Chris McComas wrote: > I have this as my template code: > > http:

Help selecting info from across databases in queries.

2011-06-24 Thread Chris McComas
Here are my models: http://dpaste.com/558411/ I'm wanting to run a query on the Team model that gets every game from Games where the team's opponent was in the Coaches Poll Top 25. So, the view is getting: team = Team.objects.get(pk=team_id) On this page, it'll display team info (I cut out loc