newforms

2007-07-19 Thread james_027

Which official django apps are using the newforms? I just want to take
a look at the coding as I am trying to learn the django's newform

thanks
james


--~--~-~--~~~---~--~~
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: setting up login required pages massly

2007-07-19 Thread Nathan Ostgard

You can define a custom decorator instead, specifying a custom
login_url:

from django.contrib.auth.decorators import user_passes_test
my_login_decorator = user_passes_test(lambda u: u.is_authenticated(),
login_url='/my/login/url')

Then you can use:

@my_login_decorator
def someview(request):
  ...

On Jul 19, 8:39 pm, james_027 <[EMAIL PROTECTED]> wrote:
> hi,
>
> is there a stupidly fast way to make select but many pages to required
> login first? I am using 0.96 @login_required is cool, but 0.96 doesn't
> support LOGIN_URL in the settings.py yet.
>
> currently i am using something like this
>
> if not request.user.is_authenticated():
> return render_to_response('login.htm', {'from':request.path})
>
> for each view's function.
>
> thanks
> james


--~--~-~--~~~---~--~~
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: Can't get database driver to use TCP

2007-07-19 Thread UnaCoder

Ha, i figured out a hack that works.  Apparently the low level
database connection driver provided by mysql will attempt to use /tmp/
mysql.sock even if you specify 'localhost' or '127.0.0.1' as the
hostname.  To work around this I added an entry to my /etc/hosts file:
127.0.0.1 localhost database

now when I specify the database hostname as 'database' it works!
woot.  An ugly hack, but if fixed the problem =))

-Dan

On Jul 19, 9:18 pm, UnaCoder <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have django installed on a development box with a local instance of
> mysql.  I'm trying to use mysql on a foreign server over an ssh
> tunnel.  I've connected the foreign mysql server to the local port
> 3307.  I've confirmed I can connect to the database using:
>
> mysql -u username -p'password' -P 3307 --protocol=TCP
>
> however MySQLdb seems intent on connecting to the local database
> through /tmp/mysql.sock when i specify host='localhost' and
> port=3307 ...
>
> Django has the same behavior.
>
> As of right now opening the mysql port on the database server to the
> public is not an option as it is a production database that is secured
> by strict firewall rules...
>
> This is very frustrating, does anyone know how to accomplish this?
>
> Thanks,
> Dan


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



Can't get database driver to use TCP

2007-07-19 Thread UnaCoder

Hi,

I have django installed on a development box with a local instance of
mysql.  I'm trying to use mysql on a foreign server over an ssh
tunnel.  I've connected the foreign mysql server to the local port
3307.  I've confirmed I can connect to the database using:

mysql -u username -p'password' -P 3307 --protocol=TCP

however MySQLdb seems intent on connecting to the local database
through /tmp/mysql.sock when i specify host='localhost' and
port=3307 ...

Django has the same behavior.

As of right now opening the mysql port on the database server to the
public is not an option as it is a production database that is secured
by strict firewall rules...

This is very frustrating, does anyone know how to accomplish this?

Thanks,
Dan


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



setting up login required pages massly

2007-07-19 Thread james_027

hi,

is there a stupidly fast way to make select but many pages to required
login first? I am using 0.96 @login_required is cool, but 0.96 doesn't
support LOGIN_URL in the settings.py yet.

currently i am using something like this

if not request.user.is_authenticated():
return render_to_response('login.htm', {'from':request.path})

for each view's function.

thanks
james


--~--~-~--~~~---~--~~
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 shared host. The docs are scaring me ;)

2007-07-19 Thread Jacob Kaplan-Moss

On 7/19/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> Gypsy is run by Jacob, so naturally ... - afaik they have a waiting
> list.

Actually, "they", err... me, are basically defunct; turned out running
a hosting company is a lot more work than I thought 

Jacob

--~--~-~--~~~---~--~~
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: Date Widget (or date format) in newforms

2007-07-19 Thread larry

> django.newforms contains a SplitDateTime field and widget for
> splitting DateTime fields into two form fields (date and time) -
> modifying this for Y/M/D shouldn't be too taxing.

I've looked at that but, unfortunately, don't come close to
understanding what it's doing -- in particular, I don't understand how
it fishes the results out of the POST soup that it gets back.

I really like the very good widgets that show up in the admin
interface.  Unfortunately, I took the documentation to heart and only
learned newforms -- while the underlying architecture may be better,
it seems like several steps backwards in terms of out-of-the-box
functionality.

Thanks -- I'll have another look at the multi-widget.
--
Larry


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

2007-07-19 Thread james_027

hi,

it seems that there is a small bug for not creating the foreign key on
the database. Please see this ticket. 
http://code.djangoproject.com/ticket/4930#preview

Thanks
james

On Jul 20, 9:05 am, james_027 <[EMAIL PROTECTED]> wrote:
> anyone to help me on this?
>
> thanks
> james
>
> On Jul 19, 3:20 pm, james_027 <[EMAIL PROTECTED]> wrote:
>
> > Hi Nathan,
>
> > I did manage.py syncdb with the table still not existing. I did
> > manage.py sqlall myapps when saw that the foreign key was not created.
>
> > here is my actual source code.
>
> > from django.db import models
> > from django.contrib.auth.models import User as AdminUser
>
> > # Create your models here.
> > DEPARTMENTS = (
> > ('HRD', 'HRD'),
> > ('ACT', 'Accounting'),
> > ('PUR', 'Purchasing'),
> > ('LOG', 'Logistics'),
> > ('PRO', 'Production'),
> > ('MKG', 'Marketing'),
> > ('EXP', 'Export'),
> > ('ITD', 'IT'),
> > )
>
> > LEVELS = (
> > ('SM', 'Senior Manager'),
> > ('MR', 'Manager'),
> > ('SP', 'Supervisor'),
> > ('ST', 'Staff'),
> > )
>
> > class User(models.Model):
> > """KSK Employee accounts to use this application"""
>
> > user = models.ForeignKey(AdminUser)
> > department = models.CharField(maxlength=3, choices=DEPARTMENTS)
> > level = models.CharField(maxlength=3, choices=LEVELS)
>
> > Thanks
> > james
>
> > On Jul 19, 2:56 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
>
> > > manage.py syncdb won't add new fields to the database if the table
> > > already exists. You'll have to do this yourself. See manage.py sqlall
> > > for some help.
>
> > > Otherwise, if you have: user = models.ForeignKey(User), then look for
> > > a field named user_id in your table.
>
> > > 
> > > Nathan Ostgard
>
> > > On Jul 18, 9:57 pm, james_027 <[EMAIL PROTECTED]> wrote:
>
> > > > hi,
>
> > > > I have a model with a field models.ForeignKey(), with manage.py
> > > > validate I check if my code are right, then run manage.py syncdb. When
> > > > I was checking the tables generated I don't see any foreign key
> > > > created? Is there something wrong? where should I check?
>
> > > > I am using django 0.96, mysql 5 on winxp
>
> > > > Thanks
> > > > james


--~--~-~--~~~---~--~~
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: Debugging file uploads

2007-07-19 Thread Russell Keith-Magee

On 7/19/07, Stefan Matthias Aust <[EMAIL PROTECTED]> wrote:
>
> Is this something I should file an issue for?
>
> The Django debug HTML page is great for finding bugs in templates and
> view functions. However, if you have an error in a view function with
> a request object that contains a - say - 200MB file object, well, then
> your browser dies a slow and painful death. At least my trusted
> Firefox does.

To the best of my knowledge, this isn't currently configurable.
However, it sounds like a reasonable suggestion. Feel free to log a
ticket. Or even a fix, if you're feeling so enthused. It shouldn't be
too difficult to implement.

> And I wish it would be possible to edit the shown code just in place
> :)  What I know about Python so far, this should be possible,
> shouldn't it? If you can load and display the source code, you must be
> able to save a modified version to the same location...

This is probably a little harder than you think. You have to get the
code back up to the server, and reload the module. Depending on how
you are deployed, you may need to restart a web server. Plus, you've
just exposed a live, editable connection to your source code - which
is a teeny tiny security risk :-)

> And, well, syntax coloring would be nice... no just kidding...

And a pony.

:-)

Yours,
Russ Magee %-)

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



Re: Django on a shared host. The docs are scaring me ;)

2007-07-19 Thread Kenneth Gonsalves


On 20-Jul-07, at 7:20 AM, walterbyrd wrote:

>> You could do what I did decide Dreamhost is unacceptable for
>> hosting anything but a very, very small Django site, and go over to
>> Webfaction.
>
> I don't use Webfaction myself, but I have heard nothing but good
> things about them. If you don't need gobs of diskspace, Webfaction is
> no more expensive either.

i have used webfaction - it is really good, the people who have set  
it up know what django is and have really thought about it. Almost as  
good as having root access.

>
> I have also read good things about "Gypsy" I don't know what that
> costs.

Gypsy is run by Jacob, so naturally ... - afaik they have a waiting  
list.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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 shared host. The docs are scaring me ;)

2007-07-19 Thread walterbyrd


On Jul 17, 2:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> You could do what I did decide Dreamhost is unacceptable for
> hosting anything but a very, very small Django site, and go over to
> Webfaction.

I don't use Webfaction myself, but I have heard nothing but good
things about them. If you don't need gobs of diskspace, Webfaction is
no more expensive either.

I have also read good things about "Gypsy" I don't know what that
costs.


--~--~-~--~~~---~--~~
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 do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-19 Thread walterbyrd


On Jul 19, 4:08 pm, FrankW <[EMAIL PROTECTED]> wrote:
> in your shell, if you cd into /home/walterbyrd/django.niche-software/
> django
> and type ./dispatch.fcgi, what do you get?
>


./dispatch.fcgi
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Status: 301 MOVED PERMANENTLY
Content-Type: text/html; charset=utf-8
Location: /


> in the dreamhost control panel do you have the domain set up with
> FastCGI support?
> what about Extra Web Security?
>

Yes to both. And I went back and double checked.


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

2007-07-19 Thread james_027

anyone to help me on this?

thanks
james

On Jul 19, 3:20 pm, james_027 <[EMAIL PROTECTED]> wrote:
> Hi Nathan,
>
> I did manage.py syncdb with the table still not existing. I did
> manage.py sqlall myapps when saw that the foreign key was not created.
>
> here is my actual source code.
>
> from django.db import models
> from django.contrib.auth.models import User as AdminUser
>
> # Create your models here.
> DEPARTMENTS = (
> ('HRD', 'HRD'),
> ('ACT', 'Accounting'),
> ('PUR', 'Purchasing'),
> ('LOG', 'Logistics'),
> ('PRO', 'Production'),
> ('MKG', 'Marketing'),
> ('EXP', 'Export'),
> ('ITD', 'IT'),
> )
>
> LEVELS = (
> ('SM', 'Senior Manager'),
> ('MR', 'Manager'),
> ('SP', 'Supervisor'),
> ('ST', 'Staff'),
> )
>
> class User(models.Model):
> """KSK Employee accounts to use this application"""
>
> user = models.ForeignKey(AdminUser)
> department = models.CharField(maxlength=3, choices=DEPARTMENTS)
> level = models.CharField(maxlength=3, choices=LEVELS)
>
> Thanks
> james
>
> On Jul 19, 2:56 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
>
> > manage.py syncdb won't add new fields to the database if the table
> > already exists. You'll have to do this yourself. See manage.py sqlall
> > for some help.
>
> > Otherwise, if you have: user = models.ForeignKey(User), then look for
> > a field named user_id in your table.
>
> > 
> > Nathan Ostgard
>
> > On Jul 18, 9:57 pm, james_027 <[EMAIL PROTECTED]> wrote:
>
> > > hi,
>
> > > I have a model with a field models.ForeignKey(), with manage.py
> > > validate I check if my code are right, then run manage.py syncdb. When
> > > I was checking the tables generated I don't see any foreign key
> > > created? Is there something wrong? where should I check?
>
> > > I am using django 0.96, mysql 5 on winxp
>
> > > Thanks
> > > james


--~--~-~--~~~---~--~~
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: Date Widget (or date format) in newforms

2007-07-19 Thread Russell Keith-Magee

On 7/20/07, larry <[EMAIL PROTECTED]> wrote:
>
> Has anyone written a date widget with separate fields for day, month,
> and year (and, ideally, a calendar) for the newforms package?

Check out the capabilities of MultiWidget. This provides a mechanism
to break apart a single model field into multiple widgets, and get the
input from multiple widgets back into a single model field.
django.newforms contains a SplitDateTime field and widget for
splitting DateTime fields into two form fields (date and time) -
modifying this for Y/M/D shouldn't be too taxing.

Yours,
Russ Magee %-)

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



Re: schema evolution

2007-07-19 Thread Derek Anderson

Hey all,

Sorry for the double-post, but I've written up some examples / 
documentation:

http://kered.org/blog/wp-content/uploads/2007/07/django_schema_evolution_documentation.html

Also, I've ported the changes to SVN.  I would like to solicit testers, 
for potential inclusion in django-proper.

Thanks,
Derek

Derek Anderson wrote:
 > Hey all,
 >
 > I've ported my schema evolution work from my SoC project last summer to
 > Django v0.96.   To use it, download the patch below, and run the 
following:
 >
 > $ cd //site-packages/django/
 > $ patch -p1 < ~//django_schema_evolution-v096patch.txt
 >
 > It should output the following:
 >
 > patching file core/management.py
 > patching file db/backends/mysql/base.py
 > patching file db/backends/mysql/introspection.py
 > patching file db/backends/postgresql/base.py
 > patching file db/backends/postgresql/introspection.py
 > patching file db/backends/sqlite3/base.py
 > patching file db/backends/sqlite3/introspection.py
 > patching file db/models/fields/__init__.py
 > patching file db/models/options.py
 >
 > To use it:
 >
 > $ cd //
 > $ ./manage.py sqlevolve 
 >
 > It should output something like this:
 >
 > BEGIN;
 > ALTER TABLE `main_query` CHANGE COLUMN `accuracy` `accuracynew`
 > numeric(10, 6) NULL;
 > ALTER TABLE `main_query` ADD COLUMN `price` varchar(256) NULL;
 > COMMIT;
 >
 > Assuming you have a model such as this:
 >
 > class Query(models.Model):
 >  query = models.CharField(maxlength=256, blank=False)
 >  accuracynew = models.FloatField(max_digits=10, decimal_places=6,
 > null=True, blank=True, aka='accuracy')
 >  price = models.CharField(maxlength=256, null=True, blank=True) #
 > new column
 >
 > Note the aka field where I changed the name of "accuracy" to 
"accuracynew".
 >
 > Let me know if you find any bugs.
 >
 > http://kered.org/blog/2007-07-19/django-schema-evolution/
 > 
http://kered.org/blog/wp-content/uploads/2007/07/django_schema_evolution-v096patch.txt
 >
 > -- Derek
 >
 >  >
 >


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



Emergency - In Need Of Developer

2007-07-19 Thread Peter Pluta


I need a developer in the US (only) with at least 2 years experience with
Django/Python to fix and optimize a Django site I had done a few weeks back.
The original developer can no longer be contacted and the code is horribly
inefficient, delaying the site from launch. Please email me for more
details. 

Thanks, 
Peter



-- 
View this message in context: 
http://www.nabble.com/Emergency---In-Need-Of-Developer-tf4114485.html#a11700313
Sent from the django-users mailing list archive at Nabble.com.


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

