xsex ....... xanal.......xfuck.......ineresting

2008-03-29 Thread XxX

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



natural love become evershine sexual

2008-03-29 Thread XxX

Hot World -- XXX
***
http://myprofile96321.blogspot.com/
http://freewebs.com/7tracks/
http://freewebs.com/zbeauti/
***
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: distinct UPDATE / INSERT before save() without select to DB

2008-03-29 Thread Amit Ramon

* eat <[EMAIL PROTECTED]> [2008-03-29 05:24 -0700]:
> 
> How to distinct in save() method of the model if the save operation
> will be update or insert.
> 
> I want to know it BEFORE doing the save().
> I want to know it WITHOUT doing a select to a database.
> 
> THe reason for that : i want to check the database conditions for the
> insert to initiate.
> 
> Currently i can only imagine i could do my own function save_insert()
> save_update() and initiate them when needed , isnt there any simpler
> method??


Have you looked at this:
http://www.djangoproject.com/documentation/db-api/#how-django-knows-to-update-vs-insert

It seems that if the object's primary key is not set, it'll be an insert; if it 
is set, according to the docs, you'll have to chack against the database.

--- Amit

> 
> 
> 

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



Admin page doesn't show calendar popup

2008-03-29 Thread Hoolio

I just installed Django 96.1 on my Mac.  When I follow the tutorial
and get to the Admin page, the calendar pop ups don't show up.  Is
there a problem with the install.  I'm using Leopard.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Do I need two classes that are identical because I want to use two database tables?

2008-03-29 Thread jeffself



On Mar 28, 9:34 pm, andy baxter <[EMAIL PROTECTED]>
wrote:
> Peter Rowell wrote:
> >> So should I just create two classes that are identical but name one
> >> CurrentElectionResults and the other PastElectionResults?
>
> Can't you just have a single class 'ElectionResults' and add a field
> called 'current'?
>
> I'm planning on doing something similar with my app.
>
> andy.

I could do that, but I'd like to keep my current election results in
its own table since I will be importing data through a CSV file.  The
CSV file will get updated frequently over the course of about 2
hours.  Because of this, I plan to either wipe all data from my
results table before importing the CSV file.  This is why I want
separate tables.  One results table would hold all the past election
results while the other would get the imports from the CSV file.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: templatetags

2008-03-29 Thread jeffself



On Mar 29, 11:40 pm, ameriblog <[EMAIL PROTECTED]> wrote:
> i have a site that lists candidates for mayor, on the page i have
> biographical information, also i want to include recent news for that
> candidate. i have news setup as a class in the models.py that has a
> ManyToMany relationship with the candidates (since plenty of news
> stories cover multiple candidates).
>
> i know how to use and setup templatetags and use them, what i am
> unsure of is how to use them to get the news item for that candidate.
>
> so for example if we have candidate John Doe we have his page 
> atwww.mysite.com/candidates/john-doe/that page would have his
> biographical information, on the right column i'd like to have the 10
> most recent news stories that are related to John Doe...

Weird.  First you post about sports ratings.  And now you are working
on an election system I presume.  Same here.  I'm working on a site
for an upcoming election this May in my city.  Get up with me.  Maybe
we can compare notes on both 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: scraping PDF

2008-03-29 Thread jeffself



On Mar 29, 12:56 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, Mar 28, 2008 at 11:21 PM,  <[EMAIL PROTECTED]> wrote:
> >  I'm trying to figure out the best way to link-up everything. Any
> >  suggestions?
>
> So, since I talked about it at PyCon, I'll take an example from this
> project:
>
> http://www2.ljworld.com/data/crime/ku/
>
> And I'll walk through this in a bit more detail than I did in my PyCon
> lightning talk, since I have more than five minutes to explain the
> process; of course, each data set you'll encounter will require some
> unique work to handle, but the general process is the same each time.
>
> The data was originally tables embedded in Microsoft Word documents,
> which were converted to HTML and then scraped with BeautifulSoup; the
> raw data was in the form of rows which looked like this:
>
> 04/23/2007 U077034 21-3701 14-304 1318 LOUISIANA 103 B 13 4 Building -
> Housing 88
> 11/26/2007 U0723675 21-3508a1 14-602 1323 OHIO   13 4 Building - Housing 88
> 08/14/2007 U0714884 21-3701a2 14-304 1515 ENGEL 307 O 12 4 Building - Housing 
> 88
>
> Some of this is irrelevant administrative stuff, so the bits I cared
> about here were:
>
> * The first field, which is the data of the crime report.
>
> * The third and fourth fields, which have data on the relevant
>   statute.
>
> * The fifth and sixth fields, which are the street address for the
>   report.
>
> I'd set up several models, but the relevant ones here were named
> ``ResidenceHall``, ``Offense`` and ``Crime``, where ``Crime``
> represents the actual report, and has foreign keys to ``Offense``
> (representing the particular crime -- burglary, vandalism, etc.) and
> to ``ResidenceHall``.
>
> What I ended up dumping to CSV was a set of data which looked like
> this:
>
> 2007-04-23,Theft,K.K. Amini Scholarship Hall
> 2007-11-26,Lewd and lascivious behavior,Dennis E. Rieger Scholarship Hall
> 2007-08-14,Theft,Templin Hall
>
> The path from the raw data to this CSV was a process of normalization;
> I chose to convert to a format of:
>
> report date,offense,residence hall
>
> Largely because of a couple of ambiguities in using other aspects of
> the data:
>
> * Though a statute number is unique within a specific legal code, we
>   were dealing with two different codes: the state laws and the city
>   ordinances. The name of the offense, however, was unique for both
>   sets.
>
> * Some residences are actually complexes of multiple buildings, or can
>   be otherwise be referred to using multiple street addresses; the
>   name of the residence is unique, though.
>
> So I set up two dictionaries: one mapped statute numbers to names of
> offenses, the other mapped street addresses to names of residence
> halls. From there, it was easy to loop over the raw data, look up the
> offense and the residence, and write out one row of normalized CSV for
> each row of raw data.
>
> This normalized CSV file was then used for a couple different
> purposes, including some initial exploration of the data by pulling it
> into a spreadsheet, and then the database import was handled by
> a script which:
>
> 1. Read in a row of CSV.
>
> 2. Used ``strftime`` to get a ``date`` object from the report date.
>
> 3. Looked up the offense by name from the ``Offense`` model.
>
> 4. Looked up the residence hall by name from the ``ResidenceHall``
>model.
>
> 5. Instantiated and saved a ``Crime`` object from these three pieces
>of data (since they corresponded to the fields on that model).
>
> And at that point I had nice, normalized, structured data and I could
> start building out the views of it.
>
> So the broad steps of the process are:
>
> 1. Find a way to get at the raw data so that it's easy to read from
>Python; in this case, that meant turning Word docs into HTML.
>
> 2. Figure out which parts of the data you care about, and build models
>to represent them in a structured way.
>
> 3. Read through the raw data and normalize it based on things you can
>guarantee will be unique to each type of record, and write this out
>to a standard format like CSV.
>
> 4. Run your database import from the normalized data; by this point
>it'll be in a format where you can simply look up relations on the
>fly and fill them in as you create new objects.
>
> Once you get used to it, and get over the initial hurdle of figuring
> out how to read the data from Python, this tends to go pretty quickly;
> as I mentioned in my PyCon talk, this crime-report project had the
> browseable database + views to drill down through the data within two
> days.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

I'm working on a similar project now, but it involves an election.  I
have direct access to the data so screen scraping won't be necessary.
However, the data is in Excel and I plan to either create CSV files
from Excel or use Python to directly read the Excel file and build a
CSV file from it.  The issue I see i

Re: sports ratings

2008-03-29 Thread jeffself

Hey ameriblog,

I do ratings as well.  My current application was written in C about
10 years ago and I've flirted with rewriting it in Python.  In fact, I
posted a message on comp.lang.python last year about trying to speed
up my app:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/1af4a5eb1a7dfe1b/1ce633422a37078f?lnk=gst&q=football#1ce633422a37078f

Do you participate on Kenneth Massey's site?

