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 model,

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 an

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 thi

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 django-us...@

Re: comments in flatpages

2010-02-16 Thread shaner
d comments %} loads 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 wrote: > anyone setup comments with

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: 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 (the one running the run

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 product

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 you're

Re: TypeError: decoding Unicode is not supported

2010-08-04 Thread Alec Shaner
LANG > > ----- > > Have you got any clues what may cause the problem? > > Thank you for your help. > > On Aug 3, 11:31 pm, Alec Shaner wrote: > > unicode gives me nightmar

Re: TypeError: decoding Unicode is not supported

2010-08-04 Thread Alec Shaner
ng special 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 wrote: > > > > On Aug 4, 6:48 pm, Alec Shaner wrote: > > I'm no expert on encodings so I can only suggest some alter

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: 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 or

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 obje

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: http://docs.djangoproject.com/en/1.2/topics/db/aggregation

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: 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: 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 in my template based on 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 w

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 callback

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, which I use to create

Re: Please wait page trouble

2010-09-07 Thread Alec Shaner
ML 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 > wrote: > > $.getJSON should be embedded in your initial Page Wait response page.

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-09 Thread Alec Shaner
>(r'^rotamer_diff/$', rotamer_dif_frame), >(r'^side-by-side/$', side_by_side), >(r'^side-by-side-key/$', side_by_side_key), >(r'^side-by-side-frame/$', side_by_side_frame), > (r'^DHM_run/$', run_DHM), >(r&#x

Re: Please wait page trouble

2010-09-09 Thread Alec Shaner
t results from session >return render_to_response('ran_DHM.html', ...) > > '# Get results from session' Would I not just do this: > > def display_DHM(request): >return render_to_response('DHM_ran.html', request.session, ...) > > Or do I have

Re: Please wait page trouble

2010-09-09 Thread Alec Shaner
} else { > alert(data); >} >} >}); > > > an of course configure url.py and view.py as explained previously. Is > there an easy way to do this? In other words, what are the > If_come_from_pageA and If_come_from_pageB conditions? Can

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 subscribed to the Google Groups "Djan

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, > self.tomorrow)) > > It retur

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', 'Exa

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 wro

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 Apache. > See > http:

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 variation

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 already filled in on the email for

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 >>> >>> On 14 ต.ค. 2010, at 22:27, Marc Aymerich wrote: >>> >>> Hi, >>

Re: Help with Manager.

2010-10-14 Thread Alec Shaner
t 5:57 PM, Marc Aymerich wrote: > > > On Thu, Oct 14, 2010 at 10:08 PM, Alec Shaner wrote: >> >> See this: >> >> http://ifacethoughts.net/2009/07/14/calculated-fields-in-django/ >> >> So perhaps the 'extra' query filter is what you need. >>

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 wrote: > > > On Fri, Oct 15, 2010 at 3:39 AM, Alec Shaner wrote: >> >> You can't add a datetime to another datetime - you want to add a

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 datet

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 much alec! > > -- > Ma

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

2010-10-15 Thread Alec Shaner
is a ticket to add F() + timedelta. http://code.djangoproject.com/ticket/10154 On Fri, Oct 15, 2010 at 2:48 PM, Marc Aymerich wrote: > > > On Fri, Oct 15, 2010 at 7:54 PM, Alec Shaner wrote: >> >> On Fri, Oct 15, 2010 at 1:26 PM, Marc Aymerich >> wrote: >> > >&

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 wrote: > Interesting solution - after all that maybe it's more concise to just > use the 'extra' filter instead since you're making it speci

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, Da

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 SQL) that I > could do