2007-07-19 Thread sean

Glad to help.
{{ images.image_set.count }} or similar should work, depending on your
models.

cheers, Sean

On Jul 20, 1:13 am, Marc Garcia <[EMAIL PROTECTED]> wrote:
> Thanks mate, it works great.
>
> Anybody could tell me if there is something like that for counting
> items on that?
>
> Don't want to do:
> {% for image in images %}
> {% if forloop.last %}
>{{ forloop.counter }}
> {% endif %}
> {% endfor %}
>
> On Jul 19, 7:51 pm, sean <[EMAIL PROTECTED]> wrote:
>
> > Try {{ images.0.image }}
>
> > Sean
>
> > On Jul 19, 7:43 pm, Marc Garcia <[EMAIL PROTECTED]> wrote:
>
> > > Hi!
>
> > > In a project I get a set of images from a model, and then I display it
> > > on the template. In same template (but in another place), I just want
> > > to display first element of set, and number of objects given. Can I do
> > > it without adding those fields to views.py?
>
> > > I've found a way for doing first, but it isn't very efficient:
>
> > > In views:
> > > images = tImage.objects.filter(product=product_id)
>
> > > In template:
> > > {% for image in images %}
> > > {% if forloop.first %}
> > >{{ image.image }}
> > > {% endif %}
> > > {% endfor %}
>
> > > Thanks a lot!
> > >   Marc


--~--~-~--~~~---~--~~
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 multiple django versions on mod_python

2007-07-19 Thread oggie rob

> In short, a C extension module may cache data from one sub interpreter
> and then use it in the context of a different sub interpreter causing
> incorrect or errornous behaviour. The problem with Decimal support in
> pyscopg falls into this category. It is entirely possible that the OP
> may have been hitting a similar obscure problem in the database
> adapter being used.
>
> The only real way to ensure that such a problem isn't encountered is
> to use mod_fastcgi or mod_wsgi daemon mode. In both these hosting
> solutions for Apache the Django instance can be run in a distinct
> process and thus one doesn't encounter issues with C extension modules
> that aren't written to work with multiple sub interpreters properly.
>
> Graham

Yep, that sounds like it!
That raises some questions as to the recommended apache setup. At
least I know a workaround, for now, but I will be watching the psycopg
wiki closely.

Thank you very much for pointing this out - I was a bit lost there and
only knew something was fishy.
 -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
-~--~~~~--~~--~--~---



Re: Problem with multiple django versions on mod_python

2007-07-19 Thread Russell Keith-Magee

On 7/20/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
>
> For the record, the description which was given to you whereby "if the
> first request served by a thread used the old version of Django, that
> was the version that was used for all subsequent requests on that
> thread" is nonsense. There has never been a problem with mod_python
> which would have caused that sort of behaviour.

I'll take your word for it. Like I said, I wasn't able to get hold of
the sysadmin that sorted out the problem, so it's entirely possible I
have the details completely mixed up.

Yours,
Russ Magee %-)

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



Re: Problem with multiple django versions on mod_python

2007-07-19 Thread Graham Dumpleton

On Jul 19, 2:07 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/19/07, oggie rob <[EMAIL PROTECTED]> wrote:
>
> > Please, if you've seen the same issue or have any helpful ideas to try
> > to stop the error, let me know.
>
> I think I've seen the same problem (or, at least, an analogous one).
> Unfortunately, I can't provide much by way of helpful debug or
> solution - the sysadmin that identified the problem for us isn't
> around for me to ask him for more details.
>
> As I recall, the problem was mod_python. Older versions of mod_python
> had some sort of issue with caching python instances. As a result, if
> you deployed two different versions of Django, the version of Django
> that was provided to a given request was determined by the thread that
> served the request. If the first request served by a thread used the
> old version of Django, that was the version that was used for all
> subsequent requests on that thread, regardless of the version that was
> required to satisfy the request.

For the record, the description which was given to you whereby "if the
first request served by a thread used the old version of Django, that
was the version that was used for all subsequent requests on that
thread" is nonsense. There has never been a problem with mod_python
which would have caused that sort of behaviour.

> I believe we fixed the problem by updating mod_python, but I'm not
> completely certain on that.

Always a good idea regardless. Using mod_python 3.3.1 is high
recommended.

Where problems can come up with hosting multiple Django instances is
not with mod_python or Django, but with third party C extension
modules which haven't been written correctly so as to be used
concurrently from multiple Python sub interpreters.

One concrete example which was identified recently was Decimal support
in pyscopg module.

  http://www.initd.org/tracker/psycopg/ticket/192

In short, a C extension module may cache data from one sub interpreter
and then use it in the context of a different sub interpreter causing
incorrect or errornous behaviour. The problem with Decimal support in
pyscopg falls into this category. It is entirely possible that the OP
may have been hitting a similar obscure problem in the database
adapter being used.

The only real way to ensure that such a problem isn't encountered is
to use mod_fastcgi or mod_wsgi daemon mode. In both these hosting
solutions for Apache the Django instance can be run in a distinct
process and thus one doesn't encounter issues with C extension modules
that aren't written to work with multiple sub interpreters properly.

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: forloop variables without for

2007-07-19 Thread Marc Garcia

Thanks mate, it works great.

Anybody could tell me if there is something like that for counting
items on that?

Don't want to do:
{% for image in images %}
{% if forloop.last %}
   {{ forloop.counter }}
{% endif %}
{% endfor %}

On Jul 19, 7:51 pm, sean <[EMAIL PROTECTED]> wrote:
> Try {{ images.0.image }}
>
> Sean
>
> On Jul 19, 7:43 pm, Marc Garcia <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > In a project I get a set of images from a model, and then I display it
> > on the template. In same template (but in another place), I just want
> > to display first element of set, and number of objects given. Can I do
> > it without adding those fields to views.py?
>
> > I've found a way for doing first, but it isn't very efficient:
>
> > In views:
> > images = tImage.objects.filter(product=product_id)
>
> > In template:
> > {% for image in images %}
> > {% if forloop.first %}
> >{{ image.image }}
> > {% endif %}
> > {% endfor %}
>
> > Thanks a lot!
> >   Marc


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



Mapping models to CRUD urls?

2007-07-19 Thread John M

Loving django still, and now I'm at the point where I'm running into a
limit on my understanding on how to map the Model CRUD functions (non-
admin style) to a URL pattern.  For example:

Model1:
  fielda
  fieldb

Model2:
  key=Foreignkey(model1)
  fielda
  fieldb

Model3:
  key=foriengkey(model2)
  fielda
  fieldb

So, i'm looking for some help to allow me to CRUD each of these
models, and I've come up with a few:

http://.../model1/add   - calls a view to add a new model1 object
to the DB.
http://.../model1/edit/#- calls a view to update the model1 ID = #

http://.../model2/add/#- calls a view to add a new model2, with a
foreign key model1 of #
http://.../model2/edit/#- calls a view to edit a model2 of ID #.

I guess I continue the same pattern for all sub-models?  so model3
would be:

http://.../model3/add/#- calls a view to add a new model3, with
foreign key model2 of #
http://.../model3/edit/#- calls a view to edit a model3 of ID#

It seems simple enough, but wanted to get everyones feedback on
anything I'm missing, or is it just this simple?

Thanks

John


--~--~-~--~~~---~--~~
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 loop through a Dict to add values?

2007-07-19 Thread Derek Anderson

well, you're dealing in $$$, so you prob. want floats...but where is 
your FloatField?  an attribute of your class Price?  or can you cast 
your Price class to a float?

pr = 0.0
for a in cart:
pr = pr + float(a['choice'].price)

do you understand how classes in object oriented languages work?  you 
can only add numbers together, not your own custom classes.  (without 
some extra work i expect - i don't know how operator overloading in 
python works, or even if it exists)  this is what your error statement 
is telling you...that you're trying to add a number to a non-number 
class.  you have to pull the actual number out of whatever class 
structure you've put it in.


