MultiValueDictKeyError on Image Uploading

2010-08-24 Thread nitin shrimali
Hello Guys,
  I am using a file uploading control in my form. On specifying
some content in that it is working fine but on leaving it blank it is
throwing an error saying that:--


Exception Type: MultiValueDictKeyError Exception Value:

Key 'image' not found in 

Exception Location:
C:\Python26\lib\site-packages\django\utils\datastructures.py in __getitem__,
line 203

in the line "*image_content = request.FILES['image'].read()*"

Please help me on this.

With Regards
Deepu.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: method on the User model?

2010-08-24 Thread Sam Lai
You need to look at SQL aggregates. See here -
http://docs.djangoproject.com/en/dev/topics/db/aggregation/

On 25 August 2010 14:44, Joel Klabo  wrote:
> I am trying to find a way to get a list of users ranked by the most
> "drinks". The drink model has a User field so I am doing this to get
> the info, based on the Drink model:
>
> http://dpaste.com/hold/233600/
>
> But, this seems like craziness. Can't I just search the
> User.objects.all().order_by('drinks') or something? Can i make a User
> method? I'm confused, obviously.

Try,

User.objects.annotate(num_drinks=Count('drink'))

(rough guess; I haven't really had a need to use this in my apps before :)

>
> Here is my Drink model so you have the whole picture:
>
> http://dpaste.com/hold/233601/
>
> Any help on this would be great, I know there is something to be
> learned from this
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



method on the User model?

2010-08-24 Thread Joel Klabo
I am trying to find a way to get a list of users ranked by the most
"drinks". The drink model has a User field so I am doing this to get
the info, based on the Drink model:

http://dpaste.com/hold/233600/

But, this seems like craziness. Can't I just search the
User.objects.all().order_by('drinks') or something? Can i make a User
method? I'm confused, obviously.

Here is my Drink model so you have the whole picture:

http://dpaste.com/hold/233601/

Any help on this would be great, I know there is something to be
learned from this

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using variables / strings to call objects (such as in making database call)?

2010-08-24 Thread Karen Tracey
On Tue, Aug 24, 2010 at 3:24 PM, Rick  wrote:

> Thanks.. I have heard why this might not be a good idea, I think, but
> if I don't use something like this then I have to just rewrite the
> same code many times, I guess I could just write a macro to generate
> the code for different modelnames, maybe thats the best approach
>

No, I think your first approach was a better idea. Check out:
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#methods-on-contenttype-instancesfor
some routines to help achieve what you were originally looking for, I
think.

Karen
-- 
http://tracey.org/kmt/

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py syncdb not working

2010-08-24 Thread !!CONDORIOUS!!
I am constantly updating the database model.  I have tried South but
still feel like the simplest most intuitive way to update a update an
existing project's database is to manually create the fields using
phpMyAdmin.  Two steps

1.  Add/Update field model.py
2.  Add/Update in database to match (phpMyAdmin makes life so much simpler).


On Tue, Aug 24, 2010 at 6:22 PM, Sells, Fred
 wrote:
> During development phase, I actually drop and recreate my database, then run
> syncdb etc to make sure I’ve got a clean start.  Probably not practical once
> I get into production.
>
>
>
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
> On Behalf Of Nick Arnett
> Sent: Tuesday, August 24, 2010 10:57 AM
> To: django-users@googlegroups.com
> Subject: Re: manage.py syncdb not working
>
>
>
>
>
> On Tue, Aug 24, 2010 at 7:43 AM, Sithembewena Lloyd Dube 
> wrote:
>
> Thanks Reinout. I have been seeing a lot of discussions regarding South
> lately - time to dive in and find out what it is and what it means for me.
>
> I was under the impression that Django would add a field to my table. So, is
> syncdb only good during initial database setup?
>
> That is essentially correct, though I have modified tables by renaming the
> old one, letting syncdb recreate it, then copy the old data into the new
> table.  However, due to foreign keys, that's not as simple as it might
> sound.  Early in development, I have also let syncdb create a whole new
> database, then copied the old data into it.
>
> Come to think of it, I have also sometimes created a modified table under a
> temporary name, so that I can see what Django would have done if it were a
> new setup, so that I can modify the old table manually to match how Django
> would have done it automatically (and then drop the temporary table).
>
> Nick
>
>
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Condor
310.951.1177
condor.c...@gmail.com

:%s/war/peace/g

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: manage.py syncdb not working

2010-08-24 Thread Sells, Fred
During development phase, I actually drop and recreate my database, then
run syncdb etc to make sure I've got a clean start.  Probably not
practical once I get into production.

 

From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Nick Arnett
Sent: Tuesday, August 24, 2010 10:57 AM
To: django-users@googlegroups.com
Subject: Re: manage.py syncdb not working

 

 

On Tue, Aug 24, 2010 at 7:43 AM, Sithembewena Lloyd Dube
 wrote:

Thanks Reinout. I have been seeing a lot of discussions regarding South
lately - time to dive in and find out what it is and what it means for
me.

I was under the impression that Django would add a field to my table.
So, is syncdb only good during initial database setup?


That is essentially correct, though I have modified tables by renaming
the old one, letting syncdb recreate it, then copy the old data into the
new table.  However, due to foreign keys, that's not as simple as it
might sound.  Early in development, I have also let syncdb create a
whole new database, then copied the old data into it.

Come to think of it, I have also sometimes created a modified table
under a temporary name, so that I can see what Django would have done if
it were a new setup, so that I can modify the old table manually to
match how Django would have done it automatically (and then drop the
temporary table).

Nick 

 

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Help with Geodjango+Postgres to find a Point, variance in decimal places

2010-08-24 Thread Sam Walters
Hi fellow Django developers

I have Lat/Lng points stored in my db:

class Airfield(models.Model):
point = models.PointField(srid=4326)

I noticed when i query on my development server with postgresql i DONT
have to have the EXACT number of decimal places to find that point.
(what i want)
However on the production server if i ask for a point then i have to
give the exact same number with the same number of decimal places.
(undesired)

Production server is postgresql-8.3 where as my development server is
postgresql-8.4

Obviously the db backend is behaving differently.

8.4:
-32.67 == -32.6667
8.3:
-32.67 !=  -32.6667

How would i solve this issue with the geodjango/django ORM?
I dont want to have to change the db to 8 decimal places and try and
standardise things if possible.
I want to find matching points regardless of wether they are 8,9,10
decimal places.


Eg:

>>> Airfield.objects.get(airfield_name="Luskintyre")


8.3:
>>> lat1 = -32.6667
>>> long1 = 151.4167
>>> destination = Point(lat1, long1)
>>> Airfield.objects.get(point=destination)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.5/site-packages/django/db/models/manager.py",
line 132, in get
return self.get_query_set().get(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 341, in get
% self.model._meta.object_name)
DoesNotExist: Airfield matching query does not exist.

8.4:
>>> lat1 = -32.6667
>>> long1 = 151.4167
>>> destination = Point(lat1, long1)
>>> Airfield.objects.get(point=destination)


cheers

sam_W

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: virtualenv and standalone scripts

2010-08-24 Thread Shawn Milochik
I have my .bashrc set to source the virtualenv, and I source .bashrc
in any shell scripts that need to run via cron. That works out well
for me, and was even seamless when I upgraded our server to Python 2.7
last weekend -- I didn't have to change a thing in any script, and
just one line in .bashrc.

Shawn

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: virtualenv and standalone scripts

2010-08-24 Thread Sam Lai
On 24 August 2010 06:54, Oivvio Polite  wrote:
> Following advice on this list I've moved to virtualenv+pip to manage my
> django stack, which so far is working out nicely.
>
> But what should I do about standalone scripts? Say I have a project
> called mysite. If I'm in a virtualenv and execute a standalone script,
> mysite won't be on my pythonpath and the script won't be able to import
> it.
>
> For now I've solved this by symlinking mysite from my virtualenv
> site-packages folder, but that sort of defeats the purpose of having
> using virtualenv.
>
> What's the right way to go about it?

Following on from the other replies, here's a neat blog post that sums
up your options -

http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

It is also useful to know that if you need to activate a certain
virtualenv for a script, you can do that by simply using the python
executable in the bin/ directory of the virtualenv directory. I use
this to run cronjobs so the virtualenv environment is set up for them.

> Oivvio
>
>
>
> --
> http://pipedreams.polite.se/about/
>
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: app engine and the non-rel stuff going on lately

2010-08-24 Thread Russell Keith-Magee
On Wed, Aug 25, 2010 at 3:57 AM, Waldemar Kornewald
 wrote:
> On Aug 24, 9:30 pm, mack the finger  wrote:
>> I'm considering starting a project, and am leaning towards using
>> google app engine instead of the traditional LAMP stack. The problem
>> is that with app engine, you can't use django models, or anything else
>> that depends on django models, which means no modelforms, no admin, no
>> authentication, no third party-apps, etc. This is a huge drawback for
>> me.
>>
>> Lately there has been some work getting non-relational databases
>> working with django.  In lieu of all of that, what is the likelihood
>> that in the near future django will grow the ability to work more
>> natively with app engine?
>
> Django-nonrel with djangoappengine is what you're searching for:
> http://www.allbuttonspressed.com/projects/django-nonrel
> http://www.allbuttonspressed.com/projects/djangoappengine
>
> With that combo you can use Django's models on App Engine (which
> includes modelforms, admin, auth, etc.). 3rd-party apps like django-
> socialauth work, too, but apps which depend on JOINs won't work
> because the App Engine datastore doesn't support JOINs. We do plan to
> solve that, too, but that'll take some time.
>
> Then, when Django 1.3 gets official nonrel support we'll port
> djangoappengine to that, so you can continue to use your code, but
> this time with the official Django release.

