TEMPLATE_DIRS problem -windows

2008-05-21 Thread emy_66

I'm doing the tutorials and am up to part 2 where we can customise
admin look and feel - I cannot get django to read my customise
template file by editing TEMPLATE_DIRS. I am working in windows using
the lastest dev version of django.

I notice that even if I place a path that does not exist into
TEMPLATE_DIRS I do not get an error message. I think am calling the
right settings.py.

Many thanks,
Emily
--~--~-~--~~~---~--~~
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: Form Fields Question

2008-05-21 Thread Chris

> Well if you are using AJAX it's necessary to have the id of an html

That is not necessarily true! There are lots of ways for a programmer
to access their elements and update them through ajax. You should
checkout mootools.net.





On May 21, 7:40 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> On May 21, 2:05 pm, Chris <[EMAIL PROTECTED]> wrote:
>
> > I wasn't saying that django was performing bad practice, I was just
> > curious as to why id over classes.
>
> > Thanks for the input.
>
> Well if you are using AJAX it's necessary to have the id of an html
> element set, so that the javascript function would know which element
> to update. I find them pretty useful
--~--~-~--~~~---~--~~
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: Making django admin change-list case sensitive

2008-05-21 Thread Karen Tracey
On Wed, May 21, 2008 at 6:03 AM, cerea <[EMAIL PROTECTED]> wrote:

> Hi, is there a simple way to make the change-lists in django's admin
> case sensitive? Right now the change_list_results.html admin template
> shows all the items in lowercase, I would like it to not display
> everything in lowercase, but I can't seem to figure it out. Thanks!


What, exactly, is showing up in lower case?  Much of what is shown on a
change list page is controlled by your model definitions, so specifics of
your models and what you are seeing in lower case that you would like to be
in mixed case would help in answering your question.

Karen

--~--~-~--~~~---~--~~
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: json/xml serializer.serialize UTF-8 Error

2008-05-21 Thread XeboyZou
For XML is works fine. BUT not JSON.
--
def left(request):

 query = Talk.objects.filter(side=2, talk_topic
=1).order_by('pub_date')[0:30]
 json_serializer = serializers.get_serializer("json")()
 data = json_serializer.serialize(query,
ensure_ascii=False,fields=('content'))
 return HttpResponse(data, "charset=UTF-8")
-
UnicodeEncodeError at /Talk/Left 'ascii' codec can't encode characters in
position 1-2: ordinal not in range(128)
Unicode error hint

The string that could not be encoded/decoded was: *"不好"*
---


On Wed, May 21, 2008 at 4:11 PM, Russell Keith-Magee <[EMAIL PROTECTED]>
wrote:

>
> On Wed, May 21, 2008 at 3:15 PM, ERic ZoU <[EMAIL PROTECTED]> wrote:
> >
> > It works in XML, but not JSON
> >
> > On May 21, 2:48 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
> >>  query = Talk.objects.filter(side=2, talk_topic
> >> =1).order_by('pub_date')[0:30]
> >>  data =  serializers.serialize('json', query, ensure_ascii=False,
> >> fields=('content'))
> >>  return HttpResponse(data, "charset=UTF-8")
> >>
> >> On May 21, 2:39 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
> >>
> >> > Exception Value:'ascii' codec can't encode characters in
> position
> >> > 1-2: ordinal not in range(128)
> >>
> >> > My content is UTF-8 encode. Seems doesn't work.
>
> It works fine. You need to read the documentation.
>
> http://www.djangoproject.com/documentation/serialization/#id1
>
> 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
-~--~~~~--~~--~--~---



possible bug in template tags

2008-05-21 Thread Jonathan Lukens

I'm encountering a problem using ContentType.model_class() within a
template tag.  The tag parses an “.“ argument and
then tries to get the model object, like this: http://dpaste.com/51963/

When I place “{% magic_archives . %}“ in a template,
I get the following:

(u'', u'', '', "")

So everything is being parsed correctly because I can get the
arguments back out, ContentType is imported correctly, because I can
look up the content type. Only .model_class() fails. Is this 1) me not
seeing a typo in two lines I've read repeatedly, 2) something not
spelled out in the documentation that I don't understand, or 3) a bug?
--~--~-~--~~~---~--~~
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: Authenticated user from models.py

2008-05-21 Thread Juanjo Conti

Thanks!

http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser is what I 
was looking for.

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

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



Re: load external xml and css with varibles?

2008-05-21 Thread Eric Abrahamsen


On May 22, 2008, at 5:15 AM, sebey wrote:

> that script you told me to do how do i get it running though the admin
> interface?

It's not going to work through the admin interface, you'll have to ssh  
into your server, or use some other interface provided by your  
webhost, to put the script in place and set up a cron job.

>
>
> On May 21, 4:25 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>> On May 21, 2008, at 11:07 PM, sebey wrote:
>>
>>
>>
 Use Feedparser (http://www.feedparser.org/) in a stand-alone  
 script,
 run by a cron job, that checks feeds for updates a few times per  
 day.
 Have a django model that represents rss feeds and feed items, and
 then
 import the necessary stuff at the top of your feed parser script so
 that you can save new feed items to the database as they come in.
 Once
 the feed items are in your database, you can use them as normal in
 the
 rest of your django app.
>>> I  am new to web development how would I go about all of this?
>>
>> To get a standalone script to run under your proper django
>> environment, put this at the top:
>>
>> from django.core.management import setup_environ
>> import sys
>> sys.path.append('/path/to/your/project')
>> from yourproject import settings
>> setup_environ(settings)
>>
>> Then you'll be able to import your feed models, create new instances,
>> and save them, all within this script.
>>
>> Next, Google for how to set up a cron job, read the feedparser
>> documentation for how to use feedparser, and you're good to go!
>>
>> E
>>
>>
>>
>>> On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
 On May 21, 2008, at 6:58 PM, sebey wrote:
>>
> I know css does not not have any variables but I was thinking that
> python/django could look though the css file and have
> background-color:{{insert python varible here}}
>>
> but I did consider that first about copy and pasting a style sheet
> and
> just change the background but I never thought about inheritance  
> so
> thank you
>>
 Why don't you just use an inline 

Re: Authenticated user from models.py

2008-05-21 Thread Patrick J. Anderson

On Wed, 21 May 2008 20:33:35 -0500, James Bennett wrote:

> On Wed, May 21, 2008 at 8:23 PM, Patrick J. Anderson
> <[EMAIL PROTECTED]> wrote:
>> Passing a Request object should work in application views, but what if
>> one wants to capture that information on every save() call, including
>> in the admin?
>>
>> What would be an elegant and beautiful approach to solving this
>> problem?
> 
> Well, newforms-admin is being written to make the HttpRequest object
> available as an argument to the various ModelAdmin methods, which means
> that when you set up your own custom admin you can do pretty much
> anything you want.
> 
> Which will make a lot of people happy, and let them go right on building
> workflows that don't make a lot of sense (if somebody's a trusted
> administrator, how come you don't trust them to fill in a field
> properly?).

This is probably not an example of how to do this, but it saves me time 
since I only have to do it once and in a single place on Model instance 
save(). 

I use admin, but my clients want many pseudo-admin interfaces for various 
reasons and various levels of trust.

So for example, in my models I have been doing something similar to this:

class Item(models.Model):
...
creator = models.ForeignKey(User, 
related_name = 'items_created',
editable = False)
time_created = models.DateTimeField(editable = False)
editor = models.ForeignKey(User,
related_name = 'items_modified',
editable = False)
time_modified = models.DateTimeField(editable = False)

def save(self):
user,now = threadlocals.get_current_user(),datetime.now()
if not self.id:
self.creator, self.time_created = user, now
self.editor, self.time_modified = user, now
super(Item, self).save()

I know that probably I should have a Log model somewhere for all this 
stuff, but this is simple enough for me and works.

I'm glad that there'll be a way to do stuff like this. In the meantime, 
I'm always ready to learn something new and better.


--~--~-~--~~~---~--~~
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: Authenticated user from models.py

2008-05-21 Thread James Bennett

On Wed, May 21, 2008 at 8:23 PM, Patrick J. Anderson
<[EMAIL PROTECTED]> wrote:
> Passing a Request object should work in application views, but what if
> one wants to capture that information on every save() call, including in
> the admin?
>
> What would be an elegant and beautiful approach to solving this problem?

Well, newforms-admin is being written to make the HttpRequest object
available as an argument to the various ModelAdmin methods, which
means that when you set up your own custom admin you can do pretty
much anything you want.

Which will make a lot of people happy, and let them go right on
building workflows that don't make a lot of sense (if somebody's a
trusted administrator, how come you don't trust them to fill in a
field properly?).


-- 
"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: Authenticated user from models.py

2008-05-21 Thread Patrick J. Anderson

On Wed, 21 May 2008 19:46:20 -0500, James Bennett wrote:

> On Wed, May 21, 2008 at 7:35 PM, Juanjo Conti <[EMAIL PROTECTED]> wrote:
>> Ugly. Is this the only way?
> 
> Sigh.
> 
> No, "ugly" is magical global variables and things that appear out of
> thin air.
> 
> Code that's clean and understandable, where you can clearly see where
> everything comes from and what it's doing, is beautiful.

Passing a Request object should work in application views, but what if 
one wants to capture that information on every save() call, including in 
the admin?

What would be an elegant and beautiful approach to solving this problem?


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



Re: Problems setting up test Django server

2008-05-21 Thread Jason

And indeed, throwing in a "PythonInterpreter site" in my port 80
VirtualHost, & a PythonInterpreter testsite in my port 8080
VirtualHost solved all my problems.  You guys are the best!

On May 21, 5:54 pm, Jason <[EMAIL PROTECTED]> wrote:
> Awesome!  Thanks for all the advice, guys.  Will try the
> PythonInterpreter trick & get back to you.
>
> Just FYI, I'd deliberately ignored that part of the documentation
> since it specifies:
>
> "If you need to put two Django installations within the same
> VirtualHost, you’ll need to take a special precaution to ensure
> mod_python’s cache doesn’t mess things up. Use the PythonInterpreter
> directive to give different  directives separate
> interpreters"
>
> ...and my two Django installations are very much in different
> VirtualHosts.  So maybe the docs could use a bit of revision there...?
>
> Also, I'd very much like to try the mod_wsgi stuff, so if anyone has a
> good pointer to docs/tutorials regarding that, I'd appreciate.  Though
> I suspect I'll have *something* googled w/in minutes of pressing
> "send" here, so no worries...
>
> Thanks again!
>
> On May 21, 4:52 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
>
> > On May 22, 9:41 am, Jason <[EMAIL PROTECTED]> wrote:
>
> > > On May 21, 4:17 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > > > On May 21, 4:10 pm, Jason <[EMAIL PROTECTED]> wrote:
>
> > > > > Hey folks--
>
> > > > > I'm trying to set up a mirror instance of Django on our webserver,
> > > > > having grown tired of bringing our whole site down every time I'm
> > > > > debugging new code.
>
> > > > Why aren't you debugging on your local machine?
>
> > > a) thought it would be safer, environment-wise, to actually test on
> > > the same machine, if possible, & b) don't really have a local machine
> > > to test on.  Could set up something on my Mac, but that would be
> > > pretty radically different.  Have an Ubuntu-converted PC, but it's
> > > also pretty janky, & setting it up to exactly mirror our remote server
> > > would be a daunting proposition.  And basically, I'd just rather do it
> > > this way if I could.
>
> > > > > I've got an Apache VirtualHost set up on port 8080 that more or less
> > > > > mirrors our website.   And I've installed a separate instance of
> > > > > Django to work with it.
>
> > > > Are you listening on both ports? Check httpd.conf and make sure it has
> > > > something like this:
>
> > > > Listen 80
> > > > Listen 8080
>
> > > Oh yeah, that's all taken care of.  The "test site" is working fine on
> > > port 8080, separate from the regular port 80 site.  My problem is that
> > > if I change the Django settings exclusively on the port 8080
> > > VirtualHost (as per my last post), it also changes my main sites
> > > settings & throws me into the empty new Django install.  Hope that's
> > > clear...?
>
> > In mod_python, a single Python interpreter instance is used for a
> > virtual host. This doesn't take into consideration the port number. As
> > such, you would be sharing the same Python interpreter for all Django
> > instances on the same virtual host.
>
> > To avoid this, use the PythonInterpreter directive from mod_python to
> > designate that each instance should run in a separate interpreter.
>
> > Better still perhaps, use mod_wsgi. Run your main live Django instance
> > in embedded mode (like with mod_python), but delegate your test
> > instance to a separate process(es) using mod_wsgi daemon mode.
>
> > This has the benefit that they do not run in the same process and thus
> > will not interfere with each other. More importantly, mod_wsgi 2.0
> > daemon mode will recycle the daemon processes and reload your
> > application, without having to restart the whole of Apache, by simply
> > touching (modifying time stamp) the WSGI script file which is the
> > entry point for your application.
>
> > Thus you achieve your aim of using same machine setup, but of being
> > able to restart Django instance without restarting whole of Apache.
>
> > 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: Problems setting up test Django server

