Re: Form Processing

2008-04-17 Thread Jeff Anderson

gvkreddy wrote:

HI,

This is vamsi . I am new  to Django.

  

Hello!

How  we  can do form processing in django.?

I need in  startup screen  to activate buttons depending on data
stored in  model.
  
I'm not sure exactly what you mean by this. Can you be more specific? 
Django can output just about anything you can think of, but when you say 
"activate buttons" that sounds like you are asking about javascript. 
You'd have to write your javascript. just like any other code that would 
come through the templates for your page.


Good luck!

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Form Processing

2008-04-17 Thread rajiv bammi
Hi..

Please go through following link..
http://www.djangobook.com/en/1.0/chapter07/

feel free if u have any problem ;)

Thanks
Rajiv Bammi

On Fri, Apr 18, 2008 at 11:07 AM, gvkreddy <[EMAIL PROTECTED]> wrote:

>
> HI,
>
> This is vamsi . I am new  to Django.
>
> How  we  can do form processing in django.?
>
> I need in  startup screen  to activate buttons depending on data
> stored in  model.
>
> How  we can done  this  in django?
>
> Any  help.
>
> Thanks  in advance.
>
>
> by
> vamsi
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Form Processing

2008-04-17 Thread gvkreddy

HI,

This is vamsi . I am new  to Django.

How  we  can do form processing in django.?

I need in  startup screen  to activate buttons depending on data
stored in  model.

How  we can done  this  in django?

Any  help.

Thanks  in advance.


by
vamsi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Prepopulate Slugfied from Foreign Key without using the id

2008-04-17 Thread Merrick

Thank you for that, I will have to study that because it is a lot
cleaner than what I did.

I added the following to my City model below Class Meta:

def save(self):
  slug_parts = self.slug.split('-')
  num_slugs = len(slug_parts)
  state_position = (num_slugs - 1)
  state = State.objects.get(id=slug_parts[state_position])
  state_slug = state.state.lower()
  city_slug = ''

  for i in range (0, (state_position)):
  city_slug += slug_parts[i] + '-'

  self.slug = "%s%s" % ( city_slug, state_slug )
  super(City, self).save()


I know it's hack a job.

On Apr 17, 7:36 pm, "James Punteney" <[EMAIL PROTECTED]> wrote:
> The javascript is part of the Simple pages app I've been working on so you
> can view the code 
> here:http://code.google.com/p/django-simplepages/source/browse/trunk/simpl...
>
> It's a little different than what you are doing as I'm not pulling the
> display value of the select box, I'm actually getting another value from the
> foreign key object. I had to do the extra step of using django to print out
> a javascript hash with the id's of the SiteSections as the key and the url
> that I'm using to prepopulate text box (hence the reason this is a django
> template file and not a plain javascript file).
>
> Overall it's pretty close to what you are wanting to do though.
>
> Hope that helps,
> --James
>
> On Thu, Apr 17, 2008 at 4:53 PM, Merrick <[EMAIL PROTECTED]> wrote:
>
> > Hi James,
>
> > thank you for responding, can you point me in the right direction with
> > the javascript.
>
> > --Merrick
>
> > On Apr 17, 1:25 pm, "James Punteney" <[EMAIL PROTECTED]> wrote:
> > > I ran into this issue the other day wanting to use a foreign key value
> > to
> > > prepopulate a slugfield  and just getting the id (if anything).
> > According to
> > > the documentation[1] prepopulate doesn't support foreign keys, so I
> > ended up
> > > going the custom javascript route in order to get it working.
>
> > > --James
>
> > > [1]http://www.djangoproject.com/documentation/model-api/#slugfield
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Feel free to test queryset-refactor branch

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 14:53 -0700, Justin Fagnani wrote:
[...]
> The first thing is that there seems to be no way to tell if an
> instance of a parent class has a child instance without trying the
> child reference and catching the DoesNotExist exception. For a class
> with multiple subclasses, this is a cumbersome, so I've been adding a
> _type field to parent classes that gets set in save() of the
> subclasses.

That's a reasonable way to do it.

Another way is to have an extra table that maps object id and content
type to "most derived content type" or something. If you had third-party
models you were subclassing, that isn't too hard to implement either.

> Is there a better way to do this, or is this something that could be
> included? I know there's no way to determine whether or not a class
> will be subclassed in the future, so I wouldn't be surprised if the
> answer is no.

That's right. There's no way to tell if something's going to be
subclassed and we don't want to change any third-party database tables
(a design feature is that you *must* be able to subclass third-party
models transparently). Also, it's quite fiddly to keep such fields up to
date if you think about the manipulation required for A subclassed by B
subclassed by C. You end up with type fields everywhere.

>  But maybe there should be a documented pattern.

I'll add something. It seems kind of obvious, though, and given that it
isn't a particularly common pattern to query the parents and descend to
the children (if you care about the differences, you'll usually be
querying the children directly; if you care about the common stuff, it's
all on the parent), I'd kind of hope people needing this already had the
skills to connect A to B.

A couple of sentences won't confuse things too much, though. We can fix
that.

> The odd part is what happens with the child reference. parent.child
> obviously works as expected, and returns either an instance of Child
> or raises DoesNotExist. But for an instance of Child, .child always
> returns a reference to itself, so that c.child == c is always True.
> This makes sense on one hand, because c is also an instance of Parent,
> but on the other, Child doesn't have a subclass, so should .child be
> None?

Hmm, hadn't noticed that, although it's not too surprising. My first
reaction is "well, don't do that."

It's quite possibly fiddly to fix, since reverse relations (which is
what the "child" attribute is) should be transparently accessible on any
child class even when they exist on the parent. I think I tried to
prevent the "traversing down to yourself" case at one point and it trips
up when you have multiple subclasses. The structure in the
tests/model_inheritance/models.py test file is a bit of a medium-level
stress test for this behaviour, since multiple unrelated things inherit
from Place and Restaurant (and are related to them and each other) and
there are more twisted cases out there, too. They're not in the test
because they rapidly become almost opaque to comprehension and we try to
keep the tests reasonably clean.

It's probably overkill to add in lots of extra processing to avoid the
case of "things on the path that lead to myself, but don't stop too soon
in the hierarchy" when it's probably easier just to not access that
attribute in the code.

The hard cases are always multi-layer hierarchies (trees of inheritance,
not just linear or dual-level cases). I'll have another look now that
it's been a while since I last look at it and maybe there's an easy fix,
but try to avoid doing that. It doesn't make sense.

> I haven't actually encountered this in any real life situation,
> because it's hard to end up with collection in Django where you have a
> mix of parent and child instances, so maybe it'll never be a problem.

Indeed (hopefully).

We're not actually just making this up as we go along and I suspect
you'll find that the cases that are harder are also relatively rare.
Quite a few of the people involved in the design of this stuff in Django
(particularly 18 months or so ago when we were doing some heavy lifting
in the design are), including myself, have a fair bit of experience with
other OO and inheritance-based systems such as C++, Java, relational
database design and CORBA interfaces,  in addition to Python. Duck
typing is handy quite often in Python, but inheritance at the data layer
level doesn't seem to be one of them. Every situation we could come up
with, or knew about from experience is possible and I hope we've found a
nice middle-ground in order to make the common stuff easy and the rarer
stuff possible (of course, one man's common is another man's rare, but
that's life in a crowded space).

> One additional thing is that in one case, I know which subclasses I'm
> interested in, and it'd be great to have a way to specify that a
> queryset should return polymorphic results by specifying the
> subclasses for the join. Something like:
> 
> 
> 

Re: mail in base64

2008-04-17 Thread James Bennett

On Thu, Apr 17, 2008 at 10:16 PM, Malcolm Tredinnick
<[EMAIL PROTECTED]> wrote:
>  (1) What version of Django are you using (the mail infrastructure has
>  changed a bit between 0.96 and trunk, from memory)?

He was using Django 0.96, and running into this (fixed on trunk) issue:

http://code.djangoproject.com/ticket/3472


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why does one work but not the other

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 12:44 -0700, phillc wrote:
> I was using new forms for one of my forms, and i wanted to save a
> relation.
> i came upon an interesting problem along the way. is there a limit in
> python on the number of chained function calls or something?

Hmm ...there's a fair bit of code here to decode. What you don't mention
is what error you are seeing, or what is going wrong and what you might
have expected to happen. You've left out the description of the problem
that's occurring.

At a guess, though, the problem is that question.options looks like it
is a model instance and yet you keep referring to it as
question.options(). Unless the model instance has a __call__ method,
those tailing parentheses are going to be trouble.

Regards,
Malcolm

-- 
What if there were no hypothetical questions? 
http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mail in base64

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 11:52 -0600, leonel wrote:
> Hello
> 
> I need to send mail  and I'm using  send_mail from django.core.mail
> All works but the mail gets  base64 encoded
> 
> Am I missing some configuration so the send_mail sends the mail not encoded

A few more details are needed here.

(1) What version of Django are you using (the mail infrastructure has
changed a bit between 0.96 and trunk, from memory)?

(2) What type of content are you sending? Email data must normally be
7-bit ASCII, so if you're trying to send stuff outside that range,
encoding must occur.

(3) Why is this even an issue? Mail clients know how to decode base64
encoded email. Any program that consumes email must be able to do the
same, since it's part of the email standards. It shouldn't really make a
difference anywhere. So what's the use-case that requires this?

Regards,
Malcolm

-- 
Experience is something you don't get until just after you need it. 
http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Python lists

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 09:13 -0700, jacoberg2 wrote:
> Hey,
>   this is more of a python question than a django question.

I don't want to sound rude, but this list has a high enough volume
without also starting to double for
http://groups.google.com/group/comp.lang.python/topics?hl=en

It would be nice if people could take their Python-specific questions to
the appropriate Python list so that we can focus on Django here.

Yes, I know it's just one question, but if we answer this, you might
feel like asking a follow-up and then another one and other people will
take the same liberties and now the list is less on-topic than
previously.

Regards,
Malcolm


-- 
The hardness of butter is directly proportional to the softness of the
bread. 
http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to display images in Admin change page?

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 08:06 -0700, Legioneer wrote:
[...]
>  I need to display
> pictures on the latter page. According to documentation one can define
> what to display there in the 'fields' attribute inside Admin inner
> class. But in this attribute only model fields are allowed to be not
> methods. So this is a problem (as I can see it).

Ah well, life's like that sometimes. You can't easily do that with
existing admin. It's not impossible to write your own edit page for a
model in admin -- it's been mentioned on this list before and I believe
there's even a page in the wiki about it (search for admin-related wiki
pages) -- but it's something with a very limited lifespan, since the
technique will be different once newforms-admin lands.

Malcolm

-- 
Works better when plugged in. 
http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django en Dreahost

2008-04-17 Thread Kenneth Gonsalves


On 18-Apr-08, at 5:01 AM, Juanjo Conti wrote:

>>2. Download, Compile and install Python 2.5. DH default is 2.3 and
>>2.4.
>
> Why this? Does not Django run with Python <= 2.3?

afaik no

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Prepopulate Slugfied from Foreign Key without using the id

2008-04-17 Thread James Punteney
The javascript is part of the Simple pages app I've been working on so you
can view the code here:
http://code.google.com/p/django-simplepages/source/browse/trunk/simplepages/templates/pages/auto_url_prepend.js

