Re: New Forms - Mixing database and non database fields

2008-02-18 Thread DanB

Malcolm,

thxs for the tip.
I was hoping to get something bit more automatized, but I think I can
live with this approach as well.

Cheers,
DanB

On Feb 15, 6:21 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-02-15 at 18:02 +0100, Dan-Cristian Bogos wrote:
> > Hello,
>
> > I need to mix fields in my forms: in the same form use perhaps fields
> > from same or different models and/or normal form.fields which do not
> > really relate to a database model.
> > What is the recommended way of doing this?
>
> Construct the form by hand or (better), use multiple Form objects to
> create your output. 
> E.g.http://www.pointy-stick.com/blog/2008/01/06/django-tip-complex-forms/
>
> Regards,
> Malcolm
>
> --
> How many of you believe in telekinesis? Raise my 
> hand...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 runserver freeze after 10-15 min

2008-02-18 Thread diadya_vova

Big thanks to all folks!
It's works fine with CherryPy.
--~--~-~--~~~---~--~~
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 field queryset filter

2008-02-18 Thread Robert

Greetings,

There's a model with few ForeignKey fields:

class Alert(models.Model):
name = models.CharField()
sms = models.BooleanField()
email = models.BooleanField()
state = models.ForeignKey(State..)
city = models.ForeignKey(City)


When user is browsing the "X" state, when creating a new alert I only
want
to have cities from state "X" displayed in the form. (For both new &
existing records).

In my view, I know what state is the user exploring, and set it after
form validation (using commit=false).

So far I've been doing this by specifying the BaseForm in
form_for_model and form_for_instance.

views.py:
state = State.objects.get(name=state_name) # grabbed from urls.py
AlertForm = form_for_model(Alert, form=AlertBaseForm)

if request.method == "POST":
form = AlertForm(state, request.POST):
.

forms.py:
class AlertBaseForm(BaseForm):
def __init__(self, state, *args, **kwargs):
super(AlertBaseForm, self).__init__(*args, **kwargs)
self.fields['city'].choices = [(c.id,c.name) for c in
City.objects.filter(state=state)]

I would like to rewrite the code to ModelForm, but I have no idea on
how to do this with ModelForm.

If anyone could share the example.

Thanks,

Robert
--~--~-~--~~~---~--~~
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: is_secure() behind reverse proxy

2008-02-18 Thread Ned Batchelder

You can use protocol-relative URLs.  If your media URLs omit the 
protocol, they will inherit it from the protocol of the page:



On a page served with https:, this image will be retrieved via https.  
On an http: page, it will be retrieved via http.

More about this: 
http://nedbatchelder.com/blog/200710/httphttps_transitions_and_relative_urls.html

--Ned.

[EMAIL PROTECTED] wrote:
> Does anyone have suggestions on how to make request.is_secure() work
> from behind a reverse proxy? I have nginx proxying to apache but since
> nginx (and not apache) is handling SSL the HTTPS environment variable
> that is_secure() reads from never gets set.
>
> This is easily solvable for standard redirects from http to https for
> certain paths. I can do this by putting them in nginx.conf. However, I
> want to have media served over SSL depending on whether the incoming
> request is SSL, I have some middleware to do this, but it relies on
> is_secure(). Any suggestions?
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: costumizing admin

2008-02-18 Thread Almir Karic

