Re: How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Jumpfroggy
Yes, it was that easy. I don't know why, but I've been banging my head against the wall on this for a while and never thought of this solution. One thing that would really help a ton is more/better examples about file-handling in django. I've spent more hours on this single feature reading & re

Re: site management - maintanance mode

2010-03-13 Thread Jukka Välimaa
That could be done with Django using middleware, like with django-maintenancemode. Only instead of using settings file, the setting could be saved into database, and turned on and off in admin. The middleware reads the setting (preferably cached), and if maintenance mode is on, returns 503 error pa

Re: How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Jumpfroggy
> you could do it manually. first use os.rename to rename the file on the disk, > and then update your model instance with the new name and save it. I think this is what I'm missing. What's the code for this? Can I just do: os.rename(model.file1.name, new_filename) model.file1.n

limit_choices_to a value on a field in the same model

2010-03-13 Thread Brandon Taylor
Evening Everyone, I have a model "Agency" with "state" as a foreign key and "counties" as a many-to-many. County has a foreign key to "state" I would like to limit the County choices in Django admin to the state of the Agency being edited, but, I can't seem to find the right place to get an insta

Re: site management - maintanance mode

2010-03-13 Thread Graham Dumpleton
On Mar 13, 11:21 pm, "Henrik Genssen" wrote: > Hi, > > I have a site that runs on more many hosts. > now hast someone an idea, how to put the whole site (on all hosts) in > "maintanance mode" (keep normal users outside with a nice hint) - > without reloading all webservers and not changing the

Re: How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Kenneth Gonsalves
On Sunday 14 Mar 2010 7:25:08 am Jumpfroggy wrote: > But I want to rename the file on the filesystem. I want something > like this: > > model.file1.rename(new_filename) > you could do it manually. first use os.rename to rename the file on the disk, and then update your model instance w

How do I rename a FileField() that's attached to a model?

2010-03-13 Thread Jumpfroggy
I've gone through the documentation a ton, been trying different techniques, and I know I'm just missing something obvious. I have a model like this: class MyModel(Model): file1 = FileField(...) So I can do this: model = MyModel.objects.get(id=1) print mo

django and buildout

2010-03-13 Thread John Griessen
I kludged together a buildout config to use django-page-cms which depends on django-mptt and it still isn't referencing my locally downloaded svn trunk version of django-mptt. Installing django. Page at http://pypi.python.org/simple/mock/ links to .py file(s) without version info; an index sca

Re: File validation process

2010-03-13 Thread hcarvalhoalves
You could avoid the Javascript check (file extensions are just a convention, rarely thrustable) and just check the uploaded file mimetype on form validation code. `import mimetypes` for more. There's no clean way to interrupt file upload, though. On Mar 12, 11:27 pm, Vincent wrote: > I would li

Re: ifequal issue

2010-03-13 Thread wolle
Hi Bill, thank you for pointing me to the stringformat template option, I was comparing Long with String. Using now try: berufe_id = int(berufe_id.strip()) except: pass What helped me a lot. On Mar 11, 5:18 pm, Bill Freeman wrote: > It's time to go back to figuring out jus

Re: Adding Fields To Querysets

2010-03-13 Thread wubble u
That's great - exactly what I needed thanks very much. The key to it was the views code: for person in people: person.calcs = [ 1, 2, 3 ] I can now assign the calcs reference to a function that returns the result of the calculation for that row, and this can be accessed as part of the qu

Re: View on site

2010-03-13 Thread Robert
Thanks, rebus. When I added an other piece of information to the information in your links, I got this to work. In this case there will be a string, a username, in the url. I have browsed the documentation and it mostly talks about digits. Then you are supposed to put a d+ for instance in the url.

Re: Hierarchical data containing different models

2010-03-13 Thread Iván Raskovsky
Hi Peter, it seems the contenttypes framework [1] is what you are looking for. You can use it to make a relationship between any model instance in your project and a node and not two different ForeignKeys. Hope it helps, Iván [1] http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/

Re: Hierarchical data containing different models

2010-03-13 Thread SteveB.
Worth a look at django-treebeard as a tree library. I'm doing some work with it at the moment and I'm very impressed with it so far. It's pretty easy to separate the different data and connect to a tree- node object. IMO the api for tree work is good and all of the SQL complexity is hidden. You

Re: site management - maintanance mode