It's a little different than what you are doing as I'm not pulling the
display value of the select box, I'm actually getting another value from the
foreign key object. I had to do the extra step of using django to print out
a javascript hash with the id's of the SiteSections as the key and the url
that I'm using to prepopulate text box (hence the reason this is a django
template file and not a plain javascript file).

Overall it's pretty close to what you are wanting to do though.

Hope that helps,
--James




On Thu, Apr 17, 2008 at 4:53 PM, Merrick <[EMAIL PROTECTED]> wrote:

>
> Hi James,
>
> thank you for responding, can you point me in the right direction with
> the javascript.
>
> --Merrick
>
>
> On Apr 17, 1:25 pm, "James Punteney" <[EMAIL PROTECTED]> wrote:
> > I ran into this issue the other day wanting to use a foreign key value
> to
> > prepopulate a slugfield  and just getting the id (if anything).
> According to
> > the documentation[1] prepopulate doesn't support foreign keys, so I
> ended up
> > going the custom javascript route in order to get it working.
> >
> > --James
> >
> > [1]http://www.djangoproject.com/documentation/model-api/#slugfield
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ORM questions...I'm not smart

2008-04-17 Thread Richard Dahl

cjl,
Essentially you need metatables that can describe the attributes  
relatable to your main models.  I built a proof of concept db backend  
last year for a 'Database Application for the Management of  
Information related to all Things' , (codenamed: DAMIT) but decided  
that while possible, it was not very practical.  I did it somewhat  
like this (code abbreviated), if my memory serves me:

AttributeType(models.Model):
datatypelist = [('string','string'),('int','int'),('float','float')]
name = CharField()
datatype = CharField(choices=datatypelist)

Attribute(models.Model):
type = FK(AttributeType)
string_data = CharField()
int_data= IntField
float_data=...

AttributeOrder(models.Model):
attributetype=FK(AttributeType)
attributeorder=IntegerField()

AssetType(models.Model):
name=CharField()
attributeorder=M2M(AttributeOrder)

Asset(models.Model):
name = CharField()
assettypes = FK(AssetType)
attributes = M2M(Attribute)

Anyway, I think this is how I did it, as you can probably make out  
from this, you cannot realistically hope to use the admin interface,  
it is essentially unusable, but you can put together a custom  
interface to deal with this.  The attributeorder and attributetype are  
used to build the forms that are presented to a user, the forms being  
nothing more than a collection of attribute.data_X fields that are  
presented in the order specified.  It was not pretty.

The Generic Relations will make this easier, but my advice to you:  
start building what you know you need, and leave yourself some  
flexibility to integrate additional fields through meta-tables only if  
absolutely required.  That is what I am doing with my much scaled down  
'Database Application for the Management of Of Very Specific Types of  
IT Related Information' , although as of yet, I have not needed any  
metatable fields. I am hoping to keep it that way.
HTH,
-richard


On Apr 17, 2008, at 3:22 PM, cjl wrote:

>
> DU:
>
> Don't ask me why, but I got the idea today to create a contact manager
> with Django, mostly as a learning exercise.
>
> Instead of doing it the 'easy' way, I had the dumb idea to make it
> 'dynamic'. What does that mean? I'm glad you asked. Here's how I see
> the database tables (I've omitted primary keys):
>
> contacts -- firstname, lastname
>
> field_definitions -- name, description, valid_regexp
>
> fields -- value, contact, field_definition
>
> Each contact could have as many or as few bits of information
> associated with it.
> I could create a default set of field definitions, ie. "Street
> Address", "Phone Number", etc.
> Field definitions could later be added dynamically, because maybe I
> want to start tracking Birthdays, or URLs, or other things I don't
> know yet.
>
> How dumb is this idea? It's not really an M2M relationship, more like
> an M2M with intermediary data.
>
> I found this:
> http://code.djangoproject.com/ticket/6095
> But this patch is not merged yet. Is there some other way to approach
> this problem?
> Am I wasting my time?
>
> Also, let's say I actually figure out how to do this...and when I look
> at a contact's information I retrieve all of the values that link to
> that contact...how could I intelligently order those values? Let's say
> some of the field definitions are "Street Address", "City", "State",
> and "Zip code", I would want them displayed in a certain
> order...hnot sure how to handle that.
>
> -cjl
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Response JSON Quoting

2008-04-17 Thread Darryl Ross

Szaijan wrote:

Thanks Justin.  Yes, I'm certain.  And my previous install was also
some variety of 0.96, though I downloaded that one manually.


What was the complete SVN URL you used? You can get it with 'svn info' 
in the directory you checked out the Django code to.


Regards
Darryl



signature.asc
Description: OpenPGP digital signature


Re: Best practices sending out http requests from within django code

2008-04-17 Thread Russell Keith-Magee

On Fri, Apr 18, 2008 at 12:51 AM, Dan-Cristian Bogos
<[EMAIL PROTECTED]> wrote:
> Folks,
>
> I was wondering what is the best way to send out http requests from within
> django. Shall I use an external library (like urllib) or use some django
> internals?
> Eg: I want to POST some info on some other django site.

Django is a framework for a HTTP server; it has almost no built-in
client capabilities. You will need to use urllib or something similar.

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



Re: ORM questions...I'm not smart

2008-04-17 Thread ydjango

If Django ORM does not do what you want, use custom query, it is quite
simple.
http://www.djangoproject.com/documentation/model-api/#executing-custom-sql

I just used it to do some aggregation functions(sum).

Rest is pretty much python. use power of python.

thanks
Ashish Gupta

On Apr 17, 1:22 pm, cjl <[EMAIL PROTECTED]> wrote:
> DU:
>
> Don't ask me why, but I got the idea today to create a contact manager
> with Django, mostly as a learning exercise.
>
> Instead of doing it the 'easy' way, I had the dumb idea to make it
> 'dynamic'. What does that mean? I'm glad you asked. Here's how I see
> the database tables (I've omitted primary keys):
>
> contacts -- firstname, lastname
>
> field_definitions -- name, description, valid_regexp
>
> fields -- value, contact, field_definition
>
> Each contact could have as many or as few bits of information
> associated with it.
> I could create a default set of field definitions, ie. "Street
> Address", "Phone Number", etc.
> Field definitions could later be added dynamically, because maybe I
> want to start tracking Birthdays, or URLs, or other things I don't
> know yet.
>
> How dumb is this idea? It's not really an M2M relationship, more like
> an M2M with intermediary data.
>
> I found this:http://code.djangoproject.com/ticket/6095
> But this patch is not merged yet. Is there some other way to approach
> this problem?
> Am I wasting my time?
>
> Also, let's say I actually figure out how to do this...and when I look
> at a contact's information I retrieve all of the values that link to
> that contact...how could I intelligently order those values? Let's say
> some of the field definitions are "Street Address", "City", "State",
> and "Zip code", I would want them displayed in a certain
> order...hnot sure how to handle that.
>
> -cjl
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django en Dreahost

2008-04-17 Thread Juanjo Conti

book4e escribió:
> I've installed and run a django app on dreamhost without problem. I
> recommend do the following things before install your django app.
> 
>1. Install virtualenv  to
>create your own Python environment.
>2. Download, Compile and install Python 2.5. DH default is 2.3 and
>2.4.

Why this? Does not Django run with Python <= 2.3?

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Feel free to test queryset-refactor branch

2008-04-17 Thread scott lewis


On 2008-04-17, at 1553, Justin Fagnani wrote:

> Hey Malcolm,
>
> I've been using qs-rf for a while now with basically no problems.  
> Excellent work.
>
> There's one thing that may a little odd that I stumbled on while  
> trying to get some primitive polymorphism working:
>
> The first thing is that there seems to be no way to tell if an  
> instance of a parent class has a child instance without trying the  
> child reference and catching the DoesNotExist exception. For a class  
> with multiple subclasses, this is a cumbersome, so I've been adding  
> a _type field to parent classes that gets set in save() of the  
> subclasses.
>
> Is there a better way to do this, or is this something that could be  
> included? I know there's no way to determine whether or not a class  
> will be subclassed in the future, so I wouldn't be surprised if the  
> answer is no. But maybe there should be a documented pattern.
>
> The odd part is what happens with the child reference. parent.child  
> obviously works as expected, and returns either an instance of Child  
> or raises DoesNotExist. But for an instance of Child, .child always  
> returns a reference to itself, so that c.child == c is always True.  
> This makes sense on one hand, because c is also an instance of  
> Parent, but on the other, Child doesn't have a subclass, so  
> should .child be None?
>
> I haven't actually encountered this in any real life situation,  
> because it's hard to end up with collection in Django where you have  
> a mix of parent and child instances, so maybe it'll never be a  
> problem.
>
> One additional thing is that in one case, I know which subclasses  
> I'm interested in, and it'd be great to have a way to specify that a  
> queryset should return polymorphic results by specifying the  
> subclasses for the join. Something like:
>
> Parent.objects.all().select_subclasses('Child1','Child2')


This is a dirty hack, but it came in handy for me...

If you add this method to your parent class:

 def canonical(self):
 attr_name = '%s_ptr' % self._meta.module_name
 children_fields = [r.get_accessor_name() for r in  
self._meta.get_all_related_objects() if r.field.name == attr_name]
 for f in children_fields:
 try:
 return getattr(self, f).canonical()
 except models.ObjectDoesNotExist:
 pass
 return self

You can then convert a queryset to a list of child classes:

 child_classes = [c.canonical() for c in Parent.objects.all()]

Basically, canonical() tries to grab a list of descendant classes,  
then cycles through those until it finds one that exists. If it can't  
find an instance of a descendant class, it just hands back the parent  
since that's what you have.  It's also recursive so it will traverse n- 
levels of inheritance.


scott.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Enterprise applications with Django

2008-04-17 Thread ydjango


rather comparing with J2EE (which has made quite a few bad
architecture choices on the way), better is to see what are your
requirements and see if Python and django can do it with less effort
and more elegance, while achieving desired maintainability,
performance and scalability. and from answers on this thread looks
like it python and django can be a good choice.

a dated article on how and where Google uses Python
http://panela.blog-city.com/python_at_google_greg_stein__sdforum.htm

It looks like python has been traditionally used as better replacement
of Perl, for scripting and glue code and in operations.
Java and J2EE has been more popular for building business
applications.

that said, it is changing fast. Partly because people frustration with
J2EE and its mistakes ( high complexity, high development time, EJB 2
model etc.)
 and partly because frameworks like django are turning out to be such
awesome alternative.


( DIsclaimer: I have almost 10 years of enterprise-class J2EE
architecture and oracle experience and before that C. And I like Java
and J2ee both despite the shortcomings which I have learned to avoid.)

BTW, the having presentation and business logic on same physical
server is nothing bad in itself, till they are logically separate.
Even in J2EE enterprise class apps We have gone that route (same
physical server but separate logical tiers) many times to avoid
overhead of remoting/networking and serialization/de-serialization. Of
Course there are surely few cases where you may want separate physical
tiers.

Ashish

On Apr 16, 7:43 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Hussein B wrote:
> > In Java we have a dedicated component model for business logic (EJB)
> > and the ability to call remotely other components
> > With Java, we can create 3-tier enterprise applications not to mention
> > a cluster of servers.
> > I didn't play with Django yet but it seems to me that the presentation
> > and logic are located on the same server for Django applications.
>
> Have you looked at PEAK Python Enterprise Application 
> Kithttp://peak.telecommunity.com/
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
>
> ___
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Generic views and user's objects

2008-04-17 Thread picky

Hi,

I'm trying to use generic view in my app and I have some problems with
objects related to the logged user.

Here is a simplified version of my models :

class Animal(models.Model):
owner = models.ForeignKey(User)
gender = models.CharField(max_length=1, choices=GENDERS)
mother = models.ForeignKey('self',
limit_choices_to={'gender_exact':'F'})
...

class Treatment(models.Model):
date = models.DateField()
animal = models.ForeignKey(Animal)
...

1) First, for creation of an Animal, I use the generic view
create_object. In this view, I don't put an input field in my template
for owner field and add a value directly in the POST of my request to
force owner value with logged user id. It works but I don't know if
it's a really good method to do that or if there is another way
smarter :

@login_required
def add_animal(request):
if request.method == 'POST':
request.POST = request.POST.copy()
request.POST.appendlist('owner', '%d' %
(request.user.id))

reponse = create_update.create_object(request, Animal)


2) After that, in this view, I would like to limit choices for the
mother with female animals owned by the user connected. I think to
'limit_choices_to' argument but I don't know if it is possible and how
to limit dynamically with logged user with an argument defined in my
models ... ?
If it isn't possible, which way must I take ?

