Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

2010-10-26 Thread Alec Shaner
On Tue, Oct 26, 2010 at 12:40 PM, Phlip wrote: > > So this statement correctly fetches only the latest items: > > SELECT a.* FROM things a WHERE a.pid in (select max(b.pid) from > content_entity b group by b.name) > > Now I thought (from my allegedly copious experience with

Re: Need help with django url errors

2010-10-17 Thread Alec Shaner
I think nother problem is your polls/urls.py is wrong. The /polls prefix of the url will be removed by the main urls.py file before being matched against the included polls/urls.py http://docs.djangoproject.com/en/1.2/topics/http/urls/#including-other-urlconfs On Sun, Oct 17, 2010 at 4:52 AM,

Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
doh! Just noticed that you already referenced ticket 10154 in your original post. On Fri, Oct 15, 2010 at 3:16 PM, Alec Shaner <asha...@chumpland.org> wrote: > Interesting solution - after all that maybe it's more concise to just > use the 'extra' filter instead since you're making

Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
() + timedelta. http://code.djangoproject.com/ticket/10154 On Fri, Oct 15, 2010 at 2:48 PM, Marc Aymerich <glicer...@gmail.com> wrote: > > > On Fri, Oct 15, 2010 at 7:54 PM, Alec Shaner <asha...@chumpland.org> wrote: >> >> On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymeri

Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymerich wrote: > > Instead of use datatime.timedelta I convert it to string with this format: >  MMDDHHMMSS and now all works fine with mysql :) Unfortunately this part > of code doesn't be database independent :( > > Thank you very

Re: F() and timedelta. Bug on django?

2010-10-15 Thread Alec Shaner
It should be clarified that this occurs on the mysql backend, but not the postgres backend. It has to do with how MySQL handles the DATETIME object. You can't add a timedelta, because it expects a double. I created a test app using a mysql backend and a Article model with created and updated

Re: Help with Manager.

2010-10-15 Thread Alec Shaner
Sorry, not sure about that warning because I'm using a postgresql database. On Fri, Oct 15, 2010 at 3:17 AM, Marc Aymerich <glicer...@gmail.com> wrote: > > > On Fri, Oct 15, 2010 at 3:39 AM, Alec Shaner <asha...@chumpland.org> wrote: >> >> You can't add a dateti

Re: Help with Manager.

2010-10-14 Thread Alec Shaner
Aymerich <glicer...@gmail.com> wrote: > > > On Thu, Oct 14, 2010 at 10:08 PM, Alec Shaner <asha...@chumpland.org> wrote: >> >> See this: >> >> http://ifacethoughts.net/2009/07/14/calculated-fields-in-django/ >> >> So perhaps the 'extra' query f

Re: Help with Manager.

2010-10-14 Thread Alec Shaner
See this: http://ifacethoughts.net/2009/07/14/calculated-fields-in-django/ So perhaps the 'extra' query filter is what you need. 2010/10/14 Marc Aymerich : > > > 2010/10/14 Marc Aymerich >> >> >> 2010/10/14 Jonathan Barratt

Re: Rich email with attachments

2010-10-14 Thread Alec Shaner
On Thu, Oct 14, 2010 at 3:45 AM, Sheena wrote: > I also want to have the option to add any attachment. So I want to > have a button that when pressed allows the user to pick a file on > their hdd and have it uploaded immediately, without loosing anything > that's

Re: treating different versions of website urls as one

2010-10-05 Thread Alec Shaner
Definitely sounds like a regular expression is what you need. Not sure what you mean by etcare you saying any variation of a web address for mysite.com, i.e., with or without www prefix, with our without protocol http://, and with our without the index page, which itself could be any

Re: Why Django Admin Won't Display full graphics

2010-09-30 Thread Alec Shaner
Also, if you're using mod_wsgi (recommended over mod_python), see this: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango On Thu, Sep 30, 2010 at 12:12 PM, Addy Yeow wrote: > runserver takes care of thing like this for you but you need to handle > it properly in

Re: Bug in model inheritance?

2010-09-28 Thread Alec Shaner
As to whether it's a bug or not I have no idea, though it seems so. If you use: entity = models.OneToOneField(Entity, parent_link=True, primary_key=True) it will create the primary key in both Kid and Adult tables, which sounds like what you want? On Tue, Sep 28, 2010 at 1:06 PM, phill

Re: Querying Exact Foreign Key Sets

2010-09-15 Thread Alec Shaner
Try this: I'm assuming you define Article.category as a ManyToMany field? I also assumed for the example that Category has a name field. # Build a queryset of all categories not in desired set, e.g., 'Exact1' and 'Exact2' bad_categories = Category.objects.exclude(category_name__in=['Exact1',