2010-03-13 Thread hcarvalhoalves
You can solve this with the server more easily than with the django app itself. I use the Cherokee webserver, and switching to maintenance mode is easy with it. Also, no need to cold-restart (your clients don't get a connection interruption). See how it works here: http://www.cherokee-project.com/

Re: Problem template library loading

2010-03-13 Thread mrsource
Ok you're right now works! I have confused clevercss with dlevercss...and I have forgotten that Django module dlevercss requires clevercss python library. On 13 Mar, 04:23, Karen Tracey wrote: > On Fri, Mar 12, 2010 at 11:37 AM, mrsource wrote: > > I have plugged dlevercss application to my Dj

RE: Re: site management - maintanance mode

2010-03-13 Thread Henrik Genssen
Yes, thanks, but does not work without a restart... >reply to message: >date: 13.03.2010 06:57:06 >from: esatterwh...@wi.rr.com >to: "Django users" >subject: Re: site management - maintanance mode > >http://code.google.com/p/django-maintenancemode/ > >On Mar 13, 6:21 am, "Henrik Genssen" wrote:

Re: _wrapped_view() problems with method_decorator

2010-03-13 Thread Karen Tracey
On Sat, Mar 13, 2010 at 7:59 AM, Aidan Fitzpatrick wrote: > > I've been happily running Django 1.1.1 for a good while. It's excellent. > Being a perfectionist with a deadline, I've wanted to make use of part of > someone else's app which is written against 1.2. So, no problem. I read the > release

Re: site management - maintanance mode

2010-03-13 Thread esatterwh...@wi.rr.com
http://code.google.com/p/django-maintenancemode/ On Mar 13, 6:21 am, "Henrik Genssen" wrote: > Hi, > > I have a site that runs on more many hosts. > now hast someone an idea, how to put the whole site (on all hosts) in > "maintanance mode" (keep normal users outside with a nice hint) - > without

_wrapped_view() problems with method_decorator

2010-03-13 Thread Aidan Fitzpatrick
Hello I've been happily running Django 1.1.1 for a good while. It's excellent. Being a perfectionist with a deadline, I've wanted to make use of part of someone else's app which is written against 1.2. So, no problem. I read the release notes, pulled down the beta. @login_required as a method deco

a bug (i think) with dynamic inlines and ManyToMany relationships

2010-03-13 Thread Simon
Hi all, I've found what I think is a bug in django 1.2 beta 1 (SVN-12773). The dynamic inlines works great with foreign key relationships, but the "Add another xxx" link doesn't appear with ManyToMany relationships. It seems to be because of the '+' character in the `inline_admin_formset.formset

Rendering individual RadioButtons in a Template

2010-03-13 Thread bustaarama
Hi list, any recommended way of rendering individual RadioButtons in a Template (from _one_ RadioSelect widget) ? Something like {{ form.field.radioselect.0 }} Thanks, ~b~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group

site management - maintanance mode

2010-03-13 Thread Henrik Genssen
Hi, I have a site that runs on more many hosts. now hast someone an idea, how to put the whole site (on all hosts) in "maintanance mode" (keep normal users outside with a nice hint) - without reloading all webservers and not changing the load-balancer / proxy config - meaning: is there a django

Re: buildout and django

2010-03-13 Thread Santiago Videla
Hi On Fri, Mar 12, 2010 at 10:20 PM, John Griessen wrote: > I tried using buildout to get some django eggs including django-page-cms > which has a dependency on mptt svn trunk. How do you take > a svn checkout and make an egg, then tell buildout to use that local egg? > You should take a look t

Re: unique_together - related Model field.

2010-03-13 Thread Dennis Kaarsemaker
On wo, 2010-03-10 at 12:24 -0800, Daniel S wrote: > However, I can't use 'item.parte' as django gives me an error that I'm > referring to a field that doesnt' exist. > > Is there a way I can use a field of another object in unique_together? No, that is not possible. You will need to make your cl

Re: buildout and django

2010-03-13 Thread andreas schmid
you can use iw.recipe.subversion like this: parts= site-packages django eggs= ... [site-packages] recipe = iw.recipe.subversion urls = svn checkout */http/*://django-mptt.googlecode.com/svn/trunk/ django-mptt [django] ... egg

Re: Self Join

2010-03-13 Thread Daniel Roseman
On Mar 12, 10:54 pm, jrs wrote: > I'm trying, without a great deal of success, to perform a simple self > join using the django orm.  I'm pretty sure the F() function is not > the answer.  I believe this only allows you to compare two field > within the same model instance, not to compare fields w