Re: How to move inline into or above fieldsets in django admin?

2010-12-11 Thread Wayne Smith
Well, the template is what controls the ordering of fields. You can create your own template that Django will then use in the admin interface. From there you can control exactly how things are displayed. On Dec 11, 2010 1:30 PM, "mongoose" wrote: > Hi wayne, > > to be honest I've no idea how i'd

Re: can't add via admin, get django template error

2010-12-08 Thread Wayne Smith
On Wed, Dec 8, 2010 at 10:49 AM, JeffH wrote: > So I'm working along, everything's humming fine. Then I try to add a > record via the admin, and get the following: > > TemplateSyntaxError at /admin/expert/expertresponse/add/ > Caught AttributeError while rendering: 'unicode' object has no > attri

Re: When to use Form API

2010-12-08 Thread Wayne Smith
It is important to distinguish between display and functionality with forms. What I mean is, using the forms does not mean you have to render (display) them the way Django has it set up by default. I always use the Form API, and if I need custom validation on a field or the entire form, I overrid

Re: sum() of Model field or DB field

2010-12-07 Thread Wayne Smith
You want to use an aggregation function: http://docs.djangoproject.com/en/dev/ref/models/querysets/#aggregation-functions On Tue, Dec 7, 2010 at 11:14 AM, Jagdeep Singh Malhi < singh.malh...@gmail.com> wrote: > hi > > I want to use mysql Query : > Select sum(field_name) FROM table_name WHERE s

Re: General question about NOT EXISTS...

2010-12-07 Thread Wayne Smith
> > How does that look when you are building an object list in the Q( )... > style format? Where I am hung up is finding syntax examples of how to > do the functional equivalent of a sql where not exists clause. > > Is there a way to do this without using .extra() and using just normal > django? >

Re: admin view

2010-12-07 Thread Wayne Smith
To fire off an action (method) after an object is saved, you want to listen for its signal. Check out http://docs.djangoproject.com/en/dev/topics/signals/ On Mon, Dec 6, 2010 at 11:28 PM, commonzenpython wrote: > hey guys, im trying to get a script to run, like a view after a user > in the admi

Re: How to save data in the model in the second step of a 2-step form?

2010-12-06 Thread Wayne Smith
> > Thanks, that's fine, but I was wondering if there was a more scalable > way. I have more fields than just "description", so it would be nice > if they could be all saved with one method call, so I don't have to > maintain this code in case I change the model. > > If you have multiple fields des

Re: django auth for existing cgi

2010-12-06 Thread Wayne Smith
On Mon, Dec 6, 2010 at 4:42 PM, bc wrote: > Is there any simple way to use django authentication/authorization to > control access to an existing (not django) cgi? > > I could use subprocess.Popen to invoke the cgi after checking > authorization, but the environment needs to be set up to look lik

Re: doing validation in admin form

2010-12-06 Thread Wayne Smith
03:05 AM, Wayne Smith wrote: > > It's hard to say, because I don't know what kind of "validation" or > business > > logic regarding it you are trying to accomplish/employ. > > > > > suppose I want a validation like this: > > the number

Re: Beginner question on admin interface

2010-12-06 Thread Wayne Smith
> > Okay, honestly I believe it will be easier to go from scratch. However > I'd still like to ask, since the idea of having an almost-done admin > interface is very neat. > > > As the other reply indicates, that is a very tall order for a beginner. The admin interface is functional for editing, b

Re: How to save data in the model in the second step of a 2-step form?

2010-12-06 Thread Wayne Smith
> After the second form is done and valid, I would like to save the > information that comes to it to Image, in the same row that has the id > I was passing. > > How can I do this? > > > image.description = information user provided image.save() By the way, your overridden save() method looks a bi

Re: Problem with redirect

2010-12-06 Thread Wayne Smith
On Mon, Dec 6, 2010 at 7:00 AM, Quetzacotl wrote: > Hello, i want to make function that wraps all things related to > comments, so there should be part that gets comments from database and > part that checks if comment was added. Then i can simply write just > one line of code in view where i wan

Re: doing validation in admin form

2010-12-05 Thread Wayne Smith
It's hard to say, because I don't know what kind of "validation" or business logic regarding it you are trying to accomplish/employ. However, if you are wanting to ensure you validate a foto during a gallery save, why not call an overridden fotos.save() from your custom galeria.save()? On Sun, De

Re: Comments by guest and foreign key in model

2010-12-05 Thread Wayne Smith
You might want to use some logic involving anonymous users. See here: http://docs.djangoproject.com/en/dev/topics/auth/#anonymous-users On Sun, Dec 5, 2010 at 2:29 PM, andy wrote: > Well you don't have to make the foreign key field required, that way > comments belonging to guest users can have

Re: how can I clean a form field before the clean method?

2010-12-04 Thread Wayne Smith
Sure. Just override the clean method for the field, or the whole form if you wish. The built-in "default" validation done by Django doesn't handle any logic; it just makes sure the format and type of each field is appropriate. On Dec 4, 2010 1:44 PM, "refreegrata" wrote: > ok, thanks for the ans

Re: not able to see models.DecimalField in template

2010-12-04 Thread Wayne Smith
You shouldn't need to. How are you rendering your fields in your template? On Dec 4, 2010 1:21 PM, "Patrick" wrote: > I have 2 fields in my model: > listing.name and listing.amount > > listing.name shows up in the template but listing.amount does not. Do > I have to convert it to unicode first?