Greg wrote:
> Derek,
> Ok...I made the change and I'm now getting the error:
> 
> TypeError at /rugs/cart/1/4/
> unsupported operand type(s) for +: 'int' and 'Price'
> 
> Is 'a['choice'].price' not an Int?  It says it is in my model file.
> 
> 
> 
> Here is my view
> 
> def showcart(request, style_id, choice_id):
>   s = Style.objects.get(id=style_id)
>   c = Choice.objects.get(id=choice_id)
>   #x = c.size, " ", c.price
>   cart = request.session.get('cart', [])
>   cart.append({'style': s, 'choice': c})
>   request.session['cart'] = cart
>   pr = 0
>   for a in cart:
>   pr = pr + a['choice'].price
>   return render_to_response('show_test.html', {'mychoice': cart, 'p':
> pr})
> 
> 
> /
> 
> Here is my template file:
> 
> {% extends "rug_leftnav.html" %}
> {% block body %}
> {% for a in mychoice %}
> {{ a.style.manufacturer }} - {{ a.style.collection }} - {{ a.style }}
> - {{ a.choice.size }} - ${{ a.choice.price }}.00
> 
> {% endfor %}
> {{ p }}
> {% endblock %}
> 
> //
> 
> Here are some of my model classes:
> 
> class Size(models.Model):
>   name = models.CharField(maxlength=100)
> 
>   def __str__(self,):
>   return self.name
> 
>   class Admin:
>   pass
> 
> class Price(models.Model):
>   name = models.IntegerField()
> 
>   def __str__(self,):
>   return str(self.name)
> 
>   class Admin:
>   pass
> 
> 
> class Choice(models.Model):
> choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
> num_in_admin=5)
> size = models.ForeignKey(Size, core=True)
> price = models.ForeignKey(Price, core=True)
> def __str__(self,):
>   return str((self.size, self.price))
> 
> class Style(models.Model):
> name = models.CharField(maxlength=200)
> color = models.CharField(maxlength=100)
> image = models.ImageField(upload_to='site_media/')
> theslug = models.SlugField(prepopulate_from=('name',))
> manufacturer = models.ForeignKey(Manufacturer)
> collection = models.ForeignKey(Collection)
> sandp = models.ManyToManyField(Choice)
> 
> class Admin:
>   search_fields = ['name']
>   list_filter = ('collection',)
>   list_display = ('name', 'theslug','collection', 'rmanu')
> 
> js = (
> '/site_media/ajax_yahoo.js',
> )
> 
> def __str__(self,):
>   return self.name
> 
> def rmanu(self):
>   return self.collection.manufacturer
> 
> 
> //
> 
> 
> Thanks for your help Derek
> 
> 
> On Jul 19, 4:46 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
>> you were supposed to substitute "value" with whatever column you have
>> defined.  (you didn't post your model def)
>>
>> Greg wrote:
>>> Derek,
>>> I tried that and now I get the following error:
>>> AttributeError at /rugs/cart/1/4/
>>> 'Choice' object has no attribute 'value'
>>> /
>>> Here is my view
>>> def showcart(request, style_id, choice_id):
>>>s = Style.objects.get(id=style_id)
>>>c = Choice.objects.get(id=choice_id)
>>>#x = c.size, " ", c.price
>>>cart = request.session.get('cart', [])
>>>cart.append({'style': s, 'choice': c})
>>>request.session['cart'] = cart
>>>pr = 0
>>>for a in cart:
>>>pr = pr + a['choice'].value
>>>return render_to_response('show_test.html', {'mychoice': cart, 'p':
>>> pr})
>>> /
>>> On Jul 19, 4:22 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
 you're not adding two ints, you're adding an int to an instance of your
 Choice class.  make your line:
   pr = pr + a['choice'].value
 or whatever you called it.
 Greg wrote:
> Hello,
> I have the following view
> def showcart(request, style_id, choice_id):
>s = Style.objects.get(id=style_id)
>c = Choice.objects.get(id=choice_id)
>cart = request.session.get('cart', [])
>cart.append({'style': s, 'choice': c})
>request.session['cart'] = cart
> pr = 0
>for a in cart:
> pr = pr + a['choice']
> return render_to_response('show_test.html', {'mychoice': cart,
> 'p': pr})
> /
> 

Re: schema evolution

2007-07-19 Thread Derek Anderson

yeah, i did a poor/non-existent job advocating inclusion of my SoC work 
into django-proper.  (combination of frustration with my original mentor 
and busy prepping for starting my phd right after it ended - i just 
handed it off and didn't follow through afterwards)  but i use django 
quite a bit now and am surprised some sort of this hasn't been merged 
yet, so i figured i'd bring it up to date and re-release.



daev wrote:
> It's great! I have my own schema evolution solution here
> http://code.google.com/p/django-schemaevolution/. But yours seems to
> be more powerful.
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
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 do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-19 Thread FrankW

in your shell, if you cd into /home/walterbyrd/django.niche-software/
django
and type ./dispatch.fcgi, what do you get?

in the dreamhost control panel do you have the domain set up with
FastCGI support?
what about Extra Web Security?


On Jul 19, 4:36 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> On Jul 19, 12:24 pm, FrankW <[EMAIL PROTECTED]> wrote:
>
> > A couple of things to check - what are the permissions on
> > dispatch.fcgi?
> > It needs to be executable, e.g. -rwxr-xr-x
>
> Permissions are correct.
>
> > Also, make sure it does not have DOS mode CR-LF
>
> No DOS mode CR-LF.
>
> > And, do you have debug set in your settings.py?
>
> from settings.py
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> My file structure:
>
> django.niche-software.com/
> --- dispatch.fcgi
> --- hello.fcgi
> --- .htaccess
> --- django/
> -- django_media/
> -- django_projects/
> - myproject/
>  settings.py
> - sqlite-3.4.0
> -- django_src/
> -- django_templates
>
> The hello.fcgi I got from the dreamhost wiki:
>
> http://www.skweezer.net/bloglines/s.aspx/2/wiki.dreamhost.com/Special...
>
> The hello.fcgi looks like this:
>
> #!/usr/bin/python2.3
> from flup.server.fcgi import WSGIServer
> def test_app(environ, start_response): start_response('200 OK',
> [('Content-Type', 'text/plain')]) yield 'Hello, world!\n'
> WSGIServer(test_app).run()
>
> I tried running that, and got the same 500 error.


--~--~-~--~~~---~--~~
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 loop through a Dict to add values?

2007-07-19 Thread Greg

Derek,
Ok...I made the change and I'm now getting the error:

TypeError at /rugs/cart/1/4/
unsupported operand type(s) for +: 'int' and 'Price'

Is 'a['choice'].price' not an Int?  It says it is in my model file.



Here is my view

def showcart(request, style_id, choice_id):
s = Style.objects.get(id=style_id)
c = Choice.objects.get(id=choice_id)
#x = c.size, " ", c.price
cart = request.session.get('cart', [])
cart.append({'style': s, 'choice': c})
request.session['cart'] = cart
pr = 0
for a in cart:
pr = pr + a['choice'].price
return render_to_response('show_test.html', {'mychoice': cart, 'p':
pr})


/

Here is my template file:

{% extends "rug_leftnav.html" %}
{% block body %}
{% for a in mychoice %}
{{ a.style.manufacturer }} - {{ a.style.collection }} - {{ a.style }}
- {{ a.choice.size }} - ${{ a.choice.price }}.00

{% endfor %}
{{ p }}
{% endblock %}

//

Here are some of my model classes:

class Size(models.Model):
name = models.CharField(maxlength=100)

def __str__(self,):
return self.name

class Admin:
pass

class Price(models.Model):
name = models.IntegerField()

def __str__(self,):
return str(self.name)

class Admin:
pass


class Choice(models.Model):
choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
num_in_admin=5)
size = models.ForeignKey(Size, core=True)
price = models.ForeignKey(Price, core=True)
def __str__(self,):
return str((self.size, self.price))

class Style(models.Model):
name = models.CharField(maxlength=200)
color = models.CharField(maxlength=100)
image = models.ImageField(upload_to='site_media/')
theslug = models.SlugField(prepopulate_from=('name',))
manufacturer = models.ForeignKey(Manufacturer)
collection = models.ForeignKey(Collection)
sandp = models.ManyToManyField(Choice)

class Admin:
search_fields = ['name']
list_filter = ('collection',)
list_display = ('name', 'theslug','collection', 'rmanu')

js = (
'/site_media/ajax_yahoo.js',
)

def __str__(self,):
return self.name

def rmanu(self):
return self.collection.manufacturer


//


Thanks for your help Derek


On Jul 19, 4:46 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
> you were supposed to substitute "value" with whatever column you have
> defined.  (you didn't post your model def)
>
> Greg wrote:
> > Derek,
> > I tried that and now I get the following error:
>
> > AttributeError at /rugs/cart/1/4/
> > 'Choice' object has no attribute 'value'
>
> > /
>
> > Here is my view
>
> > def showcart(request, style_id, choice_id):
> >s = Style.objects.get(id=style_id)
> >c = Choice.objects.get(id=choice_id)
> >#x = c.size, " ", c.price
> >cart = request.session.get('cart', [])
> >cart.append({'style': s, 'choice': c})
> >request.session['cart'] = cart
> >pr = 0
> >for a in cart:
> >pr = pr + a['choice'].value
> >return render_to_response('show_test.html', {'mychoice': cart, 'p':
> > pr})
>
> > /
>
> > On Jul 19, 4:22 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
> >> you're not adding two ints, you're adding an int to an instance of your
> >> Choice class.  make your line:
>
> >>   pr = pr + a['choice'].value
>
> >> or whatever you called it.
>
> >> Greg wrote:
> >>> Hello,
> >>> I have the following view
> >>> def showcart(request, style_id, choice_id):
> >>>s = Style.objects.get(id=style_id)
> >>>c = Choice.objects.get(id=choice_id)
> >>>cart = request.session.get('cart', [])
> >>>cart.append({'style': s, 'choice': c})
> >>>request.session['cart'] = cart
> >>> pr = 0
> >>>for a in cart:
> >>> pr = pr + a['choice']
> >>> return render_to_response('show_test.html', {'mychoice': cart,
> >>> 'p': pr})
> >>> /
> >>> Whenever i try this I get the error:
> >>> TypeError at /rugs/cart/1/4/
> >>> unsupported operand type(s) for +: 'int' and 'Choice'
> >>> //
> >>> Anybody know how I pull a value out of a dict and add it to a existing
> >>> number?
> >>> 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: Using Sessions to display the contents of a shopping cart

2007-07-19 Thread Chris Moffitt
The way we handle it with Satchmo is to have a cart object and store that id
in the session.  It's pretty simple and does not require a user to be logged
in.

-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: schema evolution

2007-07-19 Thread daev

It's great! I have my own schema evolution solution here
http://code.google.com/p/django-schemaevolution/. But yours seems to
be more powerful.


--~--~-~--~~~---~--~~
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 loop through a Dict to add values?

2007-07-19 Thread Derek Anderson

you were supposed to substitute "value" with whatever column you have 
defined.  (you didn't post your model def)


Greg wrote:
> Derek,
> I tried that and now I get the following error:
> 
> AttributeError at /rugs/cart/1/4/
> 'Choice' object has no attribute 'value'
> 
> /
> 
> Here is my view
> 
> def showcart(request, style_id, choice_id):
>   s = Style.objects.get(id=style_id)
>   c = Choice.objects.get(id=choice_id)
>   #x = c.size, " ", c.price
>   cart = request.session.get('cart', [])
>   cart.append({'style': s, 'choice': c})
>   request.session['cart'] = cart
>   pr = 0
>   for a in cart:
>   pr = pr + a['choice'].value
>   return render_to_response('show_test.html', {'mychoice': cart, 'p':
> pr})
> 
> /
> 
> 
> 
> 
> 
> On Jul 19, 4:22 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
>> you're not adding two ints, you're adding an int to an instance of your
>> Choice class.  make your line:
>>
>>   pr = pr + a['choice'].value
>>
>> or whatever you called it.
>>
>> Greg wrote:
>>> Hello,
>>> I have the following view
>>> def showcart(request, style_id, choice_id):
>>>s = Style.objects.get(id=style_id)
>>>c = Choice.objects.get(id=choice_id)
>>>cart = request.session.get('cart', [])
>>>cart.append({'style': s, 'choice': c})
>>>request.session['cart'] = cart
>>> pr = 0
>>>for a in cart:
>>> pr = pr + a['choice']
>>> return render_to_response('show_test.html', {'mychoice': cart,
>>> 'p': pr})
>>> /
>>> Whenever i try this I get the error:
>>> TypeError at /rugs/cart/1/4/
>>> unsupported operand type(s) for +: 'int' and 'Choice'
>>> //
>>> Anybody know how I pull a value out of a dict and add it to a existing
>>> number?
>>> 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: How to loop through a Dict to add values?

2007-07-19 Thread Greg

Derek,
I tried that and now I get the following error:

AttributeError at /rugs/cart/1/4/
'Choice' object has no attribute 'value'

/

Here is my view

def showcart(request, style_id, choice_id):
s = Style.objects.get(id=style_id)
c = Choice.objects.get(id=choice_id)
#x = c.size, " ", c.price
cart = request.session.get('cart', [])
cart.append({'style': s, 'choice': c})
request.session['cart'] = cart
pr = 0
for a in cart:
pr = pr + a['choice'].value
return render_to_response('show_test.html', {'mychoice': cart, 'p':
pr})

/





On Jul 19, 4:22 pm, Derek Anderson <[EMAIL PROTECTED]> wrote:
> you're not adding two ints, you're adding an int to an instance of your
> Choice class.  make your line:
>
>   pr = pr + a['choice'].value
>
> or whatever you called it.
>
> Greg wrote:
> > Hello,
> > I have the following view
>
> > def showcart(request, style_id, choice_id):
> >s = Style.objects.get(id=style_id)
> >c = Choice.objects.get(id=choice_id)
> >cart = request.session.get('cart', [])
> >cart.append({'style': s, 'choice': c})
> >request.session['cart'] = cart
> > pr = 0
> >for a in cart:
> > pr = pr + a['choice']
> > return render_to_response('show_test.html', {'mychoice': cart,
> > 'p': pr})
>
> > /
>
> > Whenever i try this I get the error:
>
> > TypeError at /rugs/cart/1/4/
> > unsupported operand type(s) for +: 'int' and 'Choice'
>
> > //
>
> > Anybody know how I pull a value out of a dict and add it to a existing
> > number?
>
> > 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: How to loop through a Dict to add values?

2007-07-19 Thread Derek Anderson

you're not adding two ints, you're adding an int to an instance of your 
Choice class.  make your line:

  pr = pr + a['choice'].value

or whatever you called it.


Greg wrote:
> Hello,
> I have the following view
> 
> def showcart(request, style_id, choice_id):
>   s = Style.objects.get(id=style_id)
>   c = Choice.objects.get(id=choice_id)
>   cart = request.session.get('cart', [])
>   cart.append({'style': s, 'choice': c})
>   request.session['cart'] = cart
> pr = 0
>   for a in cart:
> pr = pr + a['choice']
> return render_to_response('show_test.html', {'mychoice': cart,
> 'p': pr})
> 
> 
> /
> 
> Whenever i try this I get the error:
> 
> TypeError at /rugs/cart/1/4/
> unsupported operand type(s) for +: 'int' and 'Choice'
> 
> //
> 
> Anybody know how I pull a value out of a dict and add it to a existing
> number?
> 
> 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: Simple Left Join in Django question???

2007-07-19 Thread Joshua

Thanks for your help, again

On Jul 19, 4:10 pm, gkelly <[EMAIL PROTECTED]> wrote:
> The Django db-api handles JOINs for you. It abstracts them into
> "forward", "backward" and "many-to-many" relationships (as documented
> on the page I linked before).
>
> Spend some time on the command line playing with these relationships
> and you'll see how you can navigate around your models through foreign
> keys and such.
>
> Also, if you need quicker answers, join #django on irc.freenode.net
> and paste your models at dpaste.com. There's always really bright,
> helpful people hanging around on there.
>
> Grant
>
> On Jul 19, 1:49 pm, Joshua <[EMAIL PROTECTED]> wrote:
>
> > Maybe I should have titled this how do I create a left join in Django
> > syntax or with the Django db-API
>
> > All the examples in the documentation let you retrieve the related
> > object ONLY if you have ONE related object retrieved.
>
> > On Jul 19, 2:18 pm, Joshua <[EMAIL PROTECTED]> wrote:
>
> > > Thank you for your response
>
> > > I'm not familiar with the context object - I'll have to do some
> > > research.
>
> > > I have this working
>
> > > portfolioPage =
> > > client.objects.filter(project_portfolio__project_display_bit = True)
>
> > > It's returning the clients data - just not the data for the
> > > project_portfolio (it's not joining)?
>
> > > On Jul 19, 2:08 pm, gkelly <[EMAIL PROTECTED]> wrote:
>
> > > > I believe in your template you should be able to do something like:
>
> > > > {% for p in project_portfolio_list %}
> > > >   {{ p.project_name_char }} {{ p.project_client.client_name_char }}
> > > > {% endfor %}
>
> > > > If you had a view with:
>
> > > > context['project_portfolio_list'] = project_portfolio.objects.all()
>
> > > > You'll also want to be familiar with this portion of the 
> > > > docs:http://www.djangoproject.com/documentation/db-api/#related-objects
>
> > > > Hope that helps,
> > > > Grant
>
> > > > On Jul 19, 11:02 am, Joshua <[EMAIL PROTECTED]> wrote:
>
> > > > > I've tried to search for a solution to this problem for the last 2
> > > > > hours and I can't seem to figure it out.
>
> > > > > I basically want to return a joined table from a queryset - formatted
> > > > > for my template.
>
> > > > > I can't seem to figure out how to do this with the Django database
> > > > > API.
>
> > > > > With SQL a join query works out to:
>
> > > > > '''
> > > > > select project_portfolio.*, client.*
> > > > > from project_portfolio left join client
> > > > > on project_portfolio.id = client.id
> > > > > '''
> > > > > with the following simplified models:
>
> > > > > class project_portfolio(models.Model):
> > > > > project_name_char = models.CharField()
> > > > > project_client = models.ForeignKey(client)
>
> > > > > class client(models.Model):
> > > > > client_name_char = models.CharField
>
> > > > > The challenge here seems to be that I have to return MULTIPLE
> > > > > project_portfolio objects and THEN get the "client" data - because NOT
> > > > > all "clients" have "project_portfolio(s)"
>
> > > > > Thank you in advance for any help - Josh


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



How to loop through a Dict to add values?

2007-07-19 Thread Greg

Hello,
I have the following view

def showcart(request, style_id, choice_id):
s = Style.objects.get(id=style_id)
c = Choice.objects.get(id=choice_id)
cart = request.session.get('cart', [])
cart.append({'style': s, 'choice': c})
request.session['cart'] = cart
pr = 0
for a in cart:
pr = pr + a['choice']
return render_to_response('show_test.html', {'mychoice': cart,
'p': pr})


/

Whenever i try this I get the error:

TypeError at /rugs/cart/1/4/
unsupported operand type(s) for +: 'int' and 'Choice'

//

Anybody know how I pull a value out of a dict and add it to a existing
number?

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: Does a pre/post_save signal know who is the user currently logged in?

2007-07-19 Thread Xanthus

On 19 jul, 17:33, "Lic. José M. Rodriguez Bacallao" <[EMAIL PROTECTED]>
wrote:
> take a look at:http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser

Great! It worked like a charm! Thanks very much José.


--~--~-~--~~~---~--~~
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: Simple Left Join in Django question???

2007-07-19 Thread gkelly

The Django db-api handles JOINs for you. It abstracts them into
"forward", "backward" and "many-to-many" relationships (as documented
on the page I linked before).

Spend some time on the command line playing with these relationships
and you'll see how you can navigate around your models through foreign
keys and such.

Also, if you need quicker answers, join #django on irc.freenode.net
and paste your models at dpaste.com. There's always really bright,
helpful people hanging around on there.

Grant

On Jul 19, 1:49 pm, Joshua <[EMAIL PROTECTED]> wrote:
> Maybe I should have titled this how do I create a left join in Django
> syntax or with the Django db-API
>
> All the examples in the documentation let you retrieve the related
> object ONLY if you have ONE related object retrieved.
>
> On Jul 19, 2:18 pm, Joshua <[EMAIL PROTECTED]> wrote:
>
> > Thank you for your response
>
> > I'm not familiar with the context object - I'll have to do some
> > research.
>
> > I have this working
>
> > portfolioPage =
> > client.objects.filter(project_portfolio__project_display_bit = True)
>
> > It's returning the clients data - just not the data for the
> > project_portfolio (it's not joining)?
>
> > On Jul 19, 2:08 pm, gkelly <[EMAIL PROTECTED]> wrote:
>
> > > I believe in your template you should be able to do something like:
>
> > > {% for p in project_portfolio_list %}
> > >   {{ p.project_name_char }} {{ p.project_client.client_name_char }}
> > > {% endfor %}
>
> > > If you had a view with:
>
> > > context['project_portfolio_list'] = project_portfolio.objects.all()
>
> > > You'll also want to be familiar with this portion of the 
> > > docs:http://www.djangoproject.com/documentation/db-api/#related-objects
>
> > > Hope that helps,
> > > Grant
>
> > > On Jul 19, 11:02 am, Joshua <[EMAIL PROTECTED]> wrote:
>
> > > > I've tried to search for a solution to this problem for the last 2
> > > > hours and I can't seem to figure it out.
>
> > > > I basically want to return a joined table from a queryset - formatted
> > > > for my template.
>
> > > > I can't seem to figure out how to do this with the Django database
> > > > API.
>
> > > > With SQL a join query works out to:
>
> > > > '''
> > > > select project_portfolio.*, client.*
> > > > from project_portfolio left join client
> > > > on project_portfolio.id = client.id
> > > > '''
> > > > with the following simplified models:
>
> > > > class project_portfolio(models.Model):
> > > > project_name_char = models.CharField()
> > > > project_client = models.ForeignKey(client)
>
> > > > class client(models.Model):
> > > > client_name_char = models.CharField
>
> > > > The challenge here seems to be that I have to return MULTIPLE
> > > > project_portfolio objects and THEN get the "client" data - because NOT
> > > > all "clients" have "project_portfolio(s)"
>
> > > > Thank you in advance for any help - Josh


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



Re: Using Sessions to display the contents of a shopping cart

2007-07-19 Thread Jeremy Dunck

On 7/19/07, Greg <[EMAIL PROTECTED]> wrote:
> So I guess Session's will work if that is the case.  It looks
> like I will have to place a cookie on the visitor's computer using
> set_test_cookie() and test_cookie_worked() method's so that I'm able
> to tell the difference between two users that are adding products to
> the cart at the same time.  Does anybody know of any problems with
> this solution?

No, don't do that.  The session framework already does that for you.

If you use request.session, and the browser accepts cookies, you'll
magically have values in request.session as set on previous requests.

http://www.djangoproject.com/documentation/sessions/

--~--~-~--~~~---~--~~
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 for application with subdomains

2007-07-19 Thread Doug Van Horn

On Jul 19, 2:19 pm, David Marko <[EMAIL PROTECTED]> wrote:
> I know this topis has been discussed already but I stiil havent find
> solution. We would like to build up the application that will be used
> by many customers. After registration the customer will access
> application via its subdomain name:
> eg. cust1 =http://cust1.application.com
> cust2 =http://cust2.application.com
> etc.
>
> This approach requires that authentication should use subdomain name,
> username and password . How can be this scenario accomplished with
> django?
> I think its very common approach when one application is used  by many
> customers and things must work dynamicly ... so using django 'sites'
> approach is not suitable.
>
> Thanks for any advice and hits.
>
> David

If the username is unique to the subdomain, you either have to hack
around the existing User model (as per SH's suggestion) or you need
your own User model for your application (outside of the Django
standard).  I'd probably hack up the django User model and associate a
CustomerUser model to it with the 'real' login, unique to the
Customer.

Once your user is created and associated to a subdomain, you can pull
the subdomain from the request (as daev said,
request.META['SERVER_NAME'] in middleware and make it available on the
session (e.g., use it to look up a Customer object and make it
available on the request or session).

doug.



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



schema evolution

2007-07-19 Thread Derek Anderson

Hey all,

I've ported my schema evolution work from my SoC project last summer to 
Django v0.96.   To use it, download the patch below, and run the following:

$ cd //site-packages/django/
$ patch -p1 < ~//django_schema_evolution-v096patch.txt

It should output the following:

patching file core/management.py
patching file db/backends/mysql/base.py
patching file db/backends/mysql/introspection.py
patching file db/backends/postgresql/base.py
patching file db/backends/postgresql/introspection.py
patching file db/backends/sqlite3/base.py
patching file db/backends/sqlite3/introspection.py
patching file db/models/fields/__init__.py
patching file db/models/options.py

To use it:

$ cd //
$ ./manage.py sqlevolve 

It should output something like this:

BEGIN;
ALTER TABLE `main_query` CHANGE COLUMN `accuracy` `accuracynew` 
numeric(10, 6) NULL;
ALTER TABLE `main_query` ADD COLUMN `price` varchar(256) NULL;
COMMIT;

Assuming you have a model such as this:

class Query(models.Model):
 query = models.CharField(maxlength=256, blank=False)
 accuracynew = models.FloatField(max_digits=10, decimal_places=6, 
null=True, blank=True, aka='accuracy')
 price = models.CharField(maxlength=256, null=True, blank=True) # 
new column

Note the aka field where I changed the name of "accuracy" to "accuracynew".

Let me know if you find any bugs.

http://kered.org/blog/2007-07-19/django-schema-evolution/
http://kered.org/blog/wp-content/uploads/2007/07/django_schema_evolution-v096patch.txt

-- Derek

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



Unicode problem while changing from 0.95 to latest developer version

2007-07-19 Thread piotr

Hello,
I have done upgrade from 0.95 to svn developer version.

One of my django apps using unicode characters does not start anymore,
I get the following:

--

Traceback (most recent call last):

  File "C:\Python24\lib\site-packages\django\core\servers
\basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)

  File "C:\Python24\lib\site-packages\django\core\servers
\basehttp.py", line 620, in __call__
return self.application(environ, start_response)

  File "C:\Python24\lib\site-packages\django\core\handlers\wsgi.py",
line 190, in __call__
response = self.get_response(request)

  File "C:\Python24\lib\site-packages\django\core\handlers\base.py",
line 111, in get_response
return debug.technical_500_response(request, *sys.exc_info())

  File "C:\Python24\lib\site-packages\django\views\debug.py", line
141, in technical_500_response
return HttpResponseServerError(t.render(c), mimetype='text/html')

  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 181, in render
return self.nodelist.render(context)

  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 736, in render
bits.append(self.render_node(node, context))

  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 754, in render_node
result = node.render(context)

  File "C:\Python24\lib\site-packages\django\template\defaulttags.py",
line 134, in render
nodelist.append(node.render(context))

  File "C:\Python24\lib\site-packages\django\template\defaulttags.py",
line 228, in render
return self.nodelist_true.render(context)

  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 736, in render
bits.append(self.render_node(node, context))

  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 764, in render_node
raise wrapped

TemplateSyntaxError: Caught an exception while rendering: 'utf8' codec
can't decode bytes in position 833-834: invalid data

Original Traceback (most recent call last):
  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 754, in render_node
result = node.render(context)
  File "C:\Python24\lib\site-packages\django\template\defaulttags.py",
line 134, in render
nodelist.append(node.render(context))
  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 790, in render
return self.filter_expression.resolve(context)
  File "C:\Python24\lib\site-packages\django\template\__init__.py",
line 603, in resolve
obj = func(obj, *arg_vals)
  File "C:\Python24\lib\site-packages\django\template
\defaultfilters.py", line 25, in _dec
args[0] = force_unicode(args[0])
  File "C:\Python24\lib\site-packages\django\utils\encoding.py", line
42, in force_unicode
s = unicode(s, encoding, errors)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position
833-834: invalid data

--

The admin site works, I can browse and update the data base without
any problems.

My development PC runs Windows.

Any idea what can be wrong?
Regards,
Piotr


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Simple Left Join in Django question???

2007-07-19 Thread Joshua

Maybe I should have titled this how do I create a left join in Django
syntax or with the Django db-API

All the examples in the documentation let you retrieve the related
object ONLY if you have ONE related object retrieved.

On Jul 19, 2:18 pm, Joshua <[EMAIL PROTECTED]> wrote:
> Thank you for your response
>
> I'm not familiar with the context object - I'll have to do some
> research.
>
> I have this working
>
> portfolioPage =
> client.objects.filter(project_portfolio__project_display_bit = True)
>
> It's returning the clients data - just not the data for the
> project_portfolio (it's not joining)?
>
> On Jul 19, 2:08 pm, gkelly <[EMAIL PROTECTED]> wrote:
>
> > I believe in your template you should be able to do something like:
>
> > {% for p in project_portfolio_list %}
> >   {{ p.project_name_char }} {{ p.project_client.client_name_char }}
> > {% endfor %}
>
> > If you had a view with:
>
> > context['project_portfolio_list'] = project_portfolio.objects.all()
>
> > You'll also want to be familiar with this portion of the 
> > docs:http://www.djangoproject.com/documentation/db-api/#related-objects
>
> > Hope that helps,
> > Grant
>
> > On Jul 19, 11:02 am, Joshua <[EMAIL PROTECTED]> wrote:
>
> > > I've tried to search for a solution to this problem for the last 2
> > > hours and I can't seem to figure it out.
>
> > > I basically want to return a joined table from a queryset - formatted
> > > for my template.
>
> > > I can't seem to figure out how to do this with the Django database
> > > API.
>
> > > With SQL a join query works out to:
>
> > > '''
> > > select project_portfolio.*, client.*
> > > from project_portfolio left join client
> > > on project_portfolio.id = client.id
> > > '''
> > > with the following simplified models:
>
> > > class project_portfolio(models.Model):
> > > project_name_char = models.CharField()
> > > project_client = models.ForeignKey(client)
>
> > > class client(models.Model):
> > > client_name_char = models.CharField
>
> > > The challenge here seems to be that I have to return MULTIPLE
> > > project_portfolio objects and THEN get the "client" data - because NOT
> > > all "clients" have "project_portfolio(s)"
>
> > > Thank you in advance for any help - Josh


--~--~-~--~~~---~--~~
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 do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-19 Thread walterbyrd

On Jul 19, 12:24 pm, FrankW <[EMAIL PROTECTED]> wrote:
> A couple of things to check - what are the permissions on
> dispatch.fcgi?
> It needs to be executable, e.g. -rwxr-xr-x

Permissions are correct.

> Also, make sure it does not have DOS mode CR-LF

No DOS mode CR-LF.

> And, do you have debug set in your settings.py?

from settings.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG

My file structure:

django.niche-software.com/
--- dispatch.fcgi
--- hello.fcgi
--- .htaccess
--- django/
-- django_media/
-- django_projects/
- myproject/
 settings.py
- sqlite-3.4.0
-- django_src/
-- django_templates

The hello.fcgi I got from the dreamhost wiki:

http://www.skweezer.net/bloglines/s.aspx/2/wiki.dreamhost.com/Special_~_Search?search=django=Go

The hello.fcgi looks like this:

#!/usr/bin/python2.3
from flup.server.fcgi import WSGIServer
def test_app(environ, start_response): start_response('200 OK',
[('Content-Type', 'text/plain')]) yield 'Hello, world!\n'
WSGIServer(test_app).run()

I tried running that, and got the same 500 error.







--~--~-~--~~~---~--~~
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 multiple django versions on mod_python

2007-07-19 Thread oggie rob

Thanks for the tip, Niels. I tried that and it didn't work either.
I got to thinking about how likely it would be that mod_python &
interpreters were causing problems. I've used multiple interpreters
for some time and haven't noticed any other strange behaviour. A
little test by printing out the apache.interpreter showed that it
always correctly used the specified interpreter.

I started looking more at unicode. I thought it odd that it always
propagated as a unicode translation error. After a bit of poking
around, I found this line in the trunk version and I wondered if this
might be causing some issues:
django/db/backends/postgresql/base.py: cursor.execute("SET
client_encoding to 'UNICODE'")

Well I can't see why the encoding would be used in both installations,
but I think that postgres interactions were causing the problem,
rather than mod_python. To make a long story short, I switched to 0.91-
bugfix, worked through the conflicts (which is why I hadn't upgraded
earlier), and because it contains a UnicodeDatabaseWrapper, it now
appears to work without problems.

That was a doozy. Thanks all for your help!
 -rob

On Jul 19, 4:27 am, Niels <[EMAIL PROTECTED]> wrote:
> In case the problem lies in manipulating the python path inside a
>  section, perhaps you could play another trick to load the
> different versions of django. I am doing as follows, though, not with
> Location tags but in VirtualHost sections, and it works for me:
>
> Somewhere on the python path, there is a subdirectory,
> django_versions. In there, several django trees exist. On the same
> level as django_versions subdirectory i have wrapper modules, one for
> each django version i need, named django_trunk.py, django_096.py, and
> so on. The wrapper code reads:
>
> ##
> import imp, os
> django = imp.load_module(
> "django",
> *imp.find_module("django", [os.path.join(
> os.path.dirname(__file__), "django_versions", "django-
> trunk"
> )] )
> )
> del imp, os
>
> all together, the layout is:
> /python-path/django_trunk.py
> /python-path/django_someversion.py
> /python-path/django_vresions/
> /python-path/django_versions/django-trunk/django
> /python-path/django_vresions/django-someversion/django
>
> Note, there is no need to have an __init__.py inside django_versions,
> since the path munging is done in the wrapper module, where the
> required django module is loaded from a temporary fixed path set up
> dynamically.
>
> To use this, a second wrapper file is needed for the mod_python
> handler. This one is named django_trunk_handler.py and should be put
> somewhere on your python path as well:
>
> import django_trunk as django
> from django.core.handlers.modpython import handler
>
> And analogous to that, you can have django_someversion_handler.py:
>
> import django_someversion as django
> from django.core.handlers.modpython import handler
>
> Now, in httpd.conf, this comes together:
> 
>   ...
>   PythonHandler django_trunk_handler
>   PythonInterpreter version1
> 
> 
>   ...
>   PythonHandler django_someversion_handler
>   PythonInterpreter version2
> 
>
> Finally, you might want to have different manage.py stubs with an
> extra first line importing the right django module as django into the
> namespace to get going.
>
> Best regards...
>
> Niels
>
> On Jul 19, 12:46 pm, oggie rob <[EMAIL PROTECTED]> wrote:
>
> > Thanks for your help, Russ. I updated mod_python (which was probably
> > overdue anyway), but that didn't fix the problem. I've been looking
> > for other signs but nothing has surfaced yet.
> > If anybody else can recall a similar experience, please let me know!
>
> >  -rob
>
> > On Jul 18, 9:07 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> > wrote:
>
> > > On 7/19/07, oggie rob <[EMAIL PROTECTED]> wrote:
>
> > > > Please, if you've seen the same issue or have any helpful ideas to try
> > > > to stop the error, let me know.
>
> > > I think I've seen the same problem (or, at least, an analogous one).
> > > Unfortunately, I can't provide much by way of helpful debug or
> > > solution - the sysadmin that identified the problem for us isn't
> > > around for me to ask him for more details.
>
> > > As I recall, the problem was mod_python. Older versions of mod_python
> > > had some sort of issue with caching python instances. As a result, if
> > > you deployed two different versions of Django, the version of Django
> > > that was provided to a given request was determined by the thread that
> > > served the request. If the first request served by a thread used the
> > > old version of Django, that was the version that was used for all
> > > subsequent requests on that thread, regardless of the version that was
> > > required to satisfy the request.
>
> > > I believe we fixed the problem by updating mod_python, but I'm not
> > > completely certain on that.
>
> > > I know that this is all vague and ambiguous help - sorry I can't be
> > > more specific.
>
> > > Yours,
> > > Russ Magee %-)- 

Re: Does a pre/post_save signal know who is the user currently logged in?

2007-07-19 Thread Lic. José M. Rodriguez Bacallao
take a look at:
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser

On 7/19/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 7/19/07, Xanthus <[EMAIL PROTECTED]> wrote:
> > A view knows the logged in user through request.user but i could not
> > find if a signal has this information somewhere.
>
> No, this information is not available in the default signals. This is
> because Django can be used completely independently of its
> authentication system and completely indepdendently of its HTTP
> request/response system (e.g., you can set up cron jobs, use Django as
> a backend to a non-web application, etc.); if the request object and
> auth system were that tightly coupled to the model layer, a lot of
> uses wouldn't be possible.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>


-- 
Lic. José M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic por
profesionales
-

--~--~-~--~~~---~--~~
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 for application with subdomains

2007-07-19 Thread SH

Hi David,

I'm just starting on an app with the same structure. I think the main
problem here is that the username field has to be unique.

One possible solution would be to append the domain name to the
username before authentication. The user types in 'bob', then the
system munges it to 'bob.sub.domain.com' before doing the validation.

Anyone know of a less hackish answer? I know we can create custom
authentication backends, but I don't see another way to let users have
the same username across different subdomains.

SH


--~--~-~--~~~---~--~~
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: Request Context and Generic Views

2007-07-19 Thread Daniel A.

As has been mentioned, they all use a RequestContext to begin with,
but if you need additional custom variables to be exposed to your
template, then you can pass them as a dict for the extra_context
variable.

On Jul 19, 5:08 am, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> How does it exactly work when I want a RequestContext to be used in a
> generic view. There's the context_processors key in the dict you gotta
> pass it, but "A list of template-context processors to apply to the
> view's template" doesn't really mean much to me, and even less after
> giving it a "list" and seeing python complain about callables ;)
>
> Might anyone give me an example of a dict I might pass a generic view?
>
> Thanks guys!
>
>  signature.asc
> 1KDownload


--~--~-~--~~~---~--~~
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: newbie question: generating javascript, avoiding trailing comma

2007-07-19 Thread cjl

Duc & Kevin:

Thank you for your quick and accurate replies.

It looks like I need to spend more time with the documentation.

Kevin's solution fixed my problem.

-CJL


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



Re: Django's User authentication

2007-07-19 Thread rskm1

Jason F. McBrayer wrote:
> james_027 <[EMAIL PROTECTED]> writes:
>
> > what if I need additional fields or methods for my apps? Do i inherit
> > it or edit the user class?
>
> The standard approach is here:
> http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model

I'm glad this came up, I've been struggling with it myself.  I'd like
to be able to edit the additional fields that I associated with the
User (via my UserProfile class) from the admin interface, right inline
with the rest of the User fields.

So I took the advice in one of the comments in that thread.  I won't
pretend to comprehend it all, but it says:

| class UserProfile(models.Model):
|   user = models.ForeignKey(User, edit_inline=models.TABULAR,
num_in_admin=1,min_num_in_admin=1,
max_num_in_admin=1,num_extra_on_change=0)
|   # ... my additional fields


This produces an error when validating models,

| Validating models...
| keyapp.userprofile: At least one field in UserProfile should have
core=True, because it's being edited inline by user.User.
| 1 error found.


Okay, so who am I to argue with an error message?  I slap a
"core=True," in there with it (on ALL the fields in UserProfile;
anything less causes other problems), and it SEEMS to work!  That is,
there's another box in the admin interface for editing a User object,
with my additional fields available to edit.

Too good to be true, right?
Right. :-(
I can neither add a UserProfile nor edit the values of the UserProfile
from the User-edit admin page.

I know, I know, it was unreasonable to expect it to be THAT easy.  But
the fact that it DISPLAYS the fields from another table (and
*pretends* to let me edit them even though it discards my changes)
with so little work on my part makes me think it might work if I
wasn't doing something wrong or dumb.

/myproj/mainweb/settings.py:
|  INSTALLED_APPS = (
|'django.contrib.auth',
|'django.contrib.contenttypes',
|'django.contrib.sessions',
|'django.contrib.sites',
|'myproj.mainweb.myweb.myapp',  # my stuff
|'django.contrib.admin',# user-account administration interface
(provided by Django)
|  )
|  AUTH_PROFILE_MODULE = 'myapp.UserProfile'


/myproj/mainweb/myweb/myapp/models.py:
|  from django.db import models
|  from django.contrib.auth.models import User
|  class UserProfile(models.Model):
|user = models.ForeignKey(User, edit_inline=models.TABULAR,
num_in_admin=1,min_num_in_admin=1,
max_num_in_admin=1,num_extra_on_change=0, core=True)
|ftv = models.CharField('Favorite TV Station', maxlength=4,
core=True)
|phone = models.CharField('Telephone Number', maxlength=24,
core=True)
|  class Admin:
|pass

The UserProfile fields DO show up in the User-editing admin page, as
input fields... but any input or changes to them are ignored/discarded.


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



Date Widget (or date format) in newforms

2007-07-19 Thread larry

Has anyone written a date widget with separate fields for day, month,
and year (and, ideally, a calendar) for the newforms package?

Failing that, is there any way to change the format in which the text
widget used for dates displays and decodes the date.  -MM-DD may
be better in every way, but it doesn't work for this particular
application's users.
--
Larry


--~--~-~--~~~---~--~~
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: Request Context and Generic Views

2007-07-19 Thread Collin Grady

They all use RequestContext already.


--~--~-~--~~~---~--~~
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: newbie question: generating javascript, avoiding trailing comma

2007-07-19 Thread Duc Nguyen

It would probably be easier if you processed crime_list in your view and 
generated a 'crimes' variable for use in your template.

cjl wrote:
> DU:
>
> I am a newbie, and I'm working on a simple tutorial for other
> newbies.  I am trying to generate some javascript, and I have the
> following code in my template:
>
> var crimes =  [
>  {% for crime in crime_list %}
>  [ {{crime.longitude}},
> {{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date 
> }}'],
>  {% endfor %}
> ];
>
> When this template is rendered to a webpage, I can get something like
> the following:
>
> var crimes = [
> [-78.817828,42.904851,'17 Rapin
> Place','homicide','2006-01-05'],
> [-78.889458,42.897707,'155 Pennsylvania
> Street','homicide','2006-04-17'],
> [-78.884766,42.915257,'446 West
> Ferry','homicide','2006-01-10'],
> ];
>
> This is fine, but I think the trailing comma in the final array item
> is causing a javascript error in IE. Is there a way to rewrite my
> template code to avoid the trailing comma?
>
> Thanks in advance,
> cjl
>
>
> >
>   


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



Re: newbie question: generating javascript, avoiding trailing comma

2007-07-19 Thread Kevin

There's a forloop.last variable that you could test.  Eg:
var crimes =  [
 {% for crime in crime_list %}
 [ {{crime.longitude}},
{{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date 
}}']
{% if not forloop.last %},{% endif %}
 {% endfor %}
];

On Jul 19, 12:35 pm, cjl <[EMAIL PROTECTED]> wrote:
> DU:
>
> I am a newbie, and I'm working on a simple tutorial for other
> newbies.  I am trying to generate some javascript, and I have the
> following code in my template:
>
> var crimes =  [
>  {% for crime in crime_list %}
>  [ {{crime.longitude}},
> {{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date 
> }}'],
>  {% endfor %}
> ];
>
> When this template is rendered to a webpage, I can get something like
> the following:
>
> var crimes = [
> [-78.817828,42.904851,'17 Rapin
> Place','homicide','2006-01-05'],
> [-78.889458,42.897707,'155 Pennsylvania
> Street','homicide','2006-04-17'],
> [-78.884766,42.915257,'446 West
> Ferry','homicide','2006-01-10'],
> ];
>
> This is fine, but I think the trailing comma in the final array item
> is causing a javascript error in IE. Is there a way to rewrite my
> template code to avoid the trailing comma?
>
> Thanks in advance,
> cjl


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



Re: Authentication for application with subdomains

2007-07-19 Thread daev

It's very simple to implement that application structure. For
authentication you must set proper SESSION_COOKIE_DOMAIN variable in
settings:
http://www.djangoproject.com/documentation/settings/#session-cookie-domain
For manage subdomains you can write you own middleware to parse
request.META[ 'SERVER_NAME' ] value and setting some needed attributes
to request then handle it in your views late.


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



newbie question: generating javascript, avoiding trailing comma

2007-07-19 Thread cjl

DU:

I am a newbie, and I'm working on a simple tutorial for other
newbies.  I am trying to generate some javascript, and I have the
following code in my template:

var crimes =  [
 {% for crime in crime_list %}
 [ {{crime.longitude}},
{{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date 
}}'],
 {% endfor %}
];

When this template is rendered to a webpage, I can get something like
the following:

var crimes = [
[-78.817828,42.904851,'17 Rapin
Place','homicide','2006-01-05'],
[-78.889458,42.897707,'155 Pennsylvania
Street','homicide','2006-04-17'],
[-78.884766,42.915257,'446 West
Ferry','homicide','2006-01-10'],
];

This is fine, but I think the trailing comma in the final array item
is causing a javascript error in IE. Is there a way to rewrite my
template code to avoid the trailing comma?

Thanks in advance,
cjl


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



Authentication for application with subdomains

2007-07-19 Thread David Marko

I know this topis has been discussed already but I stiil havent find
solution. We would like to build up the application that will be used
by many customers. After registration the customer will access
application via its subdomain name:
eg. cust1 = http://cust1.application.com
cust2 = http://cust2.application.com
etc.

This approach requires that authentication should use subdomain name,
username and password . How can be this scenario accomplished with
django?
I think its very common approach when one application is used  by many
customers and things must work dynamicly ... so using django 'sites'
approach is not suitable.

Thanks for any advice and hits.

David


--~--~-~--~~~---~--~~
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: Simple Left Join in Django question???

2007-07-19 Thread Joshua

Thank you for your response

I'm not familiar with the context object - I'll have to do some
research.

I have this working

portfolioPage =
client.objects.filter(project_portfolio__project_display_bit = True)

It's returning the clients data - just not the data for the
project_portfolio (it's not joining)?


On Jul 19, 2:08 pm, gkelly <[EMAIL PROTECTED]> wrote:
> I believe in your template you should be able to do something like:
>
> {% for p in project_portfolio_list %}
>   {{ p.project_name_char }} {{ p.project_client.client_name_char }}
> {% endfor %}
>
> If you had a view with:
>
> context['project_portfolio_list'] = project_portfolio.objects.all()
>
> You'll also want to be familiar with this portion of the 
> docs:http://www.djangoproject.com/documentation/db-api/#related-objects
>
> Hope that helps,
> Grant
>
> On Jul 19, 11:02 am, Joshua <[EMAIL PROTECTED]> wrote:
>
> > I've tried to search for a solution to this problem for the last 2
> > hours and I can't seem to figure it out.
>
> > I basically want to return a joined table from a queryset - formatted
> > for my template.
>
> > I can't seem to figure out how to do this with the Django database
> > API.
>
> > With SQL a join query works out to:
>
> > '''
> > select project_portfolio.*, client.*
> > from project_portfolio left join client
> > on project_portfolio.id = client.id
> > '''
> > with the following simplified models:
>
> > class project_portfolio(models.Model):
> > project_name_char = models.CharField()
> > project_client = models.ForeignKey(client)
>
> > class client(models.Model):
> > client_name_char = models.CharField
>
> > The challenge here seems to be that I have to return MULTIPLE
> > project_portfolio objects and THEN get the "client" data - because NOT
> > all "clients" have "project_portfolio(s)"
>
> > Thank you in advance for any help - Josh


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

2007-07-19 Thread Chris Hoeppner
Hi there!

I just wanted to share opinions on this.

I'm in the process of building a rather large site, that's going to
expect quite some hits a day. So I want to to keep things as clean as
possible. One never knows when I'll be getting my hands dirty again.

The User(tm), can have a variable amount of profiles, depending on the
sections in the site the user... uses.

Just to picture it out:

User1:
* Base profile
* Music profile
* Food profile
* Chat profile

User2:
* Base profile
* Chat profile

User3:
* Base profile
* Music profile

And the list might go on...

As you see, every user has a Base profile assigned, and any number of
the other profiles. I have the AUTH_PROFILE_MODULE setting pointing to
the Base profile, and then I'll load the other profile(s) as needed.

I'd like everyone to share his/her insight about this kind of situation.
Should I better throw all the data together into the base profile, or
keep it separately? Is there a way to define multiple profile settings?



signature.asc
Description: OpenPGP digital signature


Re: Using Sessions to display the contents of a shopping cart

2007-07-19 Thread Greg

Lutz,
Yea I don't plan on having the user login to purchase a product from
me.  So I guess Session's will work if that is the case.  It looks
like I will have to place a cookie on the visitor's computer using
set_test_cookie() and test_cookie_worked() method's so that I'm able
to tell the difference between two users that are adding products to
the cart at the same time.  Does anybody know of any problems with
this solution?

On Jul 19, 11:40 am, Lutz Steinborn <[EMAIL PROTECTED]> wrote:
> Hi Jeremy,
>
> On Thu, 19 Jul 2007 10:45:46 -0500
>
> "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
>
> > On 7/19/07, Greg <[EMAIL PROTECTED]> wrote:
> > > x = request.session ?? # I want to add s and c to my session?
>
> > cart = request.session.get('cart', [])
> > cart.append({'style':s,'choice'c})
>
> > request.session['cart']=cart
>
> > But, fundamentally, putting cart info in session is a bad idea; people
> > switch computers (and thus cookies; sessions) fairly often.  Also,
> > people delete cookies for good reasons.  I'd be severely pissed if my
> > amazon wishlist went away when I deleted cookies.
>
> but was is the solution if the user is not logged in ?
> At this point your only chance is a session bound cookie or I'm wrong ?
>
> Kindly regards
> Lutz Steinborn


--~--~-~--~~~---~--~~
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: Simple Left Join in Django question???

2007-07-19 Thread gkelly

I believe in your template you should be able to do something like:

{% for p in project_portfolio_list %}
  {{ p.project_name_char }} {{ p.project_client.client_name_char }}
{% endfor %}

If you had a view with:

context['project_portfolio_list'] = project_portfolio.objects.all()


You'll also want to be familiar with this portion of the docs:
http://www.djangoproject.com/documentation/db-api/#related-objects


Hope that helps,
Grant

On Jul 19, 11:02 am, Joshua <[EMAIL PROTECTED]> wrote:
> I've tried to search for a solution to this problem for the last 2
> hours and I can't seem to figure it out.
>
> I basically want to return a joined table from a queryset - formatted
> for my template.
>
> I can't seem to figure out how to do this with the Django database
> API.
>
> With SQL a join query works out to:
>
> '''
> select project_portfolio.*, client.*
> from project_portfolio left join client
> on project_portfolio.id = client.id
> '''
> with the following simplified models:
>
> class project_portfolio(models.Model):
> project_name_char = models.CharField()
> project_client = models.ForeignKey(client)
>
> class client(models.Model):
> client_name_char = models.CharField
>
> The challenge here seems to be that I have to return MULTIPLE
> project_portfolio objects and THEN get the "client" data - because NOT
> all "clients" have "project_portfolio(s)"
>
> Thank you in advance for any help - Josh


--~--~-~--~~~---~--~~
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: Question about comment_utils

2007-07-19 Thread Shankar

Hi James,

Thanks. Keep up the great work! Meanwhile, I'll submit an issue report.

Shankar

On Thu, 19 Jul 2007 13:12:04 -0500, James Bennett wrote:

> On 7/19/07, Shankar <[EMAIL PROTECTED]> wrote:
>> Is anyone else seeing the same behavior? Should I be running the latest
>> SVN version of Django to take advantage of comment_utils?
> 
> You should go here
> 
> http://code.google.com/p/django-comment-utils/issues/list
> 
> and paste in the code -- including your model and your Moderator
> subclass -- into an issue report; I use Google Code specifically because
> it gives me a free bug tracking application.



--~--~-~--~~~---~--~~
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: Does a pre/post_save signal know who is the user currently logged in?

2007-07-19 Thread Lic. José M. Rodriguez Bacallao
take a look at:
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser

On 7/19/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 7/19/07, Xanthus <[EMAIL PROTECTED]> wrote:
> > A view knows the logged in user through request.user but i could not
> > find if a signal has this information somewhere.
>
> No, this information is not available in the default signals. This is
> because Django can be used completely independently of its
> authentication system and completely indepdendently of its HTTP
> request/response system (e.g., you can set up cron jobs, use Django as
> a backend to a non-web application, etc.); if the request object and
> auth system were that tightly coupled to the model layer, a lot of
> uses wouldn't be possible.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>


-- 
Lic. José M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo
mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic por
profesionales
-

--~--~-~--~~~---~--~~
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 do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-19 Thread FrankW

A couple of things to check - what are the permissions on
dispatch.fcgi?
It needs to be executable, e.g. -rwxr-xr-x

Also, make sure it does not have DOS mode CR-LF

And, do you have debug set in your settings.py?


On Jul 19, 2:04 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
> As I said, I tried to follow the tutorial:
>
> In this directory
>
> /home/walterbyrd/django.niche-software.com
>
> I have these two files:
>
> 1. dispatch.fcgi
> sys.path += ['/home/walterbyrd/django.niche-software/django/
> django_src']
> sys.path += ['/home/walterbyrd/django.niche-software/django/
> django_projects']
>
> from fcgi import WSGIServer
> from django.core.handlers.wsgi import WSGIHandler
> import os
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
> WSGIServer(WSGIHandler()).run()
>
> ---
>
> 2. dispatch.fcgi
> #!/usr/bin/env python
>
> import sys
>
> sys.path += ['/home/walterbyrd/django.niche-software/django/
> django_src']
> sys.path += ['/home/walterbyrd/django.niche-software/django/
> django_projects']
>
> from fcgi import WSGIServer
> from django.core.handlers.wsgi import WSGIHandler
> import os
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
> WSGIServer(WSGIHandler()).run()
> [niagara]$ ls -a
> .  ..  .htaccess  dispatch.fcgi  django  fcgi.py  fcgi.pyc
> [niagara]$ cat .htaccess
> RewriteEngine On
> RewriteBase /
> RewriteRule ^(media/.*)$ - [L]
> RewriteRule ^(admin_media/.*)$ - [L]
> RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
> RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]


--~--~-~--~~~---~--~~
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: Does a pre/post_save signal know who is the user currently logged in?

2007-07-19 Thread James Bennett

On 7/19/07, Xanthus <[EMAIL PROTECTED]> wrote:
> A view knows the logged in user through request.user but i could not
> find if a signal has this information somewhere.

No, this information is not available in the default signals. This is
because Django can be used completely independently of its
authentication system and completely indepdendently of its HTTP
request/response system (e.g., you can set up cron jobs, use Django as
a backend to a non-web application, etc.); if the request object and
auth system were that tightly coupled to the model layer, a lot of
uses wouldn't be possible.

-- 
"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: Question about comment_utils

2007-07-19 Thread James Bennett

On 7/19/07, Shankar <[EMAIL PROTECTED]> wrote:
> Is anyone else seeing the same behavior? Should I be running the latest
> SVN version of Django to take advantage of comment_utils?

You should go here

http://code.google.com/p/django-comment-utils/issues/list

and paste in the code -- including your model and your Moderator
subclass -- into an issue report; I use Google Code specifically
because it gives me a free bug tracking application.

-- 
"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: Unicode chars in CharField

2007-07-19 Thread Chris Hoeppner
Chris Hoeppner escribió:
> Hi there!
> 
> I'm getting this whenever I try to use some non-ascii character in a
> CharField. I know this has something to do with the unicode() function,
> but my python knowledge doesn't get me that far.
> 
> Thanks everyone!
> 
> Traceback (most recent call last):
> File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in
> get_response
>   77. response = callback(request, *callback_args, **callback_kwargs)
> File
> "/usr/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py"
> in _checklogin
>   55. return view_func(request, *args, **kwargs)
> File "/usr/lib/python2.5/site-packages/django/views/decorators/cache.py"
> in _wrapped_view_func
>   39. response = view_func(request, *args, **kwargs)
> File
> "/usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in
> add_stage
>   263. LogEntry.objects.log_action(request.user.id,
> ContentType.objects.get_for_model(model).id, pk_value,
> force_unicode(new_object), ADDITION)
> File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
> force_unicode
>   40. s = unicode(str(s), encoding, errors)
> 
>   UnicodeEncodeError at /admin/anuncios/entry/add/
>   'ascii' codec can't encode character u'\xc1' in position 0: ordinal
> not in range(128)
> 

This is being annoying. If I add to any model, and any of the fields
contains some special char, it will save the object, but throw an error
like the quoted one. If I want to edit the object in the admin, same
thing. But it shows up fine in my views.

Might this be some kind of bug?



signature.asc
Description: OpenPGP digital signature


Re: How do I know if fastcgi is installed correctly? (using dreamhost)

2007-07-19 Thread walterbyrd

As I said, I tried to follow the tutorial:

In this directory

/home/walterbyrd/django.niche-software.com

I have these two files:

1. dispatch.fcgi
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_src']
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_projects']

from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
WSGIServer(WSGIHandler()).run()

---

2. dispatch.fcgi
#!/usr/bin/env python

import sys

sys.path += ['/home/walterbyrd/django.niche-software/django/
django_src']
sys.path += ['/home/walterbyrd/django.niche-software/django/
django_projects']

from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
WSGIServer(WSGIHandler()).run()
[niagara]$ ls -a
.  ..  .htaccess  dispatch.fcgi  django  fcgi.py  fcgi.pyc
[niagara]$ cat .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(admin_media/.*)$ - [L]
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]



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



Simple Left Join in Django question???

2007-07-19 Thread Joshua

I've tried to search for a solution to this problem for the last 2
hours and I can't seem to figure it out.

I basically want to return a joined table from a queryset - formatted
for my template.

I can't seem to figure out how to do this with the Django database
API.

With SQL a join query works out to:

'''
select project_portfolio.*, client.*
from project_portfolio left join client
on project_portfolio.id = client.id
'''
with the following simplified models:

class project_portfolio(models.Model):
project_name_char = models.CharField()
project_client = models.ForeignKey(client)

class client(models.Model):
client_name_char = models.CharField

The challenge here seems to be that I have to return MULTIPLE
project_portfolio objects and THEN get the "client" data - because NOT
all "clients" have "project_portfolio(s)"

Thank you in advance for any help - Josh


--~--~-~--~~~---~--~~
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: forloop variables without for

2007-07-19 Thread sean

Try {{ images.0.image }}

Sean

On Jul 19, 7:43 pm, Marc Garcia <[EMAIL PROTECTED]> wrote:
> Hi!
>
> In a project I get a set of images from a model, and then I display it
> on the template. In same template (but in another place), I just want
> to display first element of set, and number of objects given. Can I do
> it without adding those fields to views.py?
>
> I've found a way for doing first, but it isn't very efficient:
>
> In views:
> images = tImage.objects.filter(product=product_id)
>
> In template:
> {% for image in images %}
> {% if forloop.first %}
>{{ image.image }}
> {% endif %}
> {% endfor %}
>
> Thanks a lot!
>   Marc


--~--~-~--~~~---~--~~
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: Newforms, MultiSelect, "Hold Down Control" message.

2007-07-19 Thread larry

Thanks for your reply, sorry I didn't get back to this sooner.

> The string you're referring to is appended to the help_text of a
> ManyToManyField in django.db.models.fields.related.  It's not being
> set by newforms, merely inherited.  You also wouldn't be seeing it if
> you were using CheckboxSelectMultiple, only if the normal HTML select
> widget were being used.

I'm definitely seeing this string generated by my descendant of
CheckboxSelectMultiple, and I'm pretty sure I saw it when I was using
a straight CheckboxSelectMultiple widget as well.

It's not immediately clear why user-interface oriented instructions
would be stored with the database model -- it seems to me that the
user interface code (newforms or widgets) ought to handle this itself.

I'm not comfortable subclassing Form, but I do understand using the
help_text attribute.  Since I wasn't aware it existed, I don't have
any other information in there.
--
Larry


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



forloop variables without for

2007-07-19 Thread Marc Garcia

Hi!

In a project I get a set of images from a model, and then I display it
on the template. In same template (but in another place), I just want
to display first element of set, and number of objects given. Can I do
it without adding those fields to views.py?

I've found a way for doing first, but it isn't very efficient:

In views:
images = tImage.objects.filter(product=product_id)

In template:
{% for image in images %}
{% if forloop.first %}
   {{ image.image }}
{% endif %}
{% endfor %}

Thanks a lot!
  Marc


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



Does a pre/post_save signal know who is the user currently logged in?

2007-07-19 Thread Xanthus

I'm implementing a model modification history and the only thing it is
lacking is saving the user who did the modification.

A view knows the logged in user through request.user but i could not
find if a signal has this information somewhere.

Thanks in advance!


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



Question about comment_utils

2007-07-19 Thread Shankar

Hi all,

I'm using Django 0.96 and trying to use James Bennett's comment_utils 
with my blog application. When I add the CommentModerator subclass and 
'moderator.register' statements to models.py, the ManyToManyField class 
attributes in the moderated class stop working. I keep getting the 
following error

 File "/home/web/python-2.4.4/lib/python2.4/site-packages/django/db/
models/query.py" in lookup_inner
  938. raise TypeError, "Cannot resolve keyword '%s' into field" % name

However, when I comment out the subclass and moderator.register 
statements, everything works again.

Is anyone else seeing the same behavior? Should I be running the latest 
SVN version of Django to take advantage of comment_utils?

Thanks,
Shankar


--~--~-~--~~~---~--~~
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: Bulk data upload

2007-07-19 Thread Tim Chase

>> I dislike CSV because it takes extra overhead to
>> synchronize the flavors of them (how are quotes quoted?  are
>> values quoted? etc).
> 
> Psst! Check out Python's built-in ``csv`` module
> (http://docs.python.org/lib/module-csv.html); it handles all that
> nastiness for you.

I've used it before, and it is great...if the person on the 
receiving end also has the benefits of Python's CSV module ;)

In the OP's case, this works because they're receiving the file 
and they've got Python.  So yes, use python's built-in csv module 
and relax.

However, if you're on the sending end, and your recipient 
*doesn't* have the benefit of Python's csv module, you need to 
expend brain cycles to explain the csv-flavor to the recipient. 
With tab-delimited, it's far less problematic (unless some bozo 
wants to transmit actual tabs in their data...then try 
pipe-delimited as alluded to in some early sample code in this 
thread...unless there are tabs *and* pipes in the data, in which 
case, you need to smack the pathological twit and then expend the 
brain cycles)

-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: 4 beginner's questions

2007-07-19 Thread Carl Karsten

Stefan Matthias Aust wrote:
> Carl, Jeremy,
> 
> Thanks for your answers.
> 
> Carl wrote:
> 
>> I just made this.  it should answer most of 1 and 2.
>> http://code.djangoproject.com/wiki/DatabaseReset
> 
> Somehow, it seems to me that there should be a standard utility
> function to initialize the system for command line tools. I saw your
> "nifty trick" twice and I used a similar approach.

I vote for ./manage.py -runscript myscript.py
which apparently has been shot down in the past.

> 
> Your migrate.py script seems to be very specific to your
> mysql-specific use case.

yes, but only for reading.  The writes into django db are all via the django db 
api.

The page is boarder line wiki worthy, but I got tired of pasting the same 3 
files into dpaste.com :)

Carl K

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



Colleen Robledo is out of the office

2007-07-19 Thread crobledo


I will be out of the office starting Thu 07/19/2007 and will not return
until Mon 07/23/2007.

I will return emails as soon as possible Monday 7/23.


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



Re: Using Sessions to display the contents of a shopping cart

2007-07-19 Thread Lutz Steinborn

Hi Jeremy,

On Thu, 19 Jul 2007 10:45:46 -0500
"Jeremy Dunck" <[EMAIL PROTECTED]> wrote:

> 
> On 7/19/07, Greg <[EMAIL PROTECTED]> wrote:
> > x = request.session ?? # I want to add s and c to my session?
> 
> cart = request.session.get('cart', [])
> cart.append({'style':s,'choice'c})
> 
> request.session['cart']=cart
> 
> But, fundamentally, putting cart info in session is a bad idea; people
> switch computers (and thus cookies; sessions) fairly often.  Also,
> people delete cookies for good reasons.  I'd be severely pissed if my
> amazon wishlist went away when I deleted cookies.

but was is the solution if the user is not logged in ?
At this point your only chance is a session bound cookie or I'm wrong ?

Kindly regards
Lutz Steinborn

--~--~-~--~~~---~--~~
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: Blog engine

2007-07-19 Thread Chris Hoeppner
Stefan Matthias Aust escribió:
> Chris,
> 
> 2007/7/19, Chris Hoeppner <[EMAIL PROTECTED]>:
> 
>> There would still be the problem of people wanting to
>> "one-click-install" plugins and themes. But why would such a person even
>> think about using a framework instead of wordpress?
> 
> My point was that - assuming the Django community wants to spread the
> word that Django is the best answer to whatever question - that you
> have to target people who just want to use an application and
> demonstrate the greatness. This requires a momentum, a community.
> 
> If you just not want to bother those people and do not want to be
> bothered, then, well, let them use Wordpress :)
> 
> All I tried to say is perhaps that people who are looking for a simple
> to use blogging solution might want to get there with the least amount
> of work. Installing Wordpress is damn easy. Everybody with "computer
> knowledge" therefore typically recommends Wordpress (let's not dive
> into the discussion here that PHP is nearly always preinstalled and
> Python not).
> 
> Would you recommend your non-technical friends to go and install
> Python and Django, then to compile a common repository of stuff
> grabbed from all over the web and then to write their own custom
> blogging solution because it's so easy? I guess not :)
> 

Depends. If they're non-technical but willing to learn, yes. And I'd
assist them. If they're just stupid and want it to "just plain work"
then I'd tell them to go and buy a book about "windows for dummies".

And I don't mean that I *would*, but more that I *have done many times*.
Some of them come back after a while, knowing a bit more, and wanting to
learn. Others just don't bother me ever again. I like both of them :-)



signature.asc
Description: OpenPGP digital signature


Re: Blog engine

2007-07-19 Thread Stefan Matthias Aust

Chris,

2007/7/19, Chris Hoeppner <[EMAIL PROTECTED]>:

> There would still be the problem of people wanting to
> "one-click-install" plugins and themes. But why would such a person even
> think about using a framework instead of wordpress?

My point was that - assuming the Django community wants to spread the
word that Django is the best answer to whatever question - that you
have to target people who just want to use an application and
demonstrate the greatness. This requires a momentum, a community.

If you just not want to bother those people and do not want to be
bothered, then, well, let them use Wordpress :)

All I tried to say is perhaps that people who are looking for a simple
to use blogging solution might want to get there with the least amount
of work. Installing Wordpress is damn easy. Everybody with "computer
knowledge" therefore typically recommends Wordpress (let's not dive
into the discussion here that PHP is nearly always preinstalled and
Python not).

Would you recommend your non-technical friends to go and install
Python and Django, then to compile a common repository of stuff
grabbed from all over the web and then to write their own custom
blogging solution because it's so easy? I guess not :)

-- 
Stefan Matthias Aust

--~--~-~--~~~---~--~~
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: 4 beginner's questions

2007-07-19 Thread Stefan Matthias Aust

Carl, Jeremy,

Thanks for your answers.

Carl wrote:

> I just made this.  it should answer most of 1 and 2.
> http://code.djangoproject.com/wiki/DatabaseReset

Somehow, it seems to me that there should be a standard utility
function to initialize the system for command line tools. I saw your
"nifty trick" twice and I used a similar approach.

Your migrate.py script seems to be very specific to your
mysql-specific use case.

Jeremy wrote:

> > What's the recommended way to access models from outside of views?

> What you have is pretty good, but do this, too, in order to make sure
> all models are loaded (so that descriptors for relationships are
> contributed to reverse models: [...]

Thanks, I changed my code.

> > 3) I need to create an object with a unique random id -
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/163604

Oh, it's not creating the ID, my question was whether I can safely
assume that I will always get an IntegrityError (and nothing else) and
whether just inserting stuff and catching errors is the recommended
Pythonic way.

-- 
Stefan Matthias Aust // Truth until paradox

--~--~-~--~~~---~--~~
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: Blog engine

2007-07-19 Thread Chris Hoeppner
Stefan Matthias Aust escribió:
> If it is so easy to create a blogging application with Django, then
> this should be an argument for a standard application, not against it
> IMHO.
> 
> At minimum, it could become a nice example application, either as part
> of the django distribution or as a separate download. And if it is
> still easy enough, make it a Wordpress killer. Make it as easy to
> install and to use as Wordpress, being an example for the power of
> elegance of Django (and Python) - something like Typo or Mephisto for
> Rails.
> 
> Another important argument for one de-facto standard are plug-ins and
> templates. There are zillions of templates (even nice ones) for
> Wordpress. And you can add dozens if not hundreds of plugins to
> further customize or extend the software.
> 
> If everybody is creating his or her own solution, there will not be no
> synergy, no community, no   attention. Rails became so popular,
> because people *saw* how easy it was to create something. Just telling
> them isn't enough :)
> 
> Stefan
> 
> --~--~-~--~~~---~--~~
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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
> -~--~~~~--~~--~--~---
> 

Actually... It took me 30 minutes to get my blog engine running, without
the design. And, there's no need to "make" for plugins. A Django app
*is* a plugin to the django framework itself, if you'd like to see it
that way. I have a common repository on the python path with things I
tend to use often, like typogrify, markdown, and feedparser. You can
just load them from any other app.

There would still be the problem of people wanting to
"one-click-install" plugins and themes. But why would such a person even
think about using a framework instead of wordpress?

And I still think that there's absolutely no need to make a de-facto
standard blog app in django. You gotta use what works best for you, man.



signature.asc
Description: OpenPGP digital signature


Re: Blog engine

2007-07-19 Thread Rob Hudson

Why not start a Google code repository and see how many people want to
chip in and help.  This comes up often enough that it sounds like
there's enough interest.


--~--~-~--~~~---~--~~
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 advocacy in a commercial environment

2007-07-19 Thread Rob Hudson

On Jul 19, 1:19 am, "Jon Atkinson" <[EMAIL PROTECTED]> wrote:
> If anyone has any good resources which show off the power of Django
> (and by association, the benefits of PHP), then please share them with
> us.

Where I work we migrated away from PHP to Django with great success
but it depends on your environment.

For us the Django admin was a huge factor since we have teams entering
content and the default Django admin was way better than anything we
had going so far.

There are some performance articles and blog posts, for example:
http://wiki.rubyonrails.org/rails/pages/Framework+Performance

We benefitted from the Django workflow with its built-in web server.

There's also the fact that Django is improving everyday which
translates into free new features or things that were hard to do are
easy now.  For example, databrowse or djangosnippets.

And we love Python and also love our jobs more because of the
switch.  :)

Those aren't really resources for you but depending on your in-house
requirements it's not hard to find resources online to help guide the
decision.  When I had to convince my superiors of the choice, I wrote
a PDF document looking at the best choices in each language (Ruby,
PHP, Python) and Django won out for our particular needs.

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



Re: Blog engine

2007-07-19 Thread Stefan Matthias Aust

If it is so easy to create a blogging application with Django, then
this should be an argument for a standard application, not against it
IMHO.

At minimum, it could become a nice example application, either as part
of the django distribution or as a separate download. And if it is
still easy enough, make it a Wordpress killer. Make it as easy to
install and to use as Wordpress, being an example for the power of
elegance of Django (and Python) - something like Typo or Mephisto for
Rails.

Another important argument for one de-facto standard are plug-ins and
templates. There are zillions of templates (even nice ones) for
Wordpress. And you can add dozens if not hundreds of plugins to
further customize or extend the software.

If everybody is creating his or her own solution, there will not be no
synergy, no community, no   attention. Rails became so popular,
because people *saw* how easy it was to create something. Just telling
them isn't enough :)

Stefan

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



Re: Using Sessions to display the contents of a shopping cart

2007-07-19 Thread Jeremy Dunck

On 7/19/07, Greg <[EMAIL PROTECTED]> wrote:
> x = request.session ?? # I want to add s and c to my session?

cart = request.session.get('cart', [])
cart.append({'style':s,'choice'c})

request.session['cart']=cart

But, fundamentally, putting cart info in session is a bad idea; people
switch computers (and thus cookies; sessions) fairly often.  Also,
people delete cookies for good reasons.  I'd be severely pissed if my
amazon wishlist went away when I deleted cookies.

> I'm also not sure how
> to display all the session data.

http://www.djangoproject.com/documentation/authentication/#authentication-data-in-templates
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext
http://www.djangoproject.com/weblog/2005/sep/24/newshortcuts/

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



Using Sessions to display the contents of a shopping cart

2007-07-19 Thread Greg

I have the following view:

def showcart(request, style_id, choice_id):
s = Style.objects.get(id=style_id)
c = Choice.objects.get(id=choice_id)
x = request.session ?? # I want to add s and c to my session?
return render_to_response('show_test.html', {'mychoice': x})

//

Everytime the user adds something to their shopping cart then this
view will be accessed.  I want the view to store the two parameters (s
and c) into my request.session so that the data in the session can be
showed when the website visitor checks out.  However, I'm not sure how
to add these parameters to my session variable. I'm also not sure how
to display all the session data.

Thanks for any help


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

2007-07-19 Thread Jeremy Dunck

On 7/19/07, Stefan Matthias Aust <[EMAIL PROTECTED]> wrote:
> 1) It is important for me to recreate my environment from scratch
> (that is, from the VCS). I'd like to have a working application after
> calling "syncdb". For my own application, I've create an initial_data
> fixture. But I'd like to recreate users and permissions, too.

If you don't mind calling manage.py loaddata a few more times, yes.

The parameter there is the name of the fixture, *not* the name of an app.
http://www.djangoproject.com/documentation/django-admin/#loaddata-fixture-fixture
Fixtures in other dirs:
http://www.djangoproject.com/documentation/settings/#fixture-dirs

...
> it seems that
> "syncdb" always asks for an admin account on the console. Can I
> somehow suppress that question? Instead, I'd like to load some saved
> fixture.

--noinput
http://www.djangoproject.com/documentation/django-admin/#noinput

> What's the recommended way to access models from outside of views?
>

What you have is pretty good, but do this, too, in order to make sure
all models are loaded (so that descriptors for relationships are
contributed to reverse models:

from django.db.models import get_models
get_models()


> 3) I need to create an object with a unique random id -

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/163604

> "is enforced at the database level" but it unfortunately
> does not describe what happens if the constraint is violated. Will
> this always raise an IntegrityError?

Yes.  It just doesn't let you insert dupes; there is no id-generation
fallback (unless it's an autofield).

... Leaving #4 unanswered; your understanding seems 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: Problem when inserting into a table with a MySQL auto_increment primary key

2007-07-19 Thread AnaReis



On Jul 18, 6:14 pm, Nis Jørgensen <[EMAIL PROTECTED]> wrote:
> AnaReis skrev:> Hi all,
> > I have a problem when inserting a register into this table that I'm
> > working with.
> > This table belongs to a MySQL database and the storage engine is
> > MyISAM. The database that I'm using is a legacy database and I can't
> > change it in any way.
> > When I insert a register into the table it's MySQL who generates the
> > primary key for me. Which means that I fill all the required table
> > fields and leave the primary key field empty for MySQL to fill when I
> > insert the record. The problem is, since the ".save()" method doesn't
> > return any value there is no way for me to give any confirmation for
> > the user if the register was inserted or not.
>
> Have you added the primary key to the model, like this:
>
> my_legacy_id = AutoField()
>
> If you do, I believe you will be able to read the value of the field
> after calling .save().
>  At least you can with the standard id field when using postgresql.
>
> Nis

Hi
Thanks for your help!
I had put the AutoField() part but forgot to add the "_id" in the end
of the field, that's why it wasn't working.
Thanks again! :)
Ana


--~--~-~--~~~---~--~~
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: 4 beginner's questions

2007-07-19 Thread Carl Karsten

Stefan Matthias Aust wrote:
> Hi,
> 
> Coming from a Java background, I introduced Django in my company for a
> new web application. So far, we made great progress and web
> development suddenly was fun again. Unfortunately, it feels like all
> time I save because of Django, is spent on searching for an IDE (I
> still haven't found something really usable), reading the doc and
> solving trivial Python problems. I hope this will get better once I
> have more experience with Python.
> 
> I've a few questions regarding Django I'd like to ask in this and future 
> mails.
> 
> 1) It is important for me to recreate my environment from scratch
> (that is, from the VCS). I'd like to have a working application after
> calling "syncdb". For my own application, I've create an initial_data
> fixture. But I'd like to recreate users and permissions, too.
> 
> Is this possible?
> 
> I looked into django/core/management.py and it seems that "load_data"
> simple enumerates the installed application so if I want to create a
> fixture for "auth", the initial_data file must be located inside the
> django installation. This isn't an option. Furthermore, it seems that
> "syncdb" always asks for an admin account on the console. Can I
> somehow suppress that question? Instead, I'd like to load some saved
> fixture.
> 
> 2) I'd like to run batch application against our database
> (periodically using cron). Of course, I'd like to use the same
> database abstraction as Django uses, so I tried to find a way to
> initialize the system.
> 
> What's the recommended way to access models from outside of views?
> 
> I came up with these lines (conveniently located inside the project folder):
> 
>  #!/usr/bin/env python
>  ...
>  if __name__ == '__main__':
>from django.core.management import setup_environ
>import settings
>PROJECT_DIRECTORY = setup_environ(settings)
> 
>from demo.models import Demo
>d = Demo.objects.get(...)
>...
>d.save()
> 

I just made this.  it should answer most of 1 and 2.
http://code.djangoproject.com/wiki/DatabaseReset

> 3) I need to create an object with a unique random id - and I would
> prefer not to use the database specific SQL layer. What's the best way
> to do it? My naive approach is to declare the id field unique and
> simply try to insert objects until I get no error. The documentation
> says [unique] "is enforced at the database level" but it unfortunately
> does not describe what happens if the constraint is violated. Will
> this always raise an IntegrityError?
> 

Why a unique _random_ id.  seems odd.  knowing the use case might help.

> 4) I'd like to specify the file name of an uploaded file. Right now,
> the original filename is kept and I think, this could cause problems
> if two people upload a file with the same name at the same time.
> 
> I tried to understand the file upload process in the Django source but
> there was too much meta magic for my brain. However, it seems that the
> current documentation doesn't tell the whole story. It seems, that
> there is a save_FOO_file() in addition to the documentation tree
> get_FOO_xxx methods... My guess is that manipulators.py is responsible
> for saving the uploaded file. ... Wait, I think, _save_FIELD_file()
> will eventually save the file and yes, that while loop is obviously
> not threadsafe! So I need to set the filename myself. But how?
> 

good Q  hopfully someone can answer it. :)

Carl K

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



4 beginner's questions

2007-07-19 Thread Stefan Matthias Aust

Hi,

Coming from a Java background, I introduced Django in my company for a
new web application. So far, we made great progress and web
development suddenly was fun again. Unfortunately, it feels like all
time I save because of Django, is spent on searching for an IDE (I
still haven't found something really usable), reading the doc and
solving trivial Python problems. I hope this will get better once I
have more experience with Python.

I've a few questions regarding Django I'd like to ask in this and future mails.

1) It is important for me to recreate my environment from scratch
(that is, from the VCS). I'd like to have a working application after
calling "syncdb". For my own application, I've create an initial_data
fixture. But I'd like to recreate users and permissions, too.

Is this possible?

I looked into django/core/management.py and it seems that "load_data"
simple enumerates the installed application so if I want to create a
fixture for "auth", the initial_data file must be located inside the
django installation. This isn't an option. Furthermore, it seems that
"syncdb" always asks for an admin account on the console. Can I
somehow suppress that question? Instead, I'd like to load some saved
fixture.

2) I'd like to run batch application against our database
(periodically using cron). Of course, I'd like to use the same
database abstraction as Django uses, so I tried to find a way to
initialize the system.

What's the recommended way to access models from outside of views?

I came up with these lines (conveniently located inside the project folder):

 #!/usr/bin/env python
 ...
 if __name__ == '__main__':
   from django.core.management import setup_environ
   import settings
   PROJECT_DIRECTORY = setup_environ(settings)

   from demo.models import Demo
   d = Demo.objects.get(...)
   ...
   d.save()

3) I need to create an object with a unique random id - and I would
prefer not to use the database specific SQL layer. What's the best way
to do it? My naive approach is to declare the id field unique and
simply try to insert objects until I get no error. The documentation
says [unique] "is enforced at the database level" but it unfortunately
does not describe what happens if the constraint is violated. Will
this always raise an IntegrityError?

4) I'd like to specify the file name of an uploaded file. Right now,
the original filename is kept and I think, this could cause problems
if two people upload a file with the same name at the same time.

I tried to understand the file upload process in the Django source but
there was too much meta magic for my brain. However, it seems that the
current documentation doesn't tell the whole story. It seems, that
there is a save_FOO_file() in addition to the documentation tree
get_FOO_xxx methods... My guess is that manipulators.py is responsible
for saving the uploaded file. ... Wait, I think, _save_FIELD_file()
will eventually save the file and yes, that while loop is obviously
not threadsafe! So I need to set the filename myself. But how?

-- 
Stefan Matthias Aust

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



Unicode chars in CharField

2007-07-19 Thread Chris Hoeppner
Hi there!

I'm getting this whenever I try to use some non-ascii character in a
CharField. I know this has something to do with the unicode() function,
but my python knowledge doesn't get me that far.

Thanks everyone!

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in
get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File
"/usr/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py"
in _checklogin
  55. return view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/views/decorators/cache.py"
in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File
"/usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py" in
add_stage
  263. LogEntry.objects.log_action(request.user.id,
ContentType.objects.get_for_model(model).id, pk_value,
force_unicode(new_object), ADDITION)
File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
force_unicode
  40. s = unicode(str(s), encoding, errors)

  UnicodeEncodeError at /admin/anuncios/entry/add/
  'ascii' codec can't encode character u'\xc1' in position 0: ordinal
not in range(128)



signature.asc
Description: OpenPGP digital signature


Re: Random IndexError

2007-07-19 Thread Niels

Well, that should be explained in 
http://www.djangoproject.com/documentation/contributing/#reporting-bugs

And after following the do's and avoiding the don'ts, you would
proceed at http://code.djangoproject.com/newticket

Best,

Niels

On Jul 19, 2:33 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> You're right, they was ending with '\r'. Should I file a ticket? How's
> that done? Never done it before.
>
> Niels escribió:
>
>
>
> > This might mean your sourcefile uses '\r' for newlines which isn't
> > handled correctly by django. If that's the case, this might be worth
> > filing a ticket, i think.
>
> > On Jul 19, 1:20 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> >> Hi there!
>
> >> I'm getting random IndexErrors. This has risen when loading
> >> templatetags, or just when applying a filter to a var in a template. The
> >> traceback doesn't mean much to me, and I'm pretty unsure what may have
> >> been the reason for this error.
>
> >> Any help?
>
> >> Mod_python error: "PythonHandler django.core.handlers.modpython"
>
> >> Traceback (most recent call last):
>
> >>   File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line
> >> 299, in HandlerDispatch
> >> result = object(req)
>
> >>   File
> >> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
> >> line 178, in handler
> >> return ModPythonHandler()(req)
>
> >>   File
> >> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
> >> line 151, in __call__
> >> response = self.get_response(request)
>
> >>   File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py",
> >> line 111, in get_response
> >> return debug.technical_500_response(request, *sys.exc_info())
>
> >>   File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
> >> 104, in technical_500_response
> >> pre_context_lineno, pre_context, context_line, post_context =
> >> _get_lines_from_file(filename, lineno, 7, loader, module_name)
>
> >>   File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
> >> 209, in _get_lines_from_file
> >> context_line = source[lineno].strip('\n')
>
> >> IndexError: list index out of range
>
> >>  signature.asc
> >> 1KDownload
>
> > >
>
>
>  signature.asc
> 1KDownload- 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: Random IndexError

2007-07-19 Thread Chris Hoeppner
You're right, they was ending with '\r'. Should I file a ticket? How's
that done? Never done it before.

Niels escribió:
> This might mean your sourcefile uses '\r' for newlines which isn't
> handled correctly by django. If that's the case, this might be worth
> filing a ticket, i think.
> 
> On Jul 19, 1:20 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
>> Hi there!
>>
>> I'm getting random IndexErrors. This has risen when loading
>> templatetags, or just when applying a filter to a var in a template. The
>> traceback doesn't mean much to me, and I'm pretty unsure what may have
>> been the reason for this error.
>>
>> Any help?
>>
>> Mod_python error: "PythonHandler django.core.handlers.modpython"
>>
>> Traceback (most recent call last):
>>
>>   File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line
>> 299, in HandlerDispatch
>> result = object(req)
>>
>>   File
>> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
>> line 178, in handler
>> return ModPythonHandler()(req)
>>
>>   File
>> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
>> line 151, in __call__
>> response = self.get_response(request)
>>
>>   File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py",
>> line 111, in get_response
>> return debug.technical_500_response(request, *sys.exc_info())
>>
>>   File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
>> 104, in technical_500_response
>> pre_context_lineno, pre_context, context_line, post_context =
>> _get_lines_from_file(filename, lineno, 7, loader, module_name)
>>
>>   File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
>> 209, in _get_lines_from_file
>> context_line = source[lineno].strip('\n')
>>
>> IndexError: list index out of range
>>
>>  signature.asc
>> 1KDownload
> 
> 
> --~--~-~--~~~---~--~~
> 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
> -~--~~~~--~~--~--~---
> 




signature.asc
Description: OpenPGP digital signature


Re: Random IndexError

2007-07-19 Thread Niels

This might mean your sourcefile uses '\r' for newlines which isn't
handled correctly by django. If that's the case, this might be worth
filing a ticket, i think.

On Jul 19, 1:20 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> I'm getting random IndexErrors. This has risen when loading
> templatetags, or just when applying a filter to a var in a template. The
> traceback doesn't mean much to me, and I'm pretty unsure what may have
> been the reason for this error.
>
> Any help?
>
> Mod_python error: "PythonHandler django.core.handlers.modpython"
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line
> 299, in HandlerDispatch
> result = object(req)
>
>   File
> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
> line 178, in handler
> return ModPythonHandler()(req)
>
>   File
> "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
> line 151, in __call__
> response = self.get_response(request)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py",
> line 111, in get_response
> return debug.technical_500_response(request, *sys.exc_info())
>
>   File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
> 104, in technical_500_response
> pre_context_lineno, pre_context, context_line, post_context =
> _get_lines_from_file(filename, lineno, 7, loader, module_name)
>
>   File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
> 209, in _get_lines_from_file
> context_line = source[lineno].strip('\n')
>
> IndexError: list index out of range
>
>  signature.asc
> 1KDownload


--~--~-~--~~~---~--~~
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: newforms and models unique=True validation

2007-07-19 Thread stereoit

+1 it works, perfect (I just change the self.cleaned_data into
self.clean_data). Now when you showed me the trick I was able to track
it in docs as well, unfortunately I'm using 0.96 and
http://www.djangoproject.com/documentation/0.96/newforms/ is much
different to http://www.djangoproject.com/documentation/newforms/

Is there anything coming into django that would provide validation of
unique=True out of the box?

Anyway thank you very much


On Jul 18, 8:42 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> You want to create a BaseForm to specify in your form_for_model call.
> You could do something like:
>
> from django import newforms as forms
>
> class MyBaseForm(forms.BaseForm):
>   def clean_myfield(self):
> if
> MyModel.objects.filter(myfield=self.cleaned_data['myfield']).count():
>   raise forms.ValidationError('some error message')
>
> MyForm = forms.form_for_model(MyModel, form=MyBaseForm)
>
> 
> Nathan Ostgard
>
> On Jul 18, 7:06 am, stereoit <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I have model with field that has attribute unique set to True. I know
> > newforms are not able to handle such a validation as this is DB
> > related. However I read at newforms doc page that it is possible to
> > provide method called clean_() that can do custom validation.
> > My problem is that method is supposed to access the data via
> > self.cleaned_date and I create form by using form_for_model hence I do
> > not know how to write such a method.
>
> > Can anyone point me to right direction or best practice? Handling this
> > at form.save() seem not right to me.
>
> > My idea was to create custom validation method that would try tu pull
> > object from DB with  set to same as in
> > cleaned_data['fieldname'] and if it exists it would raise
> > ValidationError. But I have no clue how to do that at the moment.


--~--~-~--~~~---~--~~
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 multiple django versions on mod_python

2007-07-19 Thread Niels

In case the problem lies in manipulating the python path inside a
 section, perhaps you could play another trick to load the
different versions of django. I am doing as follows, though, not with
Location tags but in VirtualHost sections, and it works for me:

Somewhere on the python path, there is a subdirectory,
django_versions. In there, several django trees exist. On the same
level as django_versions subdirectory i have wrapper modules, one for
each django version i need, named django_trunk.py, django_096.py, and
so on. The wrapper code reads:

##
import imp, os
django = imp.load_module(
"django",
*imp.find_module("django", [os.path.join(
os.path.dirname(__file__), "django_versions", "django-
trunk"
)] )
)
del imp, os

all together, the layout is:
/python-path/django_trunk.py
/python-path/django_someversion.py
/python-path/django_vresions/
/python-path/django_versions/django-trunk/django
/python-path/django_vresions/django-someversion/django

Note, there is no need to have an __init__.py inside django_versions,
since the path munging is done in the wrapper module, where the
required django module is loaded from a temporary fixed path set up
dynamically.

To use this, a second wrapper file is needed for the mod_python
handler. This one is named django_trunk_handler.py and should be put
somewhere on your python path as well:

import django_trunk as django
from django.core.handlers.modpython import handler

And analogous to that, you can have django_someversion_handler.py:

import django_someversion as django
from django.core.handlers.modpython import handler

Now, in httpd.conf, this comes together:

  ...
  PythonHandler django_trunk_handler
  PythonInterpreter version1


  ...
  PythonHandler django_someversion_handler
  PythonInterpreter version2


Finally, you might want to have different manage.py stubs with an
extra first line importing the right django module as django into the
namespace to get going.

Best regards...

Niels

On Jul 19, 12:46 pm, oggie rob <[EMAIL PROTECTED]> wrote:
> Thanks for your help, Russ. I updated mod_python (which was probably
> overdue anyway), but that didn't fix the problem. I've been looking
> for other signs but nothing has surfaced yet.
> If anybody else can recall a similar experience, please let me know!
>
>  -rob
>
> On Jul 18, 9:07 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On 7/19/07, oggie rob <[EMAIL PROTECTED]> wrote:
>
> > > Please, if you've seen the same issue or have any helpful ideas to try
> > > to stop the error, let me know.
>
> > I think I've seen the same problem (or, at least, an analogous one).
> > Unfortunately, I can't provide much by way of helpful debug or
> > solution - the sysadmin that identified the problem for us isn't
> > around for me to ask him for more details.
>
> > As I recall, the problem was mod_python. Older versions of mod_python
> > had some sort of issue with caching python instances. As a result, if
> > you deployed two different versions of Django, the version of Django
> > that was provided to a given request was determined by the thread that
> > served the request. If the first request served by a thread used the
> > old version of Django, that was the version that was used for all
> > subsequent requests on that thread, regardless of the version that was
> > required to satisfy the request.
>
> > I believe we fixed the problem by updating mod_python, but I'm not
> > completely certain on that.
>
> > I know that this is all vague and ambiguous help - sorry I can't be
> > more specific.
>
> > Yours,
> > Russ Magee %-)- 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
-~--~~~~--~~--~--~---



Random IndexError

2007-07-19 Thread Chris Hoeppner
Hi there!

I'm getting random IndexErrors. This has risen when loading
templatetags, or just when applying a filter to a var in a template. The
traceback doesn't mean much to me, and I'm pretty unsure what may have
been the reason for this error.

Any help?

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

  File
"/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
line 178, in handler
return ModPythonHandler()(req)

  File
"/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py",
line 151, in __call__
response = self.get_response(request)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py",
line 111, in get_response
return debug.technical_500_response(request, *sys.exc_info())

  File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
104, in technical_500_response
pre_context_lineno, pre_context, context_line, post_context =
_get_lines_from_file(filename, lineno, 7, loader, module_name)

  File "/usr/lib/python2.5/site-packages/django/views/debug.py", line
209, in _get_lines_from_file
context_line = source[lineno].strip('\n')

IndexError: list index out of range



signature.asc
Description: OpenPGP digital signature


Re: Problem with multiple django versions on mod_python

2007-07-19 Thread oggie rob

Thanks for your help, Russ. I updated mod_python (which was probably
overdue anyway), but that didn't fix the problem. I've been looking
for other signs but nothing has surfaced yet.
If anybody else can recall a similar experience, please let me know!

 -rob

On Jul 18, 9:07 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 7/19/07, oggie rob <[EMAIL PROTECTED]> wrote:
>
>
>
> > Please, if you've seen the same issue or have any helpful ideas to try
> > to stop the error, let me know.
>
> I think I've seen the same problem (or, at least, an analogous one).
> Unfortunately, I can't provide much by way of helpful debug or
> solution - the sysadmin that identified the problem for us isn't
> around for me to ask him for more details.
>
> As I recall, the problem was mod_python. Older versions of mod_python
> had some sort of issue with caching python instances. As a result, if
> you deployed two different versions of Django, the version of Django
> that was provided to a given request was determined by the thread that
> served the request. If the first request served by a thread used the
> old version of Django, that was the version that was used for all
> subsequent requests on that thread, regardless of the version that was
> required to satisfy the request.
>
> I believe we fixed the problem by updating mod_python, but I'm not
> completely certain on that.
>
> I know that this is all vague and ambiguous help - sorry I can't be
> more specific.
>
> Yours,
> Russ Magee %-)


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



Request Context and Generic Views

2007-07-19 Thread Chris Hoeppner
Hi there!

How does it exactly work when I want a RequestContext to be used in a
generic view. There's the context_processors key in the dict you gotta
pass it, but "A list of template-context processors to apply to the
view’s template" doesn't really mean much to me, and even less after
giving it a "list" and seeing python complain about callables ;)

Might anyone give me an example of a dict I might pass a generic view?

Thanks guys!



signature.asc
Description: OpenPGP digital signature


Re: Bulk data upload

2007-07-19 Thread Chris Hoeppner
This approach does sound really interesting, and is pretty close to what
I've been planning.

I wonder if I might have a look at that ExcelImport class :)

Toby Dylan Hocking escribió:
>> What about CSV?  You can export from Excel as CSV pretty easily and it's a 
>> fairly easy format to parse in python...
> 
> Either that or tab-delimited text. I have a django app that does bulk data 
> upload from the admin interface according to the following protocol.
> 
> 1. Users make their bulk upload data tables in excel.
> 
> 2. They log onto the Django admin site, where I have a special ExcelImport 
> model set up --- it just has a TextField where the data goes.
> 
> 3. They copy the entire table from excel and paste it in the TextField, 
> then click Save.
> 
> 4. I have a custom save() method for the ExcelImport class that processes 
> the data and creates the related objects.
> 
>> Thanks,
>>
>> Dave
>>
>> -- 
>> David Reynolds
>> [EMAIL PROTECTED]
>>
>>
> 
> --~--~-~--~~~---~--~~
> 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
> -~--~~~~--~~--~--~---
> 




signature.asc
Description: OpenPGP digital signature


meta path_info, yet again

2007-07-19 Thread Bram - Smartelectronix

hello everone,



a while back I mailed about a problem with path_info. Basically I'm 
having the same problem and the previous fix we discussed no longer works.

I'm getting this behavior:

http://www.com/a/ => path_info = "/a"
http://www.com/a/b/ => path_info = "/b"
http://www.com/a/b/c/ => path_info = "/b/c/"

Apache 2.2.4
mod_python 3.3.1

The previous time I had this error we were able to fix it by removing 
DocumentRoot from the apache config, but this time that's not really 
working.

This is the virtual-host section with some small obfuscations:

( settings.py is in /opt/splice/pysplice/settings.py )


 ServerName xx.splicemusic.com
 ServerAlias beard
 AcceptPathInfo On
 
 AuthName "x"
 AuthUserFile /x
 AuthType Basic
 require valid-user
 Order allow,deny
 Allow from All

 PythonInputFilter tramline.core::inputfilter TRAMLINE_INPUT
 PythonOutputFilter tramline.core::outputfilter TRAMLINE_OUTPUT
 SetInputFilter TRAMLINE_INPUT
 SetOutputFilter TRAMLINE_OUTPUT
 PythonOption tramline_path /tmp/tramline/

 SetHandler python-program
 PythonHandler django.core.handlers.modpython
 SetEnv DJANGO_SETTINGS_MODULE pysplice.settings
 SetEnv LD_LIBRARY_PATH /usr/local/lib:/usr/local/pgsql/lib
 PythonDebug On
 PythonPath "['/opt/splice/'] + sys.path"
 
 
 Satisfy Any
 Allow from All
 
 
 Satisfy Any
 Allow from All
 
 
 Satisfy Any
 Allow from All
 
 Alias /media /opt/splice/pysplice/media
  # for some things we need media served by apache!
 SetHandler None
 Satisfy Any
 Allow from All
 



I'm becoming pretty desperate for a fix as we're slowly but surely 
converting this server to our "live" server.


thanks a lot,


  - bram

PS: http://www.splicemusic.com is moving to django. Yippy :-)

--~--~-~--~~~---~--~~
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: context processor question

2007-07-19 Thread yml

Hello,

Here it is the part of the documentation you are looking for:
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext
This is an extract of the part that you are looking:
If you're using Django's render_to_response() shortcut to populate
a template with the contents of a dictionary, your template will be
passed a Context instance by default (not a RequestContext). To use a
RequestContext in your template rendering, pass an optional third
argument to render_to_response(): a RequestContext instance. Your code
might look like this:

def some_view(request):
# ...
return render_to_response('my_template.html',
  my_data_dictionary,
 
context_instance=RequestContext(request))

I hope that help.


On Jul 19, 6:45 am, james_027 <[EMAIL PROTECTED]> wrote:
> Hi Jeremy,
>
> I am a bit lost ... where do I apply that? Isn't that I just call the
> variable name/dict key in the template?
>
> Thanks
> james
>
> On Jul 19, 11:18 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
>
> > On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote:
> > ...
>
> > > the commonly use data will automatically available, do I get it right?
>
> > Yes.  Just keep in mind that you need to use RequestContext rather
> > than Context in order for context processors to be applied.


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



  1   2   >