2008-05-21 Thread Jason

Awesome!  Thanks for all the advice, guys.  Will try the
PythonInterpreter trick & get back to you.

Just FYI, I'd deliberately ignored that part of the documentation
since it specifies:

"If you need to put two Django installations within the same
VirtualHost, you’ll need to take a special precaution to ensure
mod_python’s cache doesn’t mess things up. Use the PythonInterpreter
directive to give different  directives separate
interpreters"

...and my two Django installations are very much in different
VirtualHosts.  So maybe the docs could use a bit of revision there...?

Also, I'd very much like to try the mod_wsgi stuff, so if anyone has a
good pointer to docs/tutorials regarding that, I'd appreciate.  Though
I suspect I'll have *something* googled w/in minutes of pressing
"send" here, so no worries...

Thanks again!

On May 21, 4:52 pm, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On May 22, 9:41 am, Jason <[EMAIL PROTECTED]> wrote:
>
>
>
> > On May 21, 4:17 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > > On May 21, 4:10 pm, Jason <[EMAIL PROTECTED]> wrote:
>
> > > > Hey folks--
>
> > > > I'm trying to set up a mirror instance of Django on our webserver,
> > > > having grown tired of bringing our whole site down every time I'm
> > > > debugging new code.
>
> > > Why aren't you debugging on your local machine?
>
> > a) thought it would be safer, environment-wise, to actually test on
> > the same machine, if possible, & b) don't really have a local machine
> > to test on.  Could set up something on my Mac, but that would be
> > pretty radically different.  Have an Ubuntu-converted PC, but it's
> > also pretty janky, & setting it up to exactly mirror our remote server
> > would be a daunting proposition.  And basically, I'd just rather do it
> > this way if I could.
>
> > > > I've got an Apache VirtualHost set up on port 8080 that more or less
> > > > mirrors our website.   And I've installed a separate instance of
> > > > Django to work with it.
>
> > > Are you listening on both ports? Check httpd.conf and make sure it has
> > > something like this:
>
> > > Listen 80
> > > Listen 8080
>
> > Oh yeah, that's all taken care of.  The "test site" is working fine on
> > port 8080, separate from the regular port 80 site.  My problem is that
> > if I change the Django settings exclusively on the port 8080
> > VirtualHost (as per my last post), it also changes my main sites
> > settings & throws me into the empty new Django install.  Hope that's
> > clear...?
>
> In mod_python, a single Python interpreter instance is used for a
> virtual host. This doesn't take into consideration the port number. As
> such, you would be sharing the same Python interpreter for all Django
> instances on the same virtual host.
>
> To avoid this, use the PythonInterpreter directive from mod_python to
> designate that each instance should run in a separate interpreter.
>
> Better still perhaps, use mod_wsgi. Run your main live Django instance
> in embedded mode (like with mod_python), but delegate your test
> instance to a separate process(es) using mod_wsgi daemon mode.
>
> This has the benefit that they do not run in the same process and thus
> will not interfere with each other. More importantly, mod_wsgi 2.0
> daemon mode will recycle the daemon processes and reload your
> application, without having to restart the whole of Apache, by simply
> touching (modifying time stamp) the WSGI script file which is the
> entry point for your application.
>
> Thus you achieve your aim of using same machine setup, but of being
> able to restart Django instance without restarting whole of Apache.
>
> 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: Authenticated user from models.py

2008-05-21 Thread [EMAIL PROTECTED]

Make user a parameter on the new save method and pass it to the save
method wherever you call save in your views.

On May 21, 6:58 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote:
> I can access the request from my views, but how can I acces the
> request from models.py?
>
> I am redefining a Model's save method.
> --
> Juanjo Conti
--~--~-~--~~~---~--~~
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: Authenticated user from models.py

2008-05-21 Thread Juanjo Conti

I can access the request from my views, but how can I acces the
request from models.py?

I am redefining a Model's save method.
-- 
Juanjo Conti

--~--~-~--~~~---~--~~
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: Problems setting up test Django server

2008-05-21 Thread Graham Dumpleton

On May 22, 9:41 am, Jason <[EMAIL PROTECTED]> wrote:
> On May 21, 4:17 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > On May 21, 4:10 pm, Jason <[EMAIL PROTECTED]> wrote:
>
> > > Hey folks--
>
> > > I'm trying to set up a mirror instance of Django on our webserver,
> > > having grown tired of bringing our whole site down every time I'm
> > > debugging new code.
>
> > Why aren't you debugging on your local machine?
>
> a) thought it would be safer, environment-wise, to actually test on
> the same machine, if possible, & b) don't really have a local machine
> to test on.  Could set up something on my Mac, but that would be
> pretty radically different.  Have an Ubuntu-converted PC, but it's
> also pretty janky, & setting it up to exactly mirror our remote server
> would be a daunting proposition.  And basically, I'd just rather do it
> this way if I could.
>
>
>
> > > I've got an Apache VirtualHost set up on port 8080 that more or less
> > > mirrors our website.   And I've installed a separate instance of
> > > Django to work with it.
>
> > Are you listening on both ports? Check httpd.conf and make sure it has
> > something like this:
>
> > Listen 80
> > Listen 8080
>
> Oh yeah, that's all taken care of.  The "test site" is working fine on
> port 8080, separate from the regular port 80 site.  My problem is that
> if I change the Django settings exclusively on the port 8080
> VirtualHost (as per my last post), it also changes my main sites
> settings & throws me into the empty new Django install.  Hope that's
> clear...?

In mod_python, a single Python interpreter instance is used for a
virtual host. This doesn't take into consideration the port number. As
such, you would be sharing the same Python interpreter for all Django
instances on the same virtual host.

To avoid this, use the PythonInterpreter directive from mod_python to
designate that each instance should run in a separate interpreter.

Better still perhaps, use mod_wsgi. Run your main live Django instance
in embedded mode (like with mod_python), but delegate your test
instance to a separate process(es) using mod_wsgi daemon mode.

This has the benefit that they do not run in the same process and thus
will not interfere with each other. More importantly, mod_wsgi 2.0
daemon mode will recycle the daemon processes and reload your
application, without having to restart the whole of Apache, by simply
touching (modifying time stamp) the WSGI script file which is the
entry point for your application.

Thus you achieve your aim of using same machine setup, but of being
able to restart Django instance without restarting whole of Apache.

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: Problems setting up test Django server

2008-05-21 Thread Jashugan

> > Are you listening on both ports? Check httpd.conf and make sure it has
> > something like this:
>
> > Listen 80
> > Listen 8080
>
> Oh yeah, that's all taken care of.  The "test site" is working fine on
> port 8080, separate from the regular port 80 site.  My problem is that
> if I change the Django settings exclusively on the port 8080
> VirtualHost (as per my last post), it also changes my main sites
> settings & throws me into the empty new Django install.  Hope that's
> clear...?

Perhaps setting them to different Python Interpreters as described
here:

http://www.djangoproject.com/documentation/modpython/#multiple-django-installations-on-the-same-apache

--~--~-~--~~~---~--~~
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: Authenticated user from models.py

2008-05-21 Thread Jashugan

On May 21, 4:31 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote:

> How can I access this information from the code?

It's in the request: 
http://www.djangoproject.com/documentation/authentication/#authentication-in-web-requests
--~--~-~--~~~---~--~~
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: Forms from Database Tables with choice selects.

2008-05-21 Thread Adam Gomaa

Lance, it's also not clear to me what exactly you need. Are you using
ModelForm? If not, what do you mean by the 'auto generated' form? I
think I have a rough idea what you're looking for, but a few more details
would go a long way.

Adam

On Wed, May 21, 2008 at 3:30 PM, Lance F. Squire <[EMAIL PROTECTED]> wrote:
>
> I'm trying to make a Form where 3 people need to be inputed. All three
> need to have a Title.(EG. Mr. Mrs. etc.)
>
> I tried making the Title fields in the database be a key to a table of
> title selections. The sql generation had no trouble with that, but the
> Form generator doesn't like it at all...
>
> I had them as character fields, but couldn't figure out how to get
> them to become select/choice fields after the form was auto generated
> from the table, before the view...
>
> I'm new to Django. Played with Rails some, but mostly work in Perl/
> Postgres
>
> Also looked at having the people in separate tables, but it didn't
> seem practical either from a filling in data point or a rendering/
> parching the form point.
>
> Thanks for any help and/or pointers.
> Lance
> >
>

--~--~-~--~~~---~--~~
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: Problems setting up test Django server

2008-05-21 Thread Jason

On May 21, 4:17 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> On May 21, 4:10 pm, Jason <[EMAIL PROTECTED]> wrote:
>
> > Hey folks--
>
> > I'm trying to set up a mirror instance of Django on our webserver,
> > having grown tired of bringing our whole site down every time I'm
> > debugging new code.
>
> Why aren't you debugging on your local machine?

a) thought it would be safer, environment-wise, to actually test on
the same machine, if possible, & b) don't really have a local machine
to test on.  Could set up something on my Mac, but that would be
pretty radically different.  Have an Ubuntu-converted PC, but it's
also pretty janky, & setting it up to exactly mirror our remote server
would be a daunting proposition.  And basically, I'd just rather do it
this way if I could.

>
> > I've got an Apache VirtualHost set up on port 8080 that more or less
> > mirrors our website.   And I've installed a separate instance of
> > Django to work with it.
>
> Are you listening on both ports? Check httpd.conf and make sure it has
> something like this:
>
> Listen 80
> Listen 8080

Oh yeah, that's all taken care of.  The "test site" is working fine on
port 8080, separate from the regular port 80 site.  My problem is that
if I change the Django settings exclusively on the port 8080
VirtualHost (as per my last post), it also changes my main sites
settings & throws me into the empty new Django install.  Hope that's
clear...?
--~--~-~--~~~---~--~~
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: Form Fields Question

2008-05-21 Thread Jashugan

On May 21, 2:05 pm, Chris <[EMAIL PROTECTED]> wrote:

> I wasn't saying that django was performing bad practice, I was just
> curious as to why id over classes.
>
> Thanks for the input.
>

Well if you are using AJAX it's necessary to have the id of an html
element set, so that the javascript function would know which element
to update. I find them pretty useful.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



IntegerField with choices raising an TypeError

2008-05-21 Thread Jashugan

Hello I have the following code in my model:

class SomeMode(models.Model):

CHOICES = [(1, '1'), (2, '2'), (3, 3), (4, '4'), (5, '5')]

score = models.IntegerField(choices=CHOICES)


When I change the score in the admin interface it throws this error:

an integer is required

I think this is a bug, but I have only been working with Django for
the last few days, so wasn't sure. I quickly searched the Trac ticket,
but didn't find any open tickets related to this. Is this expected
behavior?

Another thing is that Django actually saves the record to the
database, even though it gives me the error message.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Authenticated user from models.py

2008-05-21 Thread Juanjo Conti

I'd like to know which user has trigger the execution of some code in
models.py. For example, while redefining the save method of some
Model.

How can I access this information from the code?

-- 
Juanjo Conti

--~--~-~--~~~---~--~~
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: Problems setting up test Django server

2008-05-21 Thread Jashugan