Firstly -- Nobody has ever committed to getting Alex's query-refactor
branch merged in for Django 1.3. In fact, I'm on record in at least
one forum (DC.eu) saying "Almost certainly not before 1.4". As Alex
described in his end of GSoC announcement, there are still some loose
ends that need to be resolved, and the timeframe for the 1.3 release
doesn't provide enough time to get this stuff merged in time for a
feature freeze.

Secondly -- One of the reasons that this isn't going to happen for 1.4
is that we're not going to rush it. Aside from fixing the loose ends,
we need to be convinced that the changes that Alex has made are
sufficient to support multiple non-relational backends. So far, he's
got a compelling proof of concept with MongoDB; however, I need to see
similar proofs of concept for other stores (CouchDB, Cassandra and GAE
would be my ideal list) before I'm convinced that the proposed changes
are sufficient.

All this by way of saying: we need someone to port a GAE backend
*before* query-refactor is merged in, not after. If you want to speed
things up, this would be a helpful way to contribute.

Yours,
Russ Magee %-)

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django + GAE, Changing Auth from userid/password to email/password

2010-08-24 Thread nobosh
Hello, I just got my first app up: http://hellman470.appspot.com/

I'm now trying to learn how to change the authentication model to
support email/password, eliminating userids. I'm guessing this is a
pretty common request? Does anyone know of any tutorials on how to
accomplish this with Django-norel & app engine?

Thanks

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



PgWest 2010 CFP (2nd Call)

2010-08-24 Thread Joshua D. Drake
Following on the smashing success of PostgreSQL Conference East,
PostgreSQL Conference West, The PostgreSQL Conference for Decision
Makers, End Users and Developers, is being held at the St. Francis,
Drake Hotel in San Francisco from November 2nd through 4th 2010. Please
join us in making this the largest PostgreSQL Conference to date!

Main site:
http://www.postgresqlconference.org/

CFP:
http://www.postgresqlconference.org/2010/west/cfp

Thank you to our sponsors:
Command Prompt: http://www.commandprompt.com/
EnterpriseDB: http://www.enterprisedb.com/


Time line:
July 14th: Talk submission opens
Sept 5th: Talk submission closes
Sept 10th: Speaker notification

This year we will be continuing our trend of covering the entire
PostgreSQL ecosystem. We would like to see talks and tutorials on the
following topics:

  * General PostgreSQL: 
  * Administration 
  * Performance 
  * High Availability 
  * Migration 
  * GIS 
  * Integration 
  * Solutions and White Papers 
  * The Stack: 
  * Python/Django/Pylons/TurboGears/Custom 
  * Perl5/Catalyst/Bricolage 
  * Ruby/Rails 
  * Java (PLJava would be great)/Groovy/Grails 
  * Operating System optimization
(Linux/FBSD/Solaris/Windows) 
  * Solutions and White Papers 
-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: DJANGO + Google App Engine, Getting Started Tutorial

2010-08-24 Thread nobosh
Thanks for pointing that out.

On Aug 23, 4:30 am, Steve Holden  wrote:
> On 8/23/2010 7:29 AM, Russell Keith-Magee wrote:> On Mon, Aug 23, 2010 at 
> 1:01 PM,nobosh wrote:
> >> I'm very interested in finding a up-to-date tutorial that shows steps
> >> for getting DJANGO running on Google App Engine, anyone know of any
> >> such tutorials?
>
> >> Surprisingly, Google's App Engine DJANGO docs are almost a year old.
> >> What gives?
>
> > That's something you'll have to take up with Google. The Django
> > project doesn't have any formal affiliation or support for App Engine.
> > Any technical or documentation flaws you find should be reported to
> > Google, not to us.
>
> And, by the way, that's "Django", not "DJANGO" - it isn't an acronym,
> it's a tribute to a gypsy guitarist.
>
> regards
>  Steve
> --
> DjangoCon US 2010 September 7-9http://djangocon.us/

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Strange problem accessing JS for admin

2010-08-24 Thread Nick
I have a model set up to use collapsable inlines but for some reason
the path to my js files is acting very strange.

I can find the core.js at http://mysite.com/media/js/core.js  but when
i try to reach any other js http://mysite.com/media/js/inline.min.js I
get a server error

"/media/js/inlines.min.js was not found on this server"

I checked the directories and all the js files are in the right place.
Anyone encounter this before?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Displaying uploaded image

2010-08-24 Thread vishy
I have media/customermedia folder where images are uploaded for
customer model.
To display this image,the customer has image_url method which
concatenates 'media_root' plus 'image'(which has value like
customermedia/name.gif).But,for some reason the image is not getting
displayed in img src tag.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Caching JSON in Django

2010-08-24 Thread buddhasystem

Hello,

I'm trying to use native caching in Django as per
http://docs.djangoproject.com/en/dev/topics/cache/