3) Third questions is like the second. I would like to use
create_object generic view to create Treatment but I would like that
my user can only add treatment on animal owned by himself.

Is there anyone to help me on that ?

Thanks

Mathieu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: session data or ???

2008-04-17 Thread Horst Gutmann

Well, you could minimize the amount of code you will have to repeat
for each and every view function by doing some OOP. For instance you
could probably do something like this in your views.py:

class AbstractView(object):
def __init__(self, request, *args, **kwargs):
# Do some generic stuff here
pass
def __call__(self, *args, **kwargs):
raise RuntimeError, "Not implemented"

class TestView(AbstractView):
def __call__(self, *args, **kwargs):
return render_to_response('some_template.html',{})

def create_view(klass):
def _func(request, *args, **kwargs):
return klass(request, *args, **kwargs)()
return _func

test = create_view(TestView)

This module provides the view "test".
In this case, you'd put the whole generic stuff you want _all_ your
views to perform into the __init__ method of the AbstractView class.
This is just a quick solution, but it should give you an idea of how
to share processing between views if the short processing requires
request-specific data.

I hope this helps (and isn't a really stupid solution for your problem ;-) )

-- Horst

On Wed, Apr 16, 2008 at 11:01 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> great, thank you very much Horst
>
>  now it is working, but still have some question please.
>
>  for instance in my views.py i have:
>
>  index_globals={}
>  Class Test:
>  init and some more data 
>
>  def homepage(request):
> some code with variables 
> index_globals['info'] = user_system
> index_globals['timestamp'] = today
> request.session['index_globals'] = index_globals
>
>
>  so now when i need some data from index_globals in every method i have
>  to call with
>
>  user_start_time = request.session['index_globals']['timestamp']
>
>  but what about if i need in my every method the current url path
>  current_path = request.path
>
>  or this index_globals
>
>  is there a way i can make this variable global(the current_path will
>  change every time when some method in views.py will be called), and it
>  will be automaticaly assign to locals() in every method.
>  just like
>
>  current_path = request.path
>   Class Test:
>
>
>  i hope i describe it well, so you will undestand
>  thank you very much again
>  pavel
>
>
>
>  Horst Gutmann wrote:
>  > Well, depending on how you handle this "variable" you have multiple 
> options:
>  >
>  > 1. Store it into the session using request.session['info'] = info and
>  > retrieve it later from the session when you want to use this data.
>  > 2. If you also want to keep this "choice" permanently associated with
>  > the user, I'd store it in the user's profile
>  >
>  > IMO these are the only options you have and they are not really bad
>  > ones. Naturally you could also simply pass that choice using GET
>  > parameters, but again: This depends on how you want to use this value.
>  >
>  > -- Horst
>  >
>  > On Tue, Apr 15, 2008 at 3:09 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 
> wrote:
>  >
>  >> ok i will try to explain.
>  >>
>  >>  when i or whoever visit homepage, the method from views.py generates
>  >>  some data, for example
>  >>  info about operating system or whatever, just some value stored in
>  >>  variable or dict, let's call it
>  >>  info = {'system': 'unix'}
>  >>
>  >>  later when user is browsing the site, he/she visits some other part of
>  >>  site when some other method is called. And i need to access this 
> variable.
>  >>  So does it mean that in every method where i need to work with this
>  >>  variable i have to save it to sessions in first method and use
>  >>  request.session in method where i need to work with this variable, or is
>  >>  there some better way how to pass this variable?
>  >>  Please feel free to show me some code examples.
>  >>
>  >>
>  >> thank you
>  >>  pavel
>  >>
>  >>  Horst Gutmann wrote:
>  >>  > Why do you want to manipulate just a specific session that might not
>  >>  > even be an existing sesion anymore? And for what reason do you want to
>  >>  > give other views the same data as the last view that's been used? To
>  >>  > me this sounds just like using a normal session (as provided by
>  >>  > request.session) ...
>  >>  >
>  >>  > Could you perhaps tell a few more details about what you want to
>  >>  > achieve and for what reason? :-)
>  >>  >
>  >>  > -- Horst
>  >>  >
>  >>  > On Tue, Apr 15, 2008 at 2:19 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 
> wrote:
>  >>  >
>  >>  >> hi Horst
>  >>  >>
>  >>  >>  the last_login is an example from documentation. My problems are, 
> that
>  >>  >>  when i save something to the session(as current date, or user agent)
>  >>  >>  with some key, and then look to database from terminal, the key is
>  >>  >>  different.
>  >>  >>
>  >>  >>  The second problem is, that i cannot find a way how to pass some data
>  >>  >>  from one function to all other functions.
>  >>  >>
>  >>  >>  thank you
>  >>  >>  pavel
>  >>  >>
>  >>  >>

Memory Usage on a VPS

2008-04-17 Thread Tim Sawyer

Hi Folks,

I'm having trouble with Apache/Django memory usage on a Virtual Private 
Server.  I only have 150Mb memory.

I've turned KeepAlive off.  I think I'm using prefork (how do I tell?) and 
it's set at the following:


StartServers  2
MinSpareServers   1
MaxSpareServers   5
MaxClients   40
MaxRequestsPerChild 100
ServerLimit  30


php is also installed, and I have some sites using it, but I only started 
getting these out of memory errors after adding django stuff in, and then 
only recently.

I've just restarted apache, exim4, spamassassin etc, and top is giving me:

top - 22:54:32 up  4:13,  1 user,  load average: 1.01, 0.85, 0.76
Tasks:  59 total,   2 running,  57 sleeping,   0 stopped,   0 zombie
Cpu(s):  6.6%us,  0.7%sy,  0.0%ni, 56.2%id, 36.5%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:145648k total,   141976k used, 3672k free,  552k buffers
Swap:   262136k total,23728k used,   238408k free,20972k cached

which i think means I'm swapping.

Doing a ps aux gives only the following processes using double figures % of 
memory:

www-data  5103  0.1 13.4  38408 19568 ?S22:39   
0:01 /usr/sbin/apache2 -k start
www-data  5104  0.8 14.4  38696 21088 ?S22:39   
0:08 /usr/sbin/apache2 -k start
www-data  5118  0.3 13.7  38060 20064 ?S22:39   
0:03 /usr/sbin/apache2 -k start
www-data  5128  0.0 11.6  37220 17000 ?S22:40   
0:00 /usr/sbin/apache2 -k start
www-data  5129  0.3 13.6  36588 19816 ?S22:40   
0:03 /usr/sbin/apache2 -k start
root  5478  0.0 13.2  33324 19328 ?Ss   22:47   
0:00 /usr/sbin/spamd --create-prefs --max-children 
1 --helper-home-dir -d --pidfile=/v
root  5480  0.0 18.9  35800 27588 ?S22:47   0:00 spamd child

The problem I had a 5.30pm tonight was a total lack of memory, 
from /var/log/messages:

Apr 17 18:28:35 tsawyer kernel: Mem-info:
Apr 17 18:28:35 tsawyer kernel: Normal per-cpu:
Apr 17 18:28:35 tsawyer kernel: CPU0: Hot: hi:   42, btch:   7 usd:  31   
Cold: hi:   14, btch:   3 usd:   2
Apr 17 18:28:35 tsawyer kernel: Active:16505 inactive:16320 dirty:0 
writeback:0 unstable:0 free:389 slab:2005 mapped:35 pagetables:585
Apr 17 18:28:35 tsawyer kernel: Normal free:1556kB min:1560kB low:1948kB 
high:2340kB active:66020kB inactive:65280kB present:152400kB pages_scanne
d:310107 all_unreclaimable? yes
Apr 17 18:28:35 tsawyer kernel: lowmem_reserve[]: 0 0
Apr 17 18:28:35 tsawyer kernel: Normal: 1*4kB 8*8kB 15*16kB 5*32kB 1*64kB 
0*128kB 0*256kB 0*512kB 1*1024kB 0*2048kB 0*4096kB = 1556kB
Apr 17 18:28:35 tsawyer kernel: Swap cache: add 2420111, delete 2420037, find 
844817/1198912, race 8+3621
Apr 17 18:28:35 tsawyer kernel: Free swap  = 0kB
Apr 17 18:28:35 tsawyer kernel: Total swap = 262136kB
Apr 17 18:28:35 tsawyer kernel: Free swap:0kB
Apr 17 18:28:35 tsawyer kernel: 38400 pages of RAM
Apr 17 18:28:35 tsawyer kernel: 0 pages of HIGHMEM
Apr 17 18:28:35 tsawyer kernel: 1988 reserved pages
Apr 17 18:28:35 tsawyer kernel: 246 pages shared
Apr 17 18:28:35 tsawyer kernel: 74 pages swap cached

How I can reduce the memory usage?  Any pointers appreciated.

Thanks,

Tim.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Feel free to test queryset-refactor branch

2008-04-17 Thread Justin Fagnani
Hey Malcolm,
I've been using qs-rf for a while now with basically no
problems. Excellent work.

There's one thing that may a little odd that I stumbled on while trying to
get some primitive polymorphism working:

The first thing is that there seems to be no way to tell if an instance of a
parent class has a child instance without trying the child reference and
catching the DoesNotExist exception. For a class with multiple subclasses,
this is a cumbersome, so I've been adding a _type field to parent classes
that gets set in save() of the subclasses.

Is there a better way to do this, or is this something that could be
included? I know there's no way to determine whether or not a class will be
subclassed in the future, so I wouldn't be surprised if the answer is no.
But maybe there should be a documented pattern.

The odd part is what happens with the child reference. parent.child
obviously works as expected, and returns either an instance of Child or
raises DoesNotExist. But for an instance of Child, .child always returns a
reference to itself, so that c.child == c is always True. This makes sense
on one hand, because c is also an instance of Parent, but on the other,
Child doesn't have a subclass, so should .child be None?