On May 21, 4:10 pm, Jason <[EMAIL PROTECTED]> wrote:
> Hey folks--
>
> I'm trying to set up a mirror instance of Django on our webserver,
> having grown tired of bringing our whole site down every time I'm
> debugging new code.

Why aren't you debugging on your local machine?

> I've got an Apache VirtualHost set up on port 8080 that more or less
> mirrors our website.   And I've installed a separate instance of
> Django to work with it.
>

Are you listening on both ports? Check httpd.conf and make sure it has
something like this:

Listen 80
Listen 8080



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



Re: New to Django, having issues with first tutorial

2008-05-21 Thread Jashugan



On May 21, 3:07 pm, nobody <[EMAIL PROTECTED]> wrote:
> Thanks!
>

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



Problems setting up test Django server

2008-05-21 Thread Jason

Hey folks--

I'm trying to set up a mirror instance of Django on our webserver,
having grown tired of bringing our whole site down every time I'm
debugging new code.

I've got an Apache VirtualHost set up on port 8080 that more or less
mirrors our website.   And I've installed a separate instance of
Django to work with it.

Here's the Apache .conf settings for the main port 80 site:

SetHandler python-program
PythonPath "['/home/jason/killdjangokill'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
SetEnv PYTHON_EGG_CACHE /tmp
PythonDebug On
PythonAutoReload On


...and here's what I've set up for the port 8080 site:


SetHandler python-program
PythonPath "['/home/jason/testdjango'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite_test.settings
SetEnv PYTHON_EGG_CACHE /tmp
PythonDebug On
PythonAutoReload On


Problem is, when I reload Apache, the *main*, port 80, site gives me a
"Welcome to your first Django powered site!" message.  My guess is
that the 2nd PythonPath directive is just overriding the first one
(for the main site).  But heck if I know.  Anyone got any experience w/
this kind of thing?  From the documentation it seemed this would be
pretty straightforward, but maybe I'm going about it all wrong...?

Any & all help most gratefully appreciated!
--~--~-~--~~~---~--~~
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: Merging (threaded) FreeComments with Comments

2008-05-21 Thread [EMAIL PROTECTED]

There is currently work to do this, as well as other improvements to
contrib.comments, as a part of GSOC, you can see all the work here:
http://code.google.com/p/django-newcomments/

On May 21, 5:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I've been looking at the django implementation of freecomments and
> comments modules as well as the alternative threadedcomments module
> (http://code.google.com/p/django-threadedcomments/).
>
> One thing that hits me here is -- why are they always 2 different
> classes for user comments and anonymous comments? Do we have to choose
> which ones to use? Or is there an easy way to merge them but I just
> can't see it?
>
> What I would like to have is possibility for bot logged in and not
> logged in users to comment in a threaded way.
>
> If I'm asking for obvious stuff (perhaps I am, I have not done any
> django coding yet, just starting my first private project), please
> point me to the right thread/google page.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Merging (threaded) FreeComments with Comments

2008-05-21 Thread [EMAIL PROTECTED]

I've been looking at the django implementation of freecomments and
comments modules as well as the alternative threadedcomments module
(http://code.google.com/p/django-threadedcomments/).

One thing that hits me here is -- why are they always 2 different
classes for user comments and anonymous comments? Do we have to choose
which ones to use? Or is there an easy way to merge them but I just
can't see it?

What I would like to have is possibility for bot logged in and not
logged in users to comment in a threaded way.

If I'm asking for obvious stuff (perhaps I am, I have not done any
django coding yet, just starting my first private project), please
point me to the right thread/google page.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New to Django, having issues with first tutorial

2008-05-21 Thread nobody

Thanks!

I'm tired, typed something in wrong on the file in question. This is
pretty daunting at first, but I think I'll get it.

Appreciate the help.

On May 21, 5:59 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> On May 21, 2:51 pm, nobody <[EMAIL PROTECTED]> wrote:
>
> > I'm going through the "Writing your first Django app" tutorial on
> > djangoproject.com but I'm not getting very far, unfortunately.
>
> ok
>
> > >>> p = Poll.objects.get(pk=1)
> > >>> p.choice_set.create(choice='Not much', votes=0)
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "C:\Python25\lib\site-packages\django\db\models\base.py", line
> > 241, in __repr__
> >     return smart_str(u'<%s: %s>' % (self.__class__.__name__,
> > unicode(self)))
> >   File "C:\Python25\Lib\site-packages\django\testproject\..\testproject
> > \polls\models.py", line 19, in __unicod
> > e__
> >     return self.question
> > AttributeError: 'Choice' object has no attribute 'question'
>
> If you look at the Traceback, you will see that there is a problem
> with line 19 in models.py, which is helpfully printed out:
>
> return self.question
>
> Choice doesn't have an attribute called question, as described in the
> error. Perhaps another model in the same file has an attribute called
> question and you simply copied the code in the wrong place?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New to Django, having issues with first tutorial

2008-05-21 Thread Jashugan

On May 21, 2:51 pm, nobody <[EMAIL PROTECTED]> wrote:
> I'm going through the "Writing your first Django app" tutorial on
> djangoproject.com but I'm not getting very far, unfortunately.

ok

> >>> p = Poll.objects.get(pk=1)
> >>> p.choice_set.create(choice='Not much', votes=0)
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python25\lib\site-packages\django\db\models\base.py", line
> 241, in __repr__
>     return smart_str(u'<%s: %s>' % (self.__class__.__name__,
> unicode(self)))
>   File "C:\Python25\Lib\site-packages\django\testproject\..\testproject
> \polls\models.py", line 19, in __unicod
> e__
>     return self.question
> AttributeError: 'Choice' object has no attribute 'question'

If you look at the Traceback, you will see that there is a problem
with line 19 in models.py, which is helpfully printed out:

return self.question

Choice doesn't have an attribute called question, as described in the
error. Perhaps another model in the same file has an attribute called
question and you simply copied the code in the wrong place?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New Django Site

2008-05-21 Thread Jashugan



On May 21, 1:27 pm, Bret W <[EMAIL PROTECTED]> wrote:
> Hey all-
>
> Over the past few evenings, I've put together a simple site for
> submitting and listing job and salary information.
>

Congratulations!

My comments:

* I like the simple design, although some color would be nice.
* There's no privacy statement (do you track IP addresses?, etc.)
* It seems sluggish sometimes (not sure how many people use it)
* seems like there would be certain information that people would not
want to put (employer especially)
* graphs and charts would be cool
* the search needs to have AJAX
* in the future you'll need to consolidate fields such as salary into
ranges



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



New to Django, having issues with first tutorial

2008-05-21 Thread nobody

I'm going through the "Writing your first Django app" tutorial on
djangoproject.com but I'm not getting very far, unfortunately.

I'm on the last bit of the first page (http://www.djangoproject.com/
documentation/tutorial01/) basically trying to create a new choice
object. Honestly the docs are doing very little to help me understand
what's going on or troubleshoot at all, but this is my error:

>>> p = Poll.objects.get(pk=1)
>>> p.choice_set.create(choice='Not much', votes=0)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\django\db\models\base.py", line
241, in __repr__
return smart_str(u'<%s: %s>' % (self.__class__.__name__,
unicode(self)))
  File "C:\Python25\Lib\site-packages\django\testproject\..\testproject
\polls\models.py", line 19, in __unicod
e__
return self.question
AttributeError: 'Choice' object has no attribute 'question'


Unfortunately I can't even think of how to troubleshoot this as I'm
brand spanking new to Django and Python, so my knowledge in PHP isn't
doing me a whole lot. The documentation is written with sort of a
condescending tone which presents everything as super easy, which I'm
sure it is once you've played around for a while, but to a beginner
it's not really helping much.  It's a lot of do this -> see this, but
not as much explanation.

Anyway enough of my rant, any help with my clearly stupid question
would be great. 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: load external xml and css with varibles?

2008-05-21 Thread sebey

that script you told me to do how do i get it running though the admin
interface?

On May 21, 4:25 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On May 21, 2008, at 11:07 PM, sebey wrote:
>
>
>
> >> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
> >> run by a cron job, that checks feeds for updates a few times per day.
> >> Have a django model that represents rss feeds and feed items, and
> >> then
> >> import the necessary stuff at the top of your feed parser script so
> >> that you can save new feed items to the database as they come in.
> >> Once
> >> the feed items are in your database, you can use them as normal in
> >> the
> >> rest of your django app.
> > I  am new to web development how would I go about all of this?
>
> To get a standalone script to run under your proper django
> environment, put this at the top:
>
> from django.core.management import setup_environ
> import sys
> sys.path.append('/path/to/your/project')
> from yourproject import settings
> setup_environ(settings)
>
> Then you'll be able to import your feed models, create new instances,
> and save them, all within this script.
>
> Next, Google for how to set up a cron job, read the feedparser
> documentation for how to use feedparser, and you're good to go!
>
> E
>
>
>
> > On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> >> On May 21, 2008, at 6:58 PM, sebey wrote:
>
> >>> I know css does not not have any variables but I was thinking that
> >>> python/django could look though the css file and have
> >>> background-color:{{insert python varible here}}
>
> >>> but I did consider that first about copy and pasting a style sheet
> >>> and
> >>> just change the background but I never thought about inheritance so
> >>> thank you
>
> >> Why don't you just use an inline 

Re: Form Fields Question

2008-05-21 Thread Chris

>>and in 2008, does it really matter?

If you are managing a major media related site every inch counts in
order to have a fast and deliverable page!

I wasn't saying that django was performing bad practice, I was just
curious as to why id over classes.

Thanks for the input.




On May 21, 3:32 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Wed, May 21, 2008 at 3:16 PM, Chris <[EMAIL PROTECTED]> wrote:
> > Why does django by default output html id's in form fields? I thought
> > that it was good practice to use the class attribute in child elements
> > of an html form and to only use id on your container (parent) element
> > such as the form element. I think I read somewhere that classes are
> > faster to create and that id's are much slower to create.
>
> I don't know about the speed of id versus class (and in 2008, does it
> really matter?), but keep in mind that, by default, Django's forms
> also use the label element, with its "for" attribute.[1] By
> definition, that attribute must match to an *id* of a form field in
> order to work properly. With that in mind, I certainly can't imagine
> any reason by assigning an id to a form field would be bad practice.
>
> -Gul
>
> [1]http://www.w3.org/TR/html401/interact/forms.html#adef-for


--~--~-~--~~~---~--~~
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 and Linux distros

2008-05-21 Thread Gustavo Noronha Silva

On Mon, 2008-05-19 at 10:30 +0200, Matthias Kestenholz wrote:
> > just use
> >   sudo apt-get install python-django
> I'd _not_ recommend installing the django version from the ubuntu
> package. If you begin with a new project (or if you begin to learn
> django even!) you should start with a subversion trunk checkout[1], not
> with 0.96.1.

You may want to use the package from Debian's experimental repository,
though, since it is quite up-to-date with SVN, usually:

http://packages.debian.org/experimental/python-django

You can add:

   deb http://http.us.debian.org/debian experimental main

to your sources.list and force synaptic or aptitude to install the svn
snapshot version (since experimental is configured to not be a candidate
for new versions).

See you,