On Feb 18, 2008 2:22 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> On Feb 18, 2008 1:18 AM, Almir Karic <[EMAIL PROTECTED]> wrote:
>
> >
> > it seems that the name of the template is hardcoded in the code
> >
> > def result_list(cl):
> >return {'cl': cl,
> >'result_headers': list(result_headers(cl)),
> >'results': list(results(cl))}
> > result_list =
> register.inclusion_tag("admin/change_list_results.html")(result_list)
> >
> >
> > :(
> >
> > can anyone confirm this?
>
>
> Yes, that's the code from admin.  Overriding the default admin templates is
> described here:
>
> http://www.djangoproject.com/documentation/tutorial02/#customize-the-admin-look-and-feel
>
> and as far as I can see it doesn't provide for overriding a template on a
> per-model basis.  Is there some other doc where you got the idea that this
> could be done?

http://djangobook.com/en/1.0/chapter17/ is where i read things, Table
17-1. Global Admin Templates lists change_list.html as over-riddable
per app and/or object basis. i looked into that code and the
particular bit that interests me seems to be 'included' from
change_list_results.html, so i hopped that change_list_results.html is
over-riddable the same way change_list.html is. apperently i was wrong
:(.


as for what i am trying to do, i created myself a VERY simple TODO
manager (a single model, with admin and meta classes), i would like to
break the tasks into 3 visually separated blocks, one for tasks due by
today, one for future tasks and one for tasks with unassigned date.
the obvious (for me) way to  do this is to add 3 for loops with if's
inside them and some html around it to visually separate the blocks.

>
> You don't mention whether you are trying to do this with current admin or
> newforms-admin.  Personally, at this point I wouldn't be investing much time
> in trying to make customizations using old admin, so if you are not using
> newforms-admin you might want to give it a look.  Also if you give more
> details of exactly what you are trying to do someone might be able to
> provide some more specific guidance.
>
> Karen
>
>
> >
> >
> >
> >
> >
> >
> > On Feb 16, 2008 8:15 AM, Almir Karic <[EMAIL PROTECTED]> wrote:
> > > i would like to change the way django admin writes out the results for
> > > one object, the code i would like to change is located in
> > > change_list_results.html, however if i put that file in my
> > > templates/admin/// django doesn't seem to pick it
> > > up. any hints?
> > >
> > > --
> > > error: one bad user found in front of screen
> > >
> >
> >
> >
> > --
> > error: one bad user found in front of screen
> > > >
> >
>



-- 
error: one bad user found in front of screen

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Multiple attributes fieldtypes

2008-02-18 Thread timc3

I have two model development problems that I was wondering whether
they have been solved before.

Firstly lets say that I have extended the user model, but I want to be
able for a user to store multiple e-mail addresses for themselves..
Is the easiest way to store this in a separate email table, allowing
the user to add email addresses for themselves as they need into this
table, or can I have a particular fieldtype?

Second I want to store attributes on a particular item but the number
of attributes could be different for different items.  But I would
need a key for that item as well. So for instance:

Name: item1
Description: Basic Item
Attributes:  Owned_by: Bob, last_accessed: 2007-12-12

Name item2
Description: David's item
Attributes: Display_name: David1, last_accessed: 2008-01-12,
created_date: 2007-12-01

In PostgreSQL I could store the attributes as an Array type (http://
www.postgresql.org/docs/8.1/interactive/arrays.html), but I don't see
a matching field type in Django - presumably because there might not
be the same datatype in all the databases that Django supports.

So is there an easy way of doing this, or should I role my own
solution to the problem - perhaps using the array datatype in
PostgreSQL?

Thanks in advance.

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: costumizing admin

2008-02-18 Thread Karen Tracey
On Feb 18, 2008 8:38 AM, Almir Karic <[EMAIL PROTECTED]> wrote:

>
> On Feb 18, 2008 2:22 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> > On Feb 18, 2008 1:18 AM, Almir Karic <[EMAIL PROTECTED]> wrote:
> >
> > >
> > > it seems that the name of the template is hardcoded in the code
> > >
> > > def result_list(cl):
> > >return {'cl': cl,
> > >'result_headers': list(result_headers(cl)),
> > >'results': list(results(cl))}
> > > result_list =
> > register.inclusion_tag("admin/change_list_results.html")(result_list)
> > >
> > >
> > > :(
> > >
> > > can anyone confirm this?
> >
> >
> > Yes, that's the code from admin.  Overriding the default admin templates
> is
> > described here:
> >
> >
> http://www.djangoproject.com/documentation/tutorial02/#customize-the-admin-look-and-feel
> >
> > and as far as I can see it doesn't provide for overriding a template on
> a
> > per-model basis.  Is there some other doc where you got the idea that
> this
> > could be done?
>
> http://djangobook.com/en/1.0/chapter17/ is where i read things, Table
> 17-1. Global Admin Templates lists change_list.html as over-riddable
> per app and/or object basis. i looked into that code and the
> particular bit that interests me seems to be 'included' from
> change_list_results.html, so i hopped that change_list_results.html is
> over-riddable the same way change_list.html is. apperently i was wrong
> :(.
>
>
Ah, OK, now I see where you are coming from.  It does seem rather
inconsistent that some admin templates can be over-ridden per-app or model
and others not.  There's at least one other person who has run into trouble
with this:

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

You might want to check out the patch in that ticket, see if it is helpful
for your case, and provide feedback on it.  The ticket is is design decision
needed so input could be helpful in moving it along.

as for what i am trying to do, i created myself a VERY simple TODO
> manager (a single model, with admin and meta classes), i would like to
> break the tasks into 3 visually separated blocks, one for tasks due by
> today, one for future tasks and one for tasks with unassigned date.
> the obvious (for me) way to  do this is to add 3 for loops with if's
> inside them and some html around it to visually separate the blocks.
>
>

Honestly I have no idea what the best way is to go about doing this, but
maybe someone with more experience customizing admin could say.  It sounds
like a reasonable thing to want to do.

Karen


> >
> > You don't mention whether you are trying to do this with current admin
> or
> > newforms-admin.  Personally, at this point I wouldn't be investing much
> time
> > in trying to make customizations using old admin, so if you are not
> using
> > newforms-admin you might want to give it a look.  Also if you give more
> > details of exactly what you are trying to do someone might be able to
> > provide some more specific guidance.
> >
> > Karen
> >
> >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Feb 16, 2008 8:15 AM, Almir Karic <[EMAIL PROTECTED]> wrote:
> > > > i would like to change the way django admin writes out the results
> for
> > > > one object, the code i would like to change is located in
> > > > change_list_results.html, however if i put that file in my
> > > > templates/admin/// django doesn't seem to pick it
> > > > up. any hints?
> > > >
> > > > --
> > > > error: one bad user found in front of screen
> > > >
> > >
> > >
> > >
> > > --
> > > error: one bad user found in front of screen
> > > > >
> > >
> >
>
>
>
> --
> error: one bad user found in front of screen
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django on a non root Apache URL

2008-02-18 Thread [EMAIL PROTECTED]

Hi, I want to deploy a Django project on Apache but in a URL like:
http://localhost/django

I can do it but since I have some HttpResponseRedirect on my project
pointing to '/', it will end up on:
http://localhost/

Is there any way to make django to use the http://localhost/django URL
as its root URL without having to touch the projects code?

Thanks,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: costumizing admin

2008-02-18 Thread Karen Tracey
On Feb 18, 2008 1:18 AM, Almir Karic <[EMAIL PROTECTED]> wrote:

>
> it seems that the name of the template is hardcoded in the code
>
> def result_list(cl):
>return {'cl': cl,
>'result_headers': list(result_headers(cl)),
>'results': list(results(cl))}
> result_list = register.inclusion_tag
> ("admin/change_list_results.html")(result_list)
>
>
> :(
>
> can anyone confirm this?



Yes, that's the code from admin.  Overriding the default admin templates is
described here:

http://www.djangoproject.com/documentation/tutorial02/#customize-the-admin-look-and-feel

and as far as I can see it doesn't provide for overriding a template on a
per-model basis.  Is there some other doc where you got the idea that this
could be done?

You don't mention whether you are trying to do this with current admin or
newforms-admin.  Personally, at this point I wouldn't be investing much time
in trying to make customizations using old admin, so if you are not using
newforms-admin you might want to give it a look.  Also if you give more
details of exactly what you are trying to do someone might be able to
provide some more specific guidance.

Karen



>
>
> On Feb 16, 2008 8:15 AM, Almir Karic <[EMAIL PROTECTED]> wrote:
> > i would like to change the way django admin writes out the results for
> > one object, the code i would like to change is located in
> > change_list_results.html, however if i put that file in my
> > templates/admin/// django doesn't seem to pick it
> > up. any hints?
> >
> > --
> > error: one bad user found in front of screen
> >
>
>
>
> --
> error: one bad user found in front of screen
>
> >
>

--~--~-~--~~~---~--~~
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 on a non root Apache URL

2008-02-18 Thread Eric Abrahamsen

On Feb 18, 2008, at 10:06 PM, [EMAIL PROTECTED] wrote:

>
> Hi, I want to deploy a Django project on Apache but in a URL like:
> http://localhost/django
>
> I can do it but since I have some HttpResponseRedirect on my project
> pointing to '/', it will end up on:
> http://localhost/
>
> Is there any way to make django to use the http://localhost/django URL
> as its root URL without having to touch the projects code?

In your settings file, you can have ROOT_URLCONF point to a dummy url  
file, say 'dummyurls.py'. That file has a single line in the  
urlpatterns, like so:

urlpatterns = patterns('',

 (r'django/', include('path.to.real.urls')),

)

Unless I've typed something wrong, that will peel off the leading  
'django' from your path info, and the rest of your project will be  
none the wiser.

Yours,
Eric

--~--~-~--~~~---~--~~
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 on a non root Apache URL

2008-02-18 Thread [EMAIL PROTECTED]

Hi,

that won't do it when I do something like:
return HttpResponseRedirect('/')

What I want is to be able to do the command above and I'll get to the:
http://localhost/django

Instead of http://localhost/ .


Is there a way to do this?


Thanks,

On Feb 18, 2:43 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On Feb 18, 2008, at 10:06 PM, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi, I want to deploy a Django project on Apache but in a URL like:
> >http://localhost/django
>
> > I can do it but since I have some HttpResponseRedirect on my project
> > pointing to '/', it will end up on:
> >http://localhost/
>
> > Is there any way to make django to use thehttp://localhost/djangoURL
> > as its root URL without having to touch the projects code?
>
> In your settings file, you can have ROOT_URLCONF point to a dummy url
> file, say 'dummyurls.py'. That file has a single line in the
> urlpatterns, like so:
>
> urlpatterns = patterns('',
>
>  (r'django/', include('path.to.real.urls')),
>
> )
>
> Unless I've typed something wrong, that will peel off the leading
> 'django' from your path info, and the rest of your project will be
> none the wiser.
>
> Yours,
> Eric
--~--~-~--~~~---~--~~
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: djWarehouse - Django based e-commerce system

2008-02-18 Thread Nicolas Steinmetz

[EMAIL PROTECTED] a écrit :
> Hello,
> 
> I am pleased to announce the immediate availability of djWarehouse e-
> commerce system, developed on Django.

Could you provide a quick bench / swot against satchmo project as it 
looks you have the same objectives (being an e-commerce platform).

Regards,
Nicolas


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



djWarehouse - Django based e-commerce system

2008-02-18 Thread [EMAIL PROTECTED]

Hello,

I am pleased to announce the immediate availability of djWarehouse e-
commerce system, developed on Django.

It is called djWarehouse and there are Trac site for it:
  http://www.djwarehouse.org/

You can see demo site (with open /admin/ area) here:
  http://demo.djwarehouse.org/

Here is instructions how to install "simple demo site" under Linux/
FreeBSD:
  http://djwarehouse.org/wiki/DemoInstall

Regards,
Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 hosting service running Os C

2008-02-18 Thread Dj Gilcrease

On Feb 17, 2008 3:12 PM, Flavio Curella <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I developed a small application using django and CoreGraphics library
> as a school project. I'm wondering to put it online and I googled
> around looking for a web hosting solution (shared or VPS) running on
> Os X and that supports Django.
>
> Does anybody know one?


A quick Google search found a few, but most of them were way over
priced for what you got (One I saw was $55/month for shared hosting).
http://serverlogistics.com/hosting.php seemed like the most reasonably
priced one I could find

--~--~-~--~~~---~--~~
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: Problem with django.db.transaction.commit_manually

2008-02-18 Thread Brot

Hello,

The view works well if I delete the call 'otherfile.test()'
There is also no error if I delete the dictionary declaration in
'otherfile.test()'. My example code is only an extraction from my
code. In my real 'test-function' is a lot of code (I use urlib, urlib2
and htmllib there).
But the error only appears if I declare a dictonary in the function.
This makes no sense for me :-(


On 18 Feb., 16:21, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> You get this because the transaction is 'dirty' (some statement was
> executed,
> but there was no commit/rollback afterwards). I guess this happens
> in render_to_response in your example.
>
> > K'
> > finally:
> > if result['status'] == 'OK':
> > otherfile.test()
> > reserv.delete()
> > transaction.commit()
> > else:
> > transaction.rollback()
>
> > return render_to_response('template.html', {'result':result})
--~--~-~--~~~---~--~~
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 on a non root Apache URL

2008-02-18 Thread Eric Abrahamsen

On Feb 18, 2008, at 11:09 PM, [EMAIL PROTECTED] wrote:

>
> Hi,
>
> that won't do it when I do something like:
> return HttpResponseRedirect('/')
>
> What I want is to be able to do the command above and I'll get to the:
> http://localhost/django
>
> Instead of http://localhost/ .
>
>
> Is there a way to do this?

That's the extent of my helpfulness, unfortunately. The only thing I  
can think of is naming your homepage url pattern and then using  
reverse from urlresolvers to turn that into a string, but that smells  
of hack. Hopefully someone else has a better idea...

--~--~-~--~~~---~--~~
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: Problem with django.db.transaction.commit_manually

2008-02-18 Thread Thomas Guettler

Hi,

You get this because the transaction is 'dirty' (some statement was
executed,
but there was no commit/rollback afterwards). I guess this happens
in render_to_response in your example.

> K'
> finally:
> if result['status'] == 'OK':
> otherfile.test()
> reserv.delete()
> transaction.commit()
> else:
> transaction.rollback()
>
> return render_to_response('template.html', {'result':result})
>   

--~--~-~--~~~---~--~~
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: "Presales" questions

2008-02-18 Thread Tim Chase

>> I've coded in PHP, and I've coded in Python.  I'd choose
>> Python over PHP any day.  As a matter of fact, I don't touch
>> PHP any more unless I'm paid to (or maintaining some of my
>> old personal PHP code).
> 
> May I ask why this disdain for PHP? OOP type puritanism aside,
> it's a language in which one *can* code elegantly and then
> it's highly maintainable. And it's pretty well supported and
> documented around the web.

I'll enumerate a few frustrations I find with PHP:

-flat namespace vs. hierarchical namespace

-it's harder to read (extra brackets, dollar-signs, C-style 
looping constructs, etc.).  I *can* read PHP, it just takes less 
effort for me to read Python

-you have to work diligently to separate parts (models, logic, 
and presentation...this is a Django/framework specific thing, as 
Python CGI makes it easy to write hard-to-maintain 
tightly-coupled code)  As you note, you *can* code elegantly in 
PHP, but I find it takes far more conscious effort on my part 
than the same sort of development in PHP.  Django encourages 
clean separation.

-small language quirks (what order do the needle/haystack 
parameters come in various PHP searching functions?  It depends 
on which function...)

-the shift from PHP4 to PHP5 has somewhat fractured the community 
(package X requires PHP4 and doesn't run well on PHP5 while 
package Y requires PHP5 but doesn't run well on PHP4; writing for 
both requires some careful work; and PHP4's object syntax is, 
well, objectionable :).  Python 2.2 -> 2.3 -> 2.4 -> 2.5 has been 
a smooth transition.  Python3k may revoke this benefit, but 2.6 
should still stay backwards compat. with previous versions of Python.

-the Python shell and/or pdb.  A great debugging tool.  Yes, PHP 
can be used from the console, but it's primarily a web-language 
and not nearly as friendly for multi-purpose scripting.  Combined 
with Python's built-in dir() and help() functions, I need to hit 
the official Python docs far less frequently than I hit the PHP 
documentation site.

-I have a personal aversion to the various equality tests in PHP. 
  But that's not a make-or-break issue for many folks.  Passing 
by reference (and returning object references) involves some odd 
mental overhead for me as well (especially with the shift from 
PHP4->PHP5, and remembering which one uses which syntax)

-Python's introspection capabilities offer a lot of benefits I 
have difficulty giving up when I go back to PHP.

-Python's properties (getters/setters that behave code-wise like 
attributes, but actually contain programmatic behavior) allow me 
to use attributes, and then easily convert to programmatic 
getter/setter logic without editing my code.

-Python offers built-in unit-testing libraries

I do give PHP one major benefit:  every low-end cheap hosting 
service offers it.  This makes deployment to these services one 
of just getting a cheap hosting package (can be had for 
$1USD/month) and copying your files.  I love that, and wish there 
was a commonly accepted standard for doing the same with Python. 
  WSGI is contending for this role, but it's still not 
universally available on every hosting service like PHP.  There 
are still the occasional headache regarding PHP deployment (does 
the server have register-globals enabled, and other such 
settings), tweaking .htconfig files and mod_rewrite to get pretty 
URLs, etc. but all said, PHP has a far better deployment 
experience on cheap hosting.

PHP also has a minor benefit of baked-in support for a wider 
variety of databases.  Stock MySQL and PostgreSQL bindings are 
something I miss in stock Python (they're just a download away, 
but it's still one more thing to have to do)

I'm not sure I'd describe coding in PHP as "disdain", but more 
like taking out the trash, changing diapers, or washing 
dishes...a chore.  I find writing in Python to be a pleasure.

Just my $0.02 on the matter, since you asked ;)

-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: how to get related foreign key when using values in query

2008-02-18 Thread Malcolm Tredinnick


On Sun, 2008-02-17 at 22:22 -0800, [EMAIL PROTECTED] wrote:
> i have 2 Models(for example):
> one is Category, have 2 fields: title and slug, the other is Entry
> with 4 fields: title, time,category(foreign key),content.
> 
> now i just want show entry title and category slug, so i use this
> queryset:
> e = Entry.objects.all().values('title','category')
> the benefit is huge content will be omitted which can save database
> traffic(i considered).
> 
> but now category.slug is none, how can i get related value of category
> in this query?
> (i changed to e =
> Entry.objects.all().values('title','category').select_related(), the
> result was same.)

Asking for the values('category') on some level doesn't make sense,
since category is a whole object, not a single value. In fact, Django
will be returning you the value of the foreign key (an integer here).

Firstly, this smells of premature optimisation. If you're not sure you
need something, particularly if it doesn't work, don't use it until you
are sure. Once a database has to select one column from a row in  a
table it is close to zero extra effort to select the remaining columns:
it has most likely already read them from disk, since it has to read in
units of a whole disk block, which is a number of kilobytes. A general
rule of thumb in database query optimisation is that pulling out the
data (as opposed to filtering, sorting and grouping) is a negligible
amount of time. If it isn't, your query is so simple it doesn't matter
anyway. Of course, like all rules of thumb, it's a generalisation based
on experience and there are plenty of exceptions. But it does mean
"don't worry about what probably doesn't matter until it does matter".

Values() queries are faster in Django in some cases, but it's not
because of the database activity. It's because creating Python objects
doesn't take zero time and Django adds some overhead as well. If you're
working with 50,000 - 100,000 rows of data, the difference can be quite
noticeable. If you're working with a few dozen rows, not so much. Still,
that is the reason values() exists, so that if you do not just need some
specific pieces of information, you can pull them back and we only need
to create a dictionary, not a whole object instance and emit the
signals, etc.

Secondly, select-_elated() is only an optimisation. It will never change
the result set you ultimately have access to (even if you don't use
select_related(), you'll have access to the fields on category from a
normal Entry model. It will just require an extra database query). If
there is a difference between what you can do with and without a
select_related() call, it's a bug (and, yes, there are cases on trunk
like this; they're all bugs).

Thirdly, ticket #5768 is open to one day add support for values()
queries across relations. See the comments there for what is involved in
implementing this.

Regards,
Malcolm

-- 
I just got lost in thought. It was unfamiliar territory. 
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: ModelForm field queryset filter

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 04:38 -0800, Robert wrote:
[...]
> So far I've been doing this by specifying the BaseForm in
> form_for_model and form_for_instance.
> 
> views.py:
> state = State.objects.get(name=state_name) # grabbed from urls.py
> AlertForm = form_for_model(Alert, form=AlertBaseForm)
> 
> if request.method == "POST":
> form = AlertForm(state, request.POST):
> .
> 
> forms.py:
> class AlertBaseForm(BaseForm):
> def __init__(self, state, *args, **kwargs):
> super(AlertBaseForm, self).__init__(*args, **kwargs)
> self.fields['city'].choices = [(c.id,c.name) for c in
> City.objects.filter(state=state)]
> 
> I would like to rewrite the code to ModelForm, but I have no idea on
> how to do this with ModelForm.

ModelForms are just Forms underneath. All the magic happens in their
__new__ metaclass method. So you should be able do something similar to
this in the __init__ mtehod of your ModelForm subclass. Call the
standard __init__ method first and then you'll get back something that
is the same as what you had earlier.

ModelForms are a complete change from what form_for_*() provided. It's
just a way to unify the two cases and make it easier to add features
(via extra methods on the ModelForm-derived classes).

Malcolm

-- 
A clear conscience is usually the sign of a bad memory. 
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: Multiple attributes fieldtypes

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 05:25 -0800, timc3 wrote:
[...]
> In PostgreSQL I could store the attributes as an Array type (http://
> www.postgresql.org/docs/8.1/interactive/arrays.html), but I don't see
> a matching field type in Django - presumably because there might not
> be the same datatype in all the databases that Django supports.

And also because it leads to highly denormalised data structures. Array
types are very non-relational. They can always be modelled via related
fields (foreign keys).

I think the answer to both your questions in terms of Django modelling
is to create a model for these multi-values attributes and related them
via a ForeignKey to the main model.

> So is there an easy way of doing this, or should I role my own
> solution to the problem - perhaps using the array datatype in
> PostgreSQL?

You could always write a custom field subclass that used the array
column type. It's possible.

Regards,
Malcolm

-- 
If you think nobody cares, try missing a couple of payments. 
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 on a non root Apache URL

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 07:09 -0800, [EMAIL PROTECTED] wrote:
> Hi,
> 
> that won't do it when I do something like:
> return HttpResponseRedirect('/')
> 
> What I want is to be able to do the command above and I'll get to the:
> http://localhost/django
> 
> Instead of http://localhost/ .
> 
> 
> Is there a way to do this?

Not at the moment. It's something we're working on -- the main ticket to
help this along is in my "to review" pile (#245). Then, at some point,
we'll commit that and the rest of the needed bits, but the timing will
need some judging, since it will be backwards incompatible for some
people.

For now, the most maintainable solution is to have the common prefix a
setting and then refer to settings.MY_COMMON_PREFIX in your redirects
and you URLs file and everywhere else you need 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
-~--~~~~--~~--~--~---



Re: New Forms - Mixing database and non database fields

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 00:43 -0800, DanB wrote:
> Malcolm,
> 
> thxs for the tip.
> I was hoping to get something bit more automatized, but I think I can
> live with this approach as well.

I guess the approach I forgot to mention is that you can also use form
inheritance with modelforms (see the modelforms.txt documentation).
That's a really new addition to trunk.

Malcolm

-- 
Depression is merely anger without enthusiasm. 
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: djWarehouse - Django based e-commerce system

2008-02-18 Thread [EMAIL PROTECTED]


On Feb 18, 4:10 pm, Nicolas Steinmetz <[EMAIL PROTECTED]> wrote:
> > I am pleased to announce the immediate availability of djWarehouse e-
> > commerce system, developed on Django.
>
> Could you provide a quick bench / swot against satchmo project as it
> looks you have the same objectives (being an e-commerce platform).

I've tried to explain why we did not used Satchmo in our first site
we've build:
http://djwarehouse.org/wiki/About (read at bottom).

What about current differences ?  I am not 100% sure because its
difficult to quickly review
Satchmo code, but here is what I've noticed at first look:

djWarehouse itself is not a e-commerce shop, instead its a tool to
create different e-commerce stores. To make an
example, we took djWarehouse and created simple demo store (http://
demo.djwarehouse.org) but that is very minimalistic example. We plan
to release a 'bike shop' and 'gadget shop' examples later, which will
demonstrate
the power of using 'product attribute groups' and 'calculated
attributes'.

I think the most differences are:

1. We try to keep djWarehouse very minimalistic. Satchmo, by design
have everyting in it. This is true about core model fields and total
amount of core applications installed by default. We think that
developer would decide what is required, and add specific modules on
demand.

2. We tried to make system as pluggable as possible. For example you
can have own Shipment,Payment,Discount,Promotion modules which are
defined in absolutely different manners. Product Catalog, Customer and
other things can be easily extended by specific fields (via OneToOne
models of Django).

We don't hardcode many things in core, except a very simple, common
ones (as for example RegionalTax which is common in US). We don't
assume a things, like 'credit card payment' would be needed, so its
not added by default.
We think that someone, who makes store configuration, would add a
required modules.

When you look at admin site, you can compare it to Satchmo.

Please also note, I think one of important differences is that Chris
Moffit is much better communicator then we are, I expect he is
natively speaks English, and he makes a good advertisement.  Also it
seems that he spends some
amount of time into making Satchmo popular. We don't have enough time
for that, since we are small company
and all we try to do is make more e-commerce stores using djWarehouse,
and document how we do it.

We were afraid to show something which is half ready. Now it looks
like we are almost ready, so we try to build sites on djWarehouse, and
see how it works, and document things which worked well on our site.

Regards,
Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



custom field and admin widget

2008-02-18 Thread Gio

Hello,
I wrote a custom field and I would like to have a proper widget in
admin.

As you may guess reading my code I would like to manage that field
with a multiselect, but instead I get a regular select in admin. How
should I do it?

(relevant part should be definition of formfield)
#
from django.db import models
from django.core import validators
from django import newforms as forms

class MultipleChoiceField(models.TextField):
__metaclass__ = models.SubfieldBase

def __init__(self, *args, **kwargs):
if 'separator' in kwargs:
self.separator = kwargs.pop('separator')
else:
self.separator = '|'
for choice in kwargs['choices']:
if self.separator in choice[0]:
raise TypeError('Separator \'%s\' colliding with
choices, see choice \'%s\'.' % (self.separator, choice[0]))
super(MultipleChoiceField, self).__init__(*args, **kwargs)

def formfield(self, **kwargs):
defaults = {'form_class': forms.ModelMultipleChoiceField,
'widget': forms.SelectMultiple}
defaults.update(kwargs)
return super(MultipleChoiceField, self).formfield(**defaults)

def get_internal_type(self):
return "TextField"


def to_python(self, value):
if value is None:
if self.null:
return value
else:
raise validators.ValidationError, ugettext_lazy("This
field cannot be null.")
return
str(value).strip(self.separator).split(self.separator*2)

def get_db_prep_save(self, value):
if type(value) == type([]):
value = list(set(value))
elif type(value) == type(()):
value = list(value)
elif type(value) == type(''):
value = [value]
elif type(value) == type(0):
value = [str(value)]
else:
raise TypeError('Lookup value type %r not supported.' %
type(value))
value.sort()
return self.separator + (self.separator*2).join(value) +
self.separator

def get_db_prep_lookup(self, lookup_type, value):
if lookup_type == 'exact':
return self.get_db_prep_save(value)
if lookup_type == 'contains':
value.sort()
return '%' + '%'.join([self.separator + v + self.separator
for v in value]) + '%'
else:
raise TypeError('Lookup type %r not supported.' %
lookup_type)


--~--~-~--~~~---~--~~
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 Question

2008-02-18 Thread Tim Sawyer

Hi Folks,

I've read the docs for authentication but I can't see how I can replicate 
existing functionality I have using php.

I have a directory /private on the web server, marked using .htaccess 
and .htpasswd to only allow access if a username is passed.  Anything I put 
inside this directory (images, html etc) all require the password before the 
asset can be returned to the browser.

Is there any way to do this with django auth?  I need to have confidence that 
nothing can be returned (including direct image urls) from the /private 
directory without login.  Can I use http .htaccess style authentication with 
django?

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
-~--~~~~--~~--~--~---



Dolardaki Sırlar

2008-02-18 Thread kursatsenturk qp
 Dolardaki Sırlar 
Blogdevri
Network 

*[image: 1 doların
Sırrı]
BİTMEMİŞ PİRAMİT* İnşa edilmekte olan dev bir yapıt. Piramit zaten mutlak
gücün simgesi. Evrensel bir anlam taşıyor. Uzaya açılan kapı. Amerikan
ulusu, piramit gibi inşa ediliyor anlamında kullanıldı. Devamını
okuyun »

   - 0 Yorum 
   - Etiketler: ,
$,
   cent ,
dolar,
   dolardakisır ,
dolardakisırlar,
   dollar , Dollar daki
sır,
   kuruş ,
Ruble,
   türk lirası ,
usd

Blogdevri Network 

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django authentication, virtual hosts, sites and SaaS

2008-02-18 Thread Chris Smith

I'm looking for a solution (preferably off the shelf) which will allow
several things to be done at once.  I've built a couple of trivial
Django sites so I have a little experience, but a lot with Python.

I'm building a *big* high traffic SaaS (sorry for the buzzword) type
application to replace a pile of junk financial portal written in
oodles of hacked up ASP.Net.  Is the following feasable with Django?

1. I need basecamp-esque URLS i.e.  [instance].maindomain.com where
[instance] is an "instance" of the application.  I've looked at the
sites feature for this but I'm not 100% sure it's suitable with
constraint (2) below.  Is there any (optionally anecdotal) evidence
either way to suggest that it will handle this?

2. Separate authentication for each instance.  I'm not sure the user
auth stuff built into Django can do this on a per instance basis as it
lacks a ForeignKey against Site.  Is this easy to hack in before I go
doing it or is there a more django-way of doing it?

3. Project / application structure.  Should the "instance" code be an
application or a separate project?

I could probably build something custom for this but the django auth
stuff is too nice to have to throw away.

I'm going to built a test rig to see if this can be done but i'd
appreciate some input first from the pros!

Any help appreciated.

Cheers,

Chris.
--~--~-~--~~~---~--~~
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: Tumblelog - Generic table or combine queries or...?

2008-02-18 Thread Rob Hudson

On Feb 17, 12:50 am, Jamie Pittock <[EMAIL PROTECTED]> wrote:
> 2. Use the contenttypes framework and create a generic TumblelogItem
> Model that would hold the content_type and ids of all the model items
> I'd like to "tumble".  Something like...

This is pretty much what JellyRoll does:
http://code.google.com/p/jellyroll/

-Rob
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



YouTube’dan yayılan Trojen Nabload.CXU

2008-02-18 Thread kursatsenturk qp
 YouTube'dan yayılan Trojen
Nabload.CXU
blogdevri network *15* *Şub* *2008* Yazar: admin
Kategori:
İnternet 

Panda Security tespit ettiği Nabload.CXU trojan YouTube videoları ile
yayılıyor. YouTube videolarına giden linkleri barındıran e-postalara karşı
dikkatli olunması gerektiğini duyurdu.
Bu tür mailleri alan kullanıcıları maildeki video tıkladığında video
çalışıyor ama Trojan arka planda çalışarak kullanıcının bilgisayarındaki
bilgileri topluyor. Devamını okuyun
»


blogdevri network 

--~--~-~--~~~---~--~~
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 authentication, virtual hosts, sites and SaaS

2008-02-18 Thread Tim Chase

> 1. I need basecamp-esque URLS i.e.  [instance].maindomain.com where
> [instance] is an "instance" of the application.  I've looked at the
> sites feature for this but I'm not 100% sure it's suitable with
> constraint (2) below.  Is there any (optionally anecdotal) evidence
> either way to suggest that it will handle this?

Yes, Django can/does handle this.

There's a modest write-up here:
http://www.rossp.org/blog/2007/apr/28/using-subdomains-django/

This could be expanded to a middleware that attaches the hostname 
(or subdomain name) to the request object; or it could be 
implemented as a decorator that attaches itself to germane view 
functions and then mungs the call-signature or request object 
before handing it off to the actual view.

> 2. Separate authentication for each instance.  I'm not sure the user
> auth stuff built into Django can do this on a per instance basis as it
> lacks a ForeignKey against Site.  Is this easy to hack in before I go
> doing it or is there a more django-way of doing it?

I'm not sure on this one.  Depending on the scope of any cookies 
used, it may come for free, or you may have to do a little twiddling.

> 3. Project / application structure.  Should the "instance" code be an
> application or a separate project?

The concept of a "project" is actually a bit of a crutch.  It's 
nice for getting up to speed quickly, but it does promote writing 
non-portable code.  James gives a good rant^Wargument here:

http://www.b-list.org/weblog/2007/nov/09/projects/

for why the idea of a project should be dumped in favor of more 
portable apps.

It sounds like a single app can do all you need.  If it got 
large, apps should usually split along functional/conceptual 
boundaries, not along data boundaries.

My $0.02

-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: Newfroms - How to get the id for a field

2008-02-18 Thread Jorge Sousa
Hi,

{{ fields }} is rendered by the as_widget() method of the BoundField class.

Jorge


On Feb 15, 2008 8:58 PM, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:

>
>
>
> On Feb 14, 4:15 am, shabda <[EMAIL PROTECTED]> wrote:
> > When using newforms, I want to get the id set on the input field.
> > I am doing something like,
> > {% for field in form %}
> > {{ field }}
> > ...
> >
> > Now this {{field}} will render as something like,
> > 
>
>
> >
> > Withing the template how can I access the value for id. If this is not
> > possible where in code does Django set the value for id?
>
> Try {{ field.auto_id }}
>
>
> >
>


-- 
---
Jorge Sousa

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



American Idol game developed in Django

2008-02-18 Thread Ed Menendez

This was our first site in Django and also our intro to Python. We
used to play this on a spreadsheet with friends but were able to
develop the replacement in about a week with Django. Probably could
have been done much quicker if we weren't newbies to the framework.

http://aigame.digitalhaiku.com/

Special thanks to Eric Florenzano who gave us our introductory class
in Django. Hope this motivates some developers that are on the fence
on using Django.

- Ed
--~--~-~--~~~---~--~~
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 Question

2008-02-18 Thread Rajesh Dhawan

Hi Tim,

> I've read the docs for authentication but I can't see how I can replicate
> existing functionality I have using php.
>
> I have a directory /private on the web server, marked using .htaccess
> and .htpasswd to only allow access if a username is passed.  Anything I put
> inside this directory (images, html etc) all require the password before the
> asset can be returned to the browser.

Firstly, there is a big difference between PHP's filesystem based
architecture and Django's MVC-like one. Assuming that you are
following the Django recommendation of serving your media files
directly through Apache (or another web server), you can continue to
use your .htaccess files at least for your media files. To secure your
Django "views" with authentication, you will need to use Django's
authentication facility. If you want to make Apache use a Django auth
backend, take a look at: http://www.djangoproject.com/documentation/apache_auth/


>
> Is there any way to do this with django auth?  I need to have confidence that
> nothing can be returned (including direct image urls) from the /private
> directory without login.  Can I use http .htaccess style authentication with
> django?

If you're using the /private filesystem directory to hold just your
media files (i.e. /private/* does not map on to any Django views)
*and* if you're using Apache to server those /private/* media files
directly (i.e. not using Django's static media serving DEVELOPMENT-
ONLY NON-PRODUCTION-USE[1] feature), the .htaccess method of securing
those files will work fine.

-Rajesh Dhawan

[1] http://www.djangoproject.com/documentation/static_files/


--~--~-~--~~~---~--~~
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: ImportError: No module named base

2008-02-18 Thread Noah

Me too
--~--~-~--~~~---~--~~
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: ImportError: No module named base

2008-02-18 Thread James Bennett

Most likely, you all have out-of-date versions of the MySQLDb adapter
(the Python module which lets Python talk to a MySQL database).


-- 
"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
-~--~~~~--~~--~--~---



I need some help building my django site

2008-02-18 Thread sebey

ok so this kind of general instead of django focused but I am building
the site around the framework so I would love some help about how to
built the site.

ok so my site is a podcasting network.so I want to use rss to display
my content, in other words I want to show my latest show from my
podcast rss feed to show the shownotes on the screen ,and with
comenits but there is one problem I do not know a thing about
databases I have something on mysql but I am already learning so much
with so little time with ajax javascipt jquery actionscipt xml python
django etc.  so what I am trying to say is there anyway of doing a
comenit system without a database? also I want to do a newsletter can
I make a template with ads,use my rss feeds to display the latest
shows and any news updates I can enter manually

please ask me if any of this is unclear thank you so much for your
help 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
-~--~~~~--~~--~--~---



Whitespace handling in newforms modelforms

2008-02-18 Thread web-junkie

Hi,

why isn't whitespace automatically stripped from fields when using
modelforms? This would be convenient.
Is there a reason for not doing so, where is one supposed to do that?
--~--~-~--~~~---~--~~
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: ImportError: No module named base

2008-02-18 Thread [EMAIL PROTECTED]



> Most likely, you all have out-of-date versions of the MySQLDb adapter
> (the Python module which lets Python talk to a MySQL database).

I'm using the SQLite database for development, so no MySQLDb adapter
is necessary. ;-)

But it works with the Python version which comes with Leopard.
I deinstalled Python from Macports, installed PIL manually, and
tried it again. I don't know why my first attempt was not successful,
but currently it runs as expected.

Best regards,
   Ralf

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



2GB Free Online Storage !

2008-02-18 Thread kinkon gowyard
Free online photo Album, Free online auto-matic Back-up, Free Access your
MP3 music online,2 GB For Free!

That's right, we are happy to give you a whopping great 2GB of secure online
storage
where you can manage and share your files easily. For Free!

Get Free Code: Limited Time Only!
http://www.web4easy.com/free2gb

--~--~-~--~~~---~--~~
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: djWarehouse - Django based e-commerce system

2008-02-18 Thread Chris Moffitt
I'll try to respond to some of these points. To be fair, I haven't spent
much time looking at the internals of djWarehouse. From the surface, it
seems like they have some good experience and design going into the product.
I'll point out some differences - but they are mostly based on looking at
the site and not actually playing with the code:

- Satchmo is a community app while djWarehouse is built by a company (but
released open source) and used for their needs. There are at least 5 Satchmo
stores in production and probably more out there that I don't know about.
Our mailing list has over 400 users and the dev list has about 75 people. We
do get lots of patches and bug fix suggestions from the community but there
are only 4 of us with commit privileges. djWarehouse has more of a dedicated
team. I don't know that one model is better than the other - they are
different.
Satchmo has addition features such as:
-  payment modules for Authorize.net, Paypal, Google, cybersource and
trustcommerce. It also has a COD module and auto success module which might
be useful for certain types of sites.
-  UPS integration for estimating shipping charges.
- support for multiple product types including gift certificates,
downloadable products, custom products, etc.
- Satchmo allows you to generate PDF invoices and packing slips.
- supports multiple shipping calculation methods and includes geographic
info for most countries.
- Satchmo allows translation of content and allows you to test the different
translations.
- Satchmo has extensive unit tests
- There are probably others but these are some of the things that come to
mind immediately.

To be fair, Satchmo has 2 main warts:
- The product models are not as extensible as we'd like. It can be done but
it could be cleaner. I'm hopeful that the new model inheritance code will
help us out.
- The admin interface could be slicker. Our plan is to tackle that as part
of the newforms admin merge.

There's also a constant struggle with building "frameworks." Trying to
decide what does and does not go in is hard. Sometimes I think we hit it
right and other times I'm not sure. I think the djWarehouse crew felt we had
too much in the framework. It's a fair comment and reasonable people may
disagree on this point.

I will also freely admit that I am a native english speaker (and do not
speak any other languages with any proficiency whatsoever) and that I do try
to spend time promoting Satchmo ;) My main goal is to let people know there
is a reasonable alternative to OsCommerce! I don't want to put down
djWarehouse or other projects. I suspect there is a lot we can learn from
their project and would welcome any specific criticisms or suggestions for
improving Satchmo. It's a big internet out there and there are a lot of
different needs. I'd prefer to have 1 framework out there to consolidate
efforts but sometimes that just isn't possible.

If someone has played with both versions and has any more specific details,
feel free to let me know.

-Chris

--~--~-~--~~~---~--~~
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: I need some help building my django site

2008-02-18 Thread Rajesh Dhawan

Hi,

On Feb 18, 3:28 pm, sebey <[EMAIL PROTECTED]> wrote:
> ok so this kind of general instead of django focused but I am building
> the site around the framework so I would love some help about how to
> built the site.
>
> ok so my site is a podcasting network.so I want to use rss to display
> my content, in other words I want to show my latest show from my
> podcast rss feed to show the shownotes on the screen ,and with
> comenits but there is one problem I do not know a thing about
> databases

I would say that's one BIG problem! Is this your own hobby web site or
a commercial one. If it's the latter and time is of the essence,
you're much better off hiring a proper web developer to get the job
done. If it's the latter, you should start at the beginning: educate
yourself on databases, and web architecture in general, and Django in
particular by trying out smaller projects first to get your feet wet.

> I have something on mysql but I am already learning so much
> with so little time with ajax javascipt jquery actionscipt xml python
> django etc.  so what I am trying to say is there anyway of doing a
> comenit system without a database?

Perhaps. But it would be more complicated to do it that way. Django
comes with a FreeComment/Comment[1] application. You can add James'
excellent comment-utils[2] for extra moderation features. But this all
requires you to invest some time into learning how Django works.

> also I want to do a newsletter can
> I make a template with ads,use my rss feeds to display the latest
> shows and any news updates I can enter manually

Yes, you can do all this. But, with Django, you'd have to learn a
bunch of things as I mentioned above. There are no out-of-the-box
solutions that will help you if your needs are very specific and
require custom features. You can, of course, take a look at many fine
Django "plugin-like" applications[3] and pick one that's close enough
to what you're looking for and then build from there.

-Rajesh Dhawan

[1] - http://code.djangoproject.com/wiki/UsingFreeComment
[2] - http://code.google.com/p/django-comment-utils/
[3] - 
http://code.djangoproject.com/wiki/DjangoResources#Djangoapplicationcomponents
--~--~-~--~~~---~--~~
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: Head swimming - JavaScript libraries

2008-02-18 Thread Michael Hipp

Just wanted to thank everyone who replied (Julien, Dj Gilcrease, Phoenix 
Kiula, Hraban, Horst Gutmann, AmanKow, Peter Rowell).

I think I will have a go at jQuery. Looks good.

Thanks,
Michael


Peter Rowell wrote:
> Yet another vote for jQuery. It completely changed the way I look at
> using JS on pages.
> 
> BTW, ext works with jQuery. See 
> http://docs.jquery.com/Tutorials:Using_Ext_With_jQuery


--~--~-~--~~~---~--~~
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 Question

2008-02-18 Thread Tim Sawyer

On Monday 18 Feb 2008, Rajesh Dhawan wrote:
> If you want to make Apache use a Django auth backend, 
> take a look at: 
> http://www.djangoproject.com/documentation/apache_auth/

Thanks Rajesh, I think this is exactly what I was fumbling towards!  
(Excellent analysis of my non-MVC ramblings as well, bravo)

Cheers,

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: Whitespace handling in newforms modelforms

2008-02-18 Thread James Bennett

On Feb 18, 2008 2:37 PM, web-junkie <[EMAIL PROTECTED]> wrote:
> why isn't whitespace automatically stripped from fields when using
> modelforms? This would be convenient.

Up until the moment you need to store some source code written in the
language Django uses.


-- 
"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
-~--~~~~--~~--~--~---



Domain Parsing Question

2008-02-18 Thread Dave Fowler

This doesn't have a lot to do with django, but python and web
programming.

I'm having an issue parsing the sub domain from a lot of non-US urls.
In the US the format is always  subdomain.domain.sufix or
domain.sufix.  Easy to parse.

In the uk for example though the format is

subdomain.domain.co.uk or
domain.co.uk

My issue is that i'm parsing the domain.co.uk like us urls and its
parsing the domain to be "co.uk" not domain.co.uk!

example:  getDomain('bbc.co.uk') returns 'co.uk'

Any one know of a standard protocol for parsing these urls, or do I
have to find all the unique instances of co.uk, or co.nz etc.

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Whitespace handling in newforms modelforms

2008-02-18 Thread Rajesh Dhawan

Hi,

> why isn't whitespace automatically stripped from fields when using
> modelforms? This would be convenient.

It may be convenient for many cases but for many others that approach
would *lose* information irrecoverably. What if you wanted to have
some fields stored with their whitespace preserved? Say a Textarea
field where a sentence typed in with a line break at the end needs to
be interpreted differently than one without. For example, if you
needed to use Markdown on such a field, then 2 spaces followed by a
line break causes a  to be generated by Markdown. Stripping such
a field would cause a problem there.

> Is there a reason for not doing so, where is one supposed to do that?

- Add clean_ methods to the modelform class and strip() fields
there (or in the general clean() method.)

- You can also override save() on your models and strip() out relevant
fields before the data gets saved.

-Rajesh Dhawan

--~--~-~--~~~---~--~~
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: Whitespace handling in newforms modelforms

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 12:37 -0800, web-junkie wrote:
> Hi,
> 
> why isn't whitespace automatically stripped from fields when using
> modelforms? This would be convenient.

Convenient in your case. Absolutely tragic for situations where
whitespace is important. So that's why it doesn't happen automatically.

I've sometimes thought we could one day add a "strip space" option to
CharField and TextField. Not sure how that would translate up to
ModelForms, though. You might have to manually tweak the attribute in
those cases. Anyway, that's for the future.

As to how to do it now: add a clean_FOO() method for each field FOO that
you want to strip spaces from (see the newforms docs). Then read the
value out of self.cleaned_data, strip it and return it. It won't be too
repetitive, since you can write a factory function to do most of the
work.

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
-~--~~~~--~~--~--~---



One CSS, One JS in production mode for django?

2008-02-18 Thread mamcxyz

I wonder if exist a similar toolset as in ruby:

http://synthesis.sbecker.net/pages/asset_packager

The idea is put a single css & js for production mode, maybe with a
timestamp so get cached properly.

I wonder what tools are reliable for this & usable with python.
--~--~-~--~~~---~--~~
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: Deploying Django - can't get past the welcome screen

2008-02-18 Thread Darthmahon

Hi Brian,

I know how to get into python but not sure the exact commands to
import settings.py? I tried "import settings" and it didn't come back
with an error.

How do I check the __file__/__path__ module attributes?

I am now running into a weird intermittent issue which is actually not
showing the welcome page anymore, but it showing a Django error (which
is good) but I actually have Debug set to False which means I
shouldn't be seeing this page!

I am now thinking my settings.py file is not being called properly.
Here is part of the error message screen (some parts changed to X):

DOCUMENT_ROOT
'/home/mysite'
GATEWAY_INTERFACE
'CGI/1.1'
HTTP_ACCEPT
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_ENCODING
'gzip, deflate'
HTTP_ACCEPT_LANGUAGE
'en-us'
HTTP_AREA51
'1'
HTTP_CACHE_CONTROL
'max-age=0'
HTTP_CONNECTION
'keep-alive'
HTTP_COOKIE
'PHPSESSID=
HTTP_HOST
'mysite.com'
HTTP_USER_AGENT
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/
523.10.6 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6'
PATH_INFO
'/'
PATH_TRANSLATED
'/home/mysite/'
QUERY_STRING
''
REDIRECT_STATUS
'200'
REDIRECT_URI
'/mysite.fcgi/'
REMOTE_ADDR
'XX.XXX.XX.XXX'
REMOTE_PORT
'X'
REQUEST_METHOD
'GET'
REQUEST_URI
'/'
SCRIPT_FILENAME
'/home/mysite/mysite.fcgi'
SCRIPT_NAME
'/mysite.fcgi'
SERVER_ADDR
'69.72.215.66'
SERVER_NAME
'mysite.com'
SERVER_PORT
'8251'
SERVER_PROTOCOL
'HTTP/1.1'
SERVER_SOFTWARE
'lighttpd/1.4.18'
wsgi.errors

wsgi.input

wsgi.multiprocess
True
wsgi.multithread
False
wsgi.run_once
False
wsgi.url_scheme
'http'
wsgi.version
(1, 0)

Anything in there stand out as an issue?

Cheers,
Chris

On Feb 17, 6:58 pm, Brian Luft <[EMAIL PROTECTED]> wrote:
> Your code is apparently in a project called "thumbslap":
>
> >If you plan to use a database, edit the DATABASE_* settings in
> >thumbslap/settings.py.
> >Start your first app by running python thumbslap/manage.py startapp
> >[appname].
>
> But your settings file is ROOT_URL_CONF set to "mysite.urls".  Is that
> in fact the correct URLs file?
>
> I would suggest jumping into the python interpreter and importing your
> desired settings file, check the __file__/__path__ module attributes
> and also do the same with your urls.py file just to make sure you
> aren't loading something unexpected.
>
> -Brian
>
> On Feb 17, 2:52 am,Darthmahon<[EMAIL PROTECTED]> wrote:
>
> > ==
> > File: urls.py
> > ==
> > from django.conf.urls.defaults import *
> > urlpatterns = patterns('',
> >         (r'^admin/', include('django.contrib.admin.urls')),
> >         (r'^$', 'mysite.views.index'),
> >         (r'^settings/', 'mysite.people.views.settings'),
> >         (r'^register/', 'mysite.people.views.register'),
> >         (r'^login/', 'mysite.views.login'),
> >         (r'^logout/', 'mysite.people.views.logout'),
> >         (r'^people/', include('mysite.people.urls')),
> >         (r'^friends/', 'mysite.people.views.friends'),
> > )
> > ==
> > File: settings.py
> > ==
> > DEBUG = False
> > TEMPLATE_DEBUG = DEBUG
> > ADMINS = (
> > )
> > MANAGERS = ADMINS
> > DATABASE_ENGINE = 'mysql'
> > DATABASE_NAME = ''
> > DATABASE_USER = ''
> > DATABASE_PASSWORD = ''
> > DATABASE_HOST = ''
> > DATABASE_PORT = ''
> > DATABASE_OPTIONS = {'read_default_file': '/etc/my.cnf',}
> > TIME_ZONE = 'Europe/London'
> > LANGUAGE_CODE = 'en-gb'
> > SITE_ID = 1
> > USE_I18N = True
> > MEDIA_ROOT = '/home/mysite/static'
> > MAX_PHOTO_UPLOAD_SIZE = 50
> > MAX_PHOTO_WIDTH = 50
> > MAX_PHOTO_WIDTH = 50
> > MEDIA_URL = 'http://static.mysite.com/'
> > ADMIN_MEDIA_PREFIX = '/media/'
> > SECRET_KEY = ''
> > TEMPLATE_LOADERS = (
> >     'django.template.loaders.filesystem.load_template_source',
> >     'django.template.loaders.app_directories.load_template_source',
> > )
> > AUTH_PROFILE_MODULE = "people.userprofile"
> > TEMPLATE_CONTEXT_PROCESSORS = (
> >         'django.core.context_processors.auth',
> >         'django.core.context_processors.debug',
> >         'django.core.context_processors.i18n',
> >         'django.core.context_processors.request',
> >         'mysite.context_processors.static_url',
> >         'mysite.context_processors.user_profile',
> >         'django.core.context_processors.request',
> > )
> > MIDDLEWARE_CLASSES = (
> >     'django.middleware.common.CommonMiddleware',
> >     'django.contrib.sessions.middleware.SessionMiddleware',
> >     'django.contrib.auth.middleware.AuthenticationMiddleware',
> >     'django.middleware.doc.XViewMiddleware',
> > )
> > ROOT_URLCONF = 'mysite.urls'
> > TEMPLATE_DIRS = (
> >     '/home/mysite/templates',
> > )
> > INSTALLED_APPS = (
> >     'django.contrib.auth',
> >     'django.contrib.humanize',
> >     'django.contrib.contenttypes',
> >     'django.contrib.sessions',
> >     'django.contrib.sites',
> >    

Re: One CSS, One JS in production mode for django?

2008-02-18 Thread James Bennett

On Feb 18, 2008 3:21 PM, mamcxyz <[EMAIL PROTECTED]> wrote:
> I wonder if exist a similar toolset as in ruby:

Believe it or not, this question has been asked before on this very
list; try searching the archive for suggestions.


-- 
"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
-~--~~~~--~~--~--~---



PostgreSQL ByteA

2008-02-18 Thread Leonel Nunez

Hello :

What's the status for  PostgreSQL ByteA  support in django ??


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: Manually ordering content

2008-02-18 Thread Bret W

I never really heard anything back on this, so I built something based
on the models in my last message.

The details and code are here:
http://www.nyquistrate.com/django/orderedlist/

I'd appreciate any feedback you might have.  Hopefully others will
find this code useful.

Thanks,
Bret
--~--~-~--~~~---~--~~
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: Manually ordering content

2008-02-18 Thread Fco. Javier Nievas
Maybe you could use the "ordering" attribute at META class, to avoid using
order_by in every request.

Wish it helps

2008/2/18, Bret W <[EMAIL PROTECTED]>:
>
>
> I never really heard anything back on this, so I built something based
> on the models in my last message.
>
> The details and code are here:
> http://www.nyquistrate.com/django/orderedlist/
>
> I'd appreciate any feedback you might have.  Hopefully others will
> find this code useful.
>
> Thanks,
> Bret
> >
>

--~--~-~--~~~---~--~~
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: Whitespace handling in newforms modelforms

2008-02-18 Thread Fco. Javier Nievas
You can use Form inheritance to redefine default behaviour, so you will be
just writing down just a strip and after making all your forms inherit from
your BaseForm they all will strip fields

2008/2/18, James Bennett <[EMAIL PROTECTED]>:
>
>
> On Feb 18, 2008 2:37 PM, web-junkie <[EMAIL PROTECTED]> wrote:
> > why isn't whitespace automatically stripped from fields when using
> > modelforms? This would be convenient.
>
> Up until the moment you need to store some source code written in the
> language Django uses.
>
>
> --
> "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: Manually ordering content

2008-02-18 Thread Bret W

While that will allow content items to be ordered by a field in the
model, I'm looking for a way to arbitrarily order items.  I don't
think the ordering attribute will solve this problem.
--~--~-~--~~~---~--~~
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: One CSS, One JS in production mode for django?

2008-02-18 Thread mamcxyz

I found this:

http://groups.google.com/group/django-users/browse_thread/thread/31d11436b482e43c/a81a71b812d808e5?lnk=gst&q=asset_packager#a81a71b812d808e5

But is not responded ;)

The link provided is reported to not work.


I know I can do this, but I have always the lazy mode on ;)
--~--~-~--~~~---~--~~
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: PostgreSQL ByteA

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 14:40 -0700, Leonel Nunez wrote:
> Hello :
> 
> What's the status for  PostgreSQL ByteA  support in django ??

Normally it'd be a good idea to at least summarise what your research
has unturned so people don't cover what you already know (you did do
some previous research, right??)

There is none built in. You could write you own field subclass if you're
using a recent subversion checkout and you really needed to use it.

One day we'll add a portable binary field, but there are other items on
our plates first.

Malcolm

-- 
He who laughs last thinks slowest. 
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: Problem with django.db.transaction.commit_manually

2008-02-18 Thread Brot

I have found a solution. Could someone tell me, if this is OK or if
this is a bad solution?

 > > finally:
> > if result['status'] == 'OK':
transaction.set_clean()
> > otherfile.test()
> > reserv.delete()
> > transaction.commit()
> > else:
> > transaction.rollback()

> > return render_to_response('template.html', {'result':result})

On Feb 18, 4:48 pm, Brot <[EMAIL PROTECTED]> wrote:
> Hello,
>
> The view works well if I delete the call 'otherfile.test()'
> There is also no error if I delete the dictionary declaration in
> 'otherfile.test()'. My example code is only an extraction from my
> code. In my real 'test-function' is a lot of code (I use urlib, urlib2
> and htmllib there).
> But the error only appears if I declare a dictonary in the function.
> This makes no sense for me :-(
>
> On 18 Feb., 16:21, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > You get this because thetransactionis 'dirty' (some statement was
> > executed,
> > but there was no commit/rollback afterwards). I guess this happens
> > in render_to_response in your example.
>
> > > K'
> > > finally:
> > > if result['status'] == 'OK':
> > > otherfile.test()
> > > reserv.delete()
> > >transaction.commit()
> > > else:
> > >transaction.rollback()
>
> > > return render_to_response('template.html', {'result':result})
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Something I want to tell you

2008-02-18 Thread [EMAIL PROTECTED]

http://www.oyla15.de/userdaten/11969408/pdf/Edgar_Cayce_-_The_Lost_Teachings_Of_Atlantis_-_By_Jon_Peniel.pdf
--~--~-~--~~~---~--~~
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 Question

2008-02-18 Thread Graham Dumpleton

If you want to use Django user database for HTTP Basic/Digest
authentication across static files and other non Django URLs, as well
as Django, then you can also use mod_wsgi 2.0 instead of mod_python.
See:

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

When using the mod_python way of doing things, Digest type
authentication is not an option where as it is with mod_wsgi (provided
you are using Apache 2.2 :-)). The mod_wsgi support for group
authorisation also matches better the Apache way of doing things.

Graham

On Feb 19, 5:55 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi Tim,
>
> > I've read the docs for authentication but I can't see how I can replicate
> > existing functionality I have using php.
>
> > I have a directory /private on the web server, marked using .htaccess
> > and .htpasswd to only allow access if a username is passed.  Anything I put
> > inside this directory (images, html etc) all require the password before the
> > asset can be returned to the browser.
>
> Firstly, there is a big difference between PHP's filesystem based
> architecture and Django's MVC-like one. Assuming that you are
> following the Django recommendation of serving your media files
> directly through Apache (or another web server), you can continue to
> use your .htaccess files at least for your media files. To secure your
> Django "views" with authentication, you will need to use Django's
> authentication facility. If you want to make Apache use a Django auth
> backend, take a look 
> at:http://www.djangoproject.com/documentation/apache_auth/
>
>
>
> > Is there any way to do this with django auth?  I need to have confidence 
> > that
> > nothing can be returned (including direct image urls) from the /private
> > directory without login.  Can I use http .htaccess style authentication with
> > django?
>
> If you're using the /private filesystem directory to hold just your
> media files (i.e. /private/* does not map on to any Django views)
> *and* if you're using Apache to server those /private/* media files
> directly (i.e. not using Django's static media serving DEVELOPMENT-
> ONLY NON-PRODUCTION-USE[1] feature), the .htaccess method of securing
> those files will work fine.
>
> -Rajesh Dhawan
>
> [1]http://www.djangoproject.com/documentation/static_files/
--~--~-~--~~~---~--~~
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: Domain Parsing Question

2008-02-18 Thread Tim Chase

> I'm having an issue parsing the sub domain from a lot of non-US urls.
> In the US the format is always  subdomain.domain.sufix or
> domain.sufix.  Easy to parse.
> 
> In the uk for example though the format is
> 
> subdomain.domain.co.uk or
> domain.co.uk
> 
> My issue is that i'm parsing the domain.co.uk like us urls and its
> parsing the domain to be "co.uk" not domain.co.uk!
> 
> example:  getDomain('bbc.co.uk') returns 'co.uk'

I don't believe there is one, but it's not too hard to hack together:

   KNOWN_TLDS = set([
 'com', 'edu', 'gov', 'mil', 'net',
 'aero', 'biz', 'coop', 'info',
 'museum', 'name', 'pro',
 'local', 'localhost', 'invalid', 'test',
 ])

   def split_domain(domain):
 bits = domain.split('.')
 if bits[-1] in KNOWN_TLDS:
   return (
 '.'.join(bits[:-1]),
 bits[-1])
 else:
   return (
 '.'.join(bits[:-3]),
 '.'.join(bits[-2:]))

   if __name__ == "__main__":
 tests = (
   ('localhost.local', 'local'),
   ('example.com', 'com'),
   ('cs.example.edu', 'edu'),
   ('example.co.uk', 'co.uk'),
   ('example.tld.zw', 'tld.zw'),
   ('localhost', 'localhost'),
   ('', ''),
   )
 for test, result in tests:
   subdomain, tld = split_domain(test)
   print test, subdomain, tld, result
   assert tld == result

Adjust accordingly if you need.

-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
-~--~~~~--~~--~--~---



SHARE THIS WORD OF GOD

2008-02-18 Thread [EMAIL PROTECTED]

http://www.oyla15.de/userdaten/11969408/pdf/Edgar_Cayce_-_The_Lost_Teachings_Of_Atlantis_-_By_Jon_Peniel.pdf
--~--~-~--~~~---~--~~
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: Head swimming - JavaScript libraries

2008-02-18 Thread Fco. Javier Nievas
As many developers you asked, as many different answers you get. It's just a
matter of taste.

I've been using Mootools for "simple" projects, since it's very light, very
clear, smart and easy to extend. The better choice for most situations.

For complex projects, I've been using dojo for a couple of sites, and ext
for another one. Ext is definitely the "prettiest", but a bit difficult to
learn how to use it properly. Dojo is also "a big" library, full of widgets.
Both needs more/better documentation. But if you want to do a UI js-based,
it will be easier for you if you choose one of these.

But, as I started saying.. It's just a matter of taste, so.. TRY AS MUCH AS
YOU CAN  :-)

2008/2/18, Michael Hipp <[EMAIL PROTECTED]>:
>
>
> Just wanted to thank everyone who replied (Julien, Dj Gilcrease, Phoenix
> Kiula, Hraban, Horst Gutmann, AmanKow, Peter Rowell).
>
> I think I will have a go at jQuery. Looks good.
>
> Thanks,
> Michael
>
>
> Peter Rowell wrote:
> > Yet another vote for jQuery. It completely changed the way I look at
> > using JS on pages.
> >
> > BTW, ext works with jQuery. See
> http://docs.jquery.com/Tutorials:Using_Ext_With_jQuery
>
>
> >
>

--~--~-~--~~~---~--~~
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: Domain Parsing Question

2008-02-18 Thread Ned Batchelder

The different countries don't use a uniform scheme.  For example, .uk 
has a two-letter component (.co .ac, etc), but other countries do not.

I suppose the exact answer to your question ("how do I parse these 
domains") depends on why it is you are trying to parse them.  What 
information are you trying to get from the domain?

--Ned.
http://nedbatchelder.com/blog

Dave Fowler wrote:
> This doesn't have a lot to do with django, but python and web
> programming.
>
> I'm having an issue parsing the sub domain from a lot of non-US urls.
> In the US the format is always  subdomain.domain.sufix or
> domain.sufix.  Easy to parse.
>
> In the uk for example though the format is
>
> subdomain.domain.co.uk or
> domain.co.uk
>
> My issue is that i'm parsing the domain.co.uk like us urls and its
> parsing the domain to be "co.uk" not domain.co.uk!
>
> example:  getDomain('bbc.co.uk') returns 'co.uk'
>
> Any one know of a standard protocol for parsing these urls, or do I
> have to find all the unique instances of co.uk, or co.nz etc.
>
> Thanks
>
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: PostgreSQL ByteA

2008-02-18 Thread Leonel Nunez

>
> On Mon, 2008-02-18 at 14:40 -0700, Leonel Nunez wrote:
>> Hello :
>>
>> What's the status for  PostgreSQL ByteA  support in django ??
>
> Normally it'd be a good idea to at least summarise what your research
> has unturned so people don't cover what you already know (you did do
> some previous research, right??)

Yes I did and found somenon official patches  but I wanted an official
response  that's why I didn't mention anything.

>
> There is none built in. You could write you own field subclass if you're
> using a recent subversion checkout and you really needed to use it.

Thank you I'll check it out.

>
> One day we'll add a portable binary field, but there are other items on
> our plates first.
>
I imagine

Thank you very much.

> Malcolm
>
> --
> He who laughs last thinks slowest.
> http://www.pointy-stick.com/blog/
>
>


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: Django on a non root Apache URL

2008-02-18 Thread Graham Dumpleton

On Feb 19, 3:36 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-02-18 at 07:09 -0800, [EMAIL PROTECTED] wrote:
> > Hi,
>
> > that won't do it when I do something like:
> > return HttpResponseRedirect('/')
>
> > What I want is to be able to do the command above and I'll get to the:
> >http://localhost/django
>
> > Instead ofhttp://localhost/.
>
> > Is there a way to do this?
>
> Not at the moment. It's something we're working on -- the main ticket to
> help this along is in my "to review" pile (#245). Then, at some point,
> we'll commit that and the rest of the needed bits, but the timing will
> need some judging, since it will be backwards incompatible for some
> people.
>
> For now, the most maintainable solution is to have the common prefix a
> setting and then refer to settings.MY_COMMON_PREFIX in your redirects
> and you URLs file and everywhere else you need it.

Would the suggested fiddle for mod_wsgi for mounting Django
application at non root URL help in this particular case? Ie., as
outlined in:

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

use:

  import os, sys
  sys.path.append('/usr/local/django')
  os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

  import django.core.handlers.wsgi

  _application = django.core.handlers.wsgi.WSGIHandler()

  def application(environ, start_response):
  environ['PATH_INFO'] = environ['SCRIPT_NAME'] +
environ['PATH_INFO']
  return _application(environ, start_response)

I don't have time at present to try out what OP wants under this
configuration.

Graham


Graham
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist at /admin/

2008-02-18 Thread RichardH

Just rebuilt Windows XP on a new hard disk and I have found the same
problem installing Python 2.5 and the latest SVN checkout (rev 7129).
Setup.py install doesn't copy across the templates and media folders
into C:\Python25\Lib\site-packages\django\contrib\admin.
Like Nathan, a manual copy solved the issue.
RichardH

On Feb 4, 12:07 am, Nathan <[EMAIL PROTECTED]> wrote:
> Same error here on Mac OS X Leopard, having installed from the 0.96.1
> tarball via setup.py.
>
> TemplateDoesNotExist at /admin/
> admin/login.html
>
> Those folders are not present in:
> /Library/Python/2.5/site-packages/django/contrib/admin/
>
> A manual copy + authenticate resolved the issue.
--~--~-~--~~~---~--~~
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: TemplateDoesNotExist at /admin/

2008-02-18 Thread Karen Tracey
On Feb 18, 2008 6:20 PM, RichardH <[EMAIL PROTECTED]> wrote:

>
> Just rebuilt Windows XP on a new hard disk and I have found the same
> problem installing Python 2.5 and the latest SVN checkout (rev 7129).
> Setup.py install doesn't copy across the templates and media folders
> into C:\Python25\Lib\site-packages\django\contrib\admin.
> Like Nathan, a manual copy solved the issue.
>

OK, I finally found a way to recreate this on my WinXP box.  What I have to
do is issue the command:

setup.py install

instead of:

python setup.py install

(However this directly contradicts a note earlier in this discussion where
the poster says it is 'python setup.py install' that does not work, so
ymmv.)

I don't understand the difference, because I thought those two commands were
equivalent.  I checked the file type association for .py files and the
action on open is defined as:

"C:\bin\Python25\python.exe" "%1" %*

(That's the only python installed on this box.)

"Use DDE" is checked, "DDE Message" is empty, "Application" is python, "DDE
Application Not Running" is empty, and "Topic" is System.  Whatever that all
means.

Examining the output of the first command shows that 'install_data' part of
the process doesn't seem to do anything:

running install_scripts
copying build\scripts-2.5\django-admin.py -> C:\bin\Python25\Scripts
running install_data
running install_egg_info
Writing C:\bin\Python25\Lib\site-packages\Django-0.97_pre-py2.5.egg-info

Whereas with the same command preceded by 'python', the 'install_data' step
does work:

running install_scripts
copying build\scripts-2.5\django-admin.py -> c:\bin\Python25\Scripts
running install_data
creating c:\bin\Python25\Lib\site-packages\django\conf\locale
creating c:\bin\Python25\Lib\site-packages\django\conf\locale\ar
creating c:\bin\Python25\Lib\site-packages\django\conf\locale\ar\LC_MESSAGES
copying django\conf\locale\ar\LC_MESSAGES\django.mo ->
c:\bin\Python25\Lib\site-packages\django\conf\locale\ar\LC_MESSAGES
[much more snipped, including creating/copying all the admin media and
template files]

Other than the 'install_data' difference, the output of the two different
ways of invoking setup seems to be identical.

I would be interested if others who have run into this problem can duplicate
the different results of these commands.  Also wondering if people who were
missing templates and media files are also missing locale files?

Karen


>
> On Feb 4, 12:07 am, Nathan <[EMAIL PROTECTED]> wrote:
> > Same error here on Mac OS X Leopard, having installed from the 0.96.1
> > tarball via setup.py.
> >
> > TemplateDoesNotExist at /admin/
> > admin/login.html
> >
> > Those folders are not present in:
> > /Library/Python/2.5/site-packages/django/contrib/admin/
> >
> > A manual copy + authenticate resolved the issue.
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Bound form showing image default

2008-02-18 Thread Michael Newman

I have a newform that I am binding to a model and allowing a user to
edit it. Problem is the images don't show up. I know I have seen some
blog or post that discusses this, but I can't find them anywhere. I
assume the best way to do this is to create a custom widget with a
render function that includes the image. I can't find documentation
anywhere on how to create a custom widget render right. Any help would
be very appreciated!!! Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Bound form showing image default

2008-02-18 Thread Malcolm Tredinnick


On Mon, 2008-02-18 at 17:39 -0800, Michael Newman wrote:
> I have a newform that I am binding to a model and allowing a user to
> edit it. Problem is the images don't show up. I know I have seen some
> blog or post that discusses this, but I can't find them anywhere.

It's come up a few times here, but most recently on the devel list when
we were discussing ModelForms recently (search for "FileField initial
data ModelForms", for example.

It's an HTML limitation/feature: file input widgets don't show any kind
of initial value.

>  I
> assume the best way to do this is to create a custom widget with a
> render function that includes the image. I can't find documentation
> anywhere on how to create a custom widget render right. Any help would
> be very appreciated!!! Thanks

There are a few dozen examples in django/newforms/widgets.py. Start
there. In particular, start Drop in some debugging prints and write a
few quite example forms if you're not sure what is passed to the render
method.

Regards,
Malcolm

-- 
The early bird may get the worm, but the second mouse gets the cheese. 
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 get related foreign key when using values in query

2008-02-18 Thread [EMAIL PROTECTED]

Malcolm,thanks very much.
i am a newbie for django, and i just finished one big site by reading
documents and getting help here. what i think now is to optimize it,
so i use cache,select_related and values.
you give me a whole picture of django queryset, i know the difference
now, thanks again!

On Feb 19, 12:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-02-17 at 22:22 -0800, [EMAIL PROTECTED] wrote:
> > i have 2 Models(for example):
> > one is Category, have 2 fields: title and slug, the other is Entry
> > with 4 fields: title, time,category(foreign key),content.
>
> > now i just want show entry title and category slug, so i use this
> > queryset:
> > e = Entry.objects.all().values('title','category')
> > the benefit is huge content will be omitted which can save database
> > traffic(i considered).
>
> > but now category.slug is none, how can i get related value of category
> > in this query?
> > (i changed to e =
> > Entry.objects.all().values('title','category').select_related(), the
> > result was same.)
>
> Asking for the values('category') on some level doesn't make sense,
> since category is a whole object, not a single value. In fact, Django
> will be returning you the value of the foreign key (an integer here).
>
> Firstly, this smells of premature optimisation. If you're not sure you
> need something, particularly if it doesn't work, don't use it until you
> are sure. Once a database has to select one column from a row in  a
> table it is close to zero extra effort to select the remaining columns:
> it has most likely already read them from disk, since it has to read in
> units of a whole disk block, which is a number of kilobytes. A general
> rule of thumb in database query optimisation is that pulling out the
> data (as opposed to filtering, sorting and grouping) is a negligible
> amount of time. If it isn't, your query is so simple it doesn't matter
> anyway. Of course, like all rules of thumb, it's a generalisation based
> on experience and there are plenty of exceptions. But it does mean
> "don't worry about what probably doesn't matter until it does matter".
>
> Values() queries are faster in Django in some cases, but it's not
> because of the database activity. It's because creating Python objects
> doesn't take zero time and Django adds some overhead as well. If you're
> working with 50,000 - 100,000 rows of data, the difference can be quite
> noticeable. If you're working with a few dozen rows, not so much. Still,
> that is the reason values() exists, so that if you do not just need some
> specific pieces of information, you can pull them back and we only need
> to create a dictionary, not a whole object instance and emit the
> signals, etc.
>
> Secondly, select-_elated() is only an optimisation. It will never change
> the result set you ultimately have access to (even if you don't use
> select_related(), you'll have access to the fields on category from a
> normal Entry model. It will just require an extra database query). If
> there is a difference between what you can do with and without a
> select_related() call, it's a bug (and, yes, there are cases on trunk
> like this; they're all bugs).
>
> Thirdly, ticket #5768 is open to one day add support for values()
> queries across relations. See the comments there for what is involved in
> implementing this.
>
> Regards,
> Malcolm
>
> --
> I just got lost in thought. It was unfamiliar 
> territory.http://www.pointy-stick.com/blog/- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: American Idol game developed in Django

2008-02-18 Thread Ed Menendez

http://aigame.wwudo.com/

Seems like that other URL is not working for everybody...  Thanks
everyone for all the info (on the group and on the sites!). The
documentation for this framework really makes a difference.

On Feb 18, 12:41 pm, Ed Menendez <[EMAIL PROTECTED]> wrote:
> This was our first site in Django and also our intro to Python. We
> used to play this on a spreadsheet with friends but were able to
> develop the replacement in about a week with Django. Probably could
> have been done much quicker if we weren't newbies to the framework.
>
> http://aigame.digitalhaiku.com/
>
> Special thanks to Eric Florenzano who gave us our introductory class
> in Django. Hope this motivates some developers that are on the fence
> on using Django.
>
> - Ed
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---