I haven't actually encountered this in any real life situation, because it's
hard to end up with collection in Django where you have a mix of parent and
child instances, so maybe it'll never be a problem.

One additional thing is that in one case, I know which subclasses I'm
interested in, and it'd be great to have a way to specify that a queryset
should return polymorphic results by specifying the subclasses for the join.
Something like:

Parent.objects.all().select_subclasses('Child1','Child2')

Cheers and thanks,
  Justin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login with email

2008-04-17 Thread Chris

> Unless you imported Auth into the local namespace you need to call
> auth.authenticate().


Thanks for the humor!!  :)

>>> from django.contrib.auth import authenticate, login
>>> test = authenticate(username="testuser", password="testpass")
>>> test



If that were the case it would more than likely through an import
error which it is not. I use this same bit of code to login the use
when they complete registration. Its when the user goes to login it
does not return a user object to complete the login request.


On Apr 17, 4:51 pm, jonknee <[EMAIL PROTECTED]> wrote:
> > I can't get a user object to return from authenticate. any
> > suggestions?
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Prepopulate Slugfied from Foreign Key without using the id

2008-04-17 Thread Merrick

Hi James,

thank you for responding, can you point me in the right direction with
the javascript.

--Merrick


On Apr 17, 1:25 pm, "James Punteney" <[EMAIL PROTECTED]> wrote:
> I ran into this issue the other day wanting to use a foreign key value to
> prepopulate a slugfield  and just getting the id (if anything). According to
> the documentation[1] prepopulate doesn't support foreign keys, so I ended up
> going the custom javascript route in order to get it working.
>
> --James
>
> [1]http://www.djangoproject.com/documentation/model-api/#slugfield
>
> On Thu, Apr 17, 2008 at 4:11 PM, Jeff Anderson <[EMAIL PROTECTED]>
> wrote:
>
> > Merrick wrote:
>
> > > I setup the classes below in my model and would like to have access to
> > > the name of the state in the City model for use in the SlugField. As
> > > it is, I get the state id not the name of the state in the slugfield
> > > when I add a City through the admin.
>
> > This is the correct behavior-- It needs to store the id in the database.
> > When you say "I get the id" where are you doing this from? A template?
>
> > Post the code that you are using to display the information, as your
> > models appear to be done correctly.
>
> > Jeff Anderson
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: login with email

2008-04-17 Thread jonknee


> I can't get a user object to return from authenticate. any
> suggestions?
>

Unless you imported Auth into the local namespace you need to call
auth.authenticate().
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Virtual fields/columns [filtering ordering]

2008-04-17 Thread g00fy

