Re: Model Formsets.save(commit=False) behaviour

2009-05-09 Thread Margie
I've used that a lot and never had a problem. I'd recommend stepping through the code. When you call save, you go into the save() function in django/forms/models.py, which immediatey takes you into the save_Instance() method. That code is quite straight forward. At the bottom it just looks at

Re: simpletag to accumulate media without duplicates

2009-05-09 Thread Dan Mallinger
Hi Margie, I'm not sure off the top of my head, but if memory serves me right, template tags may not allow variable number of parameters. I'd take a look at the code from the {% url %} template tag, it's syntax allows for multiple variables, but they're passed in a very particular way. It's actu

simpletag to accumulate media without duplicates

2009-05-09 Thread Margie
I want to write a templatetag that goes through a bunch of media and returns the media lines without duplicates, something like this (except I'm not removing duplicates here, not sure if the '+' is going do it for me or not). def form_media(*args): finalFormMedia = Media() for formMedia i

exclude subquery executed twice?

2009-05-09 Thread Henry Andrews
Hi folks, When excluding using a subquery, I'm seeing the subquery being executed first as its own query, then seeing the correct query being run, including the subquery. Using filter instead of exclude, this does not happen. Just wanted to see if I'm missing something obvious/ well known or i

Re: How do I execute a python module within the context of a Django project?

2009-05-09 Thread Roberto Cea
Thanks, super fast, too. R. On May 9, 10:21 pm, James Bennett wrote: > On Sat, May 9, 2009 at 9:52 PM, Roberto Cea wrote: > > Here's a fairly basic question: how do I execute an arbitrary python > > module within the context of a given Django project, with access to > > its models, etc.? Curre

Re: How do I execute a python module within the context of a Django project?

2009-05-09 Thread James Bennett
On Sat, May 9, 2009 at 9:52 PM, Roberto Cea wrote: > Here's a fairly basic question: how do I execute an arbitrary python > module within the context of a given Django project, with access to > its models, etc.? Currently, I load it from a "manage.py shell" > session, but I'm sure there's a more

How to solve value error

2009-05-09 Thread Nalini
Hi, I am getting this value error in my report. i am using pagination fro my report. I have only 2 records in my database. so in order to check whether my pagination works i gave { % autopaginate Data 1 % } so that each record will get displayed in two different pages. when i generate my report t

Model Formsets.save(commit=False) behaviour

2009-05-09 Thread gorans
Hi all, I'm trying to use the .save(commit=False) method on a model formset in my view but for some strange reason, the django code executes the model's save method. My understanding of the docs is that when (commit=False) is passed - the formset will return a list of model instances but not com

Re: How to disable deletion af a model instance

2009-05-09 Thread Margie
I thought that might be the case. Is that true of the deletes done by a formset save as well? IE, when a formset.save() is done, in some cases my delete will be called, and in some cases not? Margie On May 9, 4:57 pm, James Bennett wrote: > On Sat, May 9, 2009 at 7:49 PM, George Song wrote:

How do I execute a python module within the context of a Django project?

2009-05-09 Thread Roberto Cea
Here's a fairly basic question: how do I execute an arbitrary python module within the context of a given Django project, with access to its models, etc.? Currently, I load it from a "manage.py shell" session, but I'm sure there's a more straightforward way to do it, no? --~--~-~--~~--

"-" in template variables

2009-05-09 Thread Danne
I'm using the Tumblr (http://www.tumblr.com) REST Api, and keys in returned json contains the character "-", like "post": {"regular- title": "asdf" .}. I'm having trouble printing this in the django templates since regular-title is an invalid variable name. I've tried stuff like: post["regular

Re: How to disable deletion af a model instance

2009-05-09 Thread James Bennett
On Sat, May 9, 2009 at 7:49 PM, George Song wrote: > I think if you want to know definitively if your `delete()` method is > being called or not, your debug statement should go in that method. I > wouldn't be surprised if Django is sending pre and post delete signals > even during bulk deletion.

Re: How to disable deletion af a model instance

2009-05-09 Thread George Song
On 5/9/2009 12:34 PM, Margie wrote: > I've had my share of confusion over delete. Here's a thread that I > had with Malcolm recently: > > http://groups.google.com/group/django-users/browse_thread/thread/582f21486c1073eb/7f5743953047d9fa?lnk=raot&fwc=1 > > However, I guess I'm still quite confus

Re: Test suite for Django tutorial?

2009-05-09 Thread Charles Anderson
--- On May 8, 10:09 pm, Russell Keith-Magee wrote: > On Sat, May 9, 2009 at 6:09 AM, Charles Anderson > wrote: > > Before I go off and re-invent the wheel, does anyone have a unit/ > > functionaltestfor theDjangopolltutorial(http:// > > docs.djangoproject.com/en/dev/intro/tutorial01/)? > Unfort

Re: 'base' template

2009-05-09 Thread lisa holper
No, sorry there is a misunderstanding. I did not use Apache, but just copied the html files in my directory of my homepage. So, this does not work? Do I need to use Apache? thanks again, Lisa On Sat, May 9, 2009 at 7:02 AM, Eric Abrahamsen wrote: > > On May 9, 2009, at 1:21 PM, lisa holper wro

Re: Use django error style in my templates

2009-05-09 Thread Gabriel
Laszlo Antal escribió: > Hi, > > I wrote my custome admin view and I would like to have the same error > reporting style for edit templates like django's. > > Could someone point me in the right direction on how to have the message > on the top of the page and the red color for the input boxes

Re: How to disable deletion af a model instance

2009-05-09 Thread Margie
I've had my share of confusion over delete. Here's a thread that I had with Malcolm recently: http://groups.google.com/group/django-users/browse_thread/thread/582f21486c1073eb/7f5743953047d9fa?lnk=raot&fwc=1 However, I guess I'm still quite confused. One thing I don't understand is when the "b

Re: Problem with prepopulating model form.

2009-05-09 Thread zayatzz
Thanks for the advice- it worked like a charm and i guess that was the better way to do it. But lets say i do need to create new item into database - new revision of an edited article. In that case the code i posted previously should work, or should it not? And why does'nt it work? Alan On May

Re: timeuntil filter

2009-05-09 Thread adrian
Yes, I discovered the problem was my TIME_ZONE setting did not match the system time zone, and I'm on Windows. I think the comment about offset-naive only applies to cases where you supply an optional comparison date, but it doesn't say so. On May 9, 1:38 pm, George Song wrote: > On 5/9/2009 11

Re: timeuntil filter

2009-05-09 Thread George Song
On 5/9/2009 11:28 AM, adrian wrote: > > This filter is returning an empty string for a valid date (or datetime > with 0,0,0 added) in > Django 1.0.2. > > The documentation for this says: > >> Comparing offset-naive and offset-aware datetimes will return an empty >> string. > > but it doesn't

Re: Problem with prepopulating model form.

2009-05-09 Thread Daniel Roseman
On May 9, 1:24 pm, zayatzz wrote: > Hello > > I've been trying to figure out how to use modelforms and so far ive > managed to do things on my own. But now im trying to prepopluate > modelform and it does not work - not completely anyway. > > Model: > from django.db import models > from tinymce i

Overwrite send_mail

2009-05-09 Thread Dougal
Hi, is there a hook to help me replace the django send_mail function? I know I can just create my own but I want a nice easy way to handle emails my own way for a bunch of apps and it seems almost all re- usable apps tend to use send_mail. I've hunted but can't find anything in the docs Cheers

timeuntil filter

2009-05-09 Thread adrian
This filter is returning an empty string for a valid date (or datetime with 0,0,0 added) in Django 1.0.2. The documentation for this says: > Comparing offset-naive and offset-aware datetimes will return an empty string. but it doesn't say which type it uses. Shouldn't this say something like:

question about why query filter is not working.

2009-05-09 Thread Aaron
HI, I am working on a ad rotation system. currently I got 2 problems. first problem is that I can display an ad grabphic on only the main index site the home area. However I can't see the ads when you click on navigation tabs to go to other pages on our site. The other problem is that we a

Re: 'NoneType' object is not iterable

2009-05-09 Thread Kalle
Hi Malcolm, Thank you very much for the detailed answer! Everything is working OK now. ///Kalle On May 8, 11:53 pm, Malcolm Tredinnick wrote: > On Fri, 2009-05-08 at 11:24 -0700,Kallewrote: > > Hi, > > > I'm just started to play with Django, and ran into this problem right > > away. > > > *

Re: How to disable deletion af a model instance

2009-05-09 Thread Rune Bromer
On May 9, 5:33 pm, George Song wrote: > On 5/9/2009 7:14 AM, Rune Bromer wrote: > > Hi, > > If you already did an override on `Payment.delete()`, then you should be > fine. > > Although be mindful of bulk delete, as it doesn't use `Model.delete()`: >

Re: Print question

2009-05-09 Thread Masklinn
On 9 May 2009, at 17:49 , George Song wrote: > > Does `pprint.pprint(obj.__dict__)` not do what you want? > Since __dict__ isn't recursive, I'd wager he's going to be unhappy with that solution. --~--~-~--~~~---~--~~ You received this message because you are subs

Re: Ajax and non-ajax forms.

2009-05-09 Thread esatterwh...@wi.rr.com
most javascript frameworks have a way to stop to propagation of an event - say when you click a link. jQuery: Event.stopImmidiatePropigation() MooTools: Event.stop() Both of them i think( i know mootools does ) have a way of dealing with patterns of selectors. say all of the links have an ID that

Re: django ifequal crush in chinese

2009-05-09 Thread Karen Tracey
On Sat, May 9, 2009 at 6:10 AM, linvar wrote: > > hello everybody: > i cannot use {% ifequal var1 var2 %} to test if equal when > var1,var2 are UTF8 encoding. but if var1,var2 are ansi that is ok. you > know i am in chinese and alway catche such ugly encoding problem. > anyone can help. >

Re: Print question

2009-05-09 Thread George Song
Does `pprint.pprint(obj.__dict__)` not do what you want? On 5/9/2009 8:41 AM, phoebebright wrote: > Masklinn, > > Thanks. I see what you mean about being bored! But that's a big step > forward for me. > > As a PHP convert to Django/Python, I'm looking for the equivalent of > print_r > > On Ma

Re: Print question

2009-05-09 Thread Masklinn
On 9 May 2009, at 17:41 , phoebebright wrote: > Masklinn, > > Thanks. I see what you mean about being bored! But that's a big step > forward for me. > > As a PHP convert to Django/Python, I'm looking for the equivalent of > print_r There isn't one. Though there's the `dir` builtin which will disp

Re: Print question

2009-05-09 Thread phoebebright
Masklinn, Thanks. I see what you mean about being bored! But that's a big step forward for me. As a PHP convert to Django/Python, I'm looking for the equivalent of print_r On May 9, 4:31 pm, Masklinn wrote: > On 9 May 2009, at 16:37 , phoebebright wrote: > > > Not looking for a discussion on

Re: How to disable deletion af a model instance

2009-05-09 Thread George Song
On 5/9/2009 7:14 AM, Rune Bromer wrote: > Hi, > > I run a small project handling payments from users. Each user has the > possibility to delete their account and if they do I have to keep > their payment data. Also, I would like to disable admins from deleting > the data as there are NEVER a vali

Re: Print question

2009-05-09 Thread Masklinn
On 9 May 2009, at 16:37 , phoebebright wrote: > Not looking for a discussion on debug methods, just want to know if > there is any way to print an object. > > eg. print myobject OR pprint.pprint(myobject) > > just says something like > > > > And unless I know the structure of the object I can't

Use django error style in my templates

2009-05-09 Thread Laszlo Antal
Hi, I wrote my custome admin view and I would like to have the same error reporting style for edit templates like django's. Could someone point me in the right direction on how to have the message on the top of the page and the red color for the input boxes. Thank you Laszlo Antal --~--~---

Re: Only show field in admin for superuser

2009-05-09 Thread phoebebright
Just a postscript to this - this will fail if the field being left out is a required field. The admin form will show an error but as the field is missing you will not know what the error is. I think with the new hidden_fields option, this will be a workaround. On Apr 23, 8:20 pm, phoebebright

Print question

2009-05-09 Thread phoebebright
Not looking for a discussion on debug methods, just want to know if there is any way to print an object. eg. print myobject OR pprint.pprint(myobject) just says something like And unless I know the structure of the object I can't access the values. I'm probably going to get a blasting for

How to disable deletion af a model instance

2009-05-09 Thread Rune Bromer
Hi, I run a small project handling payments from users. Each user has the possibility to delete their account and if they do I have to keep their payment data. Also, I would like to disable admins from deleting the data as there are NEVER a valid reason to do so. The payment model has foreign key

Re: 'base' template

2009-05-09 Thread ricardoandrademendo...@gmail.com
If you can see it properly in the django server but not in apache, and you see poor text instead of layout, my guess is apache can't access or find your MEDIA_URL location (check symlink or file permissions), so it does not load your images and css. also, check your apache2/access.log xau On May

Re: Error message in admin - row level permissions

2009-05-09 Thread phoebebright
A victim of my own cleverness! Part of the row permissions was to prevent the owner changing ownership, so I had this in the admin form: def get_fieldsets(self, request, obj=None): if request.user.is_superuser or request.user.has_perm ('town.admin_business'):

django ifequal crush in chinese

2009-05-09 Thread linvar
hello everybody: i cannot use {% ifequal var1 var2 %} to test if equal when var1,var2 are UTF8 encoding. but if var1,var2 are ansi that is ok. you know i am in chinese and alway catche such ugly encoding problem. anyone can help. thanks advanced! --~--~-~--~~~--

Re: Error message in admin - row level permissions

2009-05-09 Thread phoebebright
Is this a clue? Got this info from forcing an error at the top of the form. Permissions are correct but seems to think there is a field missing, but not saying which one. Tried making sure there is data in every field but still no change. Just to confirm, I can save this with a user with table

Re: environment variable DJANGO_SETTINGS_MODULE is undefined

2009-05-09 Thread NoviceSortOf
I'm not the world's leading expert -- but today I've solved the problem inside of my current python shell using os.environ.keys() I'll attempt to outline the basics, ">>>" indicates what i typed on the python shell command line "$" indicates what echoes back >>>import os # now to see what envi

Problem with prepopulating model form.

2009-05-09 Thread zayatzz
Hello I've been trying to figure out how to use modelforms and so far ive managed to do things on my own. But now im trying to prepopluate modelform and it does not work - not completely anyway. Model: from django.db import models from tinymce import models as tinymce_models class article(model

Re: 'base' template

2009-05-09 Thread Eric Abrahamsen
On May 9, 2009, at 1:21 PM, lisa holper wrote: > Hi, > > I thanks for your answer again. > Everything is showing up as plain text! It seems that the template > base.html would not be used. > > Do you have a further idea? Nothing very likely, sorry to say. It sounds like your main problem is

Re: Wrapping object_detail generic view in another view

2009-05-09 Thread Jamie Pittock
Thanks George. On May 7, 9:32 pm, George Song wrote: > On 5/7/2009 1:01 PM, Jamie Pittock wrote: > > > Basically, am I doing things right, and if so which is the best > > solution from the above? > > Yup, you are doing things correctly as far as I can tell. > > As for creating a custom method or

Re: models.ForeignKey('self' ... -> Can't create new elem

2009-05-09 Thread Bro
Yes but I've just try to delete de .db file (I user sqlite3) I syncdb and It works now :) Thanks Alex for your good advice :) On 9 mai, 11:00, Alex Gaynor wrote: > On Sat, May 9, 2009 at 10:58 AM, Bro wrote: > > > Here is the code : > > > class Category(models.Model): > >    parent = models.Fo

Re: models.ForeignKey('self' ... -> Can't create new elem

2009-05-09 Thread Alex Gaynor
On Sat, May 9, 2009 at 10:58 AM, Bro wrote: > > Here is the code : > > class Category(models.Model): >parent = models.ForeignKey('self', blank=True, null=True) >name = models.CharField(max_length=63) >def __unicode__(self): >return self.name > > I don't understand why but when

models.ForeignKey('self' ... -> Can't create new elem

2009-05-09 Thread Bro
Here is the code : class Category(models.Model): parent = models.ForeignKey('self', blank=True, null=True) name = models.CharField(max_length=63) def __unicode__(self): return self.name I don't understand why but when I create a category in the admin page, there is this error

Error message in admin - row level permissions

2009-05-09 Thread phoebebright
I have almost implemented a row level permissions facilitiy for a model in my app. I can change the owner of the record Display only their records in admin But when logged in as the owner and click Save on the edit screen I get the error "Please correct the error below." but no indication of what

Django Logging

2009-05-09 Thread Raashid Malik
Hello, I m using django-logging module and able to see log messages at the bottom of browser. I m also able to create a file. But what u want is that i should be able to create an HTML file and all the logs should be appended. -- Thanks, Raashid Malik --~--~-~--~~~