I followed the setup procedure to the tee (it's not hard, of course). What I
observe is that my app caches only views that deliver HTML. Since my
application is heavily AJAX, that's not what I want -- I want to cache JSON
-- but it doesn't work!

Any hints how I can make it work?

I can always code it up myself (I have, actually), but I try to avoid that.

Thanks.

-- 
View this message in context: 
http://old.nabble.com/Caching-JSON-in-Django-tp29526535p29526535.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



fcgi vs. manage.py runserver and URI handling

2010-08-24 Thread David Koblas
 I've got a production and a dev instance of my system, what I'm seeing 
is the following.


For the URL:
/tags/Cell%20Tower
and the urls.py rule of:
 url(r'^tags/(?P.*)', 'tags', name='tags'),

In the lighttpd proxying to a port on ./manage.py runserver  I get
tag = Cell Tower
When I run this in "production" [lighttpd fcgi] I get:
tag = Cell%20Tower

Is this a bug in how I've got lighttpd configured or a bug in the fcgi 
handling, or a bug in the django interface to fcgi?  Or something 
completely different?


Or maybe something completely different.

--
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Custom clean() method

2010-08-24 Thread Joel Klabo
Thank you, question answered.

On Aug 24, 11:45 am, Shawn Milochik  wrote:
> Your version automatically gets called during the cleaning process
> (assuming it's named properly). You don't need to call it explicitly.
> The default cleaning of the field will happen automatically. All you
> have to do is get the value from cleaned_data and make sure you return
> the value in your function.
>
> http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a...
>
> Shawn

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Loop over a form's choices (radio button) and render it

2010-08-24 Thread pravasi
If you have a function as below in the SelectForm class you can get a
iterable renderer for the radio button field.I am not very sure about
whether you have a initial  value or value in your situation.

def get_selectfield_renderer(self):
field = self.fields['selectfield']
widget =  field.widget
value = self.initial['selectfield']
renderer = widget.get_renderer('selectfield', value)
return renderer

You can then render each radio button choice in the template by using
{{ form.get_selectfield_renderer.0 }}  ,
{{ form.get_selectfield_renderer.1 }} etc.If you are using a for loop
you can use the forloop.counter0

On Aug 7, 4:03 pm, Andreas Pfrengle  wrote:
> Hello,
>
> what I want to do is to add a radio button into the last column of a
> data table. The user shall be able to select exactly one of the
> table's rows. I was thinking about defining a SelectForm with one
> 'select'-field (ChoiceField) with a RadioSelect-widget. In the
> template, I would then need to iterate over the data (each data row)
> AND each OPTION of the radio select widget.
> How would I do that? Just referring to
> {{ selectform.fields.selectfield.choices }} in the template gives me
> the list of choices (i.e. each single choice when I loop over it), but
> not the html I want.
>
> Are there any other approaches to the problem?
>
> Thanks for your suggestions,
> Andreas

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: app engine and the non-rel stuff going on lately

2010-08-24 Thread Waldemar Kornewald
On Aug 24, 9:30 pm, mack the finger  wrote:
> I'm considering starting a project, and am leaning towards using
> google app engine instead of the traditional LAMP stack. The problem
> is that with app engine, you can't use django models, or anything else
> that depends on django models, which means no modelforms, no admin, no
> authentication, no third party-apps, etc. This is a huge drawback for
> me.
>
> Lately there has been some work getting non-relational databases
> working with django.  In lieu of all of that, what is the likelihood
> that in the near future django will grow the ability to work more
> natively with app engine?

Django-nonrel with djangoappengine is what you're searching for:
http://www.allbuttonspressed.com/projects/django-nonrel
http://www.allbuttonspressed.com/projects/djangoappengine

With that combo you can use Django's models on App Engine (which
includes modelforms, admin, auth, etc.). 3rd-party apps like django-
socialauth work, too, but apps which depend on JOINs won't work
because the App Engine datastore doesn't support JOINs. We do plan to
solve that, too, but that'll take some time.

Then, when Django 1.3 gets official nonrel support we'll port
djangoappengine to that, so you can continue to use your code, but
this time with the official Django release.

So, basically, start with Django-nonrel now and then switch to Django
1.3 when it's out.

Also, if you want to manage your media/assets you should have a look
at django-mediagenerator. Unlike most alternative solutions it works
in sandboxed environments like App Engine (which should be important
to you ;) and it's very feature-rich.
http://www.allbuttonspressed.com/projects/django-mediagenerator

Bye,
Waldemar Kornewald

--
Django on App Engine, MongoDB, ...? Browser-side Python? It's open-
source:
http://www.allbuttonspressed.com/blog/django

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Connecting a django-registration signal to a function

2010-08-24 Thread Alex
Hi Kai,

I have done this very similarly(after a lot of wrong ideas). I now
have it working using 'connect' instead of 'send'

def user_profile(sender, user, request, **kwargs):
profile = UserProfile(user= user)
profile.save()

from registration.signals import user_activated
user_activated.connect(user_profile)

I picked this up from this thread :
http://stackoverflow.com/questions/3114976/extending-django-registration-using-signals/3124006#3124006

Hope this helps.

  Alex

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Notification of Model Changes

2010-08-24 Thread Shawn Milochik
On Tue, Aug 24, 2010 at 3:33 PM, Almost George
 wrote:
>
> When overriding __init__, what does that function definition need to
> look like to make sure everything else works as usual?
>

Nothing special, as long as you call the __init__ of super.

Example:  super(YourModelName, self).__init__(*args, **kwargs)

Also, make sure you do that before anything else, or it'll most likely
blow up. If you decide to pass any extra kwargs as part of your custom
functionality you should also take care to pop() them and store them
in temporary variables before calling super, or it could break the
__init__ of models.Model.

Shawn

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Notification of Model Changes

2010-08-24 Thread Almost George

On Aug 24, 2:15 pm, Shawn Milochik  wrote:
> If you override __init__() and store the value of that field in a
> temporary value, such as self.old_status, then the instance will have
> both self.status and self.old_status for comparison later.
>
> I hope this fits your use-case.
>
> Shawn

Sounds great, thanks!

When overriding __init__, what does that function definition need to
look like to make sure everything else works as usual?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



app engine and the non-rel stuff going on lately

2010-08-24 Thread mack the finger
I'm considering starting a project, and am leaning towards using
google app engine instead of the traditional LAMP stack. The problem
is that with app engine, you can't use django models, or anything else
that depends on django models, which means no modelforms, no admin, no
authentication, no third party-apps, etc. This is a huge drawback for
me.

Lately there has been some work getting non-relational databases
working with django.  In lieu of all of that, what is the likelihood
that in the near future django will grow the ability to work more
natively with app engine?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using variables / strings to call objects (such as in making database call)?

2010-08-24 Thread Rick
Thanks.. I have heard why this might not be a good idea, I think, but
if I don't use something like this then I have to just rewrite the
same code many times, I guess I could just write a macro to generate
the code for different modelnames, maybe thats the best approach

On Aug 24, 8:55 am, Рогалевич (Ковалевич) 
wrote:
> Don't think it is good idea to do so.
>
> In this case dict_variables['modelname'].objects.filter(status_listurl='u')
> you call method objects on string. but string doesn't have such method. you
> should use smth like modelclass = globals()['modelname']
>
> for example:>>> import os
> >>> o=globals()['os'] # or locals() depending on context
> >>> o
>
> 
>
> to import by passing a string try help(__import__)
>
> On 24 August 2010 12:19, Rick  wrote:
>
>
>
> > I'm using Django as my framework but am doing things beyond regular
> > web development as I have some a lot of "components" outside of any of
> > the django apps that I am often interacting with and, in some of
> > these, I want to be able to make calls to the database for a model but
> > want to be able to pass in the model's name as a variable since I want
> > to write re-usable code as much as possible... I have really been
> > struggling in figuring out how to do this and would appreciate any
> > advice.. below is some example code of what I am trying to do:
>
> > def call_database_from_variable (dict_variables)
> >    from web1.dict_variables['appname'].models import
> > dict_variables['modelname']
> >    p =
> > dict_variables['modelname'].objects.filter(status_listurl='u')
>
> > dict_variables={'app':'myappname','model':'Mymodelname','field':'field_i_want_to_get'}
> > call_database_from_variable (dict_variables)
>
> > --
> > 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...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Best Regards,
> Mila

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using variables / strings to call objects (such as in making database call)?

2010-08-24 Thread Rick
why is this not a good idea?

On Aug 24, 8:55 am, Рогалевич (Ковалевич) 
wrote:
> Don't think it is good idea to do so.
>
> In this case dict_variables['modelname'].objects.filter(status_listurl='u')
> you call method objects on string. but string doesn't have such method. you
> should use smth like modelclass = globals()['modelname']
>
> for example:>>> import os
> >>> o=globals()['os'] # or locals() depending on context
> >>> o
>
> 
>
> to import by passing a string try help(__import__)
>
> On 24 August 2010 12:19, Rick  wrote:
>
>
>
> > I'm using Django as my framework but am doing things beyond regular
> > web development as I have some a lot of "components" outside of any of
> > the django apps that I am often interacting with and, in some of
> > these, I want to be able to make calls to the database for a model but
> > want to be able to pass in the model's name as a variable since I want
> > to write re-usable code as much as possible... I have really been
> > struggling in figuring out how to do this and would appreciate any
> > advice.. below is some example code of what I am trying to do:
>
> > def call_database_from_variable (dict_variables)
> >    from web1.dict_variables['appname'].models import
> > dict_variables['modelname']
> >    p =
> > dict_variables['modelname'].objects.filter(status_listurl='u')
>
> > dict_variables={'app':'myappname','model':'Mymodelname','field':'field_i_want_to_get'}
> > call_database_from_variable (dict_variables)
>
> > --
> > 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...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Best Regards,
> Mila

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Notification of Model Changes

2010-08-24 Thread Shawn Milochik
If you override __init__() and store the value of that field in a
temporary value, such as self.old_status, then the instance will have
both self.status and self.old_status for comparison later.

I hope this fits your use-case.

Shawn

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Notification of Model Changes

2010-08-24 Thread Almost George
This is probably a very old question, but I wasn't able to find an
obvious answer - sorry if I overlooked anything.

I have a model with a "status" field (using Choices) that defaults to
"pending" and has other options like "closed", "active", etc.

I would like to implement email notifications of changes to this
model, particularly concerning this field.

I figure that a custom signal might work, but I'm not sure where to
put it.

In pre_save (the only place I know that I have access to the "old"
value), I don't know yet that the object actually finished saving
correctly. In post_save, I don't think I have the old value to compare
to the new.

The notification should be able to contain something along the lines
of "user x changed blah status from Y to Z".

Where should I be looking to utilize old-vs-new comparison, and to
generate a signal or some such, so as to handle this in an appropriate
fashion?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Custom clean() method

2010-08-24 Thread Shawn Milochik
Your version automatically gets called during the cleaning process
(assuming it's named properly). You don't need to call it explicitly.
The default cleaning of the field will happen automatically. All you
have to do is get the value from cleaned_data and make sure you return
the value in your function.

http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a-specific-field-attribute

Shawn

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Custom clean() method

2010-08-24 Thread Joel Klabo
When you write a custom clean method for a form, does is get called by
is_valid? Or does it call the standard version? Do I need to
explicitly call it?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to troubleshoot path and permission problems?

2010-08-24 Thread Timothy Makobu
This thread might help http://forum.webfaction.com/viewtopic.php?id=3171


On Tue, Aug 24, 2010 at 8:35 PM, vishy  wrote:

> I gave the permissions.But,still get this error
> OSError Exception Value:[Errno 13] Permission denied: django
>
> On Aug 23, 11:02 pm, Antoni Aloy  wrote:
> > 2010/8/23 vishy :
> >
> > > Hi,
> >
> > > I am having issues with production server.Everything is running fine
> > > on my local development server.On production site(using apache), CSS
> > > files related to admin section are not being loaded.I have a feature
> > > where admin can add products and upload images for the
> > > product.But,when admin hits save,I get permission denied message.How
> > > can I figure out what path problems are existing and how to fix them?
> > > Thanks
> >
> > on linux ls -l will givve you the perisions of each file and folder.
> > You can check what each letter means onhttp://
> www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html.
> >
> > To server files the Apache server has to have read permisions. To
> > create files it has to have write permisions.
> >
> > Best regards,
> >
> > --
> > Antoni Aloy López
> > Blog:http://trespams.com
> > Site:http://apsl.net
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to troubleshoot path and permission problems?

2010-08-24 Thread vishy
I gave the permissions.But,still get this error
OSError Exception Value:[Errno 13] Permission denied: django

On Aug 23, 11:02 pm, Antoni Aloy  wrote:
> 2010/8/23 vishy :
>
> > Hi,
>
> > I am having issues with production server.Everything is running fine
> > on my local development server.On production site(using apache), CSS
> > files related to admin section are not being loaded.I have a feature
> > where admin can add products and upload images for the
> > product.But,when admin hits save,I get permission denied message.How
> > can I figure out what path problems are existing and how to fix them?
> > Thanks
>
> on linux ls -l will givve you the perisions of each file and folder.
> You can check what each letter means 
> onhttp://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html.
>
> To server files the Apache server has to have read permisions. To
> create files it has to have write permisions.
>
> Best regards,
>
> --
> Antoni Aloy López
> Blog:http://trespams.com
> Site:http://apsl.net

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



readonly form field

2010-08-24 Thread Rodrigo Lombardo
Hi,

I'm new to Django and I'm learning a lot reading the docs and some books.
I'm trying to generate a form with some inactive fields and let the
user change only some fields. The way I found to do this is described
here: 
http://stackoverflow.com/questions/324477/in-a-django-form-how-to-make-a-field-readonly-or-disabled-so-that-it-cannot-be

My question is: Nowadays, there's a better way to do the same thing?

Thanks,
Rodrigo Nicola
Twitter: http://www.twitter.com/rodnic

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django admin not working with mod_python

2010-08-24 Thread Shamail Tayyab
Hi,

   I am facing an issue where I cannot get the admin interface working
properly when running mod_python. Although when running it using
development server, its works fine.

Problem:
  Admin interface is missing the static contents, like css, the
interface comes though.

Related info:
  OS: Ubuntu 10.04.

  urls.py - related info

 10 urlpatterns = patterns('',
 11   (r'^admin$', include(admin.site.urls)),
 12   (r'^simpleadmin$', adminview ),
 13   (r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': 'static'}),

  virtual host configuration:
  
  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE chatty.settings
  PythonPath "['/usr/local/test', '/usr/local/test/chatty'] +
sys.path"
  PythonDebug On
AuthType basic
AuthName 'Developers access'
AuthUserFile /etc/cgi-password2
Require valid-user
   
   
   SetHandler None
   

Options Indexes MultiViews FollowSymLinks
AllowOverride all


Test cases:
  On accessing something like http://www.host.com/media/css/base.css
it gives 404 Not Found.

Thanks and Regards

--
Shamail Tayyab
Blog: http://shamail.in/blog

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Why not remove csrfmiddlewaretoken in CsrfViewMiddleware from request.POST?

2010-08-24 Thread mucisland
I have various views which break on the additional csrfmiddlewaretoken
in request.POST when using the recommendet CSRF protection with
CsrfViewMiddleware and {% csrf_token %}.

Why don't we just remove the csrfmiddlewaretoken in CsrfViewMiddleware
before the request hits the views?

patch on middleware/csrf.py 1.2.1 final:

11a12
> from django import http
162a164,167
> tmp_post = request.POST.copy()
> del tmp_post['csrfmiddlewaretoken']
> request.POST = http.QueryDict(tmp_post.urlencode())

My code seems to work and the CSRF protection is now completely
transparent to the views. Only the templates and the
MIDDLEWARE_CLASSES need to know about it.

Regards,
Dirk

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Why not remove csrfmiddlewaretoken from request.POST?

2010-08-24 Thread mucisland
I have various views which break on the additional csrfmiddlewaretoken
in request.POST when using the recommendet CSRF protection with
CsrfViewMiddleware and {% csrf_token %}.

Why don't we just remove the csrfmiddlewaretoken before the request
hits the views?

patch on middleware/csrf.py 1.2.1 final:

11a12
> from django import http
162a164,167
>
> tmp_post = request.POST.copy()
> del tmp_post['csrfmiddlewaretoken']
> request.POST = http.QueryDict(tmp_post.urlencode())

My code seems to work and the CSRF protection is now completely
transparent to the views. Only the templates and the
MIDDLEWARE_CLASSES needs to know about it.

Regards,
Dirk

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can't adapt type 'Decimal'

2010-08-24 Thread Gabriel Farrell
(I tried to post the below in a comment at poupou's site (http://
www.defitek.com/blog/2010/06/29/cant-adapt-type-decimal-error-with-django-apache-postgresql-psycopg2/),
but kept getting errors.)

Just ran into the same problem. In my mod_wsgi config I had:

WSGIDaemonProcess site1 maximum-requests=1
WSGIProcessGroup site1
WSGIScriptAlias /site1 /var/www/site1/django.wsgi

WSGIDaemonProcess site2 maximum-requests=1
WSGIProcessGroup site2
WSGIScriptAlias /site2 /var/www/site2/django.wsgi

I was getting errors with that, but with the "process-group" parameter
things are running fine. Funny that at 
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives
the only place where "process-group" is mentioned is in the
WSGIImportScript section.


On Jun 28, 5:01 pm, poupou  wrote:
> I confirm that everything is working fine now.
>
> Thank you again.
>
> On 25 juin, 13:12, poupou  wrote:
>
>
>
>
>
>
>
> > Yes I'm running two sites on the same server.  Only difference with
> > you is that I'm running it with virtual host.
>
> > I modifier my Apache config, now it looks like this :
>
> > 
> >   ServerName  site1.com
> >   WSGIDaemonProcess site1
> >   WSGIScriptAlias / /var/www/site1.wsgi process-group=site1
> > application-group=%{GLOBAL}
>
> > 
>
> > 
> >   ServerName  site2.com
> >   WSGIDaemonProcess site2
> >   WSGIScriptAlias / /var/www/site2.wsgi process-group=site2
> > application-group=%{GLOBAL}
>
> > 
>
> > It will take a little to make sure it's working, I will report on this
> > thread if everything is ok.
>
> > Thank you!
>
> > On 25 juin, 10:51, Stuart  wrote:
>
> > > On Jun 25, 8:06 am, poupou  wrote:
>
> > > >   Of the 2 web site that I have, It only happens where I make request
> > > > using the the Q objects.
>
> > > If you have two django sites/projects on the same server 
> > > (e.g.http://myserver/app1andhttp://myserver/app2) and you are using
> > > mod_wsgi, I bet you're having the same problem I was. To fix it,
> > > upgrade to the latest version of mod_wsgi and run it in daemon mode.
> > > See here for 
> > > details:http://groups.google.com/group/satchmo-users/msg/a9b22c236d63c323
>
> > > Hope that helps,
>
> > > --Stuart

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: virtualenv and standalone scripts

2010-08-24 Thread shacker
On Aug 23, 1:54 pm, Oivvio Polite  wrote:
> Following advice on this list I've moved to virtualenv+pip to manage my
> django stack, which so far is working out nicely.
>
> But what should I do about standalone scripts? Say I have a project

You need to load up the current project environment at the top of your
script. I find this works well when running a script from the project
root directory, e.g.

$ cd proj_dir
$ python scripts/somescript.py

and with this at the top of the script:

# Set up Django environment
import sys,os

# These could be absolute rather than relative paths:
sys.path.append('.')
sys.path.append('../')
sys.path.append('../lib/python2.5/site-packages/django')

os.environ['DJANGO_SETTINGS_MODULE'] ='someproj.settings'

from django.core.management import setup_environ
from someproj import settings
setup_environ(settings)

./s

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using variables / strings to call objects (such as in making database call)?

2010-08-24 Thread Ковалевич
Don't think it is good idea to do so.

In this case dict_variables['modelname'].objects.filter(status_listurl='u')
you call method objects on string. but string doesn't have such method. you
should use smth like modelclass = globals()['modelname']

for example:
>>> import os
>>> o=globals()['os'] # or locals() depending on context
>>> o


to import by passing a string try help(__import__)



On 24 August 2010 12:19, Rick  wrote:

> I'm using Django as my framework but am doing things beyond regular
> web development as I have some a lot of "components" outside of any of
> the django apps that I am often interacting with and, in some of
> these, I want to be able to make calls to the database for a model but
> want to be able to pass in the model's name as a variable since I want
> to write re-usable code as much as possible... I have really been
> struggling in figuring out how to do this and would appreciate any
> advice.. below is some example code of what I am trying to do:
>
> def call_database_from_variable (dict_variables)
>from web1.dict_variables['appname'].models import
> dict_variables['modelname']
>p =
> dict_variables['modelname'].objects.filter(status_listurl='u')
>
>
> dict_variables={'app':'myappname','model':'Mymodelname','field':'field_i_want_to_get'}
> call_database_from_variable (dict_variables)
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Best Regards,
Mila

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py syncdb not working

2010-08-24 Thread Sithembewena Lloyd Dube
Thanks Nick - this echoes a thought that occured to me i.e. "create new
table, copy data". The issue with constraints is what kept me from trying
this out (remembered previous jobs updating SQL Server schemas - not fun
with live data).

Regards,
Lloyd

On Tue, Aug 24, 2010 at 4:56 PM, Nick Arnett  wrote:

>
>
> On Tue, Aug 24, 2010 at 7:43 AM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>> Thanks Reinout. I have been seeing a lot of discussions regarding South
>> lately - time to dive in and find out what it is and what it means for me.
>>
>> I was under the impression that Django would add a field to my table. So,
>> is syncdb only good during initial database setup?
>
>
> That is essentially correct, though I have modified tables by renaming the
> old one, letting syncdb recreate it, then copy the old data into the new
> table.  However, due to foreign keys, that's not as simple as it might
> sound.  Early in development, I have also let syncdb create a whole new
> database, then copied the old data into it.
>
> Come to think of it, I have also sometimes created a modified table under a
> temporary name, so that I can see what Django would have done if it were a
> new setup, so that I can modify the old table manually to match how Django
> would have done it automatically (and then drop the temporary table).
>
> Nick
>
>  --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py syncdb not working

2010-08-24 Thread Nick Arnett
On Tue, Aug 24, 2010 at 7:43 AM, Sithembewena Lloyd Dube
wrote:

> Thanks Reinout. I have been seeing a lot of discussions regarding South
> lately - time to dive in and find out what it is and what it means for me.
>
> I was under the impression that Django would add a field to my table. So,
> is syncdb only good during initial database setup?


That is essentially correct, though I have modified tables by renaming the
old one, letting syncdb recreate it, then copy the old data into the new
table.  However, due to foreign keys, that's not as simple as it might
sound.  Early in development, I have also let syncdb create a whole new
database, then copied the old data into it.

Come to think of it, I have also sometimes created a modified table under a
temporary name, so that I can see what Django would have done if it were a
new setup, so that I can modify the old table manually to match how Django
would have done it automatically (and then drop the temporary table).

Nick

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py syncdb not working

2010-08-24 Thread Sithembewena Lloyd Dube
Thanks Reinout. I have been seeing a lot of discussions regarding South
lately - time to dive in and find out what it is and what it means for me.

I was under the impression that Django would add a field to my table. So, is
syncdb only good during initial database setup?

Many thanks,

Lloyd



On Tue, Aug 24, 2010 at 4:31 PM, Reinout van Rees wrote:

> On 08/24/2010 04:17 PM, Sithembewena Lloyd Dube wrote:
>
>> Hi all,
>>
>> I have been working on some models and tried to run the manage.py syncdb
>> command. It says there are no fixtures found even after I just added a
>> field to a model.
>>
>
> No fixtures found: it means to tell you that it didn't find any
> special-named "initial_data" fixtures.
>
> Regular fixtures must/can be loaded with "manage.py loaddata fixturename".
>
>
>  A solution has been to drop the table in MySQL before running syncdb.
>> This doesn't seem feasible all the time. What could I be doing wrong?
>>
>
> It is a (sensible) restriction of syncdb: it only creates missing tables.
>  If you modified a table, the table is still there, so it won't re-add it.
>  Doing so would mean potential data corruption.
>
> So if you added fields to a model, you'll have to add that field by hand to
> the table.
>
> An alternative is for instance South (http://south.aeracode.org/) which
> *can* do the database migration for you, also in the case of added fields.
>
>
>
> Reinout
>
> --
> Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
> Programmer at http://www.nelen-schuurmans.nl
> "Military engineers build missiles. Civil engineers build targets"
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Connecting a django-registration signal to a function

2010-08-24 Thread Kai Timmer


On 23 Aug., 16:51, Kai Timmer  wrote:

> Whats the problem here?

Really? Is no one able to point me in the right direction here? Or is
the question just to stupid?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py syncdb not working

2010-08-24 Thread Reinout van Rees

On 08/24/2010 04:17 PM, Sithembewena Lloyd Dube wrote:

Hi all,

I have been working on some models and tried to run the manage.py syncdb
command. It says there are no fixtures found even after I just added a
field to a model.


No fixtures found: it means to tell you that it didn't find any 
special-named "initial_data" fixtures.


Regular fixtures must/can be loaded with "manage.py loaddata fixturename".


A solution has been to drop the table in MySQL before running syncdb.
This doesn't seem feasible all the time. What could I be doing wrong?


It is a (sensible) restriction of syncdb: it only creates missing 
tables.  If you modified a table, the table is still there, so it won't 
re-add it.  Doing so would mean potential data corruption.


So if you added fields to a model, you'll have to add that field by hand 
to the table.


An alternative is for instance South (http://south.aeracode.org/) which 
*can* do the database migration for you, also in the case of added fields.




Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: manage.py syncdb not working

2010-08-24 Thread Renne Rocha
  Hello,

  It is correct. Syncdb will not alter existing tables:

  http://docs.djangoproject.com/en/1.2/ref/django-admin/#syncdb

  The reason is that if you've changed you model with some kind of
constrains (unique fields, etc), Django will not try to guess how to
mantain the correctness of your data. It is your task.

  Renne Rocha
  renne.ro...@gmail.com
  http://www.linkedin.com/in/rennerocha

On Tue, Aug 24, 2010 at 11:17 AM, Sithembewena Lloyd Dube
 wrote:
> Hi all,
>
> I have been working on some models and tried to run the manage.py syncdb
> command. It says there are no fixtures found even after I just added a field
> to a model.
>
> A solution has been to drop the table in MySQL before running syncdb. This
> doesn't seem feasible all the time. What could I be doing wrong?
>
> Thanks
>
> --
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



manage.py syncdb not working

2010-08-24 Thread Sithembewena Lloyd Dube
Hi all,

I have been working on some models and tried to run the manage.py syncdb
command. It says there are no fixtures found even after I just added a field
to a model.

A solution has been to drop the table in MySQL before running syncdb. This
doesn't seem feasible all the time. What could I be doing wrong?

Thanks

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: static files + index.html dynamic usign django

2010-08-24 Thread Javier Guerra Giraldez
On Tue, Aug 24, 2010 at 7:33 AM, Piotr Kilczuk  wrote:
> P.S. Don't think about URLs as directories.

+1

-- 
Javier

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Documentation problems: Django at a glance

2010-08-24 Thread Rodney Topor
OK, it seems I misunderstood the purpose of this page.  I still think
some of the code is misleading, but I accept that the examples is
intended to be indicative rather than descriptive, and that it would
indeed take much more space to describe how to get this example
working.  I'm sorry to have bothered you all.
Rodney

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 view
> that has been rendered in the browser.
>
> For instance:
>
> I need to know if the user is on gather.view.create_listing or
> gather.view.edit_listing?
>
> How can I do this in django, it alludes me.
>
> Thanks,
> Patrick
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Finding current view url in template?

2010-08-24 Thread reduxdj
I have some decisions i need to make in my template based on the view
that has been rendered in the browser.

For instance:

I need to know if the user is on gather.view.create_listing or
gather.view.edit_listing?

How can I do this in django, it alludes me.

Thanks,
Patrick

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Object ID is not assigned after calling save() on a new object

2010-08-24 Thread Dan
Hi,

On 24 Aug., 14:10, Karen Tracey  wrote:
> If you want automatic assignment, you need to make
> it an AutoField with primary_key=True.
thanks a lot, that fixed it!


Regards,
Daniel

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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 to hit the database for every page view.

On Tue, Aug 24, 2010 at 3:00 AM, OliverMarchand
wrote:

> Dear all,
>
> I am thinking of creating a website that displays "mostly" database
> content, but for special content I am using flatpages. Now somehow I
> must put a link to the flatpages somewhere, most likely in a menu. If
> I put the menu in my base template, then there is no way to insert
> this link by editing.
>
> Do you have a good design idea to make the menu editable as well?
>
> thanks and cheers,
> Oliver
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: static files + index.html dynamic usign django

2010-08-24 Thread Piotr Kilczuk
Hi,

> Is it possible to mix static and dynamic content in the same directory
> using django?

Yes :) At least as far as I understand your goal.

Basic urlconf stuff - matter of order.

P.S. Don't think about URLs as directories.


Regards,
Piotr

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Object ID is not assigned after calling save() on a new object

2010-08-24 Thread Karen Tracey
On Tue, Aug 24, 2010 at 5:55 AM, Dan  wrote:

> I have some troubles with my Django model: whenever I create a new
> object the ID (primary key) is not being assigned to it after calling
> obj.save().
>
> I am on RHEL with Python 2.4.3 and Django 1.2.1 (with MySQL backend).
>
> I've uploaded a code snippet which clearly shows the problem:
> http://pastebin.com/qtRgZVQY
>
> For the reference, this is the model I am using:
> class Attribute(models.Model):
>id = models.PositiveIntegerField( db_column='attribute_id',
> primary_key=True )
>name = models.CharField(max_length=255,
> db_column='attribute_name', unique=True)
>_touchDate =
> models.DateTimeField( db_column='attribute_touchDate', editable=False,
> auto_now=True)
>_touchUser = models.CharField(max_length=255,
> db_column='attribute_touchUser', editable=False, default='Unknown')
>
>class Meta:
>db_table = 'attribute'
>app_label = 'lib'
>ordering = ( 'name', )
>
>def __unicode__(self):
>return self.name
>
> Could anybody point me into some directions in order to solve the
> problem?
>

You've explicitly defined the primary key field as a positive integer field.
Marking it primary_key=True does not make it an auto-assigned
auto-incrementing field. If you want automatic assignment, you need to make
it an AutoField with primary_key=True.

Karen
-- 
http://tracey.org/kmt/

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Object ID is not assigned after calling save() on a new object

2010-08-24 Thread Rohan Jain
Django assigns an id field to models automatically, so you dont need
to define it seperately. And even if you define it you have to assign
auto_increment = true so that it is automatically filled.

On Aug 24, 2:55 pm, Dan  wrote:
> Hi,
>
> I have some troubles with my Django model: whenever I create a new
> object the ID (primary key) is not being assigned to it after calling
> obj.save().
>
> I am on RHEL with Python 2.4.3 and Django 1.2.1 (with MySQL backend).
>
> I've uploaded a code snippet which clearly shows the 
> problem:http://pastebin.com/qtRgZVQY
>
> For the reference, this is the model I am using:
> class Attribute(models.Model):
>     id = models.PositiveIntegerField( db_column='attribute_id',
> primary_key=True )
>     name = models.CharField(max_length=255,
> db_column='attribute_name', unique=True)
>     _touchDate =
> models.DateTimeField( db_column='attribute_touchDate', editable=False,
> auto_now=True)
>     _touchUser = models.CharField(max_length=255,
> db_column='attribute_touchUser', editable=False, default='Unknown')
>
>     class Meta:
>         db_table = 'attribute'
>         app_label = 'lib'
>         ordering = ( 'name', )
>
>     def __unicode__(self):
>         return self.name
>
> Could anybody point me into some directions in order to solve the
> problem?
>
> Regards,
> Daniel

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is this a bug or is adding a ForeignKey relations at runtime not supported?

2010-08-24 Thread Olek
On 24 Sie, 13:13, Olek  wrote:
> print 'It seems that forcing cache on SomeObject._meta to reload fixes
> the problem."

Please note that this line should end with >'<, not >"<. Sorry. Other
than that code works. :)

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



GenericRelation OneToOne

2010-08-24 Thread schneck
Hi there,

I'm using GenericRelations for binding a model to several others. One
of them is a model where the generic model must have a 1:1 relation to
r. As far as I understand, GenericRelations are always ManyToMany,
right? Is there any other way to achieve it?

Thanks,
Stefan

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Is this a bug or is adding a ForeignKey relations at runtime not supported?

2010-08-24 Thread Olek
Hi,

Could you please look at this situation where I try to deal with
adding ForeignKey relation at runtime and using it in a annotate
construct? Is this code illustrates a bug in Django or am I trying to
do something illegal here? I'm using Django 1.1.

---  ---

localhost:~$ django-admin.py startproject dbg
localhost:~$ cd dbg/
localhost:~/dbg$ python manage.py startapp myapp
localhost:~/dbg$ echo "from django.db import models

class SomeObject(models.Model):
title = models.TextField()

class SomeItem(models.Model):
someint = models.IntegerField()" > myapp/models.py
localhost:~/dbg$ echo "from myapp.models import *

try:
SomeObject.objects.annotate(models.Avg('items__someint'))
except Exception as e:
print e, '(Obviously, because relation to items is not defined)'

SomeItem.add_to_class('object', models.ForeignKey(SomeObject,
related_name='items'))

try:
SomeObject.objects.annotate(models.Avg('items__someint'))
except Exception as e:
print e, \"(Doesn't work because cache in SomeObject._meta is not
updated after SomeItem.add_to_class call.)\"

print 'It seems that forcing cache on SomeObject._meta to reload fixes
the problem."
del SomeObject._meta._name_map
del SomeObject._meta._related_objects_cache

print SomeObject.objects.annotate(models.Avg('items__someint')),
'(Working!)'

from django.db import connection

print connection.queries[-1]['sql']" > test.py
localhost:~/dbg$ export DJANGO_SETTINGS_MODULE="settings"
localhost:~/dbg$ sed -i s/"DATABASE_ENGINE.*"/"DATABASE_ENGINE =
'sqlite3'"/g settings.py
localhost:~/dbg$ sed -i s/"DATABASE_NAME.*"/"DATABASE_NAME = 'db'"/g
settings.py
localhost:~/dbg$ python ./test.py
Cannot resolve keyword 'items' into field. Choices are: id, title
(Obviously, because relation to items is not defined)
Cannot resolve keyword 'items' into field. Choices are: id, title
(Doesn't work because cache in SomeObject._meta is not updated after
SomeItem.add_to_class call.)
[] (Working!)
SELECT "myapp_someobject"."id", "myapp_someobject"."title",
AVG("myapp_someitem"."someint") AS "items__someint__avg" FROM
"myapp_someobject" LEFT OUTER JOIN "myapp_someitem" ON
("myapp_someobject"."id" = "myapp_someitem"."object_id") GROUP BY
"myapp_someobject"."id", "myapp_someobject"."title" LIMIT 21

---  ---

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Object ID is not assigned after calling save() on a new object

2010-08-24 Thread Dan
Hi,

I have some troubles with my Django model: whenever I create a new
object the ID (primary key) is not being assigned to it after calling
obj.save().

I am on RHEL with Python 2.4.3 and Django 1.2.1 (with MySQL backend).

I've uploaded a code snippet which clearly shows the problem:
http://pastebin.com/qtRgZVQY

For the reference, this is the model I am using:
class Attribute(models.Model):
id = models.PositiveIntegerField( db_column='attribute_id',
primary_key=True )
name = models.CharField(max_length=255,
db_column='attribute_name', unique=True)
_touchDate =
models.DateTimeField( db_column='attribute_touchDate', editable=False,
auto_now=True)
_touchUser = models.CharField(max_length=255,
db_column='attribute_touchUser', editable=False, default='Unknown')

class Meta:
db_table = 'attribute'
app_label = 'lib'
ordering = ( 'name', )

def __unicode__(self):
return self.name

Could anybody point me into some directions in order to solve the
problem?

Regards,
Daniel

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



static files + index.html dynamic usign django

2010-08-24 Thread malo29
Hi,

I'm wondering how to solve this problem: I have a directory containing
static files to serve using django (during development), but I want
the index.html file in that directory to be created using a django
view.

Is it possible to mix static and dynamic content in the same directory
using django?

Thanks.
Andrea

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Documentation problems: Django at a glance

2010-08-24 Thread Rick
I agree with Bruno.. I'm a new user to Django, just started a week
ago, coming from using just Python (for about a month) and had been
using PHP frameworks before that).. I understood the purpose of the
tutorial as just a basic intro, I think that its generally implied
that once you get the basic "orientation" of things that you need to
then dig through the API docs, etc, sure there have been some
frustrating things that took me a little while to figure out but I
think as long as the person has previous experience with web
programming in an MVC style that the tutorial is fine

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using variables / strings to call objects (such as in making database call)?

2010-08-24 Thread Rick
I'm using Django as my framework but am doing things beyond regular
web development as I have some a lot of "components" outside of any of
the django apps that I am often interacting with and, in some of
these, I want to be able to make calls to the database for a model but
want to be able to pass in the model's name as a variable since I want
to write re-usable code as much as possible... I have really been
struggling in figuring out how to do this and would appreciate any
advice.. below is some example code of what I am trying to do:

def call_database_from_variable (dict_variables)
from web1.dict_variables['appname'].models import
dict_variables['modelname']
p =
dict_variables['modelname'].objects.filter(status_listurl='u')

dict_variables={'app':'myappname','model':'Mymodelname','field':'field_i_want_to_get'}
call_database_from_variable (dict_variables)

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to right align choice/input fields on django admin page

2010-08-24 Thread BlueSky
Hello,

I have some long field names such as "The Primary Account Number"
defined in my model. When I tried to add a new record on admin page,
the field name is overlapped by the text input box (so Number is
overwritten by the input box). Is there a way to right align the text
input or choice boxes? I know I could use label to shorten the field
name displayed but I really prefer moving the input boxes right ward
so the whole field name will been seen.

Any tips will be appreciated.

Joe

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: virtualenv and standalone scripts

2010-08-24 Thread Mathieu Leduc-Hamel
And what about using "console_scripts" entry in your setup.py script ?

http://www.google.com/search?q=console_scripts


On Mon, Aug 23, 2010 at 11:11 PM, Oivvio Polite  wrote:

> On Mon, Aug 23, 2010 at 10:54:21PM +0200, Oivvio Polite wrote:
> >
> > What's the right way to go about it?
> >
>
> Ok, just did some more googling and found out about custom management
> commands, that clearly are the django way of solving my problem.
>
> oivvio
>
>
> --
> http://pipedreams.polite.se/about/
>
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: stream (large) files from the back-end via Django to the user?

2010-08-24 Thread Markus
On Tue, Aug 24, 2010 at 2:16 AM, Eric Chamberlain  wrote:

>
> Yes. The problem is that currently our CDN is based on Hadoop which serves
> us really well for internal purpose. We can't make it accessible from the
> outside because at the moment Hadoop is missing some crucial security
> features. Still we want to serve some data from our internal CDN to the
> outside even if for this part of the story our CDN would be just a data
> store. The question is if this could be done efficiently? If "yes", how can
> it be done?
>
>
> Does django need to be in the loop for file download?  Is there some reason
> why the web server can't mount and serve the files like any other static
> file structure?
>
>
I have also thought about this. Hadoop has an hdfs fuse module. But I wasn't
sure how well it is maintained and if it will be available for a long time.
Therefore I looked for a solution to stream the data directly form hdfs
(internal) to the user.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: stream (large) files from the back-end via Django to the user?

2010-08-24 Thread Markus
On Tue, Aug 24, 2010 at 1:28 AM, Steve Holden  wrote:

> Consider using Apache or Nginx to deliver this content much as you would
> deliver static content from disk. You don't want Django-users in that loop
> if you are interested in maximum throughput.
>
>
But the question is how to get the content to the Apache and how to remove
it again if it is no longer used? The content is stored at a Hadoop cluster.
Now people use the Django web application to ask for some date, the web app
starts a HBase query, returns the text results and has a link to an internal
file. Now how do I serve the file to the outside?
I could copy it from Hadoop to the Apache directory and give the user that
download link. But if the files are large the inital copy to Apache could
take some time (maybe to long). Also the next question would be: When can
the file be removed again, when is the user download finished?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django models to SOAP

2010-08-24 Thread Alessandro Ronchi
I need to expose my models to a soap view. Is there any way to avoid
rewriting a second time my model like that:
http://djangosnippets.org/snippets/1283/

and get a magic conversion of my models?

A CharField to string, an IntegerField to Integer, a Datetime to Datetime
and so on...


-- 
Alessandro Ronchi
http://www.soasi.com

Hobby & Giochi
http://hobbygiochi.com
http://www.facebook.com/hobbygiochi

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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

2010-08-24 Thread bruno desthuilliers


On 23 août, 21:25, Cole743  wrote:
> "AttributeError at _
>
> 'QuerySet' object has no attribute 'get_payload'
>
> Request Method:         POST
> Request URL:    
> Exception Type:         AttributeError
> Exception Value:
>
> 'QuerySet' object has no attribute 'get_payload'
>
> Exception Location:     /usr/lib/python2.5/email/encoders.py in
> encode_base64, line 44
> Python Executable:      /usr/bin/python
> Python Version:         2.5.2"
>
> I recently got this error

It would have been more helpful if you posted the full traceback.

> while testing out an interface page. I had
> added the ability to send emails with attatchments as part of a
> program. When I had tried it on IE, everything worked fine. When I
> tried it on firefox, however, I got that error.
>
> I haven't been able to
> find any mention of a similar error yet and I'm not sure what would
> cause it to only happen in firefox.

There's (a priori) no reason this would work on a browser and break
with another, since it's *server side* code.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Documentation problems: Django at a glance

2010-08-24 Thread bruno desthuilliers


On 24 août, 09:06, Rodney Topor  wrote:
> The "Django at a glance" aka "Overview" page 
> athttp://docs.djangoproject.com/en/dev/intro/overview/is intended to
> introduce new users to models, queries (using the API), URLs, views,
> templates and so on.  In short, it's a simpler version of the
> tutorial.

Nope. It's not a "simpler tutorial" and has nothing to do with a
tutorial.  I think you are indeed "seriously misunderstanding" the
purpose of this page. As the name implies,  it's an *overview* of
Django - ie, it's here to let newcomers get a quick idea of what
Django has to offer.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is best practice for pluggable modules in app

2010-08-24 Thread Jani Tiainen
> Lets say I have shipping app called Shipping which is used for ups and
> fedex.
> I want just using settings.py to enable/disable them.
> 
> The structure could be:
> project
>  shipping
> modules
>   ups
>   fedex
> 
> And by putting in settings.py I could manage those modules
> INSTALLED_APPS = (
>   
>   'shipping.modules.ups',
>   'shipping.modules.fedex',
>   
> )
> 
> So what is the best way to have pluggable modules in app ?

Because Django doesn't have kind of "startup" point, most probably same way as 
admin registrations are handled.

Toplevel urls.py works quite well, just like django admin does.

Then you just need to ways to register your apps in centralized manner and 
you're good to go, specially if your apps need to contribute to ui. 

Note that  appname is only last part of python namespace and it must be unique 
within one django project. For example you can't have "shipping.modules.ups" 
and "invoicing.modules.ups" due the limitations of Django itself.

-- 

Jani Tiainen

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ANN: LFC 1.0

2010-08-24 Thread Kai Diefenbach

Hi guys,

today we released LFC 1.0. This is the first final release of LFC.

LFC is a CMS based on Python, Django and jQuery.

You can find the installer here: 
http://pypi.python.org/pypi/django-lfc/1.0. The installation is 
described here: 
http://packages.python.org/django-lfc/introduction/installation.html  
and should last just a few minutes.


Its main features are:

- Commenting
- Cut/Copy’n Paste
- Easy upload of images and files
- Flexible Databases
- Multilingual content
- Pluggable
- Role based per-object permissions
- RSS Feeds
- Search
- Tagging
- Time based publishing
- Variable Templates
- Variable Portlets
- Variable Workflows
- WYSIWYG-Editor

You can find more information on following places:

- Official Homepage: http://www.lfcproject.com/
- Documentation: http://packages.python.org/django-lfc
- Download: http://pypi.python.org/pypi/django-lfc
- Source Code: http://bitbucket.org/diefenbach/django-lfc
- Google Group: http://groups.google.com/group/django-lfc
- Twitter: http://twitter.com/lfcproject
- IRC: irc://irc.freenode.net/django-lfc

Any suggestions are highly appreciated.

Thanks
Kai


--
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



What is best practice for pluggable modules in app

2010-08-24 Thread Alsond
Lets say I have shipping app called Shipping which is used for ups and
fedex.
I want just using settings.py to enable/disable them.

The structure could be:
project
 shipping
modules
  ups
  fedex

And by putting in settings.py I could manage those modules
INSTALLED_APPS = (
  
  'shipping.modules.ups',
  'shipping.modules.fedex',
  
)

So what is the best way to have pluggable modules in app ?

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Errors when using aggregates

2010-08-24 Thread wally
Problem solved - thanks Russ, appreciate the help.

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What's the best way to custom the add page (in django admin site)

2010-08-24 Thread Sam Lai
On 23 August 2010 22:38, Yangmin Li  wrote:
> sorry for the previous incomplete message.
> Here is what I want to ask, thanks in advanced.
> I have a model called request, after registered in admin backend, user can
> add new request object in admin pages.
> I want to modify the request-add page to this: only some of the model fields
> will be shown to user, others are hidden and will be given default values
> before being saved to database.
> I've already custom the change_form template to hide the fields that I do
> not want to show them to users.
> what else should I do ?

Does that work? If that isn't enough, e.g. you need to add some more
logic into the template processing, you can override the view methods
to provide extra context. See
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#other-methods

> On Mon, Aug 23, 2010 at 8:31 PM, Yangmin Li  wrote:
>>
>> Hi All ,
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Errors when using aggregates

2010-08-24 Thread Russell Keith-Magee
On Tue, Aug 24, 2010 at 2:29 PM, wally  wrote:
> I'm getting some strange errors when trying to use the aggregate
> functions. My model looks like...
>
> class test(models.Model):
>     a = models.IntegerField()
>
> After creating a few records, I try the following:
>
 test.objects.all().aggregate(sum('a'))
> Traceback (most recent call last):
>  File "", line 1, in ?
> TypeError: unsupported operand type(s) for +: 'int' and 'str'
>
 test.objects.all().aggregate(max('a'))
> Traceback (most recent call last):
>  File "", line 1, in ?
>  File "/usr/lib/python2.4/site-packages/django/db/models/query.py",
> line 303, in aggregate
>    kwargs[arg.default_alias] = arg
> AttributeError: 'str' object has no attribute 'default_alias'
>
> I get the same response from django 1.2.0 and current SVN, .python
> 2.4.3 under CentOS 5.4.
>
> Am I missing something here? Do I have the syntax correct? Any help
> would be appreciated.

Almost, but not quite.

There is a difference between max() the python builtin function for
finding a maximum value, and Max(), Django's representation of an
aggregate function. In both your examples, you're using the Python
builtin. Max, Sum, and the rest of Django's aggregates all need to be
imported from django.db.models.

Yours,
Russ Magee %-)

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Documentation problems: Django at a glance

2010-08-24 Thread Rodney Topor
The "Django at a glance" aka "Overview" page at
http://docs.djangoproject.com/en/dev/intro/overview/ is intended to
introduce new users to models, queries (using the API), URLs, views,
templates and so on.  In short, it's a simpler version of the
tutorial.  But it lacks much information, so it fails to be useful for
new users.  For example:
1. It doesn't note that the models.py file (and others) need to be in
an app and not in the project containing the app.
2. It doesn't note that you need to edit the settings.py file
(database details, apps used) before you can run the "manage.py
syncdb" command.
3. It doesn't note that you need to run the "manage.py shell" command
before you can use the API interactively.
4. It imports model names Reporter and Article from module
mysite.models, but assuming mysite is a project (as it is elsewhere,
e.g., in the tutorial), it should import them from module
mysite.myapp.models.
5. The URLs section similarly assumes the file views.py is in mysite
instead of mysite.myapp.
6. The Templates section assumes templates are stored in a news
subdirectory, but doesn't say where this subdirectory is stored or
whether settings.py needs to be edited to say where templates are
stored.
I think I could go on.
This combination of omissions and errors means that new users can't
run these examples to reinforce their learning before they have
already understood much more about the structure of Django projects,
apps, templates and so on.  This seriously detracts from the
usefulness of the example on this page.
Now I'm sorry if this issue has been raised before or if I'm seriously
misunderstanding Django or the purpose of this page, and if so I hope
someone will enlighten me.
Otherwise, I hope someone  will revise this page to make it more
useful as a stand-alone mini-tutorial.
And I'd appreciate advice as to whether or not it's appropriate to
make these comments as a formal ticket.
Rodney

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



flatpages and menu

2010-08-24 Thread OliverMarchand
Dear all,

I am thinking of creating a website that displays "mostly" database
content, but for special content I am using flatpages. Now somehow I
must put a link to the flatpages somewhere, most likely in a menu. If
I put the menu in my base template, then there is no way to insert
this link by editing.

Do you have a good design idea to make the menu editable as well?

thanks and cheers,
Oliver

-- 
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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.