In my project i need to have fields that are dynamic generated. By
that i mean sth like SQL : "price*2 as price_2" but more complex. ( i
need to have "price*ratio + left join ). So i need to add some code in
to SQL that django generates, but i don't want to do whole SQL by
myself. Currently i'm using extra() solution, but the SQL looks awful
and the db takes long:
extra(select:{'usd_price':'SELECT price*ratio FROM exchange WHERE
exchange.from = "eur" AND exchange.to = "usd"', })
I found the solution that is used in DjangoMultilingual
http://code.google.com/p/django-multilingual/source/browse/trunk/multilingual/query.py
but i'm not shure how it works.
What would be the best solution for my problem considering that i
would like to make possible ordering by that field
[ filter(usd_price__gte =100 ) , order('-usd_price') etc ]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Prepopulate Slugfied from Foreign Key without using the id

2008-04-17 Thread James Punteney
I ran into this issue the other day wanting to use a foreign key value to
prepopulate a slugfield  and just getting the id (if anything). According to
the documentation[1] prepopulate doesn't support foreign keys, so I ended up
going the custom javascript route in order to get it working.

--James

[1]http://www.djangoproject.com/documentation/model-api/#slugfield


On Thu, Apr 17, 2008 at 4:11 PM, Jeff Anderson <[EMAIL PROTECTED]>
wrote:

> Merrick wrote:
>
> > I setup the classes below in my model and would like to have access to
> > the name of the state in the City model for use in the SlugField. As
> > it is, I get the state id not the name of the state in the slugfield
> > when I add a City through the admin.
> >
> This is the correct behavior-- It needs to store the id in the database.
> When you say "I get the id" where are you doing this from? A template?
>
> Post the code that you are using to display the information, as your
> models appear to be done correctly.
>
> Jeff Anderson
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ORM questions...I'm not smart

2008-04-17 Thread cjl

DU:

Don't ask me why, but I got the idea today to create a contact manager
with Django, mostly as a learning exercise.

Instead of doing it the 'easy' way, I had the dumb idea to make it
'dynamic'. What does that mean? I'm glad you asked. Here's how I see
the database tables (I've omitted primary keys):

contacts -- firstname, lastname

field_definitions -- name, description, valid_regexp

fields -- value, contact, field_definition

Each contact could have as many or as few bits of information
associated with it.
I could create a default set of field definitions, ie. "Street
Address", "Phone Number", etc.
Field definitions could later be added dynamically, because maybe I
want to start tracking Birthdays, or URLs, or other things I don't
know yet.

How dumb is this idea? It's not really an M2M relationship, more like
an M2M with intermediary data.

I found this:
http://code.djangoproject.com/ticket/6095
But this patch is not merged yet. Is there some other way to approach
this problem?
Am I wasting my time?

Also, let's say I actually figure out how to do this...and when I look
at a contact's information I retrieve all of the values that link to
that contact...how could I intelligently order those values? Let's say
some of the field definitions are "Street Address", "City", "State",
and "Zip code", I would want them displayed in a certain
order...hnot sure how to handle that.

-cjl

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Prepopulate Slugfied from Foreign Key without using the id

2008-04-17 Thread Jeff Anderson

Merrick wrote:

I setup the classes below in my model and would like to have access to
the name of the state in the City model for use in the SlugField. As
it is, I get the state id not the name of the state in the slugfield
when I add a City through the admin.
This is the correct behavior-- It needs to store the id in the database. 
When you say "I get the id" where are you doing this from? A template?


Post the code that you are using to display the information, as your 
models appear to be done correctly.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: How to organize views that combine multiple models

2008-04-17 Thread brooks

I'd put it in a separate, "global" views.py, outside both, like this:

project/
profile/
employment/
urls.py
views.py

--
Brooks

On Apr 16, 5:26 pm, meppum <[EMAIL PROTECTED]> wrote:
> I have a Profile app and an Employment app under one project. I've
> split these into two applications so I can reuse the Employment one
> later as it's generic (it has address, employers, and employment
> models in it). I'd like to have a single page for editing a users
> profile and their employment information using some jquery javascript
> tabs. To do this I'll need a single view that passes both the users
> profile record and employment record.
>
> My question is, where would this view go? In the profile app or the
> employment app? It seems like it would be both, but I'm not sure. I
> ask only because I'd like to keep in tune with Djangos' DRY principle.
>
> -meppum
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Prepopulate Slugfied from Foreign Key without using the id

2008-04-17 Thread Merrick

I setup the classes below in my model and would like to have access to
the name of the state in the City model for use in the SlugField. As
it is, I get the state id not the name of the state in the slugfield
when I add a City through the admin. I know the admin is aware of this
value because the select list shows me the state name, how can I
access that instead of the id of the foreign key.

I am on the latest version of django and am trying to avoid using
javascript. I am not using the built in US Statefield because this is
for an international project and another app I am using is not
compatible with new-forms admin thus local flavor is also not an
option. Thanks. -Merrick



class State(models.Model):
state = models.CharField(max_length=100, unique=True)

class Admin:
pass

def __str__(self):
return self.state

class Meta:
ordering = ['state']


class City(models.Model):
city = models.CharField(max_length=100, unique=True)
state = models.ForeignKey(State)
slug = models.SlugField(prepopulate_from=('city', 'state'), unique=True)
is_public = models.BooleanField(_('is public'), default=False,
help_text=_('Public cities will be
displayed in the default views.'))
class Admin:
list_filter = ['state']
def __unicode__(self):
  return '%s, %s' % (self.city, self.state)

class Meta:
verbose_name_plural = 'cities'
ordering = ['city']

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Why does one work but not the other

2008-04-17 Thread phillc

I was using new forms for one of my forms, and i wanted to save a
relation.
i came upon an interesting problem along the way. is there a limit in
python on the number of chained function calls or something?

This did not work:

class q_to_q_form(forms.Form):
def __init__(self, columns, question, *args, **kwargs):
super(q_to_q_form, self).__init__(*args, **kwargs)
self.question = question
self.fields['link'] = q2qModelChoiceField(required = False,
queryset = columns, label=question.asked_question)
def save(self):
self.question.options().q_column = self.cleaned_data['link']
self.question.options().q_column.save()


This worked:

class q_to_q_form(forms.Form):
def __init__(self, columns, question, *args, **kwargs):
super(q_to_q_form, self).__init__(*args, **kwargs)
self.options = question.options()  This
line
self.fields['link'] = q2qModelChoiceField(required = False,
queryset = columns, label=question.asked_question)
def save(self):
self.options.q_column = self.cleaned_data['link'] ###
and this line #
self.options.save()


all i did was move a function over


other info that might help

class q2qModelChoiceField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return obj.value


inside my Question model class is method

def options(self):
if ##criteria ##
## other code here ##
elif ## criteria ##
options, created =
some_other_object.objects.get_or_create(question=self)
return options


This confused me for a long time, and baffles me that just moving that
one thing over made it work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



login with email

2008-04-17 Thread Chris

hello, I am working on a website where our client wants to login
through use of an email. I have the registration part figured out but
when I go to login as shown here:

http://dpaste.com/45576/

I can't get a user object to return from authenticate. any
suggestions?

thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange tutorial behavior...

2008-04-17 Thread Jon

Answering my own question here :-)  It looks like this is related to
the proxy server settings in IE.  Home machine didn't use a proxy
server - no problem on IE7 (and probably not a problem on IE6 either).
On work machine, there is a proxy server in the settings and localhost
isn't automatically exempted so this was going through the proxy
server.  When I added localhost to the sites that don't use the proxy
server, it worked in IE6 (and IE7).  Firefox apparently always exempts
localhost (or at least by default) so that was probably why I saw the
immediate difference between IE and FF

So, problem appears to have been solved!

Jon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Migration from Linux to Windows Setup

2008-04-17 Thread oliver

Hi,

you shouldn't really have to change any of your code just the
settings.py file to reflect your new system layout.
I am not sure about IIS and python, i am sure there will be a lot of
hits when you google "python iis".
Mysql should not be a problem either.
Windows is less restrictive on directories so it should be easy to get
the "uploading" to work.

I develop on Windows, but host on linux. (using svn you keep the live
system up to date).

The main issue will be running your project via IIS (never done it so
dont know).

oliver

On Apr 17, 2:06 pm, shocks <[EMAIL PROTECTED]> wrote:
> Hi
>
> I've been using Django for a while on a Linux setup.  For this next
> job, Django will have to run on Windows Server 2003 with IIS 6 and
> MySQL.  The question I have relates to migrating a project from Linux/
> OS X to Windows.  I don't have a local Windows box setup at the moment
> and I will develop on a OS X test environment and then deploy the site
> onto the Windows box.  Is this a bad idea?  What issues could there be
> developing in OS X and deploying the site over to Windows?  I'm trying
> to avoid having to upgrade to a new Mac to run Windows through
> VMware.  I'm wondering about file and path issues, configuration, and
> differences between Python/Django on different platforms.
>
> Some specs of the site are:
> 1. CMS (just the admin tool) with multiple users
> 2. Uploading of images and other content
> 3. WSGI integration
> 4. Blog
> etc...
>
> Cheers!
> Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mail in base64

2008-04-17 Thread leonel

Hello

I need to send mail  and I'm using  send_mail from django.core.mail
All works but the mail gets  base64 encoded

Am I missing some configuration so the send_mail sends the mail not encoded

Thank You

Leonel


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange tutorial behavior...

2008-04-17 Thread Jon

Both cases I am using MySQL 5.0.  However, new info: this ONLY appears
in IE.  When I use Firefox, this doesn't happen.  I think this may be
an IE 6.0 problem.  I am using IE 6.0 on this machine, but at home, i
was using IE 7.0.

Still, this seems really weird.

Also, when I switch from http://localhost:8000/admin/ to
http://127.0.0.1:8000/admin/, the second exception that was occurring
above disappears (only the first remains).  And when I switch to
Firefox, no problems at all.

Any ideas?

Jon

On Apr 17, 1:27 pm, "Hernan Olivera" <[EMAIL PROTECTED]> wrote:
> Maybe something about your database settings.
> You don't say what db are you using in each case.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model View Releationship with basic newforms

2008-04-17 Thread [EMAIL PROTECTED]

Very new to Django and am trying to create an application with several
form comprising a model class. I am using:

from django import newforms as forms # and not the ModelForm

The begining of my Policy model looks like:

class Policy(models.Model):
zip_code = models.CharField(maxlength=5)
current_insurance = models.CharField(maxlength=1, choices=YN_CHOICES)
license_more_than_3yrs = models.CharField(maxlength=1,
choices=YN_CHOICES)
acc_viol_3yrs = models.CharField(maxlength=1, choices=YN_CHOICES)
first_name = models.CharField(maxlength=20, null=True)
last_name = models.CharField(maxlength=25, null=True)

And my segment of my view is like:

form_zip_code = form.clean_data['zip_code']
form_current_insurance = 
form.clean_data['current_insurance']
form_license_more_than_3yrs =
form.clean_data['license_more_than_3yrs']
form_acc_viol_3yrs = form.clean_data['acc_viol_3yrs']
p = Policy(zip_code=form_zip_code,
current_insurance=form_current_insurance,
license_more_than_3yrs=form_license_more_than_3yrs,
acc_viol_3yrs=form_acc_viol_3yrs)
p.save()


I was using the same namespace in my model/view/form and would have
prefered to do something like:

form_zip_code = form.clean_data['zip_code']
current_insurance = form.clean_data['current_insurance']
license_more_than_3yrs = 
form.clean_data['license_more_than_3yrs']
acc_viol_3yrs = form.clean_data['acc_viol_3yrs']
p = Policy(zip_code, current_insurance, 
license_more_than_3yrs,
acc_viol_3yrs)
p.save()


But this does not work. What can I do different? I would like move to
the ModelForm but there a few dependancies that I need to figure out
and I would like to get this to work cleanly before I do.

Thanks

Frank


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange tutorial behavior...

2008-04-17 Thread Hernan Olivera

Maybe something about your database settings.
You don't say what db are you using in each case.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange tutorial behavior...

2008-04-17 Thread Jon

Sure!

On Apr 17, 12:00 pm, "Eric Liu" <[EMAIL PROTECTED]> wrote:
> Hi,
> May be you can post your source code,then we can check it whether there are
> some wongs with it.
>

I simply cut and paste from the tutorial, but here 'tis:

===
polls/models.py:
===
from django.db import models

# Create your models here.
from django.db import models

class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question

class Admin:
  pass

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(maxlength=200)
votes = models.IntegerField()
# ...
def __str__(self):
return self.choice

class Admin:
  pass
===
polls/urls.py:
===
from django.conf.urls.defaults import *

urlpatterns = patterns('',
  (r'^admin/', include('django.contrib.admin.urls')),
)
===

And that is it :-)  Like I said, it was cut-and-paste from the
standard tutorial so unless I screwed something up, I don't see why I
am getting the weird error.

Thanks!

Jon


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Protecting static files

2008-04-17 Thread andy baxter

Nate wrote:
> Hi all,
> I've been googling for days and haven't really found a good solution
> to my problem.
>
> I am building a site where a user can view photos and then choose
> which of the photos they want to purchase. (Weddings/parties/HS
> graduation etc...) My client doesn't want other users of the site to
> be able to access another user's event photos.
> So far the only way I can think to truly secure photos from another
> user is to serve the image up through Django, but the website says
> it's inefficient and insecure. Honestly, the inefficiency, I can
> probably deal with as this site will be for a local photographer who
> probably won't be getting millions of hits per day, but the insecurity
> is what I'm worried about.
>
> I read django's way of protecting static files, but that only limits
> it to a group of people and not an individual.
>
> Can anyone help me?
>
> Thanks!
>
>   
pure-ftpd might be worth looking at. It is an FTP server that lets you 
authenticate requests against a mysql database, and also write simple 
custom authentication backends.

http://www.pureftpd.org/project/pure-ftpd

One way to use it is when someone logs into the site, give them 
time-limited access from the IP address they are using, which is renewed 
every time they view a new page, say for five minutes. This isn't 
perfect security, but would prevent casual attempts to view someone 
else's pictures.

I was going to say that another way would be to embed ftp username / 
password info in the img tags of the pages django serves. I.e. instead of:

http://static.mysite.com/path/img1.jpg;>

you would have:

ftp://user1:[EMAIL PROTECTED]/path/img1.jpg">

However, microsoft have added a 'feature' to IE7 which prevents it from 
opening URLs of this sort, in order (they say) to prevent the risk of 
spoofing attacks like links with the form: 
http://[EMAIL PROTECTED]

see:
http://support.microsoft.com/kb/834489

andy.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Best practices sending out http requests from within django code

2008-04-17 Thread Dan-Cristian Bogos
Folks,

I was wondering what is the best way to send out http requests from within
django. Shall I use an external library (like urllib) or use some django
internals?
Eg: I want to POST some info on some other django site.

Ta,
DanB

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Python lists

2008-04-17 Thread jacoberg2

Hey,
  this is more of a python question than a django question. I have an
XML parser set up to read some files and I want to create a list of
dictionaries to pass to the method in the view. When i create the
list, all the dictionary items end up being the same, instead of
unique like they should be. The following is my endelement code for
the content handler and i will include the code from the actual parser
after that, thanks for any help that comes my way.

def endElement(self, name):
if name == 'vidars_search_result':
return
elif name == 'match':
self.datasets.append(self.single)
elif name == 'udi':
self.single['udi'] = self.udiStr
self.udi = 0
elif name == 'url':
self.single['url'] = self.urlStr
self.url = 0
elif name == 'start_date':
self.single['start_date'] = self.start_dateStr
self.start_date = 0
elif name == 'end_date':
self.single['end_date'] = self.end_dateStr
self.end_date = 0
elif name == 'data_set_type':
self.single['data_set_type'] = self.data_set_typeStr
self.data_set_type = 0
elif name == 'start_time':
self.single['start_time'] = self.start_timeStr
self.start_time = 0
elif name == 'end_time':
self.single['end_time'] = self.end_timeStr
self.end_time = 0
elif name == 'metadata':
self.single['metadata'] = self.metadataStr
self.metadata = 0


here is the parser:

from xmlContent import GetSet
from xml.sax import make_parser
from xml.sax.handler import feature_namespaces

class XMLParser:

def __init__(self):
self.datasets = []

def getDatasets(self):
return self.datasets

def execute_parser(self, file):
f = open(file)
parser = make_parser()

parser.setFeature(feature_namespaces, 0)
handler = GetSet()
parser.setContentHandler(handler)
parser.parse(f)

self.datasets = handler.get_datasetList()
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange tutorial behavior...

2008-04-17 Thread Eric Liu
Hi,
May be you can post your source code,then we can check it whether there are
some wongs with it.

2008/4/17, Jon <[EMAIL PROTECTED]>:
>
>
> I successfully ran the complete tutorial (using version 0.96.1) on my
> home machine over last weekend without incident.
>
> This week, I tried to bring up my new application at work and started
> getting some strange errors in the admin tool.  So I went back and
> redid the tutorial (to see if I was doing anything different in my own
> app that I could understand) and I got the same weird errors (which is
> diffferent from what I got when I did this on my home machine - both
> are Windows XP, one is Home, one is Office, and the home machine is on
> Python 2.4 whereas the office machine is on Python 2.5 - those are the
> only differences).
>
> When I try to open the Polls table in the admin tool (which has the
> Date/Time), I get the following traceback:
>
> Django version 0.96.1, using settings 'mysite.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> [17/Apr/2008 11:37:11] "GET /admin/ HTTP/1.1" 200 5199
> [17/Apr/2008 11:37:16] "GET /admin/polls/choice/ HTTP/1.1" 200 1445
> [17/Apr/2008 11:37:19] "GET /admin/polls/choice/add/ HTTP/1.1" 200
> 3014
> [17/Apr/2008 11:37:19] "GET /admin/jsi18n/ HTTP/1.1" 200 801
> [17/Apr/2008 11:37:29] "GET /admin/ HTTP/1.1" 200 5199
> [17/Apr/2008 11:37:30] "GET /admin/polls/poll/ HTTP/1.1" 200 1435
> [17/Apr/2008 11:37:32] "GET /admin/polls/poll/add/ HTTP/1.1" 200 2881
> [17/Apr/2008 11:37:32] "GET /admin/jsi18n/ HTTP/1.1" 200 801
> Traceback (most recent call last):
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 273, in run
> self.finish_response()
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 312, in finish_response
> self.write(data)
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 391, in write
> self.send_headers()
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 443, in send_headers
> self.send_preamble()
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 370, in send_preamble
> self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 487, in _write
> self.stdout.write(data)
>   File "C:\Python25\lib\socket.py", line 262, in write
> self.flush()
>   File "C:\Python25\lib\socket.py", line 249, in flush
> self._sock.sendall(buffer)
> error: (10054, 'Connection reset by peer')
> Traceback (most recent call last):
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 273, in run
> self.finish_response()
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 312, in finish_response
> self.write(data)
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 391, in write
> self.send_headers()
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 443, in send_headers
> self.send_preamble()
>   File "C:\Python25\Lib\site-packages\django\core\servers
> \basehttp.py", line 373, in send_preamble
> 'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
>   File "C:\Python25\lib\socket.py", line 262, in write
> self.flush()
>   File "C:\Python25\lib\socket.py", line 249, in flush
> self._sock.sendall(buffer)
> error: (10054, 'Connection reset by peer')
>
> The admin app still appears to work and I can put new entries into the
> table.  I just keep getting these tracebacks anytime there is a date/
> time in the view.  This does not appear on the Choices screen which
> has no date in the tutorial, but if I add a date/time field, it starts
> to happen there.  Of course, the traceback indicates that it is
> happening on the time.asctime() call.
>
> Is there something that changed in Python 2.5 that causes this?
>
> HELP :-(
>
>
> Jon Rosen
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authentication django

2008-04-17 Thread Florencio Cano

Here http://www.djangoproject.com/documentation/authentication/ you
can find information about authentication in Django. Hope this helps.

2008/4/17 Fernanda Boronat <[EMAIL PROTECTED]>:
>
>  Hello, I am trying to develop a small application that allows
>  authentication, the idea is that I have a table where I store several
>  characteristics of users, I want to know how I can combine this table
>  to table auth.user of django, and use authentication of django,
>  perform any thing?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Strange tutorial behavior...

2008-04-17 Thread Jon

I successfully ran the complete tutorial (using version 0.96.1) on my
home machine over last weekend without incident.

This week, I tried to bring up my new application at work and started
getting some strange errors in the admin tool.  So I went back and
redid the tutorial (to see if I was doing anything different in my own
app that I could understand) and I got the same weird errors (which is
diffferent from what I got when I did this on my home machine - both
are Windows XP, one is Home, one is Office, and the home machine is on
Python 2.4 whereas the office machine is on Python 2.5 - those are the
only differences).

When I try to open the Polls table in the admin tool (which has the
Date/Time), I get the following traceback:

Django version 0.96.1, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[17/Apr/2008 11:37:11] "GET /admin/ HTTP/1.1" 200 5199
[17/Apr/2008 11:37:16] "GET /admin/polls/choice/ HTTP/1.1" 200 1445
[17/Apr/2008 11:37:19] "GET /admin/polls/choice/add/ HTTP/1.1" 200
3014
[17/Apr/2008 11:37:19] "GET /admin/jsi18n/ HTTP/1.1" 200 801
[17/Apr/2008 11:37:29] "GET /admin/ HTTP/1.1" 200 5199
[17/Apr/2008 11:37:30] "GET /admin/polls/poll/ HTTP/1.1" 200 1435
[17/Apr/2008 11:37:32] "GET /admin/polls/poll/add/ HTTP/1.1" 200 2881
[17/Apr/2008 11:37:32] "GET /admin/jsi18n/ HTTP/1.1" 200 801
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 273, in run
self.finish_response()
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 312, in finish_response
self.write(data)
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 391, in write
self.send_headers()
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 443, in send_headers
self.send_preamble()
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 370, in send_preamble
self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 487, in _write
self.stdout.write(data)
  File "C:\Python25\lib\socket.py", line 262, in write
self.flush()
  File "C:\Python25\lib\socket.py", line 249, in flush
self._sock.sendall(buffer)
error: (10054, 'Connection reset by peer')
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 273, in run
self.finish_response()
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 312, in finish_response
self.write(data)
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 391, in write
self.send_headers()
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 443, in send_headers
self.send_preamble()
  File "C:\Python25\Lib\site-packages\django\core\servers
\basehttp.py", line 373, in send_preamble
'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
  File "C:\Python25\lib\socket.py", line 262, in write
self.flush()
  File "C:\Python25\lib\socket.py", line 249, in flush
self._sock.sendall(buffer)
error: (10054, 'Connection reset by peer')

The admin app still appears to work and I can put new entries into the
table.  I just keep getting these tracebacks anytime there is a date/
time in the view.  This does not appear on the Choices screen which
has no date in the tutorial, but if I add a date/time field, it starts
to happen there.  Of course, the traceback indicates that it is
happening on the time.asctime() call.

Is there something that changed in Python 2.5 that causes this?

HELP :-(

Jon Rosen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi DB question

2008-04-17 Thread Ivan Sagalaev

shabda wrote:
>> You could use SQLAlchemy to access your forum database, as long as you
>> don't need it in the admin.
> 
> As, I just need to access the other DB in one place, I think this is
> the way to go here.

Come on guys! If you just need to create a record in a DB you certainly 
don't need *any* framework for it. It's a Python world, you can just 
write stuff here, not wait for any vendor to supply a framework for 
every possible movement.

This is as simple as:

 db = MySQLdb.connect(host='..', user='..', passwd='..')
 cursor = db.cursor()
 cursor.execute('insert into .. ')

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Session is new every time

2008-04-17 Thread Martin Kaffanke
Hi there!

When I try to login to the admin interface, django tells my my browser
may not support cookies, or something

Now I found out the cookie is stored correctly in the database and the
cookie is correct in firefox (I can read that out with the web-developer
toolbar) - I think the cookie is sent correctly.

But every time I load a django site a new sessionid is stored in the
cookie and database.

I use django behind apache using the wsgi like described here:

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango


What am I doing wrong and how can I solve this Problem?

Thanks,
Martin

-- 
Ihr Partner für Webdesign, Webapplikationen und Webspace.
http://www.roomandspace.com/
Martin Kaffanke +43 650 4514224


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Protecting static files

2008-04-17 Thread Nate

Hi all,
I've been googling for days and haven't really found a good solution
to my problem.

I am building a site where a user can view photos and then choose
which of the photos they want to purchase. (Weddings/parties/HS
graduation etc...) My client doesn't want other users of the site to
be able to access another user's event photos.
So far the only way I can think to truly secure photos from another
user is to serve the image up through Django, but the website says
it's inefficient and insecure. Honestly, the inefficiency, I can
probably deal with as this site will be for a local photographer who
probably won't be getting millions of hits per day, but the insecurity
is what I'm worried about.

I read django's way of protecting static files, but that only limits
it to a group of people and not an individual.

Can anyone help me?

Thanks!

-Nate
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 1 django Project / 2 designs

2008-04-17 Thread Michael
You could also just utilize your view code for the two so you don't need to
change urls.

def index(request):
   ...
   # code here that determines whether you want the winterview or summerview
   if summerview:
 return summerview(request)
   elif winterview:
 return winterview(request)

where summerview and winterview are the view functions that would return the
other two.


On Thu, Apr 17, 2008 at 6:10 AM, Massimiliano Ravelli <
[EMAIL PROTECTED]> wrote:

>
>
>
> On 15 Apr, 10:41, martyn <[EMAIL PROTECTED]> wrote:
> > I want a default saison (that could be stored in my settings file).
> > It's not only a different design but it's also a different content
> > sometimes.
> >
> > Is this can be done with middleware ? session ?
> > I don't really know this aspect of django.
>
> What about a redirect ?
>
> from django.http import HttpResponseRedirect
> def home_page(request):
>return HttpResponseRedirect("http://domain.com/winter/ ")
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authentication django

2008-04-17 Thread Fernanda Boronat

Hello, I am trying to develop a small application that allows
authentication, the idea is that I have a table where I store several
characteristics of users, I want to know how I can combine this table
to table auth.user of django, and use authentication of django,
perform any thing?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to display images in Admin change page?

2008-04-17 Thread Legioneer

  Hi Malcolm,

  Am I right that list_display option affects display on the change
list page (where one can select an object to change from the list)
rather than on an individual object change page where propetries of
the individual object are presented for edit? I need to display
pictures on the latter page. According to documentation one can define
what to display there in the 'fields' attribute inside Admin inner
class. But in this attribute only model fields are allowed to be not
methods. So this is a problem (as I can see it).

Anthony

On Apr 17, 6:08 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-04-17 at 07:00 -0700, Legioneer wrote:
> > Hi All!
>
> > Trying to get a solution for a problem. I have a model which has one
> > to many relationship with another model which contains an ImageField.
> > E.g:
>
> > class Person(models.Model):
> > name = models.CharField(max_length=512)
>
> > class Image(models.Model):
> > image = models.ImageField(upload_to='/images')
> > active = models.BooleanField(default=True)
> > person = models.ForeignKey(Person)
>
> > How is it possible to display pictures of a person (with checkbox
> > corresponding to 'active' field) in a person change page instead of
> > filenames when using django admin? Is there some 'render' method in a
> > model or smth like this? Any clue will be appreciated.
>
> Read the documentation for the list_display option in the Admin inner
> class. You can use methods on the model to create output for the change
> list page, so a method on the Person model could return the HTML
> required to display the image (read about the allow_tags attribute on
> methods in the same section of the documentation). Another method could
> return the "active" link.
>
> Regards,
> Malcolm
>
> --
> Plan to be spontaneous - tomorrow.http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi DB question

2008-04-17 Thread shabda

>You could use SQLAlchemy to access your forum database, as long as you
>don't need it in the admin.

As, I just need to access the other DB in one place, I think this is
the way to go here.

On Apr 17, 7:50 pm, "Ariel Mauricio Nunez Gomez"
<[EMAIL PROTECTED]> wrote:
> On Thu, Apr 17, 2008 at 6:00 AM, shabda <[EMAIL PROTECTED]> wrote:
>
> > I have a forum(non-Django) and a Django app both are in different
> > databases.
>
> Can you install django on the forum database? It would probably make your
> life a lot easier as you could write custom django models to use the forum
> app tables and handle them via the admin or scripts.
>
> Regards,
> Ariel.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi DB question

2008-04-17 Thread Ariel Mauricio Nunez Gomez
On Thu, Apr 17, 2008 at 6:00 AM, shabda <[EMAIL PROTECTED]> wrote:

>
> I have a forum(non-Django) and a Django app both are in different
> databases.


Can you install django on the forum database? It would probably make your
life a lot easier as you could write custom django models to use the forum
app tables and handle them via the admin or scripts.

Regards,
Ariel.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reverse relations, select_related, and the Queryset Refactor Branch

2008-04-17 Thread robotika

Awesome, thanks for the clarification Malcolm. It's certainly
something I think would be useful, especially when it comes to
geographically aware applications. I only wish I was smart enough to
help contribute towards it :) I'm probably going to try having a
GenericRelation model sit inbetween a GeoPoint model and the other
location based models in the hope that maybe it'll work without too
much stress on a server... especially in situations where there will
be the constant updating and plotting of objects when a user moves
around a map.

Thanks again :)

John

On Apr 16, 1:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:

> Not impossible to solve, but important to solve it efficiently and not
> entirely trivial to do so. Therefore, something for The Future.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to display images in Admin change page?

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 07:00 -0700, Legioneer wrote:
> Hi All!
> 
> Trying to get a solution for a problem. I have a model which has one
> to many relationship with another model which contains an ImageField.
> E.g:
> 
> class Person(models.Model):
> name = models.CharField(max_length=512)
> 
> class Image(models.Model):
> image = models.ImageField(upload_to='/images')
> active = models.BooleanField(default=True)
> person = models.ForeignKey(Person)
> 
> 
> How is it possible to display pictures of a person (with checkbox
> corresponding to 'active' field) in a person change page instead of
> filenames when using django admin? Is there some 'render' method in a
> model or smth like this? Any clue will be appreciated.

Read the documentation for the list_display option in the Admin inner
class. You can use methods on the model to create output for the change
list page, so a method on the Person model could return the HTML
required to display the image (read about the allow_tags attribute on
methods in the same section of the documentation). Another method could
return the "active" link. 

Regards,
Malcolm

-- 
Plan to be spontaneous - tomorrow. 
http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi DB question

2008-04-17 Thread Daryl Spitzer

> Is there a recent merge of Django and MultiDB?

Not that I know of.

> Do I need to use MultiDB branch for this, or is there a simpler way?

You could use SQLAlchemy to access your forum database, as long as you
don't need it in the admin.

See also this recent django-users thread:
http://groups.google.com/group/django-users/browse_thread/thread/2fb947b2305b78f/16bb2efc3c249cbe?hl=en=gst=multiple+databases#16bb2efc3c249cbe

--
Daryl


On Thu, Apr 17, 2008 at 4:00 AM, shabda <[EMAIL PROTECTED]> wrote:
>
>  I have a forum(non-Django) and a Django app both are in different
>  databases. When a user is created in the Django I want to create
>  another User in Forum. Do I need to use MultiDB branch for this, or is
>  there a simpler way? Maybe using python-MysqlDB directly? Is there a
>  recent merge of Django and MultiDB?
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to display images in Admin change page?

2008-04-17 Thread Legioneer

Hi All!

Trying to get a solution for a problem. I have a model which has one
to many relationship with another model which contains an ImageField.
E.g:

class Person(models.Model):
name = models.CharField(max_length=512)

class Image(models.Model):
image = models.ImageField(upload_to='/images')
active = models.BooleanField(default=True)
person = models.ForeignKey(Person)


How is it possible to display pictures of a person (with checkbox
corresponding to 'active' field) in a person change page instead of
filenames when using django admin? Is there some 'render' method in a
model or smth like this? Any clue will be appreciated.

Kind regards,
Anthony
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Distributed databases

2008-04-17 Thread Wes Winham

Found it. http://softwaremaniacs.org/soft/mysql_cluster/en/ (found
through Simon Willison's blog). It looks like my memory was wrong
though, because it doesn't switch databases automatically depending on
query type. It leaves it up to the view to decide which database to
use. If you absolutely must use different tables on different
databases instead of just using master/slave replication, then that
won't fit for you. I imagine looking at the code could be useful
though.

-Wes

On Apr 17, 9:49 am, Wes Winham <[EMAIL PROTECTED]> wrote:
> One of the blogs I follow posted up an example of an ORM tweak built
> for master/slave mysql setups. I'm having trouble finding it, but it's
> definitely possible to modify the ORM to make decisions about which
> database to use automatically so that you don't have to worry about it
> in your views or your models.
>
> -Wes
>
> On Apr 16, 2:44 pm, mg <[EMAIL PROTECTED]> wrote:
>
> > It sounds like you would either have to go with the custom driver idea
> > or use another ORM package like Sqlalchemy(which means you don't get
> > certain features like the contrib apps)
>
> > On Apr 16, 1:04 pm, "Chris Czub" <[EMAIL PROTECTED]> wrote:
>
> > > Would it be possible to replace the Django database driver(i.e. 
> > > postgresql,
> > > sqlite, mysql) with a custom one that managed the various database
> > > connections? Similar to the SQL proxy idea(or maybe identical).
>
> > > On Wed, Apr 16, 2008 at 1:41 PM, RaviKondamuru <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > Here is the thread that talks about multiple database support:
>
> > > >http://groups.google.com/group/django-users/browse_frm/thread/02fb947...
> > > > Ravi.
>
> > > > On Apr 16, 6:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > > > > Hello everyone,
>
> > > > > This is my first post on this list, so please by gentle and patient ;)
>
> > > > > I would like to ask, if it is possible to have DJango running on one
> > > > > machine, and have several databases (each with different content) on
> > > > > other machines. Basically I would specify a few tables, and each would
> > > > > be in different database, while main server would aggregate and
> > > > > display this data. Would be also possible, to have different database
> > > > > types (i would like to have several sqlite databases and one postgres
> > > > > running)?
>
> > > > > I need all this for scalability reasons. I am choosing framework for
> > > > > the project and what DJango provides seems really cool. If only it
> > > > > provides some mechanisms for scalability I guess I will fall in
> > > > > love ;-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Distributed databases

2008-04-17 Thread Wes Winham

One of the blogs I follow posted up an example of an ORM tweak built
for master/slave mysql setups. I'm having trouble finding it, but it's
definitely possible to modify the ORM to make decisions about which
database to use automatically so that you don't have to worry about it
in your views or your models.

-Wes

On Apr 16, 2:44 pm, mg <[EMAIL PROTECTED]> wrote:
> It sounds like you would either have to go with the custom driver idea
> or use another ORM package like Sqlalchemy(which means you don't get
> certain features like the contrib apps)
>
> On Apr 16, 1:04 pm, "Chris Czub" <[EMAIL PROTECTED]> wrote:
>
> > Would it be possible to replace the Django database driver(i.e. postgresql,
> > sqlite, mysql) with a custom one that managed the various database
> > connections? Similar to the SQL proxy idea(or maybe identical).
>
> > On Wed, Apr 16, 2008 at 1:41 PM, RaviKondamuru <[EMAIL PROTECTED]>
> > wrote:
>
> > > Here is the thread that talks about multiple database support:
>
> > >http://groups.google.com/group/django-users/browse_frm/thread/02fb947...
> > > Ravi.
>
> > > On Apr 16, 6:19 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > > > Hello everyone,
>
> > > > This is my first post on this list, so please by gentle and patient ;)
>
> > > > I would like to ask, if it is possible to have DJango running on one
> > > > machine, and have several databases (each with different content) on
> > > > other machines. Basically I would specify a few tables, and each would
> > > > be in different database, while main server would aggregate and
> > > > display this data. Would be also possible, to have different database
> > > > types (i would like to have several sqlite databases and one postgres
> > > > running)?
>
> > > > I need all this for scalability reasons. I am choosing framework for
> > > > the project and what DJango provides seems really cool. If only it
> > > > provides some mechanisms for scalability I guess I will fall in
> > > > love ;-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Migration from Linux to Windows Setup

2008-04-17 Thread shocks

Hi

I've been using Django for a while on a Linux setup.  For this next
job, Django will have to run on Windows Server 2003 with IIS 6 and
MySQL.  The question I have relates to migrating a project from Linux/
OS X to Windows.  I don't have a local Windows box setup at the moment
and I will develop on a OS X test environment and then deploy the site
onto the Windows box.  Is this a bad idea?  What issues could there be
developing in OS X and deploying the site over to Windows?  I'm trying
to avoid having to upgrade to a new Mac to run Windows through
VMware.  I'm wondering about file and path issues, configuration, and
differences between Python/Django on different platforms.

Some specs of the site are:
1. CMS (just the admin tool) with multiple users
2. Uploading of images and other content
3. WSGI integration
4. Blog
etc...

Cheers!
Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Very site for s/w review and free download.

2008-04-17 Thread GoodieMan

Very good site for Software review and free download

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



Re: Django en Dreahost

2008-04-17 Thread book4e
I've installed and run a django app on dreamhost without problem. I
recommend do the following things before install your django app.

   1. Install virtualenv  to
   create your own Python environment.
   2. Download, Compile and install Python 2.5. DH default is 2.3 and
   2.4.
   3. Edit ~/.bash_profile, set your Python path in env variable.
   4. In .py file, modify *#!/usr/bin python *to
*#!/home/your_name/python_install_directory/bin
   python*, especially *dispatch.fcgi* file.
   5. Download, Compile and install
MySQLdb1.2.1_p2.

After that, you could install django and your django app. I used mysql
backend instead of sqlite. But I think there may be no complains about your
app with using Python 2.5.

Highly recommend read this
docto learn
how to install many things on DH.

Good Luck.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Start earning money online today

2008-04-17 Thread fan.jirka

Start earning money online today

http://mimik-mik.blog.cz/0804/start-earning-money-online-today

BUX.TO = THE BEST WAY TO EARN MONEY
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ONLINE MILLIONARE JOB NETWORK GIVES THE OPPORTUNITY TO YOU EARN 2,00,000 DOLLARS IN A SINGLE WEEK. I ALSO GOT THE SAME AMOUNT LAST WEEK. JOIN WITH THEM HERE

2008-04-17 Thread niche

ONLINE MILLIONARE JOB NETWORK GIVES THE OPPORTUNITY TO YOU EARN
2,00,000 DOLLARS IN A SINGLE WEEK. I ALSO GOT THE SAME AMOUNT LAST
WEEK. JOIN WITH THEM HERE

www.onlinemillionare.blogspot.com

IT IS A FREE USE PROGRAMME
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multi DB question

2008-04-17 Thread shabda

I have a forum(non-Django) and a Django app both are in different
databases. When a user is created in the Django I want to create
another User in Forum. Do I need to use MultiDB branch for this, or is
there a simpler way? Maybe using python-MysqlDB directly? Is there a
recent merge of Django and MultiDB?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 1 django Project / 2 designs

2008-04-17 Thread Massimiliano Ravelli



On 15 Apr, 10:41, martyn <[EMAIL PROTECTED]> wrote:
> I want a default saison (that could be stored in my settings file).
> It's not only a different design but it's also a different content
> sometimes.
>
> Is this can be done with middleware ? session ?
> I don't really know this aspect of django.

What about a redirect ?

from django.http import HttpResponseRedirect
def home_page(request):
return HttpResponseRedirect("http://domain.com/winter/ ")
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New site - www.iau.org

2008-04-17 Thread Chris Hoeppner

This is really great! While I wouldn't like to speak in anybody's name,
I think I can safely say that the comunity will benefit from this, and
I'm really looking forward to the moment you opensource the code.

~ Chris

El jue, 17-04-2008 a las 02:30 -0700, [EMAIL PROTECTED] escribió:
> Hi Joe,
> 
> On Apr 16, 11:28 am, "Joe Bloggs" <[EMAIL PROTECTED]> wrote:
> > A nice clean site, I would be interested to know:-
> 
> Thanks
> 
> > How long it took to develop?
> 
> Approximately 5 man months (including all activities). Of these 5
> months, only 1 1/2 month have been spent building the actual website
> as you see it. The rest of the time has mainly been spent on reverse
> engineering a complete mess of an old site. There is a fairly complex
> member database behind (the organization has 10.000 members that can
> have various sorts of affiliations with lots of groups etc.). Before
> this member database was in a MS SQL Server, and had no administration
> interface, so the secretaries was manually updating relations in the
> database, taking the primary key of one row, and manually inserting it
> as a foreign key in another row! Also, the integration of the old
> member database on the web, once done through a various TYPO3
> extensions that, if documented, were documented and written entirely
> in french (a language I hardly speak :). On top of that, the  old
> database was in many respects seriously over-model, trying to make it
> smarter than good was. Additionally, a lot of the data in the database
> was in a poorly shape, so there was lots of cleaning to do.
> 
> > Which django components did you use?
> 
> First of all we use newforms-admin branch, since its a lot more
> flexible than the old admin. I've found the branch very stable, and
> the developers are good at describing backward incompatible changes.
> Besides we use the auth system (works fairly well for 10k members),
> and a lot of all the core modules. I found that we only seldom used
> generic views, as a get_object_or_404 witha render_reponse was much
> more flexible and nearly as easy. The new paginator works as a charm.
> 
> On top of that, we use django-mptt to manage hierarchical data. This
> is a really neat application, if you need to eg manage a menu
> structure. We also use django-cron. The rest is developed by
> ourselves, this include:
> 
> menu system + breadcrumb (inspired by the pycon-tech system)
> static pages (basically a bit like flatpages but with tinymce editor
> and options for timed publishing and more)
> press release and image archive adapted from one our other website
> (www.spacetelescope.org - soon to be running django)
> simple mass mailing
> reporting
> 
> Most of it, we will probably be releasing as open source for others to
> use, within the next half year. We need to make another site first,
> with some of the same components.
> 
> For site wide search we use google search, as it was easier and
> faster, and as we are an non-profit organization, we don't have to
> show commercials.
> 
> > Any gotchas ( things that were unexpected or non-obvious ) you had on the
> > way?
> 
> Django can get you a lot of the way very quickly, and is a lot more
> fun to work with that eg other frameworks for eg Java and PHP. That
> said, Django cannot do all, and doesn't pretend to either. Especially
> once you start modeling more complex relationships you start to see
> what Django doesn't do for you. A simple example is many-to-many
> relationships with attributes: Say you want to relate any number of
> contacts with any number of groups, with the catch, that a the contact
> can have a status within the group (e.g. the contact can be a chair of
> the group or just a normal member). The ManyToManyField and the admin
> can't handle this, so you have to do your own many to many relation,
> and own editor.
> 
> Managing hierarchical data in a relational database has always been a
> pain. Django-mptt alleviate you from a lot of the pain, however, it
> still need a good administration interface (but seems like they are
> working on that).
> 
> Cheers,
> Lars
> 
> >
> > Regards,
> >
> > Joe
> >
> > On Tue, Apr 15, 2008 at 11:03 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 
> > wrote:
> >
> > > Hi,
> >
> > > We just released a new website for the International Astronomical
> > > Union today (an organization of 10.000 professional astronomers, most
> > > famous for demoting Pluto as a planet - now it's only a "dwarf
> > > planet"). You can access website athttp://www.iau.org
> >
> > > Besides having a nice front-end for visitors, Django allowed us to
> > > quickly build an intuitive and appealing interface for the managing
> > > vast amount of membership data and relations for IAU.
> >
> > > Thanks for viewing,
> > > Lars Holm Nielsen
> > > ESA/Hubble
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email 

Re: New site - www.iau.org

2008-04-17 Thread [EMAIL PROTECTED]

Hi Joe,

On Apr 16, 11:28 am, "Joe Bloggs" <[EMAIL PROTECTED]> wrote:
> A nice clean site, I would be interested to know:-

Thanks

> How long it took to develop?

Approximately 5 man months (including all activities). Of these 5
months, only 1 1/2 month have been spent building the actual website
as you see it. The rest of the time has mainly been spent on reverse
engineering a complete mess of an old site. There is a fairly complex
member database behind (the organization has 10.000 members that can
have various sorts of affiliations with lots of groups etc.). Before
this member database was in a MS SQL Server, and had no administration
interface, so the secretaries was manually updating relations in the
database, taking the primary key of one row, and manually inserting it
as a foreign key in another row! Also, the integration of the old
member database on the web, once done through a various TYPO3
extensions that, if documented, were documented and written entirely
in french (a language I hardly speak :). On top of that, the  old
database was in many respects seriously over-model, trying to make it
smarter than good was. Additionally, a lot of the data in the database
was in a poorly shape, so there was lots of cleaning to do.

> Which django components did you use?

First of all we use newforms-admin branch, since its a lot more
flexible than the old admin. I've found the branch very stable, and
the developers are good at describing backward incompatible changes.
Besides we use the auth system (works fairly well for 10k members),
and a lot of all the core modules. I found that we only seldom used
generic views, as a get_object_or_404 witha render_reponse was much
more flexible and nearly as easy. The new paginator works as a charm.

On top of that, we use django-mptt to manage hierarchical data. This
is a really neat application, if you need to eg manage a menu
structure. We also use django-cron. The rest is developed by
ourselves, this include:

menu system + breadcrumb (inspired by the pycon-tech system)
static pages (basically a bit like flatpages but with tinymce editor
and options for timed publishing and more)
press release and image archive adapted from one our other website
(www.spacetelescope.org - soon to be running django)
simple mass mailing
reporting

Most of it, we will probably be releasing as open source for others to
use, within the next half year. We need to make another site first,
with some of the same components.

For site wide search we use google search, as it was easier and
faster, and as we are an non-profit organization, we don't have to
show commercials.

> Any gotchas ( things that were unexpected or non-obvious ) you had on the
> way?

Django can get you a lot of the way very quickly, and is a lot more
fun to work with that eg other frameworks for eg Java and PHP. That
said, Django cannot do all, and doesn't pretend to either. Especially
once you start modeling more complex relationships you start to see
what Django doesn't do for you. A simple example is many-to-many
relationships with attributes: Say you want to relate any number of
contacts with any number of groups, with the catch, that a the contact
can have a status within the group (e.g. the contact can be a chair of
the group or just a normal member). The ManyToManyField and the admin
can't handle this, so you have to do your own many to many relation,
and own editor.

Managing hierarchical data in a relational database has always been a
pain. Django-mptt alleviate you from a lot of the pain, however, it
still need a good administration interface (but seems like they are
working on that).

Cheers,
Lars

>
> Regards,
>
> Joe
>
> On Tue, Apr 15, 2008 at 11:03 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > We just released a new website for the International Astronomical
> > Union today (an organization of 10.000 professional astronomers, most
> > famous for demoting Pluto as a planet - now it's only a "dwarf
> > planet"). You can access website athttp://www.iau.org
>
> > Besides having a nice front-end for visitors, Django allowed us to
> > quickly build an intuitive and appealing interface for the managing
> > vast amount of membership data and relations for IAU.
>
> > Thanks for viewing,
> > Lars Holm Nielsen
> > ESA/Hubble
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving static content on Windows

2008-04-17 Thread apm

Indeed, the problem was the shortcut! Now, it just works fine.

Thanks a lot, Koen
André

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using a custom storage

2008-04-17 Thread [EMAIL PROTECTED]

This requires ticket #5361 (http://code.djangoproject.com/ticket/5361)
to do something like this you need to apply that patch(which should be
pretty close to fine, I would try to track the ticket closely if you
use that patch), then I would read the docs included in the patch.

On Apr 17, 2:01 am, SammyRulez <[EMAIL PROTECTED]> wrote:
> Hi folks
>
> I'm trying to implement a custom Stroage  via  s3. Something 
> likehttp://code.djangoproject.com/attachment/ticket/6390/S3_6390.20080321.py.
> I'm digging Django core code to find how to tell it to use the custom
> storage instead of the FileSystemStorage but without luck.
>
> Any suggestion on how to start?
>
> Thanks
>
> Sam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using a custom storage

2008-04-17 Thread SammyRulez

Hi folks

I'm trying to implement a custom Stroage  via  s3. Something like
http://code.djangoproject.com/attachment/ticket/6390/S3_6390.20080321.py.
I'm digging Django core code to find how to tell it to use the custom
storage instead of the FileSystemStorage but without luck.

Any suggestion on how to start?

Thanks

Sam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ModelForm, Foreign key and blank value in choices

2008-04-17 Thread eXt

Hi all!

  I have a model defined like:

class AnObject(models.Model):
object_category = models.ForeignKey(ObjectCategory)

and a ModelForm like:

class AnObjectForm(ModelForm):
class Meta:
model=AnObject

'object_category' is represented by django.newforms.ModelChoiceField
and is rendered as a 'Select'. The field has 'required = True'. The
problem is that the 'Select' always contains a blank value: '-'.

ModelForm docs say: "The blank choice will not be included if the
model field has blank=False and an explicit default value (the default
value will be initially selected instead)." Blank is True and default
doesn't make sense here... but even setting it to a value existing in
a related model doesn't help me to get rid of blank value.

Is there any way to do that, other than manually generating choices:
In AnObjectForm's __init__:

   self.fields['object_category'].widget =
forms.RadioSelect(choices=[(c.id, c) for c in
self.fields['object_category'].queryset])


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving static content on Windows

2008-04-17 Thread koenb

The error message says it all: it is looking for
testporject.polls.views.django.views.static. Notice the first part. It
means your view function is taken from within testproject.polls.views
(which is probably on top in your patterns declaration).
You should take this declaration out of there and add it seperately,
something like this:

urlpatterns = patterns('testproject.polls.views',

# your patterns here
)

urlpatterns += patterns('',...

# the static view here

)

Koen

On 16 apr, 23:43, "Andre Meyer" <[EMAIL PROTECTED]> wrote:
> hi all
>
> i am new to Django and trying to figure out a few things. so far, everything
> looks very nice.
>
> but now, i am stuck at something very simple: i cannot manage to serve
> static content (images, css, dojo, ...) from Django itself. i have done what
> is described athttp://www.djangoproject.com/documentation/static_files/and
> here is what i get as a response when trying to access some image file from
> the appropriate location.
>
> in urls.py:
> *(r'^site_media/(?P.*)$', 'django.views.static.serve',
> {'document_root': 'E:\\projects\\django\\testproject\\media',
> 'show_indexes': True}),
> *http://localhost:8000/site_media/django.gif
> ViewDoesNotExist at /site_media/django.gif Could not import
> testproject.polls.views.django.views.static. Error was: No module named
> django.views.static Request Method: GET  Request 
> URL:http://localhost:8000/site_media/django.gif Exception Type:
> ViewDoesNotExist  Exception Value: Could not import
> testproject.polls.views.django.views.static. Error was: No module named
> django.views.static  Exception Location:
> C:\Python25\Lib\site-packages\django\core\urlresolvers.py
> in _get_callback, line 127
>
> what is wrong with *django.views.static*? are modifications necessary to
> settings.py? i have tried various path syntaxes, but none worked.
>
> please, let me know what is going on
> thanks a lot for your help
> André
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Something wrong with dividing

2008-04-17 Thread Poz

Thanks Alex! works great!

On Apr 16, 10:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> When doing integer division, python returns the floor(it rounds the
> answer), you need to cast one of the things being divided to a float
> for it to return a float, pretty much remove all those int calls, and
> change the last line to read percentage = float(likeresults) /
> totalresults
>
> On Apr 17, 12:27 am, Poz <[EMAIL PROTECTED]> wrote:
>
> > Hello all,
>
> > I've got a small problem. I am a newbie and I can't figure out what is
> > wrong with the script below.
>
> > I'm trying to count up the "likes" and divid them by the
> > "likes"+"dislikes", but all I get when I divided them is
> > 0.0
>
> > Anyone have any ideas??
>
> > code is below.
>
> > Thanks,
> > poz
>
> >         likeresults = int( Vote.objects.filter(like=True).count() )
> >         totalresults = int( Vote.objects.filter(like=True).count() +
> > Vote.objects.filter(like=False).count() )
> >         precentage = int( likeresults / totalresults )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Have you used OrderingField?

2008-04-17 Thread Malcolm Tredinnick


On Thu, 2008-04-17 at 11:24 +1000, Malcolm Tredinnick wrote:
> 
> On Wed, 2008-04-16 at 06:41 -0700, Julien wrote:
> > Thanks Karen for the clarification! That code looked dead to me too...
> > is that worth filing a ticket?
> 
> It's not harmful and it could well be useful to some people who are
> using with order_with_respect_to, for example.

Scrub that. For some reason my brain had switched over to thinking about
form fields, not model fields. On second glance, this doesn't seem to be
particularly useful as it stands. We could consider removing it.

Malcolm

-- 
If it walks out of your refrigerator, LET IT GO!! 
http://www.pointy-stick.com/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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---