Re: db filter comparing a minimum to a range

2010-09-13 Thread Alec Shaner
Maybe this is what you want: http://docs.djangoproject.com/en/1.2/topics/db/aggregation/#filtering-on-annotations On Mon, Sep 13, 2010 at 3:32 PM, Phlip wrote: > Djangoids: > > Consider this QuerySet: > > Blog.objects.filter(comment__date__range=(self.yesterday, >

Re: Please wait page trouble

2010-09-10 Thread Alec Shaner
Excellent. Glad you got it working. On Fri, Sep 10, 2010 at 8:54 AM, Bradley Hintze wrote: > I got to work! I needed a good nights sleep to see it. the url was > '/DHM_run/' NOT '/run_DHM/'. > > Thanks Alec > > -- You received this message because you are

Re: Please wait page trouble

2010-09-09 Thread Alec Shaner
o do this? In other words, what are the > If_come_from_pageA and If_come_from_pageB conditions? Can I access the > context dictionary that I passed to please_wait.html? > > On Thu, Sep 9, 2010 at 11:23 AM, Bradley Hintze > <bradle...@aggiemail.usu.edu> wrote: > > Yeah, I just tried out w

Re: Please wait page trouble

2010-09-09 Thread Alec Shaner
ata? If so, how? > > > On Thu, Sep 9, 2010 at 10:37 AM, Alec Shaner <asha...@chumpland.org> > wrote: > > I feel your pain - javascript has always been a pain for me, but > libraries > > like jQuery make it more bearable! > > > > AJAX calls are made

Re: Please wait page trouble

2010-09-09 Thread Alec Shaner
me/$', side_by_side_frame), > (r'^DHM_run/$', run_DHM), >(r'^please_wait/', please_wait), > (r'^analyze/$', analyze_compare), > ) > > > On Thu, Sep 9, 2010 at 9:22 AM, Alec Shaner <asha...@chumpland.org> wrote: > > Could you post the full url

Re: Please wait page trouble

2010-09-09 Thread Alec Shaner
Could you post the full url.py file? And as Brian mentioned your javascript block should be separated. Plus you have an extra }); that's going to fail once you resolve this reverse error. It's also not clear what you intend to happen when run_DHM returns its response? It looks like your intent is

Re: Please wait page trouble

2010-09-07 Thread Alec Shaner
be a real HTML page as > an example or a live example on the web. I am sorry for the trouble > but I'd like to understand this and get it working. > > On Tue, Aug 31, 2010 at 7:37 PM, Alec Shaner <asha...@chumpland.org> > wrote: > > $.getJSON should be embedded in your in

Re: Discrepancy between model formset and the queryset it's based on

2010-09-01 Thread Alec Shaner
Perhaps see: http://docs.djangoproject.com/en/1.2/topics/forms/formsets/ where it talks about the "extra" keyword that controls how many blank forms to add, the default is 1 On Wed, Sep 1, 2010 at 5:31 PM, ses1984 wrote: > Basically I have a queryset with N items in it,

Re: Please wait page trouble

2010-08-31 Thread Alec Shaner
$.getJSON should be embedded in your initial Page Wait response page. The first argument isn't a view, rather a URL. So you might want to use the django url template tag, e.g., $.getJSON('{% url whatever.run_DHM %}', ...) The second argument is a callback function. The browser stores the

Re: Please wait page trouble