On Mar 29, 2:53 pm, ameriblog <[EMAIL PROTECTED]> wrote:
> i have my own formula used for sports ratings (like jeff sagarin, the
> bcs, etc). right now i have an old Visual Basic code that updates the
> ratings and i just save it as a text file and ftp to the web. i'd
> really love to make it dynamic, so it presents better ( 
> likehttp://kenpom.com/rpi.php), but also giving me the option of better
> utilizing the data and do some other studies easily.
>
> i new to django, i'm experienced with php. i could do it in php no
> doubt, but am really looking at doing a few projects in django as
> learning experiences.
>
> the formula isn't complex essentially an adjusted winning percentage
> (wins / games played). the tricky part is doing iterations until the
> ratings stabilize, right now i'm the ratings average out to 0.5 and i
> iterate the ratings over and over until none of them change more than
> 0.1.
>
> my dealings with django have been setting up like a blog, so i'm
> comfortable in writing everything to do with outputting the info once
> it's computed, but haven't done anything where it's a script/code that
> only i run, once a week that computes the ratings.
>
> any tips/tutorials on doing stuff like this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: templatetags

2008-03-29 Thread Michael Wieher
so...

use the view to select (10items) from news items where canidate=john-doe
order by date

then do whatever

On Sat, Mar 29, 2008 at 10:40 PM, ameriblog <[EMAIL PROTECTED]> wrote:

>
> i have a site that lists candidates for mayor, on the page i have
> biographical information, also i want to include recent news for that
> candidate. i have news setup as a class in the models.py that has a
> ManyToMany relationship with the candidates (since plenty of news
> stories cover multiple candidates).
>
> i know how to use and setup templatetags and use them, what i am
> unsure of is how to use them to get the news item for that candidate.
>
> so for example if we have candidate John Doe we have his page at
> www.mysite.com/candidates/john-doe/ that page would have his
> biographical information, on the right column i'd like to have the 10
> most recent news stories that are related to John Doe...
> >
>

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



templatetags

2008-03-29 Thread ameriblog

i have a site that lists candidates for mayor, on the page i have
biographical information, also i want to include recent news for that
candidate. i have news setup as a class in the models.py that has a
ManyToMany relationship with the candidates (since plenty of news
stories cover multiple candidates).

i know how to use and setup templatetags and use them, what i am
unsure of is how to use them to get the news item for that candidate.

so for example if we have candidate John Doe we have his page at
www.mysite.com/candidates/john-doe/ that page would have his
biographical information, on the right column i'd like to have the 10
most recent news stories that are related to John Doe...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FRIENDS YESTERDAY I MAKE $2,000BY TAKE SIMPLE ONLINE SURVEYS. YOU

2008-03-29 Thread donald

FRIENDS YESTERDAY I MAKE  $2,000BY TAKE SIMPLE ONLINE SURVEYS. YOU
JUST NEED TO JOIN THEIR COMMUNITY AND THEY GIVES YOU PLENTY OF
SURVEYS.YOU MAY CHOOSE BEST RATED SURVEY FROM THE LIST.EACH
SURVEYRATE
BEGINS WITH $200. THE LINK IS BELOW

http://jeevaraj.MYSURVEYPR.hop.clickbank.net


YOUR LIFE SHOULD BE CHANGE BY  THIS LINK

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



Re: Is Django thread safe?

2008-03-29 Thread James Bennett

On Sat, Mar 29, 2008 at 3:52 AM, Graham Dumpleton
<[EMAIL PROTECTED]> wrote:
>  The best I have ever been able to get out of anyone associated with
>  Django development about thread safety is the comments by Jacob Kaplan-
>  Moss in the following thread:

And that's really about the best anyone can say; there's never been
any exhaustive review of the codebase to look for threading issues,
but at the same time there are people who run Django under various
threaded solutions and it seems to be working for them (and if it
doesn't they should report bugs).

The more general problem of writing thread-safe code is, of course, a
huge topic, so I'm not sure that we could take Peter's suggestion and
document "how to write thread-safe Django apps" without straying quite
far from the "Django" bit and over into the "writing thread-safe code"
bit ;)


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



GSoC idea for Django-friendly static checkers

2008-03-29 Thread Todd O'Bryan
Sorry I'm so late suggesting this, but...

Do people have a desire/see a need for a way to make Pylint or PyChecker
handle Django code more robustly? Because so many of the attributes of
Django model and form objects are given as class objects or are
auto-generated in instance creation, using a static checker on Django code
is a mess.

Would a good GSoC project involve modifying one or both of the standard
Python code checkers so that they're smarter about Django?

Or maybe everybody thinks static checking is for wimps and I should just
stop misspelling things...

Todd

P.S. I'm not a student, but I teach students who might be interested in
applying.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Finding out the index of a model instance in a list

2008-03-29 Thread [EMAIL PROTECTED]

I'd consider grabbing a list of GalleryImage objects and then using
the forloop.counter in the template as you iterate over each item.

Right now, it looks like you're only grabbing one item with IImage,
even though you're using filter(). I'd try it this way:

ImageList = GalleryImage.objects.filter(album_id=foo).select_related()

then pass ImageList and ImageList.count() to the template, where you
can use the forloop.counter:

http://www.djangoproject.com/documentation/templates/#for

Derek Willis

On Mar 29, 7:00 pm, Tim Sawyer <[EMAIL PROTECTED]> wrote:
> Is there a better way that this?
>
> lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
> lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
> lImagesInAlbum = lAlbumImages.count()
> lImagePosition = None
> lPreviousImage = None
> lNextImage = None
> for lPosition in range(lImagesInAlbum):
> lEachImage = lAlbumImages[lPosition]
> if lEachImage.id == lImage.id:
> lImagePosition = lPosition + 1
> if lPosition > 0:
> lPreviousImage = lAlbumImages[lPosition-1]
> if lPosition < lImagesInAlbum-1:
> lNextImage = lAlbumImages[lPosition+1]
> break
>
> On Saturday 29 Mar 2008, Tim Sawyer wrote:
>
> > Hi Folks,
>
> > If I have an image, and a list of images, how can I work out what position
> > in the list my image is so I can do a Image 4 of 24 type annotation?
>
> > lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
> > lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
> > lImagesInAlbum = lAlbumImages.count()
> > lImagePosition = ???
>
> > My view is passed pImageSerial which is the id of the image to display.  I
> > can work out the Image object from this.  I can also get the full list of
> > images for this particular album, and work out how many images there are in
> > total. The images are ordered by filename, so I know the order will be
> > consistent.
>
> > How do I work out lImagePosition?  Can anyone give me any pointers?
>
> > Thanks,
>
> > Tim.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is Django thread safe?

2008-03-29 Thread Eric

Sorry, I forgot to post the url to the fastcgi docs
http://www.djangoproject.com/documentation/fastcgi/



On Mar 29, 7:52 pm, Eric <[EMAIL PROTECTED]> wrote:
> I currently use lighttpd and fastcgi, and I noticed that in the django
> documentation that they mention using threaded instead of prefork when
> running your fcgi server.
>
> I had the same fears and I used prefork first, but after some load
> testing of both, I decided to use threaded.  I'm a brave soul and I
> assumed that if the documentation prefered threaded, it was safe.
>
> Generally your pretty safe with threading unless you're using module
> level or global variables.
>
> I hope that helps.
>
> Eric.
>
> On Mar 29, 3:26 pm, Peter Rowell <[EMAIL PROTECTED]> wrote:
>
> > > The best I have ever been able to get out of anyone associated with
> > > Django development about thread safety is the comments by Jacob Kaplan-
> > > Moss in the following thread:
>
> > Sigh. Reading through that thread was singularly unsatisfying. I guess
> > that, for the moment, I'll have to stick with prefork.
>
> > If Django, minus any DB-related issues, is thread safe, and if the
> > supplied apps (auth comes to mind) are written correctly, then perhaps
> > Django-out-of-the-box could be declared thread safe.
>
> > Some appropriate warnings/suggestions could be put in the docs. Maybe
> > point out user operations that could pose a problem and suggest
> > possible ways to handle them.
>
> >   Thanks again,
> >   Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is Django thread safe?

2008-03-29 Thread Eric

I currently use lighttpd and fastcgi, and I noticed that in the django
documentation that they mention using threaded instead of prefork when
running your fcgi server.

I had the same fears and I used prefork first, but after some load
testing of both, I decided to use threaded.  I'm a brave soul and I
assumed that if the documentation prefered threaded, it was safe.

Generally your pretty safe with threading unless you're using module
level or global variables.

I hope that helps.

Eric.

On Mar 29, 3:26 pm, Peter Rowell <[EMAIL PROTECTED]> wrote:
> > The best I have ever been able to get out of anyone associated with
> > Django development about thread safety is the comments by Jacob Kaplan-
> > Moss in the following thread:
>
> Sigh. Reading through that thread was singularly unsatisfying. I guess
> that, for the moment, I'll have to stick with prefork.
>
> If Django, minus any DB-related issues, is thread safe, and if the
> supplied apps (auth comes to mind) are written correctly, then perhaps
> Django-out-of-the-box could be declared thread safe.
>
> Some appropriate warnings/suggestions could be put in the docs. Maybe
> point out user operations that could pose a problem and suggest
> possible ways to handle them.
>
>   Thanks again,
>   Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Finding out the index of a model instance in a list

2008-03-29 Thread Colin Bean

>
> lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
> lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
> lImagesInAlbum = lAlbumImages.count()
> lImagePosition = None
> lPreviousImage = None
> lNextImage = None
> for lPosition in range(lImagesInAlbum):
> lEachImage = lAlbumImages[lPosition]
> if lEachImage.id == lImage.id:
> lImagePosition = lPosition + 1
> if lPosition > 0:
> lPreviousImage = lAlbumImages[lPosition-1]
> if lPosition < lImagesInAlbum-1:
> lNextImage = lAlbumImages[lPosition+1]
> break
>


Pagination might be what you're looking for:
http://www.djangoproject.com/documentation/pagination/

Colin

>
>
>  On Saturday 29 Mar 2008, Tim Sawyer wrote:
>  > Hi Folks,
>  >
>  > If I have an image, and a list of images, how can I work out what position
>  > in the list my image is so I can do a Image 4 of 24 type annotation?
>  >
>  > lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
>  > lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
>  > lImagesInAlbum = lAlbumImages.count()
>  > lImagePosition = ???
>  >
>  > My view is passed pImageSerial which is the id of the image to display.  I
>  > can work out the Image object from this.  I can also get the full list of
>  > images for this particular album, and work out how many images there are in
>  > total. The images are ordered by filename, so I know the order will be
>  > consistent.
>  >
>  > How do I work out lImagePosition?  Can anyone give me any pointers?
>  >
>  > Thanks,
>  >
>  > Tim.
>  >
>  >
>
>
>  >
>

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



Shell reloading

2008-03-29 Thread Jorge Sousa
Hi,

I'm using Django on windows.
Is it possible to, once inside the Django Shell (manage.py shell) while
testing some bint and changing the code in a model method to have it
available to the shell?
Kind of autoreload thing.
It only work by exiting the shell and entering again. But then have to
import everything again.

Thanks

Jorge Sousa

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



Re: Finding out the index of a model instance in a list

2008-03-29 Thread Tim Sawyer

Is there a better way that this?

lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
lImagesInAlbum = lAlbumImages.count()
lImagePosition = None
lPreviousImage = None
lNextImage = None
for lPosition in range(lImagesInAlbum):
lEachImage = lAlbumImages[lPosition]
if lEachImage.id == lImage.id:
lImagePosition = lPosition + 1
if lPosition > 0:
lPreviousImage = lAlbumImages[lPosition-1]
if lPosition < lImagesInAlbum-1:
lNextImage = lAlbumImages[lPosition+1]
break

On Saturday 29 Mar 2008, Tim Sawyer wrote:
> Hi Folks,
>
> If I have an image, and a list of images, how can I work out what position
> in the list my image is so I can do a Image 4 of 24 type annotation?
>
> lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
> lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
> lImagesInAlbum = lAlbumImages.count()
> lImagePosition = ???
>
> My view is passed pImageSerial which is the id of the image to display.  I
> can work out the Image object from this.  I can also get the full list of
> images for this particular album, and work out how many images there are in
> total. The images are ordered by filename, so I know the order will be
> consistent.
>
> How do I work out lImagePosition?  Can anyone give me any pointers?
>
> Thanks,
>
> Tim.
>
> 


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



Need Help Thinking Through How to Setup URLS and VIEWS

2008-03-29 Thread [EMAIL PROTECTED]

I am stuck trying to think through how to work something out. I want a
user to be able to create sections in an admin for a site. A user can
assign pages to a section. For instance, create the section About and
add the pages About Us and Contact and Staff.

That is all done. No problems. The part that is hard for me is
thinking through to Urls and Views.

This is kind of what makes sense to me:

If a slug contains just a page name... display the page detail. If a
slug contains a section name... display the section and any page
associated with it. Maybe a page list.. I have a different way to
designate the section homepage.

Anyways... I thought.. ooh, wrappers would work well here. What I need
is to create a wrapper that useses the generic.views.object_detail.
That is easy enough.

Problem is... how do I query other models based on many to many
relationships ... my head is swimming.

I realize this is alot. Can anyone suggest a direction to start
looking?

Specifically, i need help with:
1. How do I test to see what a slug is? I.E. In my case, is it a
section or a page.

Finally, am I barking up the wrong tree? Would it be simpler to just
write a custom view that does what I want? Any advice is much
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
-~--~~~~--~~--~--~---



Finding out the index of a model instance in a list

2008-03-29 Thread Tim Sawyer

Hi Folks,

If I have an image, and a list of images, how can I work out what position in 
the list my image is so I can do a Image 4 of 24 type annotation?

lImage = GalleryImage.objects.filter(pk=pImageSerial).select_related()[0]
lAlbumImages = GalleryImage.objects.filter(album__id = lImage.album.id)
lImagesInAlbum = lAlbumImages.count()
lImagePosition = ???

My view is passed pImageSerial which is the id of the image to display.  I can 
work out the Image object from this.  I can also get the full list of images 
for this particular album, and work out how many images there are in total.  
The images are ordered by filename, so I know the order will be consistent.

How do I work out lImagePosition?  Can anyone give me any pointers?

Thanks,

Tim.

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



Re: sys.path vraag

2008-03-29 Thread Baurzhan Ismagulov

Hello Jaap,

On Sat, Mar 29, 2008 at 06:47:39AM -0700, Jaap wrote:
> Path onder Windows XP Home is:
> D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
> %SystemRoot%\System32\Wbem
> 
> Als ik de interpreter in PyScripter gebruik, dan krijg ik:
> >>> print sys.path
> ['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
> \Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
> Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
> packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib\
> \site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
> \lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']
> 
> Waarom zijn deze paden verschillend?

PATH is the list of directories where Windows looks for executables if
you don't specify an absolute path name. sys.path is where the Python
interpreter looks for the modules to import, see
http://docs.python.org/lib/module-sys.html .

Are you looking for os.environ['PATH'],
http://docs.python.org/lib/os-procinfo.html ?

With kind regards,
-- 
Baurzhan Ismagulov
http://www.kz-easy.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: Clearing the cache

2008-03-29 Thread Mike H


On 29 Mar 2008, at 17:49, Sebastjan Trepca wrote:
>
> I would use signals for this. For example, you could hook on post_save
> signal, so whenever a model gets saved, you refresh the cache etc.

Unfortunately it's not as simple as that, we cache groups of models,  
querysets, portions of html that many models have had their data used  
in, so there's no way for a model to know all the keys that it needs  
to 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: Is Django thread safe?

2008-03-29 Thread Peter Rowell

> The best I have ever been able to get out of anyone associated with
> Django development about thread safety is the comments by Jacob Kaplan-
> Moss in the following thread:

Sigh. Reading through that thread was singularly unsatisfying. I guess
that, for the moment, I'll have to stick with prefork.

If Django, minus any DB-related issues, is thread safe, and if the
supplied apps (auth comes to mind) are written correctly, then perhaps
Django-out-of-the-box could be declared thread safe.

Some appropriate warnings/suggestions could be put in the docs. Maybe
point out user operations that could pose a problem and suggest
possible ways to handle them.

  Thanks again,
  Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: sports ratings

2008-03-29 Thread shabda

Read this, www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/
, and create a standalone django script. Then set up a cron job to run
your script when you want.

On Mar 29, 11:53 pm, ameriblog <[EMAIL PROTECTED]> wrote:
> i have my own formula used for sports ratings (like jeff sagarin, the
> bcs, etc). right now i have an old Visual Basic code that updates the
> ratings and i just save it as a text file and ftp to the web. i'd
> really love to make it dynamic, so it presents better ( 
> likehttp://kenpom.com/rpi.php), but also giving me the option of better
> utilizing the data and do some other studies easily.
>
> i new to django, i'm experienced with php. i could do it in php no
> doubt, but am really looking at doing a few projects in django as
> learning experiences.
>
> the formula isn't complex essentially an adjusted winning percentage
> (wins / games played). the tricky part is doing iterations until the
> ratings stabilize, right now i'm the ratings average out to 0.5 and i
> iterate the ratings over and over until none of them change more than
> 0.1.
>
> my dealings with django have been setting up like a blog, so i'm
> comfortable in writing everything to do with outputting the info once
> it's computed, but haven't done anything where it's a script/code that
> only i run, once a week that computes the ratings.
>
> any tips/tutorials on doing stuff like this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



sports ratings

2008-03-29 Thread ameriblog

i have my own formula used for sports ratings (like jeff sagarin, the
bcs, etc). right now i have an old Visual Basic code that updates the
ratings and i just save it as a text file and ftp to the web. i'd
really love to make it dynamic, so it presents better ( like
http://kenpom.com/rpi.php ), but also giving me the option of better
utilizing the data and do some other studies easily.

i new to django, i'm experienced with php. i could do it in php no
doubt, but am really looking at doing a few projects in django as
learning experiences.

the formula isn't complex essentially an adjusted winning percentage
(wins / games played). the tricky part is doing iterations until the
ratings stabilize, right now i'm the ratings average out to 0.5 and i
iterate the ratings over and over until none of them change more than
0.1.

my dealings with django have been setting up like a blog, so i'm
comfortable in writing everything to do with outputting the info once
it's computed, but haven't done anything where it's a script/code that
only i run, once a week that computes the ratings.

any tips/tutorials on doing stuff like this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: compiling files when installing to a web server

2008-03-29 Thread andy baxter

Michael Wieher wrote:
> I had an intermittent error when using just apache/mod_python, but 
> haven't had it happen since i started w/django
>
It looks like the speed issue is to do with memory - with just apache2, 
mysqld and django running, it was 72M into swap. So I guess I need to 
get a faster machine. It's not too much of a problem at the moment 
though because this machine is just for running a demo - I'm not 
planning to use it for the live site.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: compiling files when installing to a web server

2008-03-29 Thread Michael Wieher
I had an intermittent error when using just apache/mod_python, but haven't
had it happen since i started w/django

On Sat, Mar 29, 2008 at 1:18 PM, andy baxter <
[EMAIL PROTECTED]> wrote:

>
> Michael Wieher wrote:
> > Well, if you could describe the error in detail, hopefully with
> > copy/paste, traceback etc. it would be easier to determine if it was
> > due to memory issues or misconfiguration...
> >
> What was happening is every now and again mod_python (not django) would
> generate an error page saying something along the lines of:
>
> 'Can't find module encoding in django.utils'
>
> But most of the time it worked OK, and
> DJANGO-PATH/django/utils/encoding.py does exist.
>
> I can't remember the exact error, and it seems to have stopped doing it
> at the moment. If it happens again I'll paste the error message here. It
> was an intermittent error - if I left it for a minute or two and tried
> again it cured itself without my having done anything to the machine.
>
> andy.
>
> >
>

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



Re: compiling files when installing to a web server

2008-03-29 Thread andy baxter

Michael Wieher wrote:
> Well, if you could describe the error in detail, hopefully with 
> copy/paste, traceback etc. it would be easier to determine if it was 
> due to memory issues or misconfiguration...
>
What was happening is every now and again mod_python (not django) would 
generate an error page saying something along the lines of:

'Can't find module encoding in django.utils'

But most of the time it worked OK, and 
DJANGO-PATH/django/utils/encoding.py does exist.

I can't remember the exact error, and it seems to have stopped doing it 
at the moment. If it happens again I'll paste the error message here. It 
was an intermittent error - if I left it for a minute or two and tried 
again it cured itself without my having done anything to the machine.

andy.

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



Re: compiling files when installing to a web server

2008-03-29 Thread Michael Wieher
Well, if you could describe the error in detail, hopefully with copy/paste,
traceback etc. it would be easier to determine if it was due to memory
issues or misconfiguration...

On Sat, Mar 29, 2008 at 1:10 PM, andy baxter <
[EMAIL PROTECTED]> wrote:

>
> andy baxter wrote:
> > andy baxter wrote:
> >
> >> hello,
> >>
> >> I have just installed a demo of an app I'm writing to a web server.
> >> There seems to be an intermittent error, and I'm wondering if this is
> to
> >> do with the permissions on the directories - I've tried to set the
> >> permissions so it can create .pyc files, but this doesn't seem to be
> >> working. What is the right way to set this up? for example is there a
> >> python command you can run to force all the modules in a given path to
> >> compile?
> >>
> >> andy baxter.
> >>
> >> -
> >>
> > I just found out how to do this:
> >
> > http://docs.python.org/lib/module-compileall.html
> >
> > andy.
> >
> Incidentally, I am running the demo on an old pentium II with 32M of
> memory, and it's a bit slow - 3-4 seconds page load times. Is this to be
> expected, or am I doing something wrong? What would people say are the
> recommended specs for a machine running a django app (assuming fairly
> light load where what matters is the response times for single requests,
> not having to deal with many concurrent requests)?
>
> andy.
>
> >
>

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



Re: compiling files when installing to a web server

2008-03-29 Thread andy baxter

andy baxter wrote:
> andy baxter wrote:
>   
>> hello,
>>
>> I have just installed a demo of an app I'm writing to a web server. 
>> There seems to be an intermittent error, and I'm wondering if this is to 
>> do with the permissions on the directories - I've tried to set the 
>> permissions so it can create .pyc files, but this doesn't seem to be 
>> working. What is the right way to set this up? for example is there a 
>> python command you can run to force all the modules in a given path to 
>> compile?
>>
>> andy baxter.
>>
>> -
>> 
> I just found out how to do this:
>
> http://docs.python.org/lib/module-compileall.html
>
> andy.
>   
Incidentally, I am running the demo on an old pentium II with 32M of 
memory, and it's a bit slow - 3-4 seconds page load times. Is this to be 
expected, or am I doing something wrong? What would people say are the 
recommended specs for a machine running a django app (assuming fairly 
light load where what matters is the response times for single requests, 
not having to deal with many concurrent requests)?

andy.

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



Re: compiling files when installing to a web server

2008-03-29 Thread andy baxter

andy baxter wrote:
> hello,
>
> I have just installed a demo of an app I'm writing to a web server. 
> There seems to be an intermittent error, and I'm wondering if this is to 
> do with the permissions on the directories - I've tried to set the 
> permissions so it can create .pyc files, but this doesn't seem to be 
> working. What is the right way to set this up? for example is there a 
> python command you can run to force all the modules in a given path to 
> compile?
>
> andy baxter.
>
> -
I just found out how to do this:

http://docs.python.org/lib/module-compileall.html

andy.

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



Re: Clearing the cache

2008-03-29 Thread Sebastjan Trepca

I would use signals for this. For example, you could hook on post_save
signal, so whenever a model gets saved, you refresh the cache etc.

Sebastjan

On Sat, Mar 29, 2008 at 4:35 PM, Mike H <[EMAIL PROTECTED]> wrote:
>
>  Hi,
>
>  I have models, views and managers that cache various things in the
>  application we're building. It all works fantastically, once
>  everything is cache we got zero queries run until the cache expires.
>  However, if the cache is turned on while we run our unit tests, things
>  start failing as we get back cached versions of things instead of the
>  data that the tests are setting up...
>
>  So, is there a standard way of clearing cache? There seems to be a
>  method on the locmem backend but it's not a standard interface across
>  all backends.
>
>  Any ideas?
>
>  Thanks,
>
>  Mike
>
>  >
>



-- 
Sebastjan

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



Re: Newforms

2008-03-29 Thread Sebastjan Trepca

Hi,

why can't you rather do this:

form = SomeForm(fields, data)
form.is_valid()

You can easily fool with fields in constructor and then call the super
with data set.

Sebastjan

On Sat, Mar 29, 2008 at 6:08 PM, Rufman <[EMAIL PROTECTED]> wrote:
>
>  Hey Guys
>
>  How and when do the django newforms validate forms and add errors to
>  the errors dictionary?
>
>  Im trying to make a dynamic form, so I add the data after creating the
>  form class and adding the attributes. This means that I will need to
>  'manually' call the form validation.
>
>  ex:
> when I do  form = SomeForm(request.POST) the fields are evaluated
>  automatically.
> I want to call this evaluation manually so that I can d:
>
> form = SomeForm()
> form.setFileds(kwargs)
> form.setData(equest.POST)
> form.
>
>
>  Thanks
>
>  Stephane
>  >
>



-- 
Sebastjan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Unittest test-database not empty

2008-03-29 Thread Emil Stenström

Hi rock,

I had the same problem and traced it to one of the contrib.auth tests.
It seems they don't delete two of the testusers there. I added a
ticket about it (http://code.djangoproject.com/ticket/6923), and will
just use another username for my own tests meanwhile.

/Emil

On 30 Jan, 10:34, rock <[EMAIL PROTECTED]> wrote:
> I have no fixtures/initial_data-files anywhere in my project tree!
> Actually, the only file named "initial_data" on my system is djtrunk/
> tests/modeltests/fixtures/fixtures/initial_data.json. And that file
> doesn't contain much.
>
> The "ghost-users" only show up when I'm running "./manage.py test".
> When I delete the project database and run "./manage.py syncdb" and "./
> manage.py runserver" an empty database is created. So I guess my
> problem has something to do with the unittesting, but it is still
> magic to me how and when these users are created.
>
> Best regards,
> Stein
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Access control

2008-03-29 Thread Peter Herndon

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



On Sat, Mar 29, 2008 at 1:04 PM, Wilson Acha <[EMAIL PROTECTED]> wrote:
>
>  Hello, django have any library that allows include a login and enable
>  restrict access to different parts of the application according to
>  roles and / or profiles
>
>  Wilson
>
>  >
>

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



Newforms

2008-03-29 Thread Rufman

Hey Guys

How and when do the django newforms validate forms and add errors to
the errors dictionary?

Im trying to make a dynamic form, so I add the data after creating the
form class and adding the attributes. This means that I will need to
'manually' call the form validation.

ex:
when I do  form = SomeForm(request.POST) the fields are evaluated
automatically.
I want to call this evaluation manually so that I can d:

form = SomeForm()
form.setFileds(kwargs)
form.setData(equest.POST)
form.


Thanks

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



Access control

2008-03-29 Thread Wilson Acha

Hello, django have any library that allows include a login and enable
restrict access to different parts of the application according to
roles and / or profiles

Wilson

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 created in postgresql is not found when Adding Data to the API.

2008-03-29 Thread Chirolo

Hi again.
Thank you once again Thomas.
I tried what you recommended and nothing worked.
Once again the problem was that I'm a newbie trying to learn.
Here is what I had done wrong since I started with this problem:
One field was never validated in my 'model.py' after running
'manage.py syncdb',
but I assumed that I could continue with my project. I never corrected
it, until now.
Here is the error that I used to get:
[EMAIL PROTECTED]:~/django_projects/iFriends/iFriends$ python manage.py
syncdb
Error: One or more models did not validate:
People.person: "headshot": To use ImageFields, you need to install the
Python Imaging Library. Get it at http://www.pythonware.com/products/pil/
.

I erased this field from my model.py and boom! IT WORKED

[EMAIL PROTECTED]:~/django_projects/iFriends/iFriends$ python manage.py
syncdb
Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table People_person
THIS IS WHAT YOU ARE SUPPOSED TO SEE WHEN RUNNING 'manage.py syncdb'

Here is my data input to the Database:
(InteractiveConsole)
>>> from iFriends.People.models import Person
>>> p = Person(name="Wiston Guzman", email="[EMAIL PROTECTED]")
>>> p.save()
>>> lst = Person.objects.all()
>>> print lst
[]
>>>
"MORALEJA: We tried to follow rules, but those rules are not well
defined. Then, we struggle along the way
until we find our own answers with the help of those who care"
WG

On Mar 26, 10:40 pm, Chirolo <[EMAIL PROTECTED]> wrote:
> Hi again.
> I tried what Thomas suggested, but I still get the following error:
> NameError: name 'pwdtuple' is not defined
>
> [EMAIL PROTECTED]:~/django_projects/iFriends/iFriends$ python manage.py
> shell
> Traceback (most recent call last):
>   File "manage.py", line 4, in 
> import settings # Assumed to be in the same directory.
>   File "/home/wistong/django_projects/iFriends/iFriends/settings.py",
> line 13, in 
> user=pwdtuple[0]
> NameError: name 'pwdtuple' is not defined
> Any ideas to fix this problem, so I can continue my learning curve.
> Thank you.
> WG
>
> On Mar 25, 7:25 pm, Chirolo <[EMAIL PROTECTED]> wrote:
>
> > Hello to all.
> > I'm a newbie trying to learn Django.
> > I'm running Django in a local machine with postgresql_psycop2 database
> > in Ubuntu 6.02.
> > So far I have been able to set up Django, Postgresql with no problems.
> > I was able to create a project name iFriends, a model People, and a
> > class Person.
> > I also created a databased named iFriendsDB with a user name 'amigo'
> > and a password 'test'.
> > I had a problem with the authentication first and I went to change the
> > file pg_hba.conf
> > I change the socket local table field method, first I tried 'md5' and
> > it didn't work, then I changed to 'trust' and It worked.
>
> > # TYPE DATABASE USER CIDR-ADDRESS METHOD
>
> > # "local" is for Unix domain socket connections only
> > local all all trust
> > # IPv4 local connections:
> > host all all 127.0.0.1/32 trust
> > # IPv6 local connections:
> > host all all ::1/128 trust
>
> > But the PROBLEM that I have now is the following message:
> > OperationalError: FATAL:  role "amigo" does not exist
>
> > >>> from iFriends.People.models import Person
> > >>> p = Person(name="name", email="email-adress")
> > >>> p.save()
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/usr/lib/python2.5/site-packages/django/db/models/base.py",
> > line 218, in save
> > cursor = connection.cursor()
> >   File "/usr/lib/python2.5/site-packages/django/db/backends/
> > __init__.py", line 33, in cursor
> > cursor = self._cursor(settings)
> >   File "/usr/lib/python2.5/site-packages/django/db/backends/
> > postgresql_psycopg2/base.py", line 69, in _cursor
> > self.connection = Database.connect(conn_string, **self.options)
> > OperationalError: FATAL:  role "amigo" does not exist
>
> > by the way I changed several times the user name and password and I
> > added them to 'settings.py'
>
> > Any Ideas what do I need to change.
>
> > Thank you.
> > Chirolo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



newform dynamic model

2008-03-29 Thread Radim

I need to pass a model to Form class as an attribute, I want to write
a generic view. How to do it?

class Frm(forms.ModelForm):
def __init__(self,model,instance):
self.model = model
forms.ModelForm.__init__(self,instance=instance)
class Meta:
model = model # <- how to get an attribute here?

form = Frm(instance=obj, model=model)

I.e. how can I pass an attribute to a class declared inside another
class? I know this is Python not Django question but hopefully
somebody can help me.

Thanks
Radim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: sys.path question

2008-03-29 Thread Jaap

The name 'sys' is confusing. If it had been named 'python.path'
instead of 'sys.path' I would have known where to look... I will be
asking stupid questions for the next month or so - it's the fate of
the newbie.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with nested loop

2008-03-29 Thread Brandon Taylor

Thank you SO much for helping Kenneth. I just had to change
'workcategory_set' to 'worksample_set' and it's all good. I never
would have found this in the documentation without knowing the '_set'
keyword, but for those of you who are interested, it's in the
documentation here: http://www.djangoproject.com/documentation/db-api/#backward

Thanks again!
Brandon

On Mar 29, 1:23 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 29-Mar-08, at 11:43 AM, Kenneth Gonsalves wrote:
>
> > {% for w in wc %}
>
> w.title    <-- forgot this
>
> >     
> > {% for sample in w.workcategory_set.all %}
> > sample
> > {% endfor %}
> > 
> > {% endfor %}
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Language code as part of URL

2008-03-29 Thread [EMAIL PROTECTED]

This isn't an answer to your technical query but rather some thoughts
on how to do localisation in URLs.

Localisation in URLs is tricky because the best way to do it varies
enormously depending on the nature of your localisation.

If the content is ultimately the same and you're simply offering
translations you don't want to put the language code before the
resource in the URL. Ie you don't want /fi/second/example/ because the
hierarchy implies that for a different country it's actually a
different object. My preferred approach for translations is /second/
example,fi/ (comma seperated as outlined in 
http://tools.ietf.org/html/rfc3986#page-23).
This says to users that they're viewing the same resource but in a
different language.

If the content of a whole section of the site is actually different
(ie not just a translation) depending on country then using a country
path segment in the URL is fine. An example use case would be the
Apple Store where the product range and information are actually
different in different countries.

This article discusses localisation in URLs in more details:
http://h3h.net/2007/01/designing-urls-for-multilingual-web-sites/

Regards,
Andrew Ingram

akaihola wrote:
> I have a website with the following i18n requirements:
>
>   Part of the site is monolingual with conventional URLs (e.g. /first/
> example/).
>
>   Another part of the site is multi-lingual content from the database
> (flatpages-like). The language code should be accepted as a prefix in
> the URL (e.g. /fi/second/example/).
>
>   Links generated with {% url %} and reverse() should retain the
> language prefix.
>
>   Multi-lingual content is editable by authorized users.
>
>   If a URL for a multi-lingual page is requested but the language code
> is missing, a redirect is done according to the visitor's active
> language (e.g. /second/example/ -> /fi/second/example/).
>
>   When editing multi-lingual pages in any language, the editing user
> interface stays always in one language chosen by the user (e.g. UI in
> German when editing content in German, Swedish or English).
>
>   If the requested multi-lingual page hasn't been translated to the
> visitor's current language, a redirect is done to an existing
> translation (according to browser preferences or site's default
> language). But navigation and other links to other pages should point
> back to URLs with the originally requested language.
>
>   In the links for viewing pages in another language, the language
> names should be in the language itself (see 
> http://code.djangoproject.com/ticket/4030).
>
>
> We have most of this functionality implemented and working, but the
> code is rather involved. I'd like to create clean, re-usable modules
> instead.
>
> I'm currently out of ideas for how to design the language code URL
> prefix handling as a drop-in module for use with any views which
> utilize Django's standard i18n infrastructure. The troublesome point
> is how to keep the language code prefix when using {% url %} /
> reverse() without having to modify the views.
>
> It's simple to use either middleware or a decorator to catch the
> language code prefix, activate the correct language and strip the
> language variable from being passed on to the view. I'm leaning on the
> decorator side since part of the site doesn't use the prefix.
>
> Currently I have a customized url() function for creating language-
> prefixed urlpattern rules. It returns a subclassed RegexURLPattern or
> RegexURLResolver which modifies the regex to catch the language
> prefix. Views are wrapped in a decorator which consumes the prefix and
> activates the correct language.
>
> The problem is that since the language prefix catcher is now part of
> the regex, I can't use  reverse() in the view or {% url %} in the
> template without modifying views/templates to pass the current
> language explicitly as a kwarg. That's goodbye to drop-in style re-
> usability.
>
> The way reverse() is implemented makes it difficult to inject the
> value of get_language() back into the URL. I doubt that the required
> changes will be accepted in Django.
>
>
> Maybe there's an easy solution I just can't see now. Also, if anyone
> has similar requirements as described above, it would be fruitful to
> share thoughts and code. If we manage to create re-usable components
> with no pre-existing counterparts, we'll of course publish and
> maintain them.
>
>
> I've collected some relevant links here: 
> http://www.diigo.com/user/akaihola/django+language-in-url
>
>
> -Antti
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: sys.path question

2008-03-29 Thread Evert Rol

> Path in Windows XP Home is:
> D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
> %SystemRoot%\System32\Wbem
>
> When I use the interpreter in PyScripter, I see:
 print sys.path
>
> ['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
> \Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
> Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
> packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib
> \
> \site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
> \lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']
>
> Why are these paths different?

The first is the path where Windows looks for executables (PATH).
The second is the path where Python looks for modules, internal and  
external (the latter is most important to you).
The first is used to find eg a Python script, if you try to run it  
from the command line from a different location (directory) than where  
the script is located. The second path is used 'inside' the script to  
be able to find and import modules.

This kind of questions is probably better asked at different mailing  
list, since they are not Django related; eg Python tutor. There's even  
a Dutch Python group, that may be suitable for you as well, [EMAIL PROTECTED] 
: http://mail.python.org/mailman/listinfo/python-nl
The answer here may be useful anyway, since some other people may  
confuse the two paths and would then ask the list how to get eg Django  
running (although not so sure if they would search the list archives  
first).


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



Clearing the cache

2008-03-29 Thread Mike H

Hi,

I have models, views and managers that cache various things in the  
application we're building. It all works fantastically, once  
everything is cache we got zero queries run until the cache expires.  
However, if the cache is turned on while we run our unit tests, things  
start failing as we get back cached versions of things instead of the  
data that the tests are setting up...

So, is there a standard way of clearing cache? There seems to be a  
method on the locmem backend but it's not a standard interface across  
all backends.

Any ideas?

Thanks,

Mike

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: sys.path question

2008-03-29 Thread Ned Batchelder
They are not meant to be the same.  Windows' PATH is the list of 
directories Windows will search for executables when running a command 
from the command line.  Python's sys.path is the list of directories 
Python will search for modules to import.

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

Jaap wrote:
> Path in Windows XP Home is:
> D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
> %SystemRoot%\System32\Wbem
>
> When I use the interpreter in PyScripter, I see:
>   
 print sys.path
 
>
> ['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
> \Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
> Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
> packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib
> \
> \site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
> \lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']
>
> Why are these paths different?
>
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


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



sys.path question

2008-03-29 Thread Jaap

Path in Windows XP Home is:
D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem

When I use the interpreter in PyScripter, I see:
>>> print sys.path

['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
\Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib
\
\site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
\lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']

Why are these paths different?

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



compiling files when installing to a web server

2008-03-29 Thread andy baxter

hello,

I have just installed a demo of an app I'm writing to a web server. 
There seems to be an intermittent error, and I'm wondering if this is to 
do with the permissions on the directories - I've tried to set the 
permissions so it can create .pyc files, but this doesn't seem to be 
working. What is the right way to set this up? for example is there a 
python command you can run to force all the modules in a given path to 
compile?

andy baxter.

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



Problem with django unit testing

2008-03-29 Thread [EMAIL PROTECTED]

Hi, all,

I meet a strangely problem on django unit testing. I use django svn
version, the test code like this:

"""
from django.test import TestCase
...

class test(TestCase):
  ...
  def setUp(self):
...

  def test_template(self):
# Test Templates for register
response = self.client.get('/accounts/register/')
self.assertTemplateUsed(response, "account/register.html")
...
"""

When I run unit test to test the class use:
  $ ./manage.py test apps.test

I'll get a failed info:
"""
F
==
FAIL:  test_template(apps.tests)
--
Traceback (most recent call last):
  File ".../apps/tests.py", line 486, in test_template
self.assertTemplateUsed(response, "account/register.html")
  File ".../django/test/testcases.py", line 185, in assertTemplateUsed
self.fail('No templates used to render the response')
AssertionError: No templates used to render the response
"""

but when I run unit test to test the failed function use:
  $ ./manage.py test apps.test.test_template
there will be ok:
"""
.
--
Ran 1 test in 1.336s

OK
"""

and I use "print respone.context" to see the template context of
response,
when I test the class, it won't get nothing(the value of
respone.context is "None"), while I test the funtion, it will get a
correct value...

Any one can tell me that's why? Thank you so much!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



sys.path vraag

2008-03-29 Thread Jaap

Path onder Windows XP Home is:
D:\Phyton25\;D:\Python25Scripts;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem

Als ik de interpreter in PyScripter gebruik, dan krijg ik:
>>> print sys.path
['C:\\Windows\\system32\\python25.zip', 'D:\\Python25\\Lib', 'D:\
\Python25\\DLLs', 'D:\\Python25\\Lib\\lib-tk', 'C:\\Documents and
Settings\\', 'D:\\Python25', 'D:\\Python25\\lib\\site-
packages', 'D:\\Python25\\lib\\site-packages\\PIL', 'D:\\Python25\\lib\
\site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\
\lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin']

Waarom zijn deze paden verschillend?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 with Apache + mod_python [SOLVED]

2008-03-29 Thread Ramiro Morales

On Fri, Mar 28, 2008 at 11:45 PM, Graham Dumpleton
<[EMAIL PROTECTED]> wrote:
>
>  On Mar 29, 5:04 am, Slayer_X <[EMAIL PROTECTED]> wrote:
>  > Problem solved!
>  >
>  > I deleted the symlinks, delete de django-trunk dir and make a fresh
>  > install directly in
>  >
>  > /usr/lib/python2.4/site-packages/django
>
>  What do you mean by 'make a fresh install directly in'? Do you mean
>  you copied it in by hand or did you use an appropriate setup.py file
>  script?
>

We were chatting on #django-es when César solved this. What he means when
he says a fresh install is that he removed the django symlink from
/usr/lib/python2.4/site-packages/ (that pointed to a Django SVN WC on his
home dir)

Then, as root, he did a

cd /usr/lib/python2.4/site-packages/
svn co http://code.djangoproject.com/svn/django/trunk/django

The problem he was having with the symlink approach was related to the fact
that, even when he theoretically disabled SElinux and rebooted, something
wasn´t working when mod_python wanted to import django (importing
django in a normal user interactive python session worked ok.)

>
>  > In my Apache conf I use this path
>  >
>  > PythonPath "['/'] + sys.path"
>

>  Why are you adding '/' to the module search path. There shouldn't be
>  any need to add the root of the file system to it.
>

This is because his project was located in a dir below / as in:

/
ripsol/
settings.py
urls.spy
...

-- 
 Ramiro Morales

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



distinct UPDATE / INSERT before save() without select to DB

2008-03-29 Thread eat

How to distinct in save() method of the model if the save operation
will be update or insert.

I want to know it BEFORE doing the save().
I want to know it WITHOUT doing a select to a database.

THe reason for that : i want to check the database conditions for the
insert to initiate.

Currently i can only imagine i could do my own function save_insert()
save_update() and initiate them when needed , isnt there any simpler
method??


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: many to many field problem

2008-03-29 Thread Evert Rol

Where or what is the Transparency member in the tableslots you call  
below? I guess I forgot to ask for that previously.
You may also want to check how your Align is defined (in choices=Align).

> >{%for tableslots in tableslots_list%}
> > {{tableslots.Transparency}} 
> >{%endfor%}
> >{%for querysetups in querysetups_list%}
> >{{querysetups.dbTemp}} 
> >{%endfor%}


Lastly, for simple debugging purposes, you could comment out either  
one of the two above for loops (or even both). You mentioned the error  
occurs when looping through that, although I didn't get if it happens  
for both individually, or that you've only tried them together.
If it happens in only one of the two for-loops, that makes it a lot  
easier to track down the problem.

Oh, if listings get long, you could use http://dpaste.com/ for code  
listings. (Probably also helps with the indentation, because it  
appears a bit mixed up below).

Cheers,

   Evert



> hi this is my class for columnsetup and querysetup.. thanks a lot  
> for your help
>
> class columnSetup(models.Model):
> name=models.CharField("Name",max_length=50)
> width   =models.IntegerField("Width",max_length=3)
> align  
> =models.CharField("Align",max_length=1,choices=Align)
> tableList  =models.ManyToManyField(tableSlot)
>
> def __unicode__(self):
> return self.name
>
> def save(self):# update lastupdate  
> in all possible DS setting
> super(columnSetup, self).save() # Call the  
> "real" save() method.
>
> class Meta:
> verbose_name = ('Column Setup')
>
> class Admin:
> fields = (
> ('Column Setup', {
> 'fields' : (('name', 'width', 'align'), 'tableList')
> }),
> )
> list_display=('name','width','align')
> save_as=True
>
> class querySetup(models.Model):
> sqlQue=models.CharField("SQL Query",max_length=200)
> dbTemp=models.CharField("Database",max_length=50)
> tableList  =models.ManyToManyField(tableSlot)
>
> def __unicode__(self):
> return self.sqlQue
>
> def save(self):# update lastupdate  
> in all possible DS setting
> super(querySetup, self).save() # Call the "real"  
> save() method.
> for tl in self.tableList.all():
> tl.setting.lastUpdate = datetime.now()
> tl.setting.save()
>
> class Meta:
> verbose_name = ('Query Setup')
>
> class Admin:
> fields = (
> ('Query Setup', {
> 'fields' : (('sqlQue','dbTemp'), 'tableList')
> }),
> )
> list_display=('sqlQue','dbTemp')
> save_as=True
>
>
> - Original Message 
> From: Evert Rol <[EMAIL PROTECTED]>
> To: django-users@googlegroups.com
> Sent: Saturday, March 29, 2008 1:34:21 AM
> Subject: Re: many to many field problem
>
>
> >ds = DigitalSignage.objects.get(pk=ds_id)
> > #Digital Signage config & setting
> >setting = ds.setting
> >textslots = ds.textslot_set.all()
> >slots = ds.slot_set.all()
> >tableslots = tableSlot.objects.filter(DS_List=ds)
> >columnsetups = columnSetup.objects.filter(tableList=tableslots)
> >querysetups = querySetup.objects.filter(tableList=tableslots)
> >
> > but bumps into another problems.. really headache when i call the
> > columnsetups or querysetups it will gave me error
> >
> >{%for tableslots in tableslots_list%}
> > {{tableslots.Transparency}} 
> >{%endfor%}
> >{%for querysetups in querysetups_list%}
> >{{querysetups.dbTemp}} 
> >{%endfor%}
> >
> > Request Method:
> > GET
> > Request URL:
> > http://localhost/reed/1/ds.xml
> > Exception Type:
> > InterfaceError
> > Exception Value:
> > Error binding parameter 0 - probably unsupported type.
> > Exception Location:
> > C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py in
> > execute, line 133
> > Python Executable:
> > C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe
> > Python Version: 2.5.1
>
> Bit of blank guessing from the error message, but there may just be
> some awkward/exotic field in one of your models that sqlite cannot
> handle; or it's a genuine Django backend bug. What do your model
> definitions look like for columnSetup and querySetup?
>
>
> >
> > > thanks for reply, but i don't quite understand :( sorry i'm newbie
> > > here
> > > First my models.py is like this
> > > class DigitalSignage(models.Model):
> > >DS_ID = integerField()
> > >
> > > class tableSlot(models.Model):
> > >ds_id =models.ManyToManyField(DigitalSignage)
> > >
> > > class columnSetup(models.Model):
> > >tableList  =models.ManyToManyField(tableSlot)
> > >
> > > so in my views.py like this:
> >
> >
> > >
> > > >ds = DigitalS

Re: Is Django thread safe?

2008-03-29 Thread Graham Dumpleton

The best I have ever been able to get out of anyone associated with
Django development about thread safety is the comments by Jacob Kaplan-
Moss in the following thread:

  
http://groups.google.com/group/django-developers/browse_frm/thread/905f79e350525c95/dfed56f8ed65aed2

Graham

On Mar 29, 6:40 am, Peter Rowell <[EMAIL PROTECTED]> wrote:
> Graham --
>
> Thanks very much for your replies.
>
> My concerns were from having two authorities saying different things
> -- it makes the unwashed masses nervous. :-)
>
> Of course, *now* I need to do a code review, since I hadn't been
> thinking "thread safe" when I wrote it.
>
> Is anyone (Django core developers?) reading this who can verify that
> Django is, in fact, thread safe and plays well under worker MPM?
>
>  TIA,
>  Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: IOError: decoder jpeg not available

2008-03-29 Thread zombat

I solved the problem by using the Python packages from pythonmac.org
(pythonmac.org/packages/). There seems to be no more problems with
django an PIL.

The strange thing was that that PIL worked properly with the standard
python from Mac OS 10.5. In the python shell I could retrieve the
width and height of a jpeg image but when I tried to retrieve these
properties with the django database api via get_picture_width() it did
not work. Strange..

Well, now it works. Thanks for your answer.

Thomas.

On Mar 22, 1:04 pm, Evert Rol <[EMAIL PROTECTED]> wrote:
> > I get a strange error in my "django-shell" when I am trying to get the
> > picture-width our height of an image-field.
> > Here's the error: IOError: decoder jpeg not available
>
> Can you give the full traceback for that?
> Also, print out the sys.path from the django shell
>
> > I'm working on a Mac with 10.5.2 and python 2.5.1 width django 0.96.1,
> > PIL 1.6 is installed. The strange thing is that I can retrieve the
> > image-width or height by accessing it directly through the shell, so
> > my jpeg decoder works properly.
>
> Which shell do you mean here? Python, iPython, BASH, Django? If one of  
> the first two, check your sys.path again.
>
> Probably also best to show to command you use in either shell (import  
> PIL; etc). There may be something clashing, but without a traceback  
> and entered commands, that's hard to deduce (unless someone has  
> exactly the same experience).
>
> That all said, it looks like this is a common problem on OS 
> X:http://www.google.com/search?client=safari&rls=en-us&q=PIL+IOError:+d...
>   would have helped you more than the Django list.
>
> (btw, I take it you mean PIL 1.1.6, not 1.6)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: many to many field problem

2008-03-29 Thread didia lim
hi this is my class for columnsetup and querysetup.. thanks a lot for your help

class columnSetup(models.Model):
name=models.CharField("Name",max_length=50)
width   =models.IntegerField("Width",max_length=3)
align =models.CharField("Align",max_length=1,choices=Align)
tableList  =models.ManyToManyField(tableSlot)

def __unicode__(self):
return self.name

def save(self):# update lastupdate in all 
possible DS setting
super(columnSetup, self).save() # Call the "real" save() 
method.

class Meta:
verbose_name = ('Column Setup')

class Admin:
fields = (
('Column Setup', {
'fields' : (('name', 'width', 'align'), 'tableList')
}),
)
list_display=('name','width','align')
save_as=True

class querySetup(models.Model):
sqlQue=models.CharField("SQL Query",max_length=200)
dbTemp=models.CharField("Database",max_length=50)
tableList  =models.ManyToManyField(tableSlot)

def __unicode__(self):
return self.sqlQue

def save(self):# update lastupdate in all 
possible DS setting
super(querySetup, self).save() # Call the "real" save() 
method.
for tl in self.tableList.all():
tl.setting.lastUpdate = datetime.now()
tl.setting.save()

class Meta:
verbose_name = ('Query Setup')

class Admin:
fields = (
('Query Setup', {
'fields' : (('sqlQue','dbTemp'), 'tableList')
}),
)
list_display=('sqlQue','dbTemp')
save_as=True


- Original Message 
From: Evert Rol <[EMAIL PROTECTED]>
To: django-users@googlegroups.com
Sent: Saturday, March 29, 2008 1:34:21 AM
Subject: Re: many to many field problem


> ds = DigitalSignage.objects.get(pk=ds_id) 
> #Digital Signage config & setting
> setting = ds.setting
> textslots = ds.textslot_set.all()
> slots = ds.slot_set.all()
> tableslots = tableSlot.objects.filter(DS_List=ds)
> columnsetups = columnSetup.objects.filter(tableList=tableslots)
> querysetups = querySetup.objects.filter(tableList=tableslots)
>
> but bumps into another problems.. really headache when i call the  
> columnsetups or querysetups it will gave me error
>
> {%for tableslots in tableslots_list%}
>  {{tableslots.Transparency}} 
> {%endfor%}
> {%for querysetups in querysetups_list%}
> {{querysetups.dbTemp}} 
> {%endfor%}
>
> Request Method:
> GET
> Request URL:
> http://localhost/reed/1/ds.xml
> Exception Type:
> InterfaceError
> Exception Value:
> Error binding parameter 0 - probably unsupported type.
> Exception Location:
> C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py in  
> execute, line 133
> Python Executable:
> C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe
> Python Version: 2.5.1

Bit of blank guessing from the error message, but there may just be  
some awkward/exotic field in one of your models that sqlite cannot  
handle; or it's a genuine Django backend bug. What do your model  
definitions look like for columnSetup and querySetup?


>
> > thanks for reply, but i don't quite understand :( sorry i'm newbie
> > here
> > First my models.py is like this
> > class DigitalSignage(models.Model):
> >DS_ID = integerField()
> >
> > class tableSlot(models.Model):
> >ds_id =models.ManyToManyField(DigitalSignage)
> >
> > class columnSetup(models.Model):
> >tableList  =models.ManyToManyField(tableSlot)
> >
> > so in my views.py like this:
>
>
> >
> > >ds = DigitalSignage.objects.get(pk=ds_id)
>
> Here, you are retrieving a single object, namely a DigitalSignage (as
> defined in your model).
> The _set identifier will work for objects, as below.
>
>
> > >tableslots = ds.tableslot_set.all()
>
> Here, you're retrieving all tableslots, which results in a QuerySet.
> It is a QuerySet of your tableSlot model, but it's not the model
> itself. A QuerySet allows filtering, but you cannot directly retrieve
> any of the relations defined in your models, since it's not the model
> itself.
> Have another look at 
> http://www.djangoproject.com/documentation/db-api/#many-to-many-relationships
> You'll see that the _set is used for an object, not a
> QuerySet.
>
>
> >
> > >columnsetups = tableslots.columnsetup_set.all()
> >
> > so now if i change upwards... that's mean my models.py should be
> > like this:
> > class DigitalSignage(models.Model):
> >DS_ID = integerField()
> >
> > class columnSetup(models.Model):
> >field1 = models.charField()
> >
> > class tableSlot(models.Model):
> >ds_id =models.ManyToManyField(DigitalSignage)
> >columnList  =models.ManyToManyField(columnSetup)
>

Re: many to many field problem

2008-03-29 Thread Evert Rol

> ds = DigitalSignage.objects.get(pk=ds_id) 
> #Digital Signage config & setting
> setting = ds.setting
> textslots = ds.textslot_set.all()
> slots = ds.slot_set.all()
> tableslots = tableSlot.objects.filter(DS_List=ds)
> columnsetups = columnSetup.objects.filter(tableList=tableslots)
> querysetups = querySetup.objects.filter(tableList=tableslots)
>
> but bumps into another problems.. really headache when i call the  
> columnsetups or querysetups it will gave me error
>
> {%for tableslots in tableslots_list%}
>  {{tableslots.Transparency}} 
> {%endfor%}
> {%for querysetups in querysetups_list%}
> {{querysetups.dbTemp}} 
> {%endfor%}
>
> Request Method:
> GET
> Request URL:
> http://localhost/reed/1/ds.xml
> Exception Type:
> InterfaceError
> Exception Value:
> Error binding parameter 0 - probably unsupported type.
> Exception Location:
> C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py in  
> execute, line 133
> Python Executable:
> C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe
> Python Version: 2.5.1

Bit of blank guessing from the error message, but there may just be  
some awkward/exotic field in one of your models that sqlite cannot  
handle; or it's a genuine Django backend bug. What do your model  
definitions look like for columnSetup and querySetup?


>
> > thanks for reply, but i don't quite understand :( sorry i'm newbie
> > here
> > First my models.py is like this
> > class DigitalSignage(models.Model):
> >DS_ID = integerField()
> >
> > class tableSlot(models.Model):
> >ds_id =models.ManyToManyField(DigitalSignage)
> >
> > class columnSetup(models.Model):
> >tableList  =models.ManyToManyField(tableSlot)
> >
> > so in my views.py like this:
>
>
> >
> > >ds = DigitalSignage.objects.get(pk=ds_id)
>
> Here, you are retrieving a single object, namely a DigitalSignage (as
> defined in your model).
> The _set identifier will work for objects, as below.
>
>
> > >tableslots = ds.tableslot_set.all()
>
> Here, you're retrieving all tableslots, which results in a QuerySet.
> It is a QuerySet of your tableSlot model, but it's not the model
> itself. A QuerySet allows filtering, but you cannot directly retrieve
> any of the relations defined in your models, since it's not the model
> itself.
> Have another look at 
> http://www.djangoproject.com/documentation/db-api/#many-to-many-relationships
> You'll see that the _set is used for an object, not a
> QuerySet.
>
>
> >
> > >columnsetups = tableslots.columnsetup_set.all()
> >
> > so now if i change upwards... that's mean my models.py should be
> > like this:
> > class DigitalSignage(models.Model):
> >DS_ID = integerField()
> >
> > class columnSetup(models.Model):
> >field1 = models.charField()
> >
> > class tableSlot(models.Model):
> >ds_id =models.ManyToManyField(DigitalSignage)
> >columnList  =models.ManyToManyField(columnSetup)
>
> Changing your models has nothing to do with it.
>
> Therefore, continuing with the model defintion you originally had (top
> of this mail), you should probably access things from the other side:
> ds = DigitalSignage.objects.get(pk=ds_id)
> tableslots = tableSlot.objects.filter(ds_id=ds)  # note: not using
> ds.id. See also note below
>
> Also, have another good luck at 
> http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships
>
>
> Lastly, I can suggest some renaming, to stay with the usage in Python
> and Django. Has nothing to do with the problem, so consider it free
> (and possibly unwanted) advice:
> - model names start with a Capital (TableSlot instead of tableSlot);
> as you do for DigitalSignage.
> - m2m relations are often named as the plural of the relation they
> refer to. So ds_id should become something like digital_signages (or
> signages, if you consider that too long). In particular, the ds_id
> naming is rather badly chosen, since it should reflect an object, not
> the database id of that object (don't think database-level, think
> object-level). It is indeed an id (integer) in the database, but if
> you would retrieve if from your model (through a_table_slot.ds_id),
> it'll show up as a DigitalSignage object, not a number.
>
> Good luck.
>
>
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  
> Try it now.
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: javascript in django

2008-03-29 Thread Przemek Gawronski

Dnia Fri, Mar 28, 2008 at 09:00:26AM -0700, [EMAIL PROTECTED] napisał:

> So if it was called "color" in your model, the field name would be
> "id_foo"

A mistype above, it would be:

color -> id_color

Przemek
-- 
AIKIDO TANREN DOJO  -   Poland - Warsaw - Mokotow - Ursynow - Natolin
info:  http://tanren.pl/   phone:+4850151   mailto:[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
-~--~~~~--~~--~--~---