Re: Parsing a complex query with many parentheses, ORs, ANDs, and (hopefully) NOTs

2008-11-21 Thread Michael Keselman
On Nov 21, 2008, at 11:46 PM, Malcolm Tredinnick wrote: > > > On Fri, 2008-11-21 at 22:37 -0500, Michael Keselman wrote: >> Hello, >> >> http://pastie.org/private/xvqf5tgjnimiolakhawgg (relevant code) >> >> Django's QuerySets allow you to do ORs (unions) pretty nicely with >>

Re: Parsing a complex query with many parentheses, ORs, ANDs, and (hopefully) NOTs

2008-11-21 Thread Malcolm Tredinnick
On Fri, 2008-11-21 at 22:37 -0500, Michael Keselman wrote: > Hello, > > http://pastie.org/private/xvqf5tgjnimiolakhawgg (relevant code) > > Django's QuerySets allow you to do ORs (unions) pretty nicely with > Model.manager.filter(Q(...) | Q(...)). However, ANDs don't work quite > as nicely

Re: Dynamic columns in admin changelists

2008-11-21 Thread AndyB
Thanks Malcolm, That was so much easier than I was expecting: class ItemOptions(admin.ModelAdmin): def changelist_view(self, request, extra_context=None): self.list_display = request.session['item_columns'] return super(ItemOptions, self).changelist_view(request,

Parsing a complex query with many parentheses, ORs, ANDs, and (hopefully) NOTs

2008-11-21 Thread Michael Keselman
Hello, http://pastie.org/private/xvqf5tgjnimiolakhawgg (relevant code) Django's QuerySets allow you to do ORs (unions) pretty nicely with Model.manager.filter(Q(...) | Q(...)). However, ANDs don't work quite as nicely in my situation because I want AND to do what

Re: Currency field type in model

2008-11-21 Thread dash86no
Malclom, Thanks for the helpful answer. I need to do numerical work on the values so I think I'll store the currency type in a separate field. Cheers, On Nov 22, 10:54 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2008-11-21 at 17:49 -0800, dash86no wrote: > > I'm have a number

Re: Template tag attribute lookup with abstracted variable

2008-11-21 Thread Malcolm Tredinnick
On Fri, 2008-11-21 at 12:06 -0800, Andy Young wrote: > I'm looking for an elegant way of stepping through my models from > within my template tags. > > I have 3 model classes chained by many-to-many relationships, viz > Category --> Item --> Detail. This model pertains to resume data, > e.g.,

Re: Currency field type in model

2008-11-21 Thread Malcolm Tredinnick
On Fri, 2008-11-21 at 17:49 -0800, dash86no wrote: > I'm have a number of "price" fields in my application. I searched > around the net and it seems to be the case that there are no explicit > currency types in Django. What is the best data type to use for > currency? Would it be decimal? It

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Jeff FW
You could define the CHOICES as a member of your model class, like so: class Movie( Relic ): CHOICES=((u'1','one'), (u'2',u'two')) disk_type = models.CharField( 'Type', max_length=8, choices=CHOICES) Then, in your form: class MovieForm( BasicRelicForm ): disk_type =

Currency field type in model

2008-11-21 Thread dash86no
I'm have a number of "price" fields in my application. I searched around the net and it seems to be the case that there are no explicit currency types in Django. What is the best data type to use for currency? Would it be decimal? Thanks, --~--~-~--~~~---~--~~ You

dynamic method calling

2008-11-21 Thread Chris
Hello everyone, I have a quick python question. Is they a better way of calling a method dynamically then what I have below? Is there a more elegant approach? Thanks in advance. try: push = getattr(self, 'get_%s_content' % self.name) except AttributeError: raise "Method does not exist"

Re: 'QuerySet' object has no attribute '_meta'

2008-11-21 Thread [EMAIL PROTECTED]
You can pass modelformset_factory a kwarg form which should just me the form class you want to use(aka make a ModelForm with the changes to the widgets). Alex On Nov 21, 7:25 pm, ayayalar <[EMAIL PROTECTED]> wrote: > Karen, > > On this note, is it possible to customize the widget's for formsets

Re: 'QuerySet' object has no attribute '_meta'

2008-11-21 Thread ayayalar
Karen, On this note, is it possible to customize the widget's for formsets as well? Thank you. On Nov 21, 3:23 pm, ayayalar <[EMAIL PROTECTED]> wrote: > Thanks Karen. That's exactly the case. Link you provided very helpful. > > On Nov 21, 3:00 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > >

Re: Flatpage App vs. Static Template

2008-11-21 Thread Caisys
Thank you all, it's my first django project and its nice to be reassured ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To

Re: 'QuerySet' object has no attribute '_meta'

2008-11-21 Thread ayayalar
Thanks Karen. That's exactly the case. Link you provided very helpful. On Nov 21, 3:00 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Fri, Nov 21, 2008 at 4:22 PM, ayayalar <[EMAIL PROTECTED]> wrote: > > > I am just simply trying to display all existing objects in a form > > > MODEL: > >

Re: New Django user: How do I return the server's IP address?

2008-11-21 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Where can I get the Host server's IP address? > > request.META['SERVER_NAME'] simply returns localhost instead of > whatever my ip address is > > Try import socket socket.gethostbyname(request.META['SERVER_NAME']) regards Steve

Re: New Django user: How do I return the server's IP address?

2008-11-21 Thread Karen Tracey
On Fri, Nov 21, 2008 at 5:14 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote: > > Where can I get the Host server's IP address? > > request.META['SERVER_NAME'] simply returns localhost instead of > whatever my ip address is > Your machine likely has more than one IP address: one for each network

Re: Where are you developing your python?

2008-11-21 Thread Ovnicraft
2008/11/21 Tim Chase <[EMAIL PROTECTED]> > > > Just wondering where everyone is developing there pythong code? > > Anyone using development environments, if so which one? > > I'm from the old-school of folks that just use a text-editor (Vim > in my case). I tend to run it within "screen", with

Re: 'QuerySet' object has no attribute '_meta'

2008-11-21 Thread Karen Tracey
On Fri, Nov 21, 2008 at 4:22 PM, ayayalar <[EMAIL PROTECTED]> wrote: > > I am just simply trying to display all existing objects in a form > > MODEL: > class Product(models.Model): >name = models.CharField(max_length=30) > >def __unicode__(self): >return self.name > > VIEW > def

Re: Help with GeoDjango and Google Maps, please...

2008-11-21 Thread Ariel Mauricio Nunez Gomez
ChrisK, I use: * from django.contrib.gis.geos import fromstr gpoly=GPolygon(fromstr(poly.wkt, srid=4326))* --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Where are you developing your python?

2008-11-21 Thread Tim Chase
> Just wondering where everyone is developing there pythong code? > Anyone using development environments, if so which one? I'm from the old-school of folks that just use a text-editor (Vim in my case). I tend to run it within "screen", with the following windows/screens: - editor (vim)

New Django user: How do I return the server's IP address?

2008-11-21 Thread [EMAIL PROTECTED]
Where can I get the Host server's IP address? request.META['SERVER_NAME'] simply returns localhost instead of whatever my ip address is Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Template tag attribute lookup with abstracted variable

2008-11-21 Thread Andy Young
I'm looking for an elegant way of stepping through my models from within my template tags. I have 3 model classes chained by many-to-many relationships, viz Category --> Item --> Detail. This model pertains to resume data, e.g., Category='Education', Item='Univ1', Detail='Biology coursework'.

Re: Help with GeoDjango and Google Maps, please...

2008-11-21 Thread ChrisK
Well, this is interesting. The problem seems to be that GPolygon calls self.latlng_from_coords(poly.shell.coords) to unpack the coordinates. I handed in 2D points for the shell coordinates, but somewhere along the line, a third coordinate of "almost zero" in floating point was added to every

'QuerySet' object has no attribute '_meta'

2008-11-21 Thread ayayalar
I am just simply trying to display all existing objects in a form MODEL: class Product(models.Model): name = models.CharField(max_length=30) def __unicode__(self): return self.name VIEW def product(request): product = Product.objects.all() form =

Where are you developing your python?

2008-11-21 Thread prem1er
Just wondering where everyone is developing there pythong code? Anyone using development environments, if so which one? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: model.Model has no attribute 'objects'

2008-11-21 Thread craic
as soon as i posted i found the fix. my model needs to define the objects and point to the custom manager, ie class Raw(models.Model): objects = DBManager() On Nov 21, 11:54 am, craic <[EMAIL PROTECTED]> wrote: > I have a class called Raw which extends model. Much like every other >

model.Model has no attribute 'objects'

2008-11-21 Thread craic
I have a class called Raw which extends model. Much like every other class. Except, i'm using the method on this page to connect to a different DB. In the admin tool, all is lovely. I can view and add new "Raw" objects. http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/

Re: Using a HTML to fire off a data processing script on the server (REST or SOAP)

2008-11-21 Thread Jeff Anderson
Shao wrote: > Dear ALL, > > I am very much interested in using a HTML to fire off a data > processing script to run over the internet. > > I will be very grateful if you can advise me on passing parameters > from an HTML form to a script and fire the script off to carry out > full execution,

Re: Keeping fields out of the Admin

2008-11-21 Thread maeck
Please note that the result of this is that if you use 'editable=False' this field is not visible in the admin at all. As far as I know there is no good way (see below) of putting read only data in an admin page. You could however, create a read only widget (there are some examples to be fund on

Re: NoReverseMatch question

2008-11-21 Thread goblue0311
ok, the view function I'm using appears to be importable - because if I remove the line "print item.get_absolute_url()", the view function is called appropriately, with the odd exception that all instances where the template is calling "get_absolute_url( )" are resolving to the same page. A clue

Re: Auto-notify outside/API services when instance Updated - Best Practices?

2008-11-21 Thread Rajesh Dhawan
On Nov 20, 3:40 pm, "John.R" <[EMAIL PROTECTED]> wrote: > I'm working with an Event Model that, when saved (and possibly when > updated) needs to run some custom Python code to notify some outside > APIs - Twitter, Pownce, Google Calendar for instance. > > I know enough to implement Signals so

Re: order_by function

2008-11-21 Thread Rajesh Dhawan
> Can I order_by a function within the model? I know you can list them > in the admin inteface, etc. But can you order_by a model function? Or > would you have to write a custom piece of code to do that? In addition to the two solutions that John mentioned, you can do the following in many

Re: order_by function

2008-11-21 Thread John M
I wanted the same thing long ago, you have a couple of choices: 1. Use custom SQL functions (but kinda locks u in), 2. Use the python sort function. This basically takes ur queryset, turns it into a list and then sorts it. Since all querysets are just lists in python you can do this:

Re: Using just one custom manager

2008-11-21 Thread John M
Spoksss, I brought this up as a BUG? subject and got some traction from Malcom. Malcom opened a tracking ticket to get it fixed. I was able to work around it by sending some querysets to my view before, instead of using the related sets in the view. If you'd like to see my work around, please

Re: order_by function

2008-11-21 Thread Емил Иванов / Emil Ivanov
Check out http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields 2008/11/21 Luke Seelenbinder <[EMAIL PROTECTED]>: > > Can I order_by a function within the model? I know you can list them > in the admin inteface, etc. But can you order_by a model function? Or > would you have

Re: Flatpage App vs. Static Template

2008-11-21 Thread DavidA
I do something like you are suggesting: I actually write my "flat" pages in Markdown since I prefer it to HTML, and I keep the contents in a file instead of the database, so I can edit them with Emacs. Then I just route these special pages to a trivial template that uses the markdown filter to

Re: NoReverseMatch question

2008-11-21 Thread Jarek Zgoda
Wiadomość napisana w dniu 2008-11-21, o godz. 15:40, przez goblue0311: > Thanks for the suggestion! > > This code came from the basicApps collection, so I'm not sure why > they're using a Word regex to match the day, I'm going to try changing > that to Digit. > > However, I did remove the

order_by function

2008-11-21 Thread Luke Seelenbinder
Can I order_by a function within the model? I know you can list them in the admin inteface, etc. But can you order_by a model function? Or would you have to write a custom piece of code to do that? Thanks, Luke --~--~-~--~~~---~--~~ You received this message

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Donn
On Friday, 21 November 2008 13:46:35 Daniel Roseman wrote: > There is an alternative, though: instead of overriding the fields > declaratively, you can define a formfield_callback function. This seems interesting. I have searched the docs online for 'formfield_callback' and get no useful

Re: NoReverseMatch question

2008-11-21 Thread goblue0311
good call - I repeated my concern below before I saw your response, so please disregard. On Nov 21, 9:35 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > Wiadomość napisana w dniu 2008-11-21, o godz. 15:22, przez goblue0311: > > > Another note if interest is that the error message is citing the > >

Re: NoReverseMatch question

2008-11-21 Thread goblue0311
Thanks for the suggestion! This code came from the basicApps collection, so I'm not sure why they're using a Word regex to match the day, I'm going to try changing that to Digit. However, I did remove the underscore from my slug, so now it's just 'secondPost', and I get the same error. I also

Re: NoReverseMatch question

2008-11-21 Thread Jarek Zgoda
Wiadomość napisana w dniu 2008-11-21, o godz. 15:22, przez goblue0311: > Another note if interest is that the error message is citing the > keyword arguments in the order year, slug, day, and month. However, > get_absoloute_url and the urls.py function use year, month, day, and > slug. Maybe I

Re: NoReverseMatch question

2008-11-21 Thread Alex Koshelev
You have an underscore in slug - "second_post" but your regex doesn't allow it - "[-\w]+". I think it is the problem. And why you did you choose "\w" for day? On Fri, Nov 21, 2008 at 17:16, goblue0311 <[EMAIL PROTECTED]> wrote: > > Hi all: > > I'm receiving this error: > >

Re: NoReverseMatch question

2008-11-21 Thread goblue0311
Another note if interest is that the error message is citing the keyword arguments in the order year, slug, day, and month. However, get_absoloute_url and the urls.py function use year, month, day, and slug. Maybe I have some outdated code here, but where would it reside?

NoReverseMatch question

2008-11-21 Thread goblue0311
Hi all: I'm receiving this error: #* NoReverseMatch at /blog/ Reverse for 'blog_detail' with arguments '()' and keyword arguments '{'year': 2008, 'slug': u'second_post', 'day': 21, 'month': 'nov'}' not found." #* when I

How to test request.session after HttpResponseRedirect?

2008-11-21 Thread Florencio Cano
Hi! Is there any way to access request.session from a unit test if I have a response that is a HttpResponseRedirect. I know HttpResponse have the attribute session but HttpResponseRedirect does not. I've read that HttpResponseRedirect is a subclass of HttpResponse, can I access to the

Re: configuring production server for static media

2008-11-21 Thread Serdar T.
For posterity, I should point out that Graham's suggestion did indeed work and the final set of problems stemmed from my django app code. I had copied over some old code from my development environment to the production server, but the dev server was running an older version of django so the code

Re: Request object from models

2008-11-21 Thread barbara shaurette
Yeah, you want to assign that user_id value in the view, when you're saving the instance: mydocument.author_id = request.user.id mydocument.save() Are you trying to solve for a case where you want the current *admin* user to be the author_id for the record? You can also add a save

Re: Request object from models

2008-11-21 Thread Steve Holden
FT wrote: > class Document(models.Model): > > created = models.DateTimeField( > help_text='Timestamp when the document is created', > blank=True, > default=datetime.datetime.now) > > author = models.EmailField(blank=True, default=request.user) > > Hi there, > > I'm

Re: django site within 7 hours (a day)

2008-11-21 Thread tom
> Although the submit button at the top doesn't seem to work... the submit button should work now and it is also possible to add releases to an application. looking forward having your app listed! have a nice day! tom --~--~-~--~~~---~--~~ You received this

Re: Request object from models

2008-11-21 Thread Alex Koshelev
No. Request object does not exist when model classes are created. On Fri, Nov 21, 2008 at 13:47, FT <[EMAIL PROTECTED]> wrote: > > class Document(models.Model): > >created = models.DateTimeField( >help_text='Timestamp when the document is created', > blank=True, >

Re: Flatpage App vs. Static Template

2008-11-21 Thread Malcolm Tredinnick
On Fri, 2008-11-21 at 03:29 -0800, Caisys wrote: > Hi, > I would like to publish some statics files on my website and I have a > some questions: > 1- The flatpage app examples like http://www.lawrence.com/about/staph/ > contain elaborate html, is this edited as a text field in the admin >

Re: Flatpage App vs. Static Template

2008-11-21 Thread Daniel Roseman
On Nov 21, 11:29 am, Caisys <[EMAIL PROTECTED]> wrote: > Hi, > I would like to publish some statics files on my website and I have a > some questions: > 1- The flatpage app examples likehttp://www.lawrence.com/about/staph/ > contain elaborate html, is this edited as a text field in the admin >

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Daniel Roseman
On Nov 21, 9:09 am, Donn <[EMAIL PROTECTED]> wrote: > On Friday, 21 November 2008 08:06:32 urukay wrote: > > > easy way how to solve it is to put definition of your choices out of model > > definition: > > Yeah, that's what I call a 'global', but is there no way to get the choices > from the

Flatpage App vs. Static Template

2008-11-21 Thread Caisys
Hi, I would like to publish some statics files on my website and I have a some questions: 1- The flatpage app examples like http://www.lawrence.com/about/staph/ contain elaborate html, is this edited as a text field in the admin interface, wouldn't it be tedious to maintain? 2- Can i do something

Request object from models

2008-11-21 Thread FT
class Document(models.Model): created = models.DateTimeField( help_text='Timestamp when the document is created', blank=True, default=datetime.datetime.now) author = models.EmailField(blank=True, default=request.user) Hi there, I'm trying to set up a default value the

Re: Using just one custom manager

2008-11-21 Thread Spoksss
Hello, I have the same problem with entry_set in my related_manager. On 8 Lis, 05:32, John M <[EMAIL PROTECTED]> wrote: > DR, > > Now I have a new problem.  When I use this as a related_manager > (Report.objects.all()[0].task_set.accomplishments()) it returns all > the accomplishments.  I've

Re: Dynamic columns in admin changelists

2008-11-21 Thread Malcolm Tredinnick
On Fri, 2008-11-21 at 02:08 -0800, AndyB wrote: > I basically would like some way for staff users to choose which > columns are displaying in an object's changelist. > > So far I've got an ugly solution which I can actually have some idea > how to implement and the 'correct' solution which

Dynamic columns in admin changelists

2008-11-21 Thread AndyB
I basically would like some way for staff users to choose which columns are displaying in an object's changelist. So far I've got an ugly solution which I can actually have some idea how to implement and the 'correct' solution which requires quite a lot of digging in the django internals. The

Re: Validating two forms in one

2008-11-21 Thread Malcolm Tredinnick
On Fri, 2008-11-21 at 10:28 +0100, Florencio Cano wrote: > Hello all, > I have two models called User and Responsible. When I add a > Responsible automatically a User is added. I have only one form to add > a User and a Responsible. > > class NewUserResponsibleForm(forms.Form): > username =

Validating two forms in one

2008-11-21 Thread Florencio Cano
Hello all, I have two models called User and Responsible. When I add a Responsible automatically a User is added. I have only one form to add a User and a Responsible. class NewUserResponsibleForm(forms.Form): username = forms.CharField(max_length=30) password =

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread urukay
u can use ModelForm and you don't have to write choices. Don't know any other way. But I don't suppose there is other way, these two "ways" can solve everything, I think. Or maybe someone else would help R. Donn Ingle wrote: > > > On Friday, 21 November 2008 08:06:32 urukay wrote: >> easy

Re: Problems with file upload and model forms

2008-11-21 Thread Marc Barranco
Oh yeah!! It was that! Thank you veru much Alex :) I forgot to put the template code, Here it is (mayb useful for some other): --upload.html-- {% for field in form %} {{ field.label_tag }} {{ field }}

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Donn
On Friday, 21 November 2008 08:06:32 urukay wrote: > easy way how to solve it is to put definition of your choices out of model > definition: Yeah, that's what I call a 'global', but is there no way to get the choices from the field in the model class? \d

change in admin template django/contrib/admin/templates/widget

2008-11-21 Thread [EMAIL PROTECTED]
hi all, i am using debian etch stable version 0.95 please i would like to know if there is a way to change admin, when displaying link "Currently" in models.BooleanField. When i have images locally this can be done just by changing urls.py . But when i copy this file to another server during