2010-08-31 Thread Alec Shaner
Rolando's suggestion is a pretty straight forward method to achieve what you want. You probably need to elaborate where in the process you're having trouble (although based on your response maybe it's the first step?). You can indeed call a view.my function from your please wait template, but you

Re: Finding current view url in template?

2010-08-24 Thread Alec Shaner
You could set a context variable, e.g., listing_operation = 'Edit' or 'Create'. Or you could use different templates, each inheriting a common template and only doing minor tweaks. On Tue, Aug 24, 2010 at 9:04 AM, reduxdj wrote: > I have some decisions i need to make

Re: flatpages and menu

2010-08-24 Thread Alec Shaner
You could use a context processor to read the flatpage table to build the menu. If you want more control over the menu then create a Menu model and store the flatpage links there and again build the menu in a context processor. You would probably want to use some level of caching if you don't want

Re: select statements with specific fields across multiple tables...

2010-08-16 Thread Alec Shaner
1. What is your code for doing the filters? If you want to start with physical drives it would be something like: RaidPhysicalDrive.objects.filter(in_array__in_storage__in_system__id=) 2. In your template you've referenced pd.in_array_id, but don't you just want pd.in_array if you're wanting to

Re: query evaluation problem

2010-08-16 Thread Alec Shaner
Regarding your issue with get_next, could be because you're invoking the method when you define default=get_next(). Try it with just the bare method name get_next. You could also use the aggregate function instead of creating a new model:

Re: confusing query involving time ranges

2010-08-12 Thread Alec Shaner
Hopefully some django sql guru will give you a better answer, but I'll take a stab at it. What you describe does sound pretty tricky. Is this something that has to be done in a single query statement? If you just need to build a list of objects you could do it in steps, e.g.: # Get all State

Re: queryset field order

2010-08-06 Thread Alec Shaner
You can't use a dictionary if you expect a certain order of key/value pairs. Given model A you could get a list of field objects in the same order (I think) as defined in the model class A._meta.fields At least with that information you could programatically produce a list of data in matching

Re: overriding model.save()

2010-08-05 Thread Alec Shaner
The "new" values are what you just set: in your example, self.a=3 and self.b=4 if you're inside your custom save method. Then you can get the current values from the database from inside your custom save with something like: current = Foo.objects.get(pk=self.pk) and inspect current.b for special

Re: TypeError: decoding Unicode is not supported

2010-08-04 Thread Alec Shaner
with apache. If you put that in your code and it has UTF-8 in both cases then this issue is beyond me. On Wed, Aug 4, 2010 at 4:10 PM, sohesado <gnubun...@gmail.com> wrote: > > > > On Aug 4, 6:48 pm, Alec Shaner <asha...@chumpland.org> wrote: > > I'm no expert on e

Re: TypeError: decoding Unicode is not supported

2010-08-04 Thread Alec Shaner
to use the system default locale > instead: > #. /etc/default/locale > > export LANG > > - > > Have you got any clues what may cause the problem? > > Thank you for your help. > > On Aug 3, 11:31 pm, Alec Shaner <asha...@chumpland.org> wrote: > > unicode giv

Re: TypeError: decoding Unicode is not supported

2010-08-03 Thread Alec Shaner
unicode gives me nightmares. Taking django out of the picture for a moment: >>> unicode('foo', 'utf-8') u'foo' >>> unicode(u'foo', 'utf-8') Traceback (most recent call last): File "", line 1, in TypeError: decoding Unicode is not supported So I would assume when you run it inside django

Re: is it possible to pass a dynamic list of choices to a select widget?

2010-08-03 Thread Alec Shaner
Based on what you described as your intent, have you looked at ModelChoiceField? You could create a new table, e.g. ProductOptions, that has a foreign key to your Product table. In your form class you can then pass a queryset into the ModelChoiceField that selects only the options for that

Re: about sending email

2010-02-17 Thread shaner
you can try gmail to test too http://ltslashgt.com/2007/07/02/gmail-and-django/ On Feb 17, 9:38 am, Marco Rogers wrote: > Check out this solution for testing emails when in development.  It > allows you to use send_mail and the email output is printed to the > terminal

Re: Downloadable CSV file of Survey?

2010-02-17 Thread shaner
i just added a csv export as an admin action from details here django csv http://docs.djangoproject.com/en/1.1/howto/outputting-csv/#howto-outputting-csv admin actions http://docs.djangoproject.com/en/1.1/ref/contrib/admin/actions/#ref-contrib-admin-actions On Feb 17, 7:49 am, Shawn Milochik

Re: comments in flatpages

2010-02-16 Thread shaner
comments for the flatpage {% get_comment_list for flatpage as comment_list %} {% for comment in comment_list %} {{ comment }} {% endfor %} loads a form to submit new comments {% render_comment_form for flatpage %} On Feb 16, 6:43 pm, shaner <shane.n...@gmail.com> wrote: > anyone setup

comments in flatpages

2010-02-16 Thread shaner
anyone setup comments with flatpages? doesn't appear to be documented anywhere other than each individually, maybe nobody wants it to be too easy -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

m2m in views

2010-01-12 Thread shaner
I'm trying to make a model's detail view, take movies for example; actors are m2m to movies this works but it doesn't feel right is there, i pass this context to the template where i for loop through the actor list >>> Movie.objects.filter(pk=movie_id)[0].character.all() [, ] -- You received

constraints fail importing data

2010-01-05 Thread shaner
INSERT INTO table (col1,col2) SELECT col1,col2 FROM table2 is what i'm trying do, copy some columns from one table to one in django, i get constraints failed i made a test db and tested this and worked, copied the two columns to another table fine, also tried recreating the model w/ blank=true

populate fields

2009-12-29 Thread shaner
new to django, i'm looking for some documentation on how i can populate one model with data from another one is there a dry method for that? i've seen the examples for populating user or slug but i'd just like to go from one model to another for example a support ticket model, and an office