-- 
Gustavo Noronha Silva <[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
-~--~~~~--~~--~--~---



Re: Forms from Database Tables with choice selects.

2008-05-21 Thread Richard Dahl
I would caution you to think in the terms of the data storage
(models) separately from data entry (forms via views). Most likely you want
a class Person which would have a field for title.  Maybe the title field is
a FK to the Title model, maybe it is a charfield with or without 'choices'
depending on your particular needs.  As far as a form with 3 people,
you probably are talking again about a ThreeRelatedPeople model (perhaps
there is more descriptive name) that needs to track three people.  It could
have one m2m or 3 fks to Person depending on the strictness of the
requirement for 3 and the business logic it supports.  If you went this
route, you could present a user with a form for ThreeRelatedPeople and they
could choose three existing or create the requisite Person objects.
-richard


On 5/21/08, Lance F. Squire <[EMAIL PROTECTED]> wrote:
>
>
> I'm trying to make a Form where 3 people need to be inputed. All three
> need to have a Title.(EG. Mr. Mrs. etc.)
>
> I tried making the Title fields in the database be a key to a table of
> title selections. The sql generation had no trouble with that, but the
> Form generator doesn't like it at all...
>
> I had them as character fields, but couldn't figure out how to get
> them to become select/choice fields after the form was auto generated
> from the table, before the view...
>
> I'm new to Django. Played with Rails some, but mostly work in Perl/
> Postgres
>
> Also looked at having the people in separate tables, but it didn't
> seem practical either from a filling in data point or a rendering/
> parching the form point.
>
> Thanks for any help and/or pointers.
> Lance
> >
>

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



RSS Syndication and iTunes Tags

2008-05-21 Thread Gremmie

I was considering using django to generate an RSS feed for a podcast.
iTunes likes it very much if you add some non-standard tags to the
xml. Is this there a way to leverage the existing slick syndication
feature of django but also get these tags into the feed?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



New Django Site

2008-05-21 Thread Bret W

Hey all-

Over the past few evenings, I've put together a simple site for
submitting and listing job and salary information.

There are several more complex surveys and sites for this type of
information, but none that are quick and easy.

I'd appreciate the Django Community's thoughts on the site.

It's here:  http://www.howmuchdoyoumake.net/

If this testing goes well, I hope to keep the information entered, so
please be honest.
That said, I might have to reset the app again before really
launching, so please don't be upset if what you enter is deleted.

Thanks for your thoughts and opinions!

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



Forms from Database Tables with choice selects.

2008-05-21 Thread Lance F. Squire

I'm trying to make a Form where 3 people need to be inputed. All three
need to have a Title.(EG. Mr. Mrs. etc.)

I tried making the Title fields in the database be a key to a table of
title selections. The sql generation had no trouble with that, but the
Form generator doesn't like it at all...

I had them as character fields, but couldn't figure out how to get
them to become select/choice fields after the form was auto generated
from the table, before the view...

I'm new to Django. Played with Rails some, but mostly work in Perl/
Postgres

Also looked at having the people in separate tables, but it didn't
seem practical either from a filling in data point or a rendering/
parching the form point.

Thanks for any help and/or pointers.
Lance
--~--~-~--~~~---~--~~
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: User.get_profile() (was: Re: Reusable models?)

2008-05-21 Thread Marty Alchin

On Wed, May 21, 2008 at 3:00 PM, Jeremy Bornstein <[EMAIL PROTECTED]> wrote:
> (assuming your profile model is called "UserProfile")

I think you just answered your own question. Consider a third-party
app that might be used to manage user profiles, but leaves the actual
implementation of that profile to each individual project. There's no
way it could possibly know what you've named your user profile model.
By including a setting to specify this, and a standard method to
handle the retrieval behind the scenes, it becomes a quite reasonable
scenario.

I could be wrong about the actual reason it was implemented like that,
since I wasn't involved in that process, but that's at least one big
advantage for doing it the way it's done.

-Gul

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



User.get_profile() (was: Re: Reusable models?)

2008-05-21 Thread Jeremy Bornstein

On Wed, May 21, 2008 at 01:41:35PM -0500, James Bennett wrote:
> Note that this is, for example, how Django's User model works: you
> relate another model to it with a good old-fashioned foreign key, and
> there's a nice API for specifying which model represents the "user
> profile" for a given site. You could emulate that for your own models
> quite easily.

This brings up something I don't quite get: Django provides
user.get_profile(), but the ORM makes it just as easy to say
user.userprofile (assuming your profile model is called
"UserProfile").  Is there any reason to set up and use
user_get_profile() instead?

-Jeremy

P.S. Since I almost never post, I'd like to add a huge THANK YOU to
all the contributors for Django, which I use just about every day and
with which I have built many projects.

--~--~-~--~~~---~--~~
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: Reusable models?

2008-05-21 Thread James Bennett

On Wed, May 21, 2008 at 12:29 PM, Aidas Bendoraitis
<[EMAIL PROTECTED]> wrote:
> One use case could be, for example,
> the Institution model with title and description fields in project A,
> then the Institution model with title, description, and address fields
> in project B,
> and then the Institution model with title, description, and category
> fields in project C.

A whole bunch of people are going to tell you to use inheritance and
subclass the base model everywhere.

Those people are probably a bit over-eager to treat inheritance as a
cure-all; the only time I've ever seen it used in production code, it
became a maintenance nightmare (pro tip: World Online has been using
Django since, well, as long as it's existed. We have exactly one model
that's subclassed, and every time I have to deal with it I wish it
wasn't).

The way I'd do this is with an application which provides a basic
model with the core fields, and then other models in other
applications relating to it and adding information as needed.
Incidentally, this leads to precisely the same underlying database
configuration as inheritance, but is conceptually quite a bit cleaner
since you're being explicit about the relationship.

Note that this is, for example, how Django's User model works: you
relate another model to it with a good old-fashioned foreign key, and
there's a nice API for specifying which model represents the "user
profile" for a given site. You could emulate that for your own models
quite easily.


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



Integrating Flexigrid (jquery)

2008-05-21 Thread Joseph

All,
I'm trying to integrate flexigrid (http://www.webplicity.net/
flexigrid/). However I'm running to problems and I hope someone can
help me.

This is my snippet of flexigrid configuration:

...
url: '/populategrid/',
...

and the view is:
def populategrid(request):
#page that is requested
if request.POST.has_key('page'):
pagenum = request.POST['page']
else:
pagenum = "1"
#rows per page
if request.POST.has_key('rp'):
rp = int(request.POST['rp'])
else:
rp = 10
rows = [{'id': row.id,
 'cell': [row.id, row.title, row.publisher, row.isbn]} for
row in Book.objects.all()]

count = Book.objects.all().count()

from django.utils import simplejson
data = simplejson.dumps(dict(page=pagenum, total = count,
rows=rows))

return HttpResponse(data, mimetype='application/javascript')

when I view http://localhost/populategrid/ it shows the dict values;
but the flexigrid doesn't show up any value. Can anyone help?

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



Re: postgresql_psycopg2 module errors (Windows)

2008-05-21 Thread nobody

This is the exact error:

C:\Python25\Lib\site-packages\django\testproject>manage.py runserver
Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "C:\Python25\lib\site-packages\django\core\management\commands
\runserver.
py", line 47, in inner_run
self.validate(display_num_errors=True)
  File "C:\Python25\lib\site-packages\django\core\management\base.py",
line 112,
 in validate
num_errors = get_validation_errors(s, app)
  File "C:\Python25\lib\site-packages\django\core\management
\validation.py", lin
e 22, in get_validation_errors
from django.db import models, connection
  File "C:\Python25\lib\site-packages\django\db\__init__.py", line 17,
in 
backend = __import__('%s%s.base' % (_import_path,
settings.DATABASE_ENGINE),
 {}, {}, [''])
  File "C:\Python25\lib\site-packages\django\db\backends
\postgresql_psycopg2\bas
e.py", line 15, in 
raise ImproperlyConfigured("Error loading psycopg2 module: %s" %
e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2
module: No m
odule named psycopg2


On May 21, 10:50 am, nobody <[EMAIL PROTECTED]> wrote:
> I know this has been brought up before, but unfortunately I'm having
> the same problem I've seen posted but the reasoning is different.
>
> I've compiled pyscopg2 with mingw32 which I assume was successful as
> the files all now reside within django/db/backends
>
> However when I try to runserver I get an error telling me that I have
> incorrectly configured psycopg2 and that the psycopg2 module doesn't
> exist.
>
> Obviously this is false, so I'm curious what my next step is here.
--~--~-~--~~~---~--~~
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: Reusable models?

2008-05-21 Thread Richard Dahl
Why not just define your base models in a Module in your import path called
basemodels.py and import the specific  base models you need into the
requisite app.  You could then use model inheritance to add the specific
fiddly bits required for that app.  It is just python after all.  Am I
underthinking this?
-richard



On 5/21/08, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
>
>
> James Bennett introduced some handy tricks about forms, templates, and
> URLs in his presentation about reusable apps:
> http://www.b-list.org/weblog/2008/mar/15/slides/
>
> However the presentation doesn't touch the theme about reusability of
> models with small differences.
>
> One use case could be, for example,
> the Institution model with title and description fields in project A,
> then the Institution model with title, description, and address fields
> in project B,
> and then the Institution model with title, description, and category
> fields in project C.
>
> As the possible solutions I see
> 1. Duplicating the application with the Institution model for each
> project.
> 2. Having the Institution models in a common application for all
> projects and then monkey-patching it with specific fields for projects
> B and C.
> 3. Having the Institution models in a common application for all
> projects and extending it with specific fields for projects B and C
> (How to import the project-specific Institution model in the common
> views and forms?)
> 4. Having one Institution model in a common application which would
> check the settings.SITE_ID and optionally create the appropriate
> fields.
>
> What would be the best practices for reusing models?
>
> Regards,
> Aidas Bendoraitis [aka Archatas]
> >
>

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



TimeField display in Admin interface

2008-05-21 Thread puff

I'm new to Django and noticed that a timefield set to 00:00:00
(midnight in the default choice list) displays as (none) in the admin
interface.  Is this expected behavior?  Is there some way to cause it
to display as midnight?  I also noticed that a timefield of 00:00:01
DOES display as midnight in the Admin!

Thanks for any clues.
--~--~-~--~~~---~--~~
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: load external xml and css with varibles?

2008-05-21 Thread sebastian stephenson

I done python and html/css and I have had had no programing experence
On 21 May 2008, at 17:11, Matthias Kestenholz wrote:

>
> On Wed, 2008-05-21 at 08:34 -0700, sebey wrote:
>> what I really need is how to code this I know what to do but I don't
>> know how to do it
>>
>
> Then learn how to do it. The time between the very clear email of Eric
> and your reply suggests that you have not done your homework.
>
> What is your experience with development for the web or programming in
> general? Maybe you'd be better off starting with a Python tutorial and
> basic HTML/CSS stuff before trying Django again? I really don't  
> want to
> insult you, but maybe you should begin with the basics instead of
> jumping right into intermediate/advanced stuff?
>
> Matthias
>
> >

see ya

sebey



--~--~-~--~~~---~--~~
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: relationships problem

2008-05-21 Thread Richard Dahl
I am not really sure exactly what you are trying to accomplish here, if you
want to 'create a load of Places based on what is in RawPlaces but with a
resource' wouldn't a FK or M2M (depending on your cardinality requirements)
relationship to RawPlaces within Resource simplify this process?  I am not
sure of the point of the apparent redundancy of Places and RawPlaces.

My (limited) understanding of OneToOne relationships is that it is usually
used when an object extends another object, i.e. AppUser extends User or
from the model-api doc Restaurant extends Place.  Do you really want Place
to extend Resource?

Another solution is to have Place have a M2M relationship to Resource, which
sounds more logical to me (of course, I have no idea what your app is
designed to do) as any Place (probably) has more than one Resource.
hth,
-richard


On 5/21/08, Col Wilson <[EMAIL PROTECTED]> wrote:
>
>
> I'm brand new to django from rails, and I'm a bit stuck trying to get
> relationships to work. RawPlaces table is full of place names and data
> already.
>
> My model looks like this:
>
> from django.db import models
> import sys, os
>
> class RawPlace(models.Model):
>name = models.CharField(max_length=64)
>lat = models.IntegerField()
>lng = models.IntegerField()
>population = models.IntegerField()
>country = models.IntegerField()
>region = models.IntegerField()
>
>class Admin:
>pass
>
>def __unicode__(self):
>return self.name
>
> class Resource(models.Model):
>gold = models.IntegerField(default=0)
>food = models.IntegerField(default=0)
>recruits = models.IntegerField(default=0)
>
>class Admin:
>pass
>
>def randomize(self, population=0):
>gold = random.randint(0, population)
>food = random.randint(0, population)
>recruits = random.randint(0, population)
>
> class PlaceManager(models.Manager):
>
>def randomize(self):
>for p in Place.objects.all():
>p.delete()
>for raw in RawPlace.objects.all():
>print raw
>r = Resource()
>r.save()
>p = Place(lat=raw.lat, lng = raw.lng,
> population=raw.population,
> country=raw.country, region=raw.region, resource=r)
>p.save()
>return Place.objects.all()
>
> class Place(models.Model):
>name = models.CharField(max_length=64)
>lat = models.IntegerField()
>lng = models.IntegerField()
>population = models.IntegerField()
>country = models.IntegerField()
>region = models.IntegerField()
>resource = models.OneToOneField(Resource, primary_key=True)
>objects = PlaceManager()
>
>class Admin:
>pass
>
>def __unicode__(self):
>return self.name
>
>
> So I want to create a load of Places based on what's in RawPlaces, but
> with a Resource:
>
> >>> from places.models import Place, RawPlace, Resource
> >>> Place.objects.randomize()
> Saint Martin's
> Traceback (most recent call last):
> File "", line 1, in 
> File "C:\local\workspaces\project4\places\models.py", line 42, in
> randomize
>r.save()
> File "C:\Python25\Lib\site-packages\django\db\models\base.py", line
> 272, in save
>self.save_base()
> File "C:\Python25\Lib\site-packages\django\db\models\base.py", line
> 336, in save_base
>transaction.commit_unless_managed()
> File "C:\Python25\Lib\site-packages\django\db\transaction.py", line
> 136, in commit_unless_managed
>connection._commit()
> File "C:\Python25\Lib\site-packages\django\db\backends\__init__.py",
> line 20, in _commit
>return self.connection.commit()
> OperationalError: SQL logic error or missing database
>
> 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
-~--~~~~--~~--~--~---



Reusable models?

2008-05-21 Thread Aidas Bendoraitis

James Bennett introduced some handy tricks about forms, templates, and
URLs in his presentation about reusable apps:
http://www.b-list.org/weblog/2008/mar/15/slides/

However the presentation doesn't touch the theme about reusability of
models with small differences.

One use case could be, for example,
the Institution model with title and description fields in project A,
then the Institution model with title, description, and address fields
in project B,
and then the Institution model with title, description, and category
fields in project C.

As the possible solutions I see
1. Duplicating the application with the Institution model for each
project.
2. Having the Institution models in a common application for all
projects and then monkey-patching it with specific fields for projects
B and C.
3. Having the Institution models in a common application for all
projects and extending it with specific fields for projects B and C
(How to import the project-specific Institution model in the common
views and forms?)
4. Having one Institution model in a common application which would
check the settings.SITE_ID and optionally create the appropriate
fields.

What would be the best practices for reusing models?

Regards,
Aidas Bendoraitis [aka Archatas]
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Inheriting auth.models User

2008-05-21 Thread Gollum

Since this
http://groups.google.com/group/django-users/browse_thread/thread/171886a67b8ed839/11564423d7a7680d?lnk=gst=gollum#11564423d7a7680d
went unnoticed...
Did anybody at all try to inherit from auth.models User and what
worked (or didn't)?
--~--~-~--~~~---~--~~
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 in a HA cluster web services application with some near real time elements

2008-05-21 Thread puff

Thanks Ben for responding so promptly.

> I'm probably not qualified to comment on the deeper technical issues
> mentioned here. However that said I've just taken over quite a large
> codebase that does some of this stuff, and it can be quite painful! I'd
> suggest keeping your django code as simple as possible, i.e. just to process
> the request and return the results. There are a few instances where we've
> called out to other web services in a view and it's gone ok... but there are
> a couple where it's bitten us HARD! (SOAP over https using the ZSI library).

Fortunately, I'v complete control over BOTH sides of the external
services.  The current approach is to use URI's and exchange HTTP/
Json.  I've no need to deal with SOAP or anything beyond that.  What
sorts of issues did you encounter when interfacing to other web
services?

> If you're thinking of a cron job, then I would say a good match would be a
> custom management command, this is the approach we now take as much as
> possible and it works well for us.

I'm not sure what you mean here.  Can you expand a bit?

> I'd second Graham's sentiments here... we're trying to move from fastcgi and
> a number of nasty hacks put in place by the previous people to a more normal
> setup as per community recommendations for running django at the moment it
> isn't easy, we have a lot of bugs surfacing  and a lot of trouble finding
> where the originate! Our code uses threadlocal in some places - I'm not sure
> how similar threadlocal is to 'threading' (if anyone can enlighten me I'd
> appreciate it!), but I think it might be causing a few of our problems.

Point taken but I'm not sure what you mean by threadlocal.  Is it
http://docs.python.org/lib/module-threading.html
mydata = threading.local()
mydata.x = 1

>
> Cheers,
> Ben
>
> --
> Regards,
> Ben Ford
> [EMAIL PROTECTED]
> +447792598685
--~--~-~--~~~---~--~~
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 in a HA cluster web services application with some near real time elements

2008-05-21 Thread puff

Thanks Graham and Ben for the prompt feedback.  It was most helpful.

> Depending on the hosting mechanism has been configured, any Django
> startup may only happen the first time a request comes in. This would
> potentially delay requests if the initialisation takes a while.

Our current hosting intent is Apache per the current configuration
recommendations.  Unfortunately, I'm not familiar with Arache/mod-
Python so I'm on unknown ground.  Initialization time is not an issue
as the system as a whole takes a few minutes to come up as multiple
servers and daemons are involved.  If I understand your feedback
properly, it sounds like startup.py isn't processed until the first
time Django is tickled.  That being the case it would appear sensible
to have something external to Django/Apache post to a URI to cause
initialization.  Does this seem reasonable?

> > Part of the application involves running an external application on a
> > scheduled basis.
>
> Apache is a multiprocess web server. Does it matter that your request
> is going to only one of the possible many processes which may be
> running?

Hmmm.  I'd not considered that.  Part of the requirement here is that
one and only one of these scheduled things be running at a  time.  The
tentative approach is to queue the cron generated items for later
consumption by a separate process.  That being the case, it appears
that I don't really care what process services the cron URI.  Thanks
for pointing it out.

Do I understand correctly from your feedback that there may be many
Django processes running within Apache/mod-Python?

> Do note it is possible to write standalone scripts that import your
> Django instance and thus allow you to do stuff on the database outside
> of the context of an Apache process.

Can you give me a pointer?

> > What, if any, issues are there with a daemon like process running
> > within Django/Apache?
>
> Do you mean a daemonised thread running in Apache processes? Running
> Django under Apache is not an issue, so not sure if you mean something
> else.

I didn't explain myself very well here.  The application needs to
maintain a work queue.  Work arrives via URI post and is enqueued to a
work queue.  When work arrives the python method that processes the
work queue needs to be started if necessary.  It dequeues work items
in turn and performs them.  The work involves either sending a URI to
another web service to cause the work to happen or executing an
external application such as RSYNC.  In either case progress needs to
be monitored and recorded.  The current approach is to start the
method that consumes the work queue and let it run indefinitely.
Since I'm unfamiliar with Django/Apache/mod-Python I'm uncertain of
what, if any, issues this approach has.

> There is unfortunately no definitive answer to that. Although people
> use Django on Apache winnt and worker MPMs, plus with multithreaded
> fastcgi configurations, there is no guarantee that Django is thread
> safe.

Thanks.

> You may perhaps want to split out any long running activities from the
> Django processes running in Apache into a separate backend server
> independent from Apache. That backend process can be a true long
> running process, where as with processes under Apache, they can be
> recycled by Apache which may be an issue where an activity is
> interrupted.

We are using that approach in one part of the system already and
considering it for dealing with the work queue.

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



URL redirects in Django

2008-05-21 Thread Jashugan

Hello, I'm using the photologue application and would like to redirect
the base site (i.e. '') to 'pl-gallery-list'.

/urls.py
... snip ...
urlpatterns = patterns('',
(r'^photologue/', include('photologue.urls')),
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
)


/photologue/urls.py
... snip ...
# galleries
gallery_args = {'allow_empty': True, 'queryset':
Gallery.objects.filter(is_public=True), 'extra_context':
{'sample_size':SAMPLE_SIZE}}

urlpatterns = patterns('django.views.generic.list_detail',
url(r'^gallery/?$', 'object_list', gallery_args, name='pl-gallery-
list'),
url(r'^gallery/(?P[\-\d\w]+)/$', 'object_detail',
{'slug_field': 'slug', 'queryset':
Gallery.objects.filter(is_public=True), 'extra_context':
{'sample_size':SAMPLE_SIZE}}, name='pl-gallery-detail'),
)
... snip ...

What I would like to do is something like this (in /urls.py):
urlpatterns += ('',
(r'', reverse('pl-gallery-list')
)

However, this doesn't work. Is this the right way of going about doing
this? Should I use a HTTPRedirect, or simply copy the full 'pl-gallery-
list' regex from /photologue/urls.py (although this is not very DRY)?
--~--~-~--~~~---~--~~
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: Testing login required views

2008-05-21 Thread Adam Gomaa

On Tue, May 20, 2008 at 9:19 PM, Julien <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a site where pretty much all views (except for register, login
> and logout) require the user to log in. Now that the number of views
> has grown I'd like to test that I didn't forget to protect them with
> the login_required decorator.
>
> I'm looking for an automated way to do that. Is that achievable, and
> if so, how?
>
> I've started looking into unit testing but I'm struggling a bit and
> I'm not sure if that could do the trick. What I'd like to do is test
> all possible urls from the URLConf and spot those that are not
> redirected to the login page.
>
> Any hint?

Julien, I'd just use 'grep' for this:

grep -A 2 -R --include="*.py"  -E "^def .*\(req" ./

That'll show two lines above a view definition - so just look for any
that are missing @login_required.

Course, that's hardly portable...

Adam

>
> Thank you,
>
> Julien
> >

--~--~-~--~~~---~--~~
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: load external xml and css with varibles?

2008-05-21 Thread Matthias Kestenholz

On Wed, 2008-05-21 at 08:34 -0700, sebey wrote:
> what I really need is how to code this I know what to do but I don't
> know how to do it
> 

Then learn how to do it. The time between the very clear email of Eric
and your reply suggests that you have not done your homework.

What is your experience with development for the web or programming in
general? Maybe you'd be better off starting with a Python tutorial and
basic HTML/CSS stuff before trying Django again? I really don't want to
insult you, but maybe you should begin with the basics instead of
jumping right into intermediate/advanced stuff?

Matthias

--~--~-~--~~~---~--~~
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: Try Except Statement not working properly.

2008-05-21 Thread Norman Harman

Greg wrote:

> Norman,
> I added those print statements and ran the script.  The output was
> this over and over again:
> 
> ///
> 
> current transaction is aborted, commands ignored until end of
> transaction block
> 
> //
> 
> Any suggestions?

It sounds like some other exception is, sadly, being masked by the 
transaction abort exception.

Unless you know and like to use debuggers, the answer is almost always 
more print statements :)

I suspect that the file you are reading isn't properly formated csv, or 
the data in row[0] or row[1] aren't what your database expects, or some 
other error like that.

What you need to do is figure out what is actually being sent into 
OrderEmail and why that is causing database to choke and rollback.

   for row in reader:
try:
print row
print row[0], row[1]
b = OrderEmail(name=row[0], email=row[1], been_sent="0")
b.save()
print "saved", row
except Exception, msg:
print msg


I have no idea what OrderEmail is about but this
been_sent="0"
looks suspicious.  Booleans, which been_sent certainly sounds like, in 
Python use True/False not 1/0 and esp not strings "0".  Try
been_sent=False


-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

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



Re: load external xml and css with varibles?

2008-05-21 Thread sebey

what I really need is how to code this I know what to do but I don't
know how to do it

On May 21, 4:31 pm, sebey <[EMAIL PROTECTED]> wrote:
> ok but how can I add it though the admin interface and I how would I
> get a relationship between models and the feedparser script?
>
> On May 21, 4:25 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>
> > On May 21, 2008, at 11:07 PM, sebey wrote:
>
> > >> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
> > >> run by a cron job, that checks feeds for updates a few times per day.
> > >> Have a django model that represents rss feeds and feed items, and
> > >> then
> > >> import the necessary stuff at the top of your feed parser script so
> > >> that you can save new feed items to the database as they come in.
> > >> Once
> > >> the feed items are in your database, you can use them as normal in
> > >> the
> > >> rest of your django app.
> > > I  am new to web development how would I go about all of this?
>
> > To get a standalone script to run under your proper django
> > environment, put this at the top:
>
> > from django.core.management import setup_environ
> > import sys
> > sys.path.append('/path/to/your/project')
> > from yourproject import settings
> > setup_environ(settings)
>
> > Then you'll be able to import your feed models, create new instances,
> > and save them, all within this script.
>
> > Next, Google for how to set up a cron job, read the feedparser
> > documentation for how to use feedparser, and you're good to go!
>
> > E
>
> > > On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> > >> On May 21, 2008, at 6:58 PM, sebey wrote:
>
> > >>> I know css does not not have any variables but I was thinking that
> > >>> python/django could look though the css file and have
> > >>> background-color:{{insert python varible here}}
>
> > >>> but I did consider that first about copy and pasting a style sheet
> > >>> and
> > >>> just change the background but I never thought about inheritance so
> > >>> thank you
>
> > >> Why don't you just use an inline 

Re: load external xml and css with varibles?

2008-05-21 Thread sebey

ok but how can I add it though the admin interface and I how would I
get a relationship between models and the feedparser script?

On May 21, 4:25 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On May 21, 2008, at 11:07 PM, sebey wrote:
>
>
>
> >> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
> >> run by a cron job, that checks feeds for updates a few times per day.
> >> Have a django model that represents rss feeds and feed items, and
> >> then
> >> import the necessary stuff at the top of your feed parser script so
> >> that you can save new feed items to the database as they come in.
> >> Once
> >> the feed items are in your database, you can use them as normal in
> >> the
> >> rest of your django app.
> > I  am new to web development how would I go about all of this?
>
> To get a standalone script to run under your proper django
> environment, put this at the top:
>
> from django.core.management import setup_environ
> import sys
> sys.path.append('/path/to/your/project')
> from yourproject import settings
> setup_environ(settings)
>
> Then you'll be able to import your feed models, create new instances,
> and save them, all within this script.
>
> Next, Google for how to set up a cron job, read the feedparser
> documentation for how to use feedparser, and you're good to go!
>
> E
>
>
>
> > On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> >> On May 21, 2008, at 6:58 PM, sebey wrote:
>
> >>> I know css does not not have any variables but I was thinking that
> >>> python/django could look though the css file and have
> >>> background-color:{{insert python varible here}}
>
> >>> but I did consider that first about copy and pasting a style sheet
> >>> and
> >>> just change the background but I never thought about inheritance so
> >>> thank you
>
> >> Why don't you just use an inline 

Re: load external xml and css with varibles?

2008-05-21 Thread Eric Abrahamsen

On May 21, 2008, at 11:07 PM, sebey wrote:

>
>
>> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
>> run by a cron job, that checks feeds for updates a few times per day.
>> Have a django model that represents rss feeds and feed items, and  
>> then
>> import the necessary stuff at the top of your feed parser script so
>> that you can save new feed items to the database as they come in.  
>> Once
>> the feed items are in your database, you can use them as normal in  
>> the
>> rest of your django app.
> I  am new to web development how would I go about all of this?

To get a standalone script to run under your proper django  
environment, put this at the top:

from django.core.management import setup_environ
import sys
sys.path.append('/path/to/your/project')
from yourproject import settings
setup_environ(settings)

Then you'll be able to import your feed models, create new instances,  
and save them, all within this script.

Next, Google for how to set up a cron job, read the feedparser  
documentation for how to use feedparser, and you're good to go!

E



>
> On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>> On May 21, 2008, at 6:58 PM, sebey wrote:
>>
>>
>>
>>> I know css does not not have any variables but I was thinking that
>>> python/django could look though the css file and have
>>> background-color:{{insert python varible here}}
>>
>>> but I did consider that first about copy and pasting a style sheet  
>>> and
>>> just change the background but I never thought about inheritance so
>>> thank you
>>
>> Why don't you just use an inline 

Re: load external xml and css with varibles?

2008-05-21 Thread sebey


> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
> run by a cron job, that checks feeds for updates a few times per day.
> Have a django model that represents rss feeds and feed items, and then
> import the necessary stuff at the top of your feed parser script so
> that you can save new feed items to the database as they come in. Once
> the feed items are in your database, you can use them as normal in the
> rest of your django app.


I am new to web devlopment so how would I do this?

thanks
On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On May 21, 2008, at 6:58 PM, sebey wrote:
>
>
>
> > I know css does not not have any variables but I was thinking that
> > python/django could look though the css file and have
> > background-color:{{insert python varible here}}
>
> > but I did consider that first about copy and pasting a style sheet and
> > just change the background but I never thought about inheritance so
> > thank you
>
> Why don't you just use an inline 

Re: load external xml and css with varibles?

2008-05-21 Thread sebey


> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
> run by a cron job, that checks feeds for updates a few times per day.
> Have a django model that represents rss feeds and feed items, and then
> import the necessary stuff at the top of your feed parser script so
> that you can save new feed items to the database as they come in. Once
> the feed items are in your database, you can use them as normal in the
> rest of your django app.
I  am new to web development how would I go about all of this?
On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On May 21, 2008, at 6:58 PM, sebey wrote:
>
>
>
> > I know css does not not have any variables but I was thinking that
> > python/django could look though the css file and have
> > background-color:{{insert python varible here}}
>
> > but I did consider that first about copy and pasting a style sheet and
> > just change the background but I never thought about inheritance so
> > thank you
>
> Why don't you just use an inline 

Re: load external xml and css with varibles?

2008-05-21 Thread sebey


> Use Feedparser (http://www.feedparser.org/) in a stand-alone script,
> run by a cron job, that checks feeds for updates a few times per day.
> Have a django model that represents rss feeds and feed items, and then
> import the necessary stuff at the top of your feed parser script so
> that you can save new feed items to the database as they come in. Once
> the feed items are in your database, you can use them as normal in the
> rest of your django app.
I  am new to web development how would I go about all of this?
On May 21, 12:12 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On May 21, 2008, at 6:58 PM, sebey wrote:
>
>
>
> > I know css does not not have any variables but I was thinking that
> > python/django could look though the css file and have
> > background-color:{{insert python varible here}}
>
> > but I did consider that first about copy and pasting a style sheet and
> > just change the background but I never thought about inheritance so
> > thank you
>
> Why don't you just use an inline 

Re: Try Except Statement not working properly.

2008-05-21 Thread Greg

Norman,
I added those print statements and ran the script.  The output was
this over and over again:

///

current transaction is aborted, commands ignored until end of
transaction block

//

Any suggestions?

On May 20, 3:24 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Greg wrote:
> > Since we know what the exception is.  The email address already exist
> > in the db (I have unique=True for the email field).  I thought that
> > having 'except: pass' would solve that problem.  However, do I need to
> > catch a certain exception in order for my loop to continue.  Because
> > as of now when the exception happens my loop stops.
>
> You don't *know* that is what the exception is, you assume that.  This
> is one reason it is bad to catch all exceptions.  You don't know what
> you are getting.
>
> The loop, as written, will continue.  There is something else going on.
>
> I would add print statements to determine what is in fact happening.
>
> for row in reader:
>   try:
>   b = OrderEmail(name=row[0], email=row[1], been_sent="0")
>   b.save()
>   print "saved", row
>   except Exception, msg:
>   print msg
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
> ___
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



postgresql_psycopg2 module errors (Windows)

2008-05-21 Thread nobody

I know this has been brought up before, but unfortunately I'm having
the same problem I've seen posted but the reasoning is different.

I've compiled pyscopg2 with mingw32 which I assume was successful as
the files all now reside within django/db/backends

However when I try to runserver I get an error telling me that I have
incorrectly configured psycopg2 and that the psycopg2 module doesn't
exist.

Obviously this is false, so I'm curious what my next step is here.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



error installing django on windows vista...

2008-05-21 Thread agusti

I download the latest version (0.96.2) and when I tried to install
this message appears:
running install
running build
running build_py
package init file '\django\__init__.py' not found (or not a regular
file)
error: package directory '\django\bin' does not exist

I tried twice, downloading again the tar.gz and still the same

Thanks for all!

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



Related object create/update form noob question

2008-05-21 Thread Smacc Kleina
Hi guys,
I wrote simple object edit forms at this time, but now i have to add a
"related" object to an another, let's say add Album to existing Artist.
Inserting new Album to existing Artist and editing existing Album requires
two forms or can be just one?
Is there any example somewhere?
Thank you all,
Smacc

--~--~-~--~~~---~--~~
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 in a HA cluster web services application with some near real time elements

2008-05-21 Thread Ben Ford
Hi there,

I'm probably not qualified to comment on the deeper technical issues
mentioned here. However that said I've just taken over quite a large
codebase that does some of this stuff, and it can be quite painful! I'd
suggest keeping your django code as simple as possible, i.e. just to process
the request and return the results. There are a few instances where we've
called out to other web services in a view and it's gone ok... but there are
a couple where it's bitten us HARD! (SOAP over https using the ZSI library).

If you're thinking of a cron job, then I would say a good match would be a
custom management command, this is the approach we now take as much as
possible and it works well for us.

> It seems likely that parts of our application will want to be
> threaded.  What, if any, issues are there with threading within Django/
> Apache?

I'd second Graham's sentiments here... we're trying to move from fastcgi and
a number of nasty hacks put in place by the previous people to a more normal
setup as per community recommendations for running django at the moment it
isn't easy, we have a lot of bugs surfacing  and a lot of trouble finding
where the originate! Our code uses threadlocal in some places - I'm not sure
how similar threadlocal is to 'threading' (if anyone can enlighten me I'd
appreciate it!), but I think it might be causing a few of our problems.

Cheers,
Ben



-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+447792598685

--~--~-~--~~~---~--~~
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: Renaming variables passed to inherited templates

2008-05-21 Thread Hans

Ooops. I thought I had read the documentation thoroughly, but found
the WITH filter. http://www.djangoproject.com/documentation/templates/#with
I guess I can use that?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: My DateField is displaying "True" in my Admin??

2008-05-21 Thread Cliff

Sorry I didn't get back sooner on this, but SQLite doesn't have a
datetime field, so django fakes it by using a string type there, but
giving making it look like a date in django.  My mistake.  See
documentation here: http://www.sqlite.org/datatype3.html


On May 7, 11:46 am, Greg <[EMAIL PROTECTED]> wrote:
> Cliff,
> I just looked at my table and the type is varchar(100).  Not sure why
> the type is a varchar when the field is a DateTime.  I tried changing
> the table but wasn't able to change the type to date.  I'll brush up
> on my SQL and hopefully be able to change the type.  I'll let ya know.
>
> Thanks
>
> On May 7, 10:25 am, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, 2008-05-07 at 07:37 -0700, Greg wrote:
> > > Karen,
> > > Here is the error that I'm getting:
>
> > > //
> > > Enter a valid date in -MM-DD format.
> > > //
>
> > > I'm using SQLite
>
> > Go into the database shell using `manage.py dbshell` and type `PRAGMA
> > TABLE_INFO(your_table_name);`.  If you're unsure what your table is
> > named, you can find it from the shell with `.tables` (no semicolon).
>
> > Make sure the database is using the correct column type for your date
> > field.  For sqlite this should be "datetime" or just "date".
>
> > Cheers,
> > Cliff
--~--~-~--~~~---~--~~
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: Mysql vs. sqlite filtering of datetimefields with None values

2008-05-21 Thread Hans

Bump
--~--~-~--~~~---~--~~
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 in a HA cluster web services application with some near real time elements

2008-05-21 Thread Graham Dumpleton

On May 21, 10:37 pm, puff <[EMAIL PROTECTED]> wrote:
> As part of startup, the application needs to initialize itself from a
> number of external applications.  We've Googled the issue and it
> appears that it is reasonable to do this initialization by putting
> code in startup.py.  Is this the case?  When is startup.py executed by
> Django?  Under what conditions, if any, will it be re-executed?

Depending on the hosting mechanism has been configured, any Django
startup may only happen the first time a request comes in. This would
potentially delay requests if the initialisation takes a while.

You may need to look at the hosting mechanism being used to see if it
has a means of loading code and performing actions when processes are
first loaded. This can still result in requests being delayed in
certain circumstances but impact is otherwise a lot less.

> Part of the application involves running an external application on a
> scheduled basis.  Our tentative approach is to use cron to post a URI
> to cause Django to start the external application.

Apache is a multiproces web server. Does it matter that your request
is going to only one of the possible many processes which may be
running?

Do note it is possible to write standalone scripts that import your
Django instance and thus allow you to do stuff on the database outside
of the context of an Apache process.

So, do you really need it to be done inside the context of a running
Apache process?

> What, if any, issues are there with a daemon like process running
> within Django/Apache?

Do you mean a daemonised thread running in Apache processes? Running
Django under Apache is not an issue, so not sure if you mean something
else.

> It seems likely that parts of our application will want to be
> threaded.  What, if any, issues are there with threading within Django/
> Apache?

There is unfortunately no definitive answer to that. Although people
use Django on Apache winnt and worker MPMs, plus with multithreaded
fastcgi configurations, there is no guarantee that Django is thread
safe.

> Any insight that the group might provide will be greatly appreciated
> as these are rather critical architectural questions that impact how
> we will use Django and the overall design of our application.

You may perhaps want to split out any long running activities from the
Django processes running in Apache into a separate backend server
independent from Apache. That backend process can be a true long
running process, where as with processes under Apache, they can be
recycled by Apache which may be an issue where an activity is
interrupted.

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: uploading CSV files

2008-05-21 Thread Marcin Mierzejewski

Dear Nanda,

Please visit the link below:
http://www.zoia.org/blog/2007/07/29/django-file-upload/

I hope that it helps you.

Best regards,
Marcin Mierzejewski


On May 21, 1:40 pm, nandu <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I am having a problem with where to start when I am faced with
> uploading a CSV file.  I do not want to create a model for the file as
> there is no need for me to keep track of the files that I am uploading
> to the server.
>
> Could you please give me a set of steps I need to follow or point me
> in the right direction of where to start.
>
> Thank you.
>
> Yours sincerely,
> Nanda
--~--~-~--~~~---~--~~
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: Ordering extra fields in ModelForm

2008-05-21 Thread John Hensley

http://code.djangoproject.com/wiki/CookBookNewFormsFieldOrdering

On May 21, 2008, at 8:15 AM, omat wrote:
[...]
> My form class is like that:
>
> class NoteForm(forms.ModelForm):
>is_location = forms.BooleanField(required=False)
>
>class Meta:
>model = Note
>
> I wish this checkbox to appear just before the location field which is
> specified in my model. But it appears as the last field when I display
> the form.
>
[...]
> Is there a way to specify the field order in ModelForm with extra
> fields?


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



Django in a HA cluster web services application with some near real time elements

2008-05-21 Thread puff

We are considering using Django as part of a HA cluster web services
application that has some near real time elements.  While much of our
application seems well suited to Django  some of the near real time
elements are concerns and we were hoping that this list might provide
some perspective on them.

In several places in the application we need to interface to other web
services.  We've experimented with HTTP/JSON from inside a view and
that seems to work OK in the small scale tests we've run.  Are there
any gotchas that we need to be aware of?  Are there liable to be
scaling issues?

As part of startup, the application needs to initialize itself from a
number of external applications.  We've Googled the issue and it
appears that it is reasonable to do this initialization by putting
code in startup.py.  Is this the case?  When is startup.py executed by
Django?  Under what conditions, if any, will it be re-executed?

Part of the application involves running an external application on a
scheduled basis.  Our tentative approach is to use cron to post a URI
to cause Django to start the external application.  Are there any
issues with a view that does NOT return a response (cron doesn't need
to know or care about the response)?  The external application may run
for an extended time (many minutes) and it is necessary to monitor the
external application to track progress and insure that it is operating
successfully.  Our tentative approach to monitoring is to simply poll
the external application and log progress to a DB table from inside
Django/Apache.  Is this a reasonable approach from Django's POV?  Is
there a better approach?  What, if any, issues are there with a long
running application within Django/Apache?

Part of the application needs to consume a work queue where entries
are placed in the queue by various user actions and/or external
applications via a URI request.  Our tentative approach to this need
is to hold the queue in a DB table.  Entries will be serviced in turn
by a 'daemon' like process running inside Django/Apache.  Is this a
reasonable approach from Django's POV?  Is there a better approach?
What, if any, issues are there with a daemon like process running
within Django/Apache?

It seems likely that parts of our application will want to be
threaded.  What, if any, issues are there with threading within Django/
Apache?

Any insight that the group might provide will be greatly appreciated
as these are rather critical architectural questions that impact how
we will use Django and the overall design of our application.

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: load external xml and css with varibles?

2008-05-21 Thread sebey

"mime type"? sorry new to web development  what is this?


"Why don't you just use an inline 

Ordering extra fields in ModelForm

2008-05-21 Thread omat

I would like to add an extra checkbox to my form which I generate with
ModelForm. This is for visual enhancement of the form. If the extra
checkbox is checked, I will display a map for user to mark his
location.

My form class is like that:

class NoteForm(forms.ModelForm):
is_location = forms.BooleanField(required=False)

class Meta:
model = Note


I wish this checkbox to appear just before the location field which is
specified in my model. But it appears as the last field when I display
the form.

Documention suggests to order the fields in the model class in the
order we wish hem to be displayed, but this is not applicable to my
case.

I tried specifying fields = (...) in the Meta inner class of the
ModelForm class, but its order is not taken into account.

Is there a way to specify the field order in ModelForm with extra
fields?


Thanks,
omat

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



uploading CSV files

2008-05-21 Thread nandu

Dear All,

I am having a problem with where to start when I am faced with
uploading a CSV file.  I do not want to create a model for the file as
there is no need for me to keep track of the files that I am uploading
to the server.

Could you please give me a set of steps I need to follow or point me
in the right direction of where to start.

Thank you.

Yours sincerely,
Nanda
--~--~-~--~~~---~--~~
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 Json server testing, new to Django

2008-05-21 Thread puff

Thanks Diego.  I'd looked at the tutorial as I got started but that
didn't register.  It is, of course, the case as when I ran a second
development server on a different port and modified the URI
appropriately things worked.

On May 20, 9:45 pm, Diego Ucha <[EMAIL PROTECTED]> wrote:
> Puff,
>
> I recommend reading "The Development Server" section from Chapter 2 of
> Django Book (http://www.djangobook.com/en/1.0/chapter02/).
> "The development server can handle only a single request at a time
> reliably...".
> Looks like that is your case.
>
> []s
> Diego Ucha
>
> On 20 maio, 18:40, puff <[EMAIL PROTECTED]> wrote:
>
> > I'm rather new to Django and working on a site that will need to do
> > the usual Django things by way of serving DB backed dynamic pages.  It
> > addition it needs to serve JSON and make JSON requests.
>
> > For the moment, I'm just experimenting with some very simple tests
> > using Django's development web server.
>
> > I'm able to get JSON responses ok from 'http://localhost:8000/json'
> > but when I try to access a JSON URI for json_get Django hangs.  If
> > instead of   'http://localhost:8000/json'Iaccess 
> > 'http://www.google.com'thingswork.  I assume that there is an issue with
> > Django's development server that limits it to serving a single view at
> > a time.  Can anyone verify this?
>
> > Thanks for any clues.
>
> > Puff
>
> > < code >
>
> > import urllib
> > from django.http import HttpResponse
> > from django.utils import simplejson
>
> > # test json view
> > mtj = 'application/json'
> > mtt = 'text/plain'
> > mt = mtt
>
> > def json(request):
> > data = {'first': 'richard', 'last': 'bell'}
> > json = simplejson.dumps(data)
> > return HttpResponse(json, mimetype=mt)
>
> > def json_day(request, day):
> > data = {'first': 'richard', 'last': 'bell', 'day': day}
> > json = simplejson.dumps(data)
> > return HttpResponse(json, mimetype=mt)
>
> > def json_get(request):
> > print 'in json_get'
> > url = 'http://localhost:8000/json'
> > #url = 'http://www.google.com'
> > f = urllib.urlopen(url)
> > print 'got f'
> > print f
> > doc = f.read()
> > print 'got doc %s' % doc
> > return HttpResponse('Inside json_get with <<%s>>' % doc)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



multi-thread query on Mysql

2008-05-21 Thread free won
i am writing a Campus Search ENgine  on DJango.while  i create 2 tables for
FtpUrls  and HttpUrls.
after i restart the serves.  I start the query.

At first time ,it goes well,runs very quickly. However,it stop load   when i
start the second Query,the error-number is   301.

i wonder whether something wrong on threading?


a = ftpsearch(word)
b = websearch(word)
 for t in [a,b]:
 t.start()
 t.join()

---It's my code on threading

Can Someone help me with it?  Thank You very much.
-- 
Start Dream
http://www.freeis.cn/

--~--~-~--~~~---~--~~
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 make two fields appear on a single line

2008-05-21 Thread Juanjo Conti

amar escribió:
> HI,
>  I am developing a simple project on django and now i want to make two
> text boxes appear on a single row, please help me

What are your doing now? {{ form }}?

Try {{ field.label_tag1 }}: {{ form.field1 }} {{ field.label_tag2 }}: {{ 
form.field2 }}

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

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



Re: load external xml and css with varibles?

2008-05-21 Thread Ronny Haryanto

On Wed, May 21, 2008 at 5:58 PM, sebey <[EMAIL PROTECTED]> wrote:
> I know css does not not have any variables but I was thinking that
> python/django could look though the css file and have
> background-color:{{insert python varible here}}

Django's templating is not restricted to HTML only. You can do
something like this in the view:

render_to_response('style.css', {'bgcol': '#fff', })

Then in style.css you can have:

background-color: {{ bgcol }}

You might need to set the correct mime type when serving non-html
files. Please check the docs.

Ronny

--~--~-~--~~~---~--~~
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: load external xml and css with varibles?

2008-05-21 Thread sebey

I know css does not not have any variables but I was thinking that
python/django could look though the css file and have
background-color:{{insert python varible here}}

but I did consider that first about copy and pasting a style sheet and
just change the background but I never thought about inheritance so
thank you

but please doe anyone no about import rss feeds form other sites and
grabing about the feed them manipulate  the tags to mark them up and
css them

On May 21, 1:33 am, Simon Tite <[EMAIL PROTECTED]> wrote:
> I'm afraid I don't quite understand all of your question, but I can
> possibly answer part of it, although please bear in mind I'm quite new
> at Django, so there may be better ways of doing it.
>
> On May 19, 11:50 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > I am thinking about making a template that has the sturcture and and
> > have a css template with the background color as a variable is this
> > possible basically all the shows come form this template  and css
> > file
>
> As far as I know, CSS files can't have variables or constants defined
> within them. To have different colour backgrounds, my first approach
> would be simply to have different CSS files, e.g. base_red.css,
> base_green.css, etc. This is an approach I am currently using in a
> development I am doing, however, the drawback is obviously going to be
> the ongoing maintenance of two or more CSS files which need to be
> identical apart from one or two lines defining the colour. Probably
> not a tremendous problem if it is ONLY the background colour which
> needs to change... The applicable CSS file to be used can be defined
> using the template system: in my base.html (which defines to overall
> structure of all subordinate pages) I have the following line:
>
> (in the . block): 
>
> The variable {{ style }} can be defined in the URL, or maybe in the
> GET data (eg www..com/?style=red), or anywhere you like.
>
> This worked fine for me, because I am using it to define more than
> just the background colour, but also to radically change the layout of
> the page, such as fonts, borders, graphics, element positioning etc.
>
> However the next stage might be, to have more than one stylesheet for
> the page... I think this would work fine for just background colour
> changes, for example:
>
> Style sheet red.css:
> body {background-color: #FF;}
>
> Style sheet green.css:
> body {background-color: #00FF00;}
>
> Style sheet base.css:
> All the other stuff!
>
> base.html:
> 
>   type="text/css">
>  
> 
>
> I haven't tried this yet, but I think it would work.
>
> The third thought to occur to me was to use JavaScript (or something)
> to directly modify the DOM model, however at this stage the learning
> curve seem too scary to me, however it might actually be the best way
> in the end, if the variations in styles become too complex.
>
> > not to mention can you load a template with in a template like have
> > the homepages with templates inside them?
>
> Well, yes I think so... I'm not sure why you think that would not be
> possible, have you had a problem with it, or am I misunderstanding
> your question?
--~--~-~--~~~---~--~~
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: Admin : Select category -> show subcategory

2008-05-21 Thread martyn

Stupid me, yes you're absolutly right.
It could be something like this

$(document).ready(function(){
changeMySelect();
# ... and select my subcategorie too.
}

$("select#id_categorie").change(function(){
changeMySelect();
}

function changeMySelect(){
   ...do something to change my select list...
}

I'm not sure about the exact syntax, but the jquery IRC or
documentation could help me.

Thank you Diego


On 21 mai, 03:38, Diego Ucha <[EMAIL PROTECTED]> wrote:
> Ok Martyn, understood.
> Mainly that piece of code represents many functions, one inside the
> other, since you need to reuse one, than you could declare this inner
> function that you are aiming at, outside the event and call it on the
> event(s) (in your case onchange and document ready).
> That way you will have to write this function only once.
> What do you think?
>
> []s
> Diego Ucha
>
> Declare it somewhere else, and call him from the event
>
> On 20 maio, 05:59, martyn <[EMAIL PROTECTED]> wrote:
>
> > In fact, at the creation, you select a category, the the
> > subcategories
> > are shown. It's OK
>
> > /*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-
> > ===Create_Object===
>
> > Category
> > [--select_category--]
>
> > SubCategory
> > [--select_subcategory--]
>
> > /*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-
>
> > But, at the modification / edition of an object, I have to set the
> > right category and the right subcategory.
>
> > /*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-
> > ===Edit_Object===
>
> > Category
> > [--shoes--]
>
> > SubCategory
> > [--pretty_shoes--]
>
> > /*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-/*-
>
> > All I want is not to right the same javascript code twice
> > (on_selectlist_change == on_document_ready)
> > I don't know the better way to do this in django FW.
> > The only thing I did is to right the same code twice... It's not the
> > DRY philosophy of Django.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



FAMOUS PHOTO COLLECTION ,NATURE PHOTOS, DRAWINGS,

2008-05-21 Thread magesh kotteswaran
HAI FRIENDS ,
   I HAVE LOT OF NATURE PHOTOS , DRAWING PHOTOS AND FLOWERS AND
DIFFERENT  ONE HUMAN ANATOMY PLASTIC MODELS, I HAVE SEND WITH YOU, JUST
CLICK FOLLOWING LINK AND ENJOY IT,

DRAWING & PHOTOS  COLLECTION 

http://mageshdrawfedi.blogspot.com/

FLOWERS AND NATURE PHOTOS 

http://mageshflowerfedi.blogspot.com/

HUMAN ANATOMY PLASTIC MODELS (DON'T AFRAID)

THANKNG YOU

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



Making django admin change-list case sensitive

2008-05-21 Thread cerea

Hi, is there a simple way to make the change-lists in django's admin
case sensitive? Right now the change_list_results.html admin template
shows all the items in lowercase, I would like it to not display
everything in lowercase, but I can't seem to figure it out. 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: What do you use for project management?

2008-05-21 Thread @@
On 5/21/08, woeye <[EMAIL PROTECTED]> wrote:
>
>
> I'd like to add Redmine (Rails based) and Mantis (PHP based).
> A Django based solution I do not know, though.



 the djangoproject itself use Trac.

--~--~-~--~~~---~--~~
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: What do you use for project management?

2008-05-21 Thread woeye

I'd like to add Redmine (Rails based) and Mantis (PHP based).
A Django based solution I do not know, though.

On 21 Mai, 00:24, "Gene Campbell" <[EMAIL PROTECTED]> wrote:
> I have used Jira, and I'm looking at Trac today.   Is there something
> more Djangonic?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Amazing video!

2008-05-21 Thread Marhcsi


http://tinyurl.com/3qoh99

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



relationships problem

2008-05-21 Thread Col Wilson

I'm brand new to django from rails, and I'm a bit stuck trying to get
relationships to work. RawPlaces table is full of place names and data
already.

My model looks like this:

from django.db import models
import sys, os

class RawPlace(models.Model):
name = models.CharField(max_length=64)
lat = models.IntegerField()
lng = models.IntegerField()
population = models.IntegerField()
country = models.IntegerField()
region = models.IntegerField()

class Admin:
pass

def __unicode__(self):
return self.name

class Resource(models.Model):
gold = models.IntegerField(default=0)
food = models.IntegerField(default=0)
recruits = models.IntegerField(default=0)

class Admin:
pass

def randomize(self, population=0):
gold = random.randint(0, population)
food = random.randint(0, population)
recruits = random.randint(0, population)

class PlaceManager(models.Manager):

def randomize(self):
for p in Place.objects.all():
p.delete()
for raw in RawPlace.objects.all():
print raw
r = Resource()
r.save()
p = Place(lat=raw.lat, lng = raw.lng, 
population=raw.population,
country=raw.country, region=raw.region, resource=r)
p.save()
return Place.objects.all()

class Place(models.Model):
name = models.CharField(max_length=64)
lat = models.IntegerField()
lng = models.IntegerField()
population = models.IntegerField()
country = models.IntegerField()
region = models.IntegerField()
resource = models.OneToOneField(Resource, primary_key=True)
objects = PlaceManager()

class Admin:
pass

def __unicode__(self):
return self.name


So I want to create a load of Places based on what's in RawPlaces, but
with a Resource:

>>> from places.models import Place, RawPlace, Resource
>>> Place.objects.randomize()
Saint Martin's
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\local\workspaces\project4\places\models.py", line 42, in
randomize
r.save()
  File "C:\Python25\Lib\site-packages\django\db\models\base.py", line
272, in save
self.save_base()
  File "C:\Python25\Lib\site-packages\django\db\models\base.py", line
336, in save_base
transaction.commit_unless_managed()
  File "C:\Python25\Lib\site-packages\django\db\transaction.py", line
136, in commit_unless_managed
connection._commit()
  File "C:\Python25\Lib\site-packages\django\db\backends\__init__.py",
line 20, in _commit
return self.connection.commit()
OperationalError: SQL logic error or missing database

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



how to make two fields appear on a single line

2008-05-21 Thread amar

HI,
 I am developing a simple project on django and now i want to make two
text boxes appear on a single row, please help me
--~--~-~--~~~---~--~~
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: Adding Adjacent fields in the dajngo templates

2008-05-21 Thread Adi J. Sieker

Hi,
Harish wrote:
> hi friends
>
> i want to implement the adjacent text fields using django.
> currently when we add two text fields, it will come one down the
> other...
> i want to override this functionality and make the two text box appear
> adjacent to one another
> can anybody help me how to proceeds to solve this problem ?
>
>   
If you are using newforms, I suggest reading 
http://www.djangoproject.com/documentation/newforms/#outputting-forms-as-html

adi

-- 
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
  openbc: https://www.openbc.com/hp/AdiJoerg_Sieker/

--~--~-~--~~~---~--~~
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: json/xml serializer.serialize UTF-8 Error

2008-05-21 Thread Russell Keith-Magee

On Wed, May 21, 2008 at 3:15 PM, ERic ZoU <[EMAIL PROTECTED]> wrote:
>
> It works in XML, but not JSON
>
> On May 21, 2:48 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
>>  query = Talk.objects.filter(side=2, talk_topic
>> =1).order_by('pub_date')[0:30]
>>  data =  serializers.serialize('json', query, ensure_ascii=False,
>> fields=('content'))
>>  return HttpResponse(data, "charset=UTF-8")
>>
>> On May 21, 2:39 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
>>
>> > Exception Value:'ascii' codec can't encode characters in position
>> > 1-2: ordinal not in range(128)
>>
>> > My content is UTF-8 encode. Seems doesn't work.

It works fine. You need to read the documentation.

http://www.djangoproject.com/documentation/serialization/#id1

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



Adding Adjacent fields in the dajngo templates

2008-05-21 Thread Harish

hi friends

i want to implement the adjacent text fields using django.
currently when we add two text fields, it will come one down the
other...
i want to override this functionality and make the two text box appear
adjacent to one another
can anybody help me how to proceeds to solve this problem ?

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



helpers on managers versus models module top-level?

2008-05-21 Thread James Tauber

I find myself being inconsistent in whether I put model helper methods  
on a custom manager or just as top-level functions in models.py

For example, in django-friends I have:

class FriendshipManager(models.Manager):
def friends_for_user(self, user):
...code with self.filter...

whereas I just accepted a patch to django-notification that has:

def notices_for(user, archived=False):
...code with Notice.objects.filter...


Any thoughts on best practices? Heuristics for deciding which to use?

I'd like some consistency across all my reusable apps.

James
--
James Tauber  http://jtauber.com/
journeyman of some   http://jtauber.com/blog/





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



wholesale cheap nike adidas puma bape shoes and clothes jeans nfl nhl nba mlb jersey www.bbnike.com

2008-05-21 Thread bbnike1

www.bbnike.com  ,We are a leading company that wholesales
shoes :Nike,Jordan,dunk,shox,max,air force
one,james,dunk.gucci,prada,Adidas,rift,Puma,Gucci,Prada,Timberland.Ice,D,Adio,Armani,DC,ES,Lacoste,
4US,Converse,bape.chanel,hongan,tods,richmond,eneruie,dsquared,diesel.armant,dior,ice
cream,kids shoes,women shoes,
jeans : bape,Diesel,Rock,Seven,red monkey,Evisu,lee,D,True
religion,bape,antik,jack
jones,armani,kepasa,apple,bbc,levi's,guess,cocobongo,only,replay,on
line,MNG hoodies,polo,red monkey,evsiu ,Richmond ,
clothes : lrg hoodies,face coat,ed hardy,prada
jackets,bbc,a,akademiks,hurberry,d,polo,rock rupblic,bape,NFL
jersey .NBA jersey ,MLB jersey ,NHL jersey ,lacoste
shirts,sweater,jacket lacoste hat, new are caps,glasses,and
ipod ,MP4,LV,GUCCI,Chanel,fendi ,bags.
If you want to order more newer products,Any question please feel free
--~--~-~--~~~---~--~~
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: json/xml serializer.serialize UTF-8 Error

2008-05-21 Thread ERic ZoU

It works in XML, but not JSON

On May 21, 2:48 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
>  query = Talk.objects.filter(side=2, talk_topic
> =1).order_by('pub_date')[0:30]
>  data =  serializers.serialize('json', query, ensure_ascii=False,
> fields=('content'))
>  return HttpResponse(data, "charset=UTF-8")
>
> On May 21, 2:39 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
>
> > Exception Value:'ascii' codec can't encode characters in position
> > 1-2: ordinal not in range(128)
>
> > My content is UTF-8 encode. Seems doesn't work.
>
> > I am using the latest version checkout from SVN
--~--~-~--~~~---~--~~
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: json/xml serializer.serialize UTF-8 Error

2008-05-21 Thread ERic ZoU

 query = Talk.objects.filter(side=2, talk_topic
=1).order_by('pub_date')[0:30]
 data =  serializers.serialize('json', query, ensure_ascii=False,
fields=('content'))
 return HttpResponse(data, "charset=UTF-8")


On May 21, 2:39 pm, ERic ZoU <[EMAIL PROTECTED]> wrote:
> Exception Value:'ascii' codec can't encode characters in position
> 1-2: ordinal not in range(128)
>
> My content is UTF-8 encode. Seems doesn't work.
>
> I am using the latest version checkout from SVN
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



json/xml serializer.serialize UTF-8 Error

2008-05-21 Thread ERic ZoU

Exception Value:'ascii' codec can't encode characters in position
1-2: ordinal not in range(128)

My content is UTF-8 encode. Seems doesn't work.

I am using the latest version checkout from SVN
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---