Re: Django and Services

2008-05-02 Thread Peter Rowell

> The one catch that I see is that you still
> have to go through all your views and make sure that you're now
> passing in a request object, and if you miss any then you won't
> necessarily know until you notice that your page is rendered funny.

No problems, mate. :-) All Django views a) take a request object as
their first arg, and b) return an HttpResponse object.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Another installation problem

2008-05-02 Thread LRP

Hi Folks,

I've been trying for days now to correctly install python2.5 and
psycop2 on my Debian Etch system so I can work with postgresql8.1,
django, and web2py.

I've installed python2.5 from the Debian repository and made it the
default choice. When I call python from the CLI I get Python2.5.

But no matter how I try to install psycop2, I can't get django or
web2py to recognize it. On django it comes up as refusal to connect to
postgresql; on web2py it comes up as an error message saying "global
name psycopg2 is not defined'"

Psycopg2 seems to want to install against python2.4. I've tried
symlinks from /usr/lib/python2.5/site-packages to /usr/lib/2.4/site-
packages/psycopg2, but that doesn't work; nor have various other
installation methods that I"ve tried.

Can anyone show me how to correctly install and configure the packages
I need to run SVN django on Debian Etch and postgresql8.1? Must be
many others who've confronted the same issues.

Many thanks,

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



Re: Pass extra data to a view

2008-05-02 Thread Jay Parlar

On 5/2/08, Jay Parlar <[EMAIL PROTECTED]> wrote:
> I must be missing something super obvious here, but I can't figure out
>  how to pass data to a new view, from the old one.
>
>  For example, I have the following in a view:
>
>  categories = [1,2,3]
>  return HttpResponseRedirect(
> reverse('question-select',
>
>  args=[position_id],kwargs={'categories':categories}))
>
>
>  A URL pattern of:
>
>  url(r'^(?P\d+)/question-select/$',
>  choose_questions,kwargs={'categories':None}, name='question-select' ),
>
>
>  And a 'choose_questions' view of:
>
>  def choose_questions(request, position_id, categories=None):
> ...
>
>
>  I would *love* to have the value of 'categories' in 'choose_questions'
>  be [1,2,3], the value I passed to reverse(). However, this isn't
>  happening. What, if any, is the proper way to pass extra context to a
>  view like this?


Wait a sec, I'm crazy, aren't I... The call to HttpResponseRedirect is
just going to tell the browser to redirect to a new URL, so there's no
direct calling of the view function. Oops.

If anyone has a better way to do it, I'd like to hear. I guess for now
I'll use sessions.

Jay P.

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



Installation problem...

2008-05-02 Thread Pedro Vidal
Hello guys, I'm a new django user, and I'm tryin since three days ago
install django, but it's still not working...
That's the problem:

Installed Python, ok.
Installed mod_python, ok.
Downloaded and extracted django, renamed the folder to "django" and put it
in C:/, everything ok.
The Apache server is working.
MySql working.
I added the python path to PATH environment variable
Opened "cmd", cd to django folder and executed "python setup.py install"
Added in Apache's httpd.conf following line:
LoadModule python_module modules/mod_python.so

Following the information under the installation guide from django's
official site, the troubles begin, and here I am completely lost:
I add the following lines to the httpd.conf:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonPath "['c:/django'] + sys.path"


When I try to test this, acessing the http://localhost/mysite I can't see
the page that should (I guess) be created.
So I ask all of you, where is the error? Or where ARE the errors???
Sorry for my poor english, I'm brazilian and I have not found help articles
in portuguese...

I'm using these versions of archives:
Django version 0.96.1
python version 2.5
mod-python version 3.3.1.win32-py2.5-Apache2.2.exe
Apache version 2.2
MySQL-python-1.2.2.win32-py2.5.exe

Thanks for help,
Pedro Vidal

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



Patch #2070, progress bar and form view. Can't make it work.

2008-05-02 Thread Julien

Hi everyone,

I'm trying to use patch with ticket #2070 [1] to be able to upload big
files and have a progress bar, and I can't quite figure out how to
make it work...

I'm also using 2 snippets [2] and [3]. Then, here's my simple view and
template:

View
---

def frontpage(request):
if request.method == 'POST':
# [] I don't know what to put there!...
else:
form = UploadForm()

return render_to_response('frontpage.html',
  { 'form': form },
 
context_instance=RequestContext(request))

Template
-

[insert javascript from snippet [3] here]

 
{{ form }}
   
 


Settings
---
from django.conf import global_settings
FILE_UPLOAD_HANDLERS =
('upload.upload_handler.UploadProgressCachedHandler', ) +
global_settings.FILE_UPLOAD_HANDLERS

The form just contains a file input. When I press submit,  I enter the
view again but I don't know what code to put in that view to replace
the [] thing above. Should that code wait for the end of the
upload before returning anything, and if so, how?

I couldn't find any help on the ticket page or on this mailing list.
Can you see what I'm missing to make it work?

Many thanks!

Julien


[1] http://code.djangoproject.com/ticket/2070
[2] http://www.djangosnippets.org/snippets/678/
[3] http://www.djangosnippets.org/snippets/679/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django installation problem ...

2008-05-02 Thread Karen Tracey
On Fri, May 2, 2008 at 5:27 PM, AY <[EMAIL PROTECTED]> wrote:

>
> Following the instruction on Django tutorial #4,  I had encounted the
> following problem:
>
> On the website of http://localhost:8000/polls/ ...it displays only one
> line of information ...". What's up? "
>
> and on the website of (1)http://localhost:8000/polls/poll_list.html or
> (2) http://localhost:8000/poll_list.html (3)http://localhost:8000/
> results.htmlor (4)http://localhost:8000/polls/resultsl.html...or
> (5) http://localhost:8000/polls/1/.
>
> the screen displays the following ERROR messages:
>
> How do I break throught this hurdle!? Thanks in advance for your
> assistances!!
>
> P/S: the template_dirs in setting.py for urls is 
>
> TEMPLATE_DIRS = ("C:/home/html/django_templates", "C:/home1/html1/
> django_templates1"
>
> where 1st string is for django/template/admin/(includes:
> base_site.html, index.html) and the 2nd string is for django_template/
> polls/(includes: poll_detail.html, poll_list.html, results.html and
> 404.html)
> 
> the screen displays the following error messages:
>
>
> Traceback (most recent call last):
>
[snipped some]

>
> TemplateDoesNotExist: 404.html


404.html is the template used to display "Page not found" type errors.
Django doesn't come with one, you are responsible for providing one.  I'd
guess you haven't done that, so you get this error.

Now, I doubt the tutorial is telling you to do anything intentionally that
would generate a 404 (page not found) response.  So, the real problem is in
your url mappings (assuming those urls are valid for the tutorial setup..I
haven't looked at the tutorial in a while).  Are you sure you have followed
the instructions on setting up urls.py correctly?

Karen

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



Debugging, breakpoints, and newforms-admin

2008-05-02 Thread Martin Diers

I have a problem I am trying to troubleshoot, specifically on the  
newforms-admin branch, latest revision as of this afternoon.

The trouble is in an Inline, which contains MultiWidgets assigned two  
MultipleValueFields. In this case, it is a Bible reference being  
displayed as a select, and two text fields, which is compressed to a  
serial number representing a specific single verse.

I can create new Inline records. I can delete them. They display  
properly. But when I try to change the Inline record, the admin  
reports that the record has been saved, but it never actually gets  
saved to the DB (postgresql in this case). I go back into the record,  
and it has not changed. I could delete the record, and replace it with  
a corrected one, but I cannot change it.

Evidently, somewhere along the line, the code is not detecting a  
change in the value of the field.  I am trying to figure out where.

I can set breakpoints in my site, and they trigger properly when I am  
running my own views. But my breakpoints NEVER trigger when I am  
running the admin. This is true even of code that I know has to be  
called, like the decompress method of the MultiWidget which is called  
to display my Inline.

Yes, I am passing "runserver --noreload" as the program arguments to  
manage.py in Eclipse.

--
Martin Diers




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



Re: Looking at objects by year, month

2008-05-02 Thread Pawel Pilitowski

Maybe something like this would help:

in the month loop:

{% if forloop.counter|divisibleby:"2" %}

{% else %}

{% endif %}

or try forloop.parentloop.counter if you need to get at it from you  
event loop.

Cheers,

Pawel



On 03/05/2008, at 11:15 AM, Darryl Ross wrote:

Ryan Vanasse wrote:
> Now, my problem is that for every month, I want a different color of
> image text...
>  //blue/orange swap
> so that on even months i'd have them come from the blue folder and odd
> months they'd come from the orange folder (or something of that
> nature). As far as I can tell, none of the default equality comparison
> tags (if,ifequal, ifchanged?) would be able to select based on odd/
> even. Count wouldn't work, I think, because it would change for each
> individual event, instead of monthly.

My first thought was {%cycle%}, but as you said, that would alternate  
for every event, even if one month had multiple events.

What should work instead is to add a property to your Event model,  
which returns a boolean value based on if the month number is odd or  
even, and then you can use the standard if/else tag:

   class Event(models.Model):
 # ...
 @property
 def month_is_even(self):
 return self.start_DateTime.month % 2 and False or True




That code is of course making the assumption that start_DateTime can  
never be Null, or you're likely to end up with an exception:  
"NullType has no property month"

Cheers
Darryl

-- 

Darryl Ross, VK5FUNE
Director, AFOYI, "Information Technology Solutions"
p +61 8 7127 1831
f +61 8 8425 9607
e [EMAIL PROTECTED]



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



Re: Looking at objects by year, month

2008-05-02 Thread Darryl Ross

Ryan Vanasse wrote:

Now, my problem is that for every month, I want a different color of
image text...
 //blue/orange swap

so that on even months i'd have them come from the blue folder and odd
months they'd come from the orange folder (or something of that
nature). As far as I can tell, none of the default equality comparison
tags (if,ifequal, ifchanged?) would be able to select based on odd/
even. Count wouldn't work, I think, because it would change for each
individual event, instead of monthly.


My first thought was {%cycle%}, but as you said, that would alternate 
for every event, even if one month had multiple events.


What should work instead is to add a property to your Event model, which 
returns a boolean value based on if the month number is odd or even, and 
then you can use the standard if/else tag:


  class Event(models.Model):
# ...
@property
def month_is_even(self):
return self.start_DateTime.month % 2 and False or True




That code is of course making the assumption that start_DateTime can 
never be Null, or you're likely to end up with an exception: "NullType 
has no property month"


Cheers
Darryl

--

Darryl Ross, VK5FUNE
Director, AFOYI, "Information Technology Solutions"
p +61 8 7127 1831
f +61 8 8425 9607
e [EMAIL PROTECTED]



signature.asc
Description: OpenPGP digital signature


Pass extra data to a view

2008-05-02 Thread Jay Parlar

I must be missing something super obvious here, but I can't figure out
how to pass data to a new view, from the old one.

For example, I have the following in a view:

categories = [1,2,3]
return HttpResponseRedirect(
reverse('question-select',

args=[position_id],kwargs={'categories':categories}))


A URL pattern of:

url(r'^(?P\d+)/question-select/$',
choose_questions,kwargs={'categories':None}, name='question-select' ),


And a 'choose_questions' view of:

def choose_questions(request, position_id, categories=None):
...


I would *love* to have the value of 'categories' in 'choose_questions'
be [1,2,3], the value I passed to reverse(). However, this isn't
happening. What, if any, is the proper way to pass extra context to a
view like this?

Thanks,
Jay P

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



Re: File caching and pickling issue

2008-05-02 Thread Julien

>
> So we have same problem? Have you find solution?

I don't know if we both have the same problem... the error messages
seem to be a bit different.

I have had other problems with caching that same function (all other
parts of the site that are cached work perfectly). I've got
"TypeError: object does not support item assignment" and also
"UnicodeDecodeError: 'utf8' codec can't decode byte 0xae in position
5946: unexpected code byte".

All those errors had the same traceback as above, and came in bulk of
20 within a very short time.

One important remark, most of these errors seem to be caught by web
crawlers:

HTTP_USER_AGENT': 'msnbot/1.1 (+http://search.msn.com/msnbot.htm)
 or
 'HTTP_USER_AGENT': 'WebAlta Crawler/2.0 (http://www.webalta.net/ru/
about_webmaster.html) (Windows; U; Windows NT 5.1; ru-RU)'
 or
'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://
www.google.com/bot.html)'
 or
'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; Yahoo! Slurp;
http://help.yahoo.com/help/us/ysearch/slurp)',

Any idea what's going on here?

Many thanks,

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



Re: efficiency of apache+mod_fastcgi --> django+flup

2008-05-02 Thread Graham Dumpleton

On May 3, 3:10 am, Robin Becker <[EMAIL PROTECTED]> wrote:
> Djangophiles, is there any kind of analysis of the above combination with 
> regard
> to efficiency. It seems that mod_fastcgi must talk to the flup server through 
> a
> single socket (or rather each front end apache process must do so) and the 
> flup
> server spawns flup/fastcgi children(I'm using a forking flup) to respond to 
> the
> requests. I think there are no bottlenecks here, but I'm not sure who's
> responsible for scaling up and down as requests come in. Can anybody 
> enlighten me?

Ultimately the network overheads in a specific hosting mechanism,
although they differ between different mechanisms, are not where your
bottlenecks are going to be. The real bottlenecks are going to be in
your Python application code and any back end database access. So,
except for avoiding CGI and not using the Django internal development
server for a production system, the hosting mechanism will not matter
too much. Thus, simply choose the one that you think works best for
you as far as easy of installation, configuration and management.

That all said, if you are still obsessive about performance, or truly
are creating a site which will require super performance, you would be
better off looking at mod_wsgi with Apache. For highest performance,
use Apache prefork MPM with mod_wsgi embedded mode and dedicate the
server to just your Python application, with static files hosted off a
separate system. If running as a particular user is still important,
use mod_wsgi embedded mode instead.

For some comparisons of different mechanisms see:

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

In respect of Apache/mod_fastcgi/flup, it is generally a bit slower
than mod_python, thus you can put things in context.

As I said though, this is not where your bottlenecks will be.

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



DjangoAMF vs. pyAMF - any opinions?

2008-05-02 Thread J Peyret

I am just starting out with Flex 3 and I'd like to know if anybody's
got any strong opinions on which AMF<=>Python bridge is best for using
AMF to talk to Django.

I do know Python and am somewhat familiar with Django.

Things that make a difference to me, roughly in order of decreasing
importance:

- code maturity
- how much activity there is on the project, by how many developers
- absolute drop-dead bugs that prohibit using either under specific
circumstances
- documentation
- ease of use and clean design
- performance

Far as I can tell from surfing around, DjangoAMF is more mature and
perhaps easier to set up, but it is hosted in Japan and last time I
checked I didn't speak Japanese so I am worried about missing out on
the latest project "gossip".

Neither seem to have much documentation going for them.  That's OK to
an extent, I'll probably try both, but I'd welcome some insight from
people who have used them in anger.

What I would like to do is to move data back and forth from a Django-
based postgreSQL database backend to a GUI application with complex
behavior requirements, using Apache to serve the SWFs.  Not all of the
relational data will be housed in Django models either, as I will use
some raw SQL to manipulate it as needed.

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



Django installation problem ...

2008-05-02 Thread AY

Following the instruction on Django tutorial #4,  I had encounted the
following problem:

On the website of http://localhost:8000/polls/ ...it displays only one
line of information ...". What's up? "

and on the website of (1)http://localhost:8000/polls/poll_list.html or
(2) http://localhost:8000/poll_list.html (3)http://localhost:8000/
results.htmlor (4)http://localhost:8000/polls/resultsl.html...or
(5) http://localhost:8000/polls/1/.

the screen displays the following ERROR messages:

How do I break throught this hurdle!? Thanks in advance for your
assistances!!

P/S: the template_dirs in setting.py for urls is 

TEMPLATE_DIRS = ("C:/home/html/django_templates", "C:/home1/html1/
django_templates1"

where 1st string is for django/template/admin/(includes:
base_site.html, index.html) and the 2nd string is for django_template/
polls/(includes: poll_detail.html, poll_list.html, results.html and
404.html)

the screen displays the following error messages:


Traceback (most recent call last):

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

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

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

  File "C:\Python25\Lib\site-packages\django\core\handlers\base.py",
line 108, in get_response
return callback(request, **param_dict)

  File "C:\Python25\lib\site-packages\django\views\defaults.py", line
79, in page_not_found
t = loader.get_template(template_name) # You need to create a
404.html template.

  File "C:\Python25\lib\site-packages\django\template\loader.py", line
79, in get_template
source, origin = find_template_source(template_name)

  File "C:\Python25\lib\site-packages\django\template\loader.py", line
72, in find_template_source
raise TemplateDoesNotExist, name

TemplateDoesNotExist: 404.html


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



Code works with Django's server, but not with Apache+mod_python?

2008-05-02 Thread mw

Hello,


I've emailed the mailing list in the past because of problems with PIL
and and image field upload in the admin interface.  The problem, just
got weirder.

I noticed that images were never validating as actual images and were
constantly being rejected.  Out of a hunch, I fired up the django
built-in server and tried the same page with the same image.  This
time, the image validated and it was correctly uploaded.


Does anyone happen to know what would then be stopping the code from
validating the image upload when run through apache instead of the
django development server?


I'm using the SVN of django on OS X.



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



Re: django can't find admin or any other templates

2008-05-02 Thread jmDesktop

I got it to find the /media/ directory by adding the media folder to
inetpub/wwwroot directory.  I had that when I initially created my
wsgi dll with isapi-wsgi.  I tried changing the root folder to my real
root folder, but it did not affect anything.  It required the media
folder in inet pub.  I'm sure there's probably some way around it, but
for now it works.  It does see my local template directory, after
all.  I changed the base_site.html file and could see the changes.  It
just could see the media file.  All I can do is experiment and see if
django is going to be reliable in this configuration.  Thanks.

On May 2, 3:20 pm, jmDesktop <[EMAIL PROTECTED]> wrote:
> I am using IIS 5.1, xp pro, isapi-wsgi.
>
> I can get the admin page working.  It has not CSS and is plain because
> it cannot resolve the link to the stylesheet /media/css...
>
> In my settings.py I have:
>
> ADMIN_MEDIA_PREFIX = "/media/"
>
> TEMPLATE_DIRS - (
>     "C:/sw/django/mysite/templates", #I have the trailing comma
>
> )
>
> I have tried, in TEMPLATE_DIRS
>
> import os
>
> os.getcwd().replace("\\","/")+'/templates'
> and
> "c:/python25/lib/site-packages/django/contrib/admin/templates",
>
> I try the local templates because I could not get Django to find them
> regularly, so I created my own local templates as per the tutorial.
>
> What could be wrong?  If I use an absolute path in ADMIN_MEDIA_PREFIX
> like:
>
> ADMIN_MEDIA_PREFIX="c:/sw/django/mysite/templates/admin/media/"
>
> it finds the CSS.  I can't leave it that way, of course, because real
> users can never find the absolute path.
>
> I'm not sure what to do.  I have to have Django running on IIS, or I
> cannot use it.  Strict requirement.
>
> Thanks for any help.  I've almost got it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django can't find admin or any other templates

2008-05-02 Thread jmDesktop

I have verified that it is pulling the admin template from the site-
packages and not my new templates directory, for some reason.  I
changed base_site.html and it only updates from the site-packages
base_site.html file, not the local templates directory.

On May 2, 3:20 pm, jmDesktop <[EMAIL PROTECTED]> wrote:
> I am using IIS 5.1, xp pro, isapi-wsgi.
>
> I can get the admin page working.  It has not CSS and is plain because
> it cannot resolve the link to the stylesheet /media/css...
>
> In my settings.py I have:
>
> ADMIN_MEDIA_PREFIX = "/media/"
>
> TEMPLATE_DIRS - (
>     "C:/sw/django/mysite/templates", #I have the trailing comma
>
> )
>
> I have tried, in TEMPLATE_DIRS
>
> import os
>
> os.getcwd().replace("\\","/")+'/templates'
> and
> "c:/python25/lib/site-packages/django/contrib/admin/templates",
>
> I try the local templates because I could not get Django to find them
> regularly, so I created my own local templates as per the tutorial.
>
> What could be wrong?  If I use an absolute path in ADMIN_MEDIA_PREFIX
> like:
>
> ADMIN_MEDIA_PREFIX="c:/sw/django/mysite/templates/admin/media/"
>
> it finds the CSS.  I can't leave it that way, of course, because real
> users can never find the absolute path.
>
> I'm not sure what to do.  I have to have Django running on IIS, or I
> cannot use it.  Strict requirement.
>
> Thanks for any help.  I've almost got it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File caching and pickling issue

2008-05-02 Thread Josh Whitaker
tell me what you mean.


- Original Message 
From: Szymon <[EMAIL PROTECTED]>
To: Django users 
Sent: Friday, May 2, 2008 2:28:43 PM
Subject: Re: File caching and pickling issue


On 30 Kwi, 16:12, Julien <[EMAIL PROTECTED]> wrote:
> [...]

http://groups.google.com/group/django-users/browse_thread/thread/ed3abed9122f5506/eb4237d8fe579e7b?lnk=gst=pickling+error#eb4237d8fe579e7b

So we have same problem? Have you find solution?


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File caching and pickling issue

2008-05-02 Thread Szymon

On 30 Kwi, 16:12, Julien <[EMAIL PROTECTED]> wrote:
> [...]

http://groups.google.com/group/django-users/browse_thread/thread/ed3abed9122f5506/eb4237d8fe579e7b?lnk=gst=pickling+error#eb4237d8fe579e7b

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



django can't find admin or any other templates

2008-05-02 Thread jmDesktop

I am using IIS 5.1, xp pro, isapi-wsgi.

I can get the admin page working.  It has not CSS and is plain because
it cannot resolve the link to the stylesheet /media/css...

In my settings.py I have:

ADMIN_MEDIA_PREFIX = "/media/"

TEMPLATE_DIRS - (
"C:/sw/django/mysite/templates", #I have the trailing comma

)

I have tried, in TEMPLATE_DIRS

import os

os.getcwd().replace("\\","/")+'/templates'
and
"c:/python25/lib/site-packages/django/contrib/admin/templates",

I try the local templates because I could not get Django to find them
regularly, so I created my own local templates as per the tutorial.

What could be wrong?  If I use an absolute path in ADMIN_MEDIA_PREFIX
like:

ADMIN_MEDIA_PREFIX="c:/sw/django/mysite/templates/admin/media/"

it finds the CSS.  I can't leave it that way, of course, because real
users can never find the absolute path.

I'm not sure what to do.  I have to have Django running on IIS, or I
cannot use it.  Strict requirement.

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



blogmaker: bool not iterable

2008-05-02 Thread gregf

Hi,

I'm trying to get Blogmaker  (.6 Jan 2) running.  I'm using django
trunk from today, but got the same error on an older trunk.

Dbsync created the databases properly, and the front-end is showing
without error, although there are no entries.

Admin is giving this error on a template.  {{ LANGUAGE_CODE }} is in
red:

TypeError at /admin/
argument of type 'bool' is not iterable

Any help would be appreciated

--Greg

p.s.
Here is a dump of the error screen:

Environment:

Request Method: GET
Request URL: http://localhost:8181/admin/
Django Version: 0.97-pre-SVN-unknown
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.humanize',
 'django.contrib.sites',
 'django.contrib.markup',
 'django.contrib.admin',
 'blog',
 'comments',
 'util']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Template error:
In template /Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/contrib/admin/templates/admin/
base.html, error at line 2
   Caught an exception while rendering: argument of type 'bool' is not
iterable
   1 : http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>


   2 : http://www.w3.org/1999/xhtml;
lang=" {{ LANGUAGE_CODE }} " xml:lang="{{ LANGUAGE_CODE }}" {% if
LANGUAGE_BIDI %}dir="rtl"{% endif %}>


   3 : 


   4 : {% block title %}{% endblock %}


   5 : 


   6 : {% if LANGUAGE_BIDI %}{% endif %}


   7 : {% block extrastyle %}{% endblock %}


   8 : {% block extrahead %}{% endblock %}


   9 : {% block blockbots %}{% endblock %}


   10 : 


   11 : {% load i18n %}


   12 :


Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/template/debug.py" in render_node
  71. result = node.render(context)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/template/debug.py" in render
  87. output =
force_unicode(self.filter_expression.resolve(context))
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/template/__init__.py" in resolve
  526. invalid_var_format_string = '%s' in
settings.TEMPLATE_STRING_IF_INVALID

Exception Type: TypeError at /admin/
Exception Value: argument of type 'bool' is not iterable






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



Re: django-tagging doesn't work with qs-ref

2008-05-02 Thread Michael
Update your django-tagging. This bug was fixed in the new svn release.

On Fri, May 2, 2008 at 2:10 PM, James Bennett <[EMAIL PROTECTED]> wrote:

>
> On Fri, May 2, 2008 at 1:05 PM, bcurtu <[EMAIL PROTECTED]> wrote:
> >  How can I solve this parse_lookup problem?
> >  Cheers
>
> Have you considered looking at that project's bug tracker?
>
>
> http://code.google.com/p/django-tagging/issues/detail?id=106=1=queryset-refactor
>
>
> --
> "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
-~--~~~~--~~--~--~---



Sorry to butt in. I'm just trying to get my message out.

2008-05-02 Thread Slayer

Please come check out SaveTheWorld.  It's my own group that I'm trying
to get started.
There's no harm in looking is there?  Come see what I'm trying to do
to change the world.
Come to look, to laugh, to get enraged in debate, but please come.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-tagging doesn't work with qs-ref

2008-05-02 Thread James Bennett

On Fri, May 2, 2008 at 1:05 PM, bcurtu <[EMAIL PROTECTED]> wrote:
>  How can I solve this parse_lookup problem?
>  Cheers

Have you considered looking at that project's bug tracker?

http://code.google.com/p/django-tagging/issues/detail?id=106=1=queryset-refactor


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



django-tagging doesn't work with qs-ref

2008-05-02 Thread bcurtu

Hi,

Have any of you used django-tagging with the new qs-ref? It doesn't
work, when I do a manage.py syncdb it yells:
...
  File "/usr/local/lib/python2.5/site-packages/tagging/managers.py",
line 6, in 
from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup

How can I solve this parse_lookup problem?
Cheers

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



Re: What is reverse() good for? Not really reversing...

2008-05-02 Thread J. Cliff Dyer

On Thu, 2008-05-01 at 09:36 -0700, web-junkie wrote:
> Hi,
> 
> what is the new reverse() method good for? Seems it just swaps the
> order_by statement?
> I would appreciate a reverse() method that, if used after slicing,
> would actually reverse the queryset.
> In the docs it's said: "Django doesn't support that mode of access
> (slicing from the end), because it's not possible to do it efficiently
> in SQL."
> That is nonsense, because reverse should not slice from anywhere, it
> should just reverse, and you can do that in python.
> So when I have Articles.objects.all()[:3] which gives me a,b,c,
> Articles.objects.all()[:3].reverse() would make c,b,a out of it, not
> z,y,x! Or am I missing something?

The problem seems to be in getting the ORM to write an appropriate query
to return the results you want.  Would it work for your needs if you
pull it out of the queryset into a list, and then reverse it at the
python level?

Something like this (untested code follows)

py>>> arts = Articles.objects.all()[:3]
py>>> arts = list(arts)
py>>> arts.reverse()

The drawback, of course, is that you no longer have a query set, so
whether this will work for you depends on your use case.

Cheers,
Cliff



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



Re: Need help with tutorial url.py not matching using IIS and isapi_wsgi

2008-05-02 Thread jmDesktop

On May 2, 12:25 pm, jmDesktop <[EMAIL PROTECTED]> wrote:
> On May 2, 10:18 am, jmDesktop <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi, I am using isapi_wsgi with django, or trying to:
>
> >http://code.google.com/p/isapi-wsgi/wiki/IntegrationWithDjango
>
> > I have my script exactly like the example.  I created the same
> > directories on my pc.  I believe django is "trying" to work, but it
> > cannot resolve the URLs.  I have done syncdb and can run the admin
> > pages from the developmen server.  There is something about the url
> > getting passed via IIS that django does not like:
>
> > Page not found (404)
> > Request Method: GET
> > Request URL:http://localhost/
>
> > Using the URLconf defined in mysite.urls, Django tried these URL
> > patterns, in this order:
>
> > ^admin/
> > The current URL, , didn't match any of these.
>
> > Is there any way to capture or print on the screen what I am sending
> > to django that it cannot resolve so I can change my urls.py?  I have
> > tried
>
> > (r'^admin/', include('django.contrib.admin.urls')),
>
> > to (r'^mysite/admin/', include('django.contrib.admin.urls')),
>
> > and a few other variations, but it is never found.  I know it's
> > probably something very simple.  I don't know what django is looking
> > for.
>
> > Thank you for any help.
>
> I got it to find the admin site with
>
>  (r' ', include('django.contrib.admin.urls')),
>
> but as soon as I login it goes back tohttp://localhostand can't find
> anything again.  why it get the URL above as , , or blank, I don't
> know.- Hide quoted text -
>
> - Show quoted text -

I was able to get to the admin page, finally, with:

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

last entry and changed wsgi.py like 78

remove 78   self.path = force_unicode(environ['PATH_INFO'])
add  78 self.path = force_unicode(environ['SCRIPT_NAME'] +
environ['PATH_INFO'])

I can logon, but links are broken in parts of the admin page.  For
example, I cannot get template.  By that I mean it is defaulting to
plain white and text, not the standard look for the admin page.  I'm
sure the urls are broken in admin somewhere.  Another evidence was
that when I clicked logout it took me to /*.admin/logout that does not
exist, but /admin/logout does.  So somewhere it's not right.

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



Re: Rendering specific widgets of a MultiWidget

2008-05-02 Thread Bram Duvigneau

Thanks for the replies. I'm not really new to Django, but this is my
first application that I'm really building with it.

I never said that this should be in trunk or something, but if it will
get in, I would prefer something more customizable. However, it seems
that writing my own version that just uses hours/minutes isn't such a
big deal with the DurationField sourcecode at hand.

Bram
Marty Alchin wrote:
> Wow, a conversation about DurationField and I totally missed it. For
> what it's worth, that patch needs a bit more work before even I want
> it included in trunk. I've been putting it off because of my file
> storage work, but I do plan to get back to it soon.
>
> And Martin's right. Currently, DurationField is very much tied to
> dealing with all the aspects of a duration, from days to microseconds.
> If you need less precision, you'll pretty need to write your own.
> Definitely look at the existing DurationField to see how to convert to
> and from a Python timedelta.
>
> As for whether DurationField should be in trunk, I honestly don't have
> much of an opinion on the matter. It's quite possible to use it
> without touching trunk, so if the ticket gets marked as a wontfix, I
> won't cry. I'll just leave that decision to the Power That Be and see
> where it goes.
>
> -Gul
>
> >
>   


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



Re: profiling django with fastcgi & cprofile?

2008-05-02 Thread skunkwerk

I tried appending -m cProfile -o project.profile to this call:
/usr/bin/python manage.py runfcgi...

but i got an error saying can't open cProfile - no such file or
directory.  is this even the right place to call cProfile?

the other option would be to modify this:http://code.djangoproject.com/
browser/django/trunk/django/core/handlers/profiler-hotshot.py
to work with cProfile instead.  what would I replace the
ModPythonHandler with (i'm using fastcgi)

thanks again

On May 1, 11:31 am, skunkwerk <[EMAIL PROTECTED]> wrote:
> the page here:http://code.djangoproject.com/wiki/ProfilingDjango
> mentions profiling with hotshot & mod_python, or wsgi & cprofile.  the
> stuff here:http://www.djangosnippets.org/snippets/605/is also for
> hotshot, not cprofile.  i'm not sure how to get this going with
> fastcgi - which i'm starting through an init.d script like so:
>
> start-stop-daemon --start --exec /usr/bin/python $SITES_PATH/$SITE/
> manage.py runfcgi method=threaded host=$HOST port=$PORT pidfile=
> $RUNFILES_PATH/$SITE.pid --pidfile
>
> would i just need to pass an argument to get it to go through
> cProfile, or write/adapt an entire script?
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need help with tutorial url.py not matching using IIS and isapi_wsgi

2008-05-02 Thread jmDesktop

On May 2, 10:18 am, jmDesktop <[EMAIL PROTECTED]> wrote:
> Hi, I am using isapi_wsgi with django, or trying to:
>
> http://code.google.com/p/isapi-wsgi/wiki/IntegrationWithDjango
>
> I have my script exactly like the example.  I created the same
> directories on my pc.  I believe django is "trying" to work, but it
> cannot resolve the URLs.  I have done syncdb and can run the admin
> pages from the developmen server.  There is something about the url
> getting passed via IIS that django does not like:
>
> Page not found (404)
> Request Method: GET
> Request URL:http://localhost/
>
> Using the URLconf defined in mysite.urls, Django tried these URL
> patterns, in this order:
>
> ^admin/
> The current URL, , didn't match any of these.
>
> Is there any way to capture or print on the screen what I am sending
> to django that it cannot resolve so I can change my urls.py?  I have
> tried
>
> (r'^admin/', include('django.contrib.admin.urls')),
>
> to (r'^mysite/admin/', include('django.contrib.admin.urls')),
>
> and a few other variations, but it is never found.  I know it's
> probably something very simple.  I don't know what django is looking
> for.
>
> Thank you for any help.

I got it to find the admin site with

 (r' ', include('django.contrib.admin.urls')),

but as soon as I login it goes back to http://localhost and can't find
anything again.  why it get the URL above as , , or blank, I don't
know.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File Upload, form issue

2008-05-02 Thread Peter

It's probably one of two things:

1. You might be pointing to the wrong template, load the page in your
browser and hit view source to ensure that your form is indeed doing
enctype="multipart/form-data", and that whatever url you're pointing
to for the action attribute is blank or for debugging, try hardcoding
the correct url.

2. Some guy in another thread claimed that changing "enctype" to
"ENCTYPE" fixed his issue... but that's hearsay on my part.

On Apr 16, 1:48 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 16, 2008 at 11:39 AM, sparky <[EMAIL PROTECTED]> wrote:
>
> > Thank you for your help.
>
> > I'm baffled. The validation error is:
>
> > contentThis field
> > is required.
>
> > which is fair enough... but it is in the form and I've selected a
> > file, clicked open, and clicked submit...
>
> I've never seen that behavior.  I assume you've tried different files,
> different browsers, etc.?  Is there anything in your setup that would limit
> request bodies to something smaller than the size of the file you are trying
> to upload (I believe apache has a parameter for this but I thought you would
> get an error, not silent dropping of the file data, if you ran into it)?  If
> request.FILES is empty immediately upon entry to your view then it is
> something outside of the code you have posted that is causing that, but I
> have no idea what.
>
> Karen
>
> > I'm probably doing something mind-meltingly stupid.
>
> > hmmm.
>
> > Glad the rest of it seems ok, though.
>
> > On Apr 16, 1:41 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Wed, Apr 16, 2008 at 6:55 AM, sparky <[EMAIL PROTECTED]> wrote:
>
> > > > Hello all,
>
> > > > I have a slightly unusual requirement: I want to use a FileField in a
> > > > form but with a TextField in the model. (The content being uploaded is
> > > > a big bit of flat text, but I want to store it in the database, not as
> > > > a file.)
>
> > > > The problem is that with the code that I have together the
> > > > request.FILES parameter is empty, so the form fails validation, any
> > > > suggestions as to where I'm going wrong, thanks.
>
> > > I do not see any reason why what you have posted below would fail form
> > > validation.  request.FILES will be populated, assuming you actually
> > choose a
> > > file before you click "Submit".  Are you really seeing a problem with
> > form
> > > validation failing?  If so, what exactly is the validation error message
> > ?
> > > "This field is required." or "The submitted file is empty" or ...?
>
> > > The problem I do see in your code below is that you do not put the
> > content
> > > of the uploaded file in your model as you state you want to.  When your
> > form
> > > is validated, cleaned_data['content'] will be an UploadedFile.  If you
> > want
> > > to access the content of the UploadedFile, you need to use
> > > cleaned_data['content'].content.  As you have coded it below I believe
> > you
> > > will get the name of your uploaded file put into your model's content
> > field.
>
> > > Karen
>
> > > > sparky
>
> > > > the form:
> > > > class SubmissionForm(forms.Form):
> > > >title = forms.CharField(max_length=100)
> > > >description = forms.CharField(widget=forms.Textarea)
> > > >content = forms.FileField(widget=forms.FileInput)
>
> > > > the model:
>
> > > > class Submission(models.Model):
> > > >"""
> > > >Submission model
> > > >"""
> > > >creator = models.ForeignKey(User)
> > > >created_datetime  = models.DateTimeField(auto_now_add=True)
> > > >title = models.CharField(max_length=100)
> > > >description = models.TextField()
> > > >content = models.TextField()
>
> > > > The view code:
> > > >if request.method == 'POST':
> > > >form = SubmissionForm(request.POST, request.FILES)
> > > >if form.is_valid():
> > > >s = Submission(creator=request.user,
> > > >created_datetime=datetime.datetime.now(),
> > > >title=form.cleaned_data['title'],
> > > >description=form.cleaned_data['description'],
> > > >content=form.cleaned_data['content'])
>
> > > > the template:
>
> > > >
> > > >
> > > >{{ form.as_p }}
> > > >
> > > >
> > > >
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What is reverse() good for? Not really reversing...

2008-05-02 Thread Justin Lilly
Interesting. To support your statement, I tried it myself and here's what I
got from my shell...
In [1]: from aids.trends.models import County

In [2]: foo = County.objects.all()[:3]

In [3]: foo

Out[3]: [, , ]

In [4]: foo.reverse()

Out[4]: [, , ]

In [5]: foo.reverse()

Out[5]: [, , ]

In [6]: foo

Out[6]: [, , ]

In [7]: l = [1,2,3]

In [8]: l

Out[8]: [1, 2, 3]

In [9]: l.reverse()

In [10]: l

Out[10]: [3, 2, 1]

And then I fixed it with:

In [18]: County.objects.order_by('-id')[County.objects.count()-3:]

Out[18]: [, , ]

Not sure how, from a performance prospective, that works... but it does
work.

 -justin

On Fri, May 2, 2008 at 11:11 AM, web-junkie <[EMAIL PROTECTED]> wrote:

>
> That's exactly what I tried, and as I described, it gives you
> something wrong, not the queryset reversed...
>
> On 1 Mai, 19:32, "Justin Lilly" <[EMAIL PROTECTED]> wrote:
> > While it may be the long way around, can you not do the following?
> > a = Articles.objects.all()[:3]
> > a.reverse()
> >
> > That would probably be my solution.
> >
> >   -justin
> >
> >
> >
> >
> >
> > On Thu, May 1, 2008 at 12:36 PM, web-junkie <[EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> >
> > > what is the new reverse() method good for? Seems it just swaps the
> > > order_by statement?
> > > I would appreciate a reverse() method that, if used after slicing,
> > > would actually reverse the queryset.
> > > In the docs it's said: "Django doesn't support that mode of access
> > > (slicing from the end), because it's not possible to do it efficiently
> > > in SQL."
> > > That is nonsense, because reverse should not slice from anywhere, it
> > > should just reverse, and you can do that in python.
> > > So when I have Articles.objects.all()[:3] which gives me a,b,c,
> > > Articles.objects.all()[:3].reverse() would make c,b,a out of it, not
> > > z,y,x! Or am I missing something?
> >
> > --
> > Justin Lilly
> > Web Developer/Designerhttp://justinlilly.com- Zitierten Text ausblenden
> -
> >
> > - Zitierten Text anzeigen -
> >
>


-- 
Justin Lilly
Web Developer/Designer
http://justinlilly.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: What is reverse() good for? Not really reversing...

2008-05-02 Thread Karen Tracey
On Fri, May 2, 2008 at 11:11 AM, web-junkie <[EMAIL PROTECTED]> wrote:

>
> On 1 Mai, 19:32, "Justin Lilly" <[EMAIL PROTECTED]> wrote:
> > While it may be the long way around, can you not do the following?
> > a = Articles.objects.all()[:3]
> > a.reverse()
> >
> > That would probably be my solution.
>
> That's exactly what I tried, and as I described, it gives you
> something wrong, not the queryset reversed...
>

Now, I don't think what it give you is wrong, it's just not what you
wanted/expected.  Instead of reversing the result after retrieval/slicing
using the normal ordering, it is reversing the normal ordering and then
retrieving/slicing the result.  So, given a sequence with normal ordering:

a,b,c,x,y.z

You are looking to get (c,b,a) instead of (z,y,x).  Below, you mention a doc
note that explains why it doesn't do what you want by noting that there is
no efficient way in SQL to produce the result you are looking for and say
that is nonsense.  If it is nonsense, could you please state the SQL
statement you would use to achieve the result you are looking for?

Karen


> >
> >
> > On Thu, May 1, 2008 at 12:36 PM, web-junkie <[EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> >
> > > what is the new reverse() method good for? Seems it just swaps the
> > > order_by statement?
> > > I would appreciate a reverse() method that, if used after slicing,
> > > would actually reverse the queryset.
> > > In the docs it's said: "Django doesn't support that mode of access
> > > (slicing from the end), because it's not possible to do it efficiently
> > > in SQL."
> > > That is nonsense, because reverse should not slice from anywhere, it
> > > should just reverse, and you can do that in python.
> > > So when I have Articles.objects.all()[:3] which gives me a,b,c,
> > > Articles.objects.all()[:3].reverse() would make c,b,a out of it, not
> > > z,y,x! Or am I missing something?
> >
> > --
> > Justin Lilly
> > Web Developer/Designerhttp://justinlilly.com- Zitierten Text ausblenden
> -
> >
> > - Zitierten Text anzeigen -
> >
>

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



Re: Should I set up Django locally or on a web server?

2008-05-02 Thread Justin Lilly
Just to save you a step, you don't have to create the sqlite db file. If you
reference it in settings.py, then run syncdb.. django will create it for
you.

On Fri, May 2, 2008 at 11:31 AM, Matic Žgur <[EMAIL PROTECTED]> wrote:

>
> I use Sqlite3 for development because it already comes installed with
> Ubuntu. I used to use Apache and MySQL, but it didn't make much sense
> using that since Django development server and Sqlite3 handle serving
> quite well and are quite lightweight.
>
> To start using Sqlite you just have to create a new database file and
> setup project's setting.py file accordingly.
>
> Cheers,
> Matic
>
> On Fri, May 2, 2008 at 3:28 PM, Taylor <[EMAIL PROTECTED]> wrote:
> >
> >  SQLite is a good solution, but if you maybe want something that's
> >  closer to what you may be using in production, installation of MySQL
> >  on OS X is pretty easy.
> >  Check out this link:
> >  http://dev.mysql.com/doc/refman/5.1/en/mac-os-x-installation.html
> >
> >  The only other thing you need is the database binding so that Python
> >  can talk to MySQL.  You can get that here:
> >  http://sourceforge.net/projects/mysql-python
> >
> >  I prefer MySQL over SQLite because it's more of a "real" database, you
> >  don't feel like you are just playing with a toy, but actually working
> >  on what will be in your production.
> >  If you have OS X, don't bother doing any hobby programming on your
> >  webserver.  You can do anything / install anything on your mac that
> >  you could on the webserver, plus it will be much faster and more
> >  convenient.  The best part is that you learn more by installing things
> >  yourself.  I say suffer through a couple of tough installs, document
> >  what you do so that you can do it again, and then you will be a lot
> >  better off, and have a greater understanding of how everything works.
> >
> >  At least, that's what I do.
> >
> >  Taylor
> >
> >
> >
> >
> >  On May 1, 10:43 pm, selmac <[EMAIL PROTECTED]> wrote:
> >  > I didn't realize I could use an SQLite that was already installed. I
> >  > have python 2.5.1 on my IMac.  I've gone as far through the tutorial
> >  > and already installed Django and run some of the code in the first
> few
> >  > chapters, I was just getting stuck with how to interface with the
> >  > database. Is there something I need to do to interface Django with
> >  > SQLite?  Is this what most Djangophiles are using to build sites
> >  > before they go live?
> >  >
> >  > I'll look into MacPorts and Fink as well, I've never heard of them.
> >  > I'll need to find a way to configure the thing for production at some
> >  > point if it's going to be of any use to me.
> >  >
> >  > Thanks for the tips
> >  >
> >
>
> >
>


-- 
Justin Lilly
Web Developer/Designer
http://justinlilly.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: Should I set up Django locally or on a web server?

2008-05-02 Thread Matic Žgur

I use Sqlite3 for development because it already comes installed with
Ubuntu. I used to use Apache and MySQL, but it didn't make much sense
using that since Django development server and Sqlite3 handle serving
quite well and are quite lightweight.

To start using Sqlite you just have to create a new database file and
setup project's setting.py file accordingly.

Cheers,
Matic

On Fri, May 2, 2008 at 3:28 PM, Taylor <[EMAIL PROTECTED]> wrote:
>
>  SQLite is a good solution, but if you maybe want something that's
>  closer to what you may be using in production, installation of MySQL
>  on OS X is pretty easy.
>  Check out this link:
>  http://dev.mysql.com/doc/refman/5.1/en/mac-os-x-installation.html
>
>  The only other thing you need is the database binding so that Python
>  can talk to MySQL.  You can get that here:
>  http://sourceforge.net/projects/mysql-python
>
>  I prefer MySQL over SQLite because it's more of a "real" database, you
>  don't feel like you are just playing with a toy, but actually working
>  on what will be in your production.
>  If you have OS X, don't bother doing any hobby programming on your
>  webserver.  You can do anything / install anything on your mac that
>  you could on the webserver, plus it will be much faster and more
>  convenient.  The best part is that you learn more by installing things
>  yourself.  I say suffer through a couple of tough installs, document
>  what you do so that you can do it again, and then you will be a lot
>  better off, and have a greater understanding of how everything works.
>
>  At least, that's what I do.
>
>  Taylor
>
>
>
>
>  On May 1, 10:43 pm, selmac <[EMAIL PROTECTED]> wrote:
>  > I didn't realize I could use an SQLite that was already installed. I
>  > have python 2.5.1 on my IMac.  I've gone as far through the tutorial
>  > and already installed Django and run some of the code in the first few
>  > chapters, I was just getting stuck with how to interface with the
>  > database. Is there something I need to do to interface Django with
>  > SQLite?  Is this what most Djangophiles are using to build sites
>  > before they go live?
>  >
>  > I'll look into MacPorts and Fink as well, I've never heard of them.
>  > I'll need to find a way to configure the thing for production at some
>  > point if it's going to be of any use to me.
>  >
>  > Thanks for the tips
>  >
>

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



Re: What is reverse() good for? Not really reversing...

2008-05-02 Thread web-junkie

That's exactly what I tried, and as I described, it gives you
something wrong, not the queryset reversed...

On 1 Mai, 19:32, "Justin Lilly" <[EMAIL PROTECTED]> wrote:
> While it may be the long way around, can you not do the following?
> a = Articles.objects.all()[:3]
> a.reverse()
>
> That would probably be my solution.
>
>   -justin
>
>
>
>
>
> On Thu, May 1, 2008 at 12:36 PM, web-junkie <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > what is the new reverse() method good for? Seems it just swaps the
> > order_by statement?
> > I would appreciate a reverse() method that, if used after slicing,
> > would actually reverse the queryset.
> > In the docs it's said: "Django doesn't support that mode of access
> > (slicing from the end), because it's not possible to do it efficiently
> > in SQL."
> > That is nonsense, because reverse should not slice from anywhere, it
> > should just reverse, and you can do that in python.
> > So when I have Articles.objects.all()[:3] which gives me a,b,c,
> > Articles.objects.all()[:3].reverse() would make c,b,a out of it, not
> > z,y,x! Or am I missing something?
>
> --
> Justin Lilly
> Web Developer/Designerhttp://justinlilly.com- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Users Group Belfast

2008-05-02 Thread Gareth Fleming

This is probably not the place to discuss this, but are there enough
Django users interested to start a user group in Belfast?

I have no experience of running a user group (apart from an internal
one at work, and that's not going too well), but I'd love to meet with
other users in the area.

Anyone interested can contact me directly.

Cheers,
Gareth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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 with tutorial url.py not matching using IIS and isapi_wsgi

2008-05-02 Thread jmDesktop

Hi, I am using isapi_wsgi with django, or trying to:

http://code.google.com/p/isapi-wsgi/wiki/IntegrationWithDjango

I have my script exactly like the example.  I created the same
directories on my pc.  I believe django is "trying" to work, but it
cannot resolve the URLs.  I have done syncdb and can run the admin
pages from the developmen server.  There is something about the url
getting passed via IIS that django does not like:

Page not found (404)
Request Method: GET
Request URL: http://localhost/

Using the URLconf defined in mysite.urls, Django tried these URL
patterns, in this order:

^admin/
The current URL, , didn't match any of these.

Is there any way to capture or print on the screen what I am sending
to django that it cannot resolve so I can change my urls.py?  I have
tried

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

to (r'^mysite/admin/', include('django.contrib.admin.urls')),

and a few other variations, but it is never found.  I know it's
probably something very simple.  I don't know what django is looking
for.

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



self-rerencing ForeignKey menu in admin

2008-05-02 Thread leland

Hi all - I have this code:

class Page(models.Model):
visible = models.BooleanField(default=True)
parent = models.ForeignKey('self', null=True, blank=True)
title = models.CharField(max_length=255)

In the admin, I don't want a user to be able to select the current
page as its own parent. How do I modify the choices in the parent
select menu so that the current page is not in the menu? Anyone ever
had to do this? Or was this already discussed previously? I couldn't
find anything through a search.

It seemed like all the solutions that I found to this online were
pretty complicated, so I wanted to see if there was an easier way.

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



Re: Should I set up Django locally or on a web server?

2008-05-02 Thread Taylor

SQLite is a good solution, but if you maybe want something that's
closer to what you may be using in production, installation of MySQL
on OS X is pretty easy.
Check out this link:
http://dev.mysql.com/doc/refman/5.1/en/mac-os-x-installation.html

The only other thing you need is the database binding so that Python
can talk to MySQL.  You can get that here:
http://sourceforge.net/projects/mysql-python

I prefer MySQL over SQLite because it's more of a "real" database, you
don't feel like you are just playing with a toy, but actually working
on what will be in your production.
If you have OS X, don't bother doing any hobby programming on your
webserver.  You can do anything / install anything on your mac that
you could on the webserver, plus it will be much faster and more
convenient.  The best part is that you learn more by installing things
yourself.  I say suffer through a couple of tough installs, document
what you do so that you can do it again, and then you will be a lot
better off, and have a greater understanding of how everything works.

At least, that's what I do.

Taylor


On May 1, 10:43 pm, selmac <[EMAIL PROTECTED]> wrote:
> I didn't realize I could use an SQLite that was already installed. I
> have python 2.5.1 on my IMac.  I've gone as far through the tutorial
> and already installed Django and run some of the code in the first few
> chapters, I was just getting stuck with how to interface with the
> database. Is there something I need to do to interface Django with
> SQLite?  Is this what most Djangophiles are using to build sites
> before they go live?
>
> I'll look into MacPorts and Fink as well, I've never heard of them.
> I'll need to find a way to configure the thing for production at some
> point if it's going to be of any use to me.
>
> Thanks for the tips
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Announcing django-compress

2008-05-02 Thread Andreas Pelme

On 2 Maj, 02:04, hiwd <[EMAIL PROTECTED]> wrote:
> this sounds awesome.
>
> i'll take a look, and implement, and try to push some code to prod
> next week (if things are hunky dory)
>

Great! I'd be happy to hear how it went!

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



Re: Custom Authentication System

2008-05-02 Thread Abdallah El Guindy

Thanks for the reply... I'll try that out and see if it works out...

On May 2, 1:18 am, jonknee <[EMAIL PROTECTED]> wrote:
> > Can anyone refer a nice tutorial or explain how to create custom
> > user attributes and use the authentication/authorization app?
>
> It would be just like a regular user registration form, only with
> more
> fields. In the view you would create the account using the data
> that belongs to Auth and after that succeeds create the profile by
> using the data in the remaining fields (and the newly created user).
> You'll be updating two models.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Announcing django-compress

2008-05-02 Thread desfrenes

Thank you ! I used to have a similar tool in PHP and having it for
Django is a blessing.

On May 1, 3:57 pm, [EMAIL PROTECTED] wrote:
> Hi
>
> I recently put up django-compress on Google 
> Code:http://code.google.com/p/django-compress/
>
> django-compress provides an automated system for compressing CSS and
> JavaScript files. By default, it only outputs compressed files, while
> not in DEBUG-mode. That means you can still debug and edit your source
> files while coding, and when going to production, the compressed files
> will be automatically generated.
>
> Support for jsmin and CSSTidy is included and enabled by default (but
> can easily be disabled).
>
> django-compress includes template tags for outputting the URLs to the
> CSS/JavaScript-files and some other goodies to improve the performance
> of serving static media.
>
> See the Google Code Wiki-pages for more information.
>
> django-compress also got a page at Django 
> Pluggables:http://djangoplugables.com/projects/django-compress/
>
> I would be happy to get feedback on the features and implementation!
>
> Cheers
> Andreas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Memcached hangs & never responds?

2008-05-02 Thread Gregor Hochmuth

I think this might be it, thank you *so much* Karen!


On May 2, 1:55 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, May 1, 2008 at 6:51 PM, Gregor Hochmuth <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > Has anyone experienced the following symptom with Memcached before?
>
> > Intermittently and unpredictably, requests to our production web
> > server will start "hanging" in the "Waiting for response..." loop and
> > never get any further. When we restart memcached on the server, the
> > request executes right away and things are back to normal (even
> > requests that were pending suddenly finish)
>
> > Do you happen to know what the cause of this might be? We're using the
> > most recent version of python-memcached (from tummy.com) and a recent
> > development version of Django (0.97x)
>
> > I'd much appreciate any advice! Thanks,
>
> Could it be the same problem as this:
>
> http://code.djangoproject.com/ticket/5133
>
> ?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin : Select category -> show subcategory

2008-05-02 Thread martyn

Hi,

I've created a simple product model :

class Produit(models.Model):
nom = models.CharField(maxlength=200)
slug = models.SlugField(prepopulate_from=('nom',))
description = models.TextField(blank=True)
published = models.BooleanField(default=True)
prix_ht = models.DecimalField(max_digits=30, decimal_places=2)
famille = models.ForeignKey('Famille')
sous_categorie = models.ForeignKey('SousCategorie')
clic

class Admin:
pass

I've got also Category and SubCategory :


class Categorie(models.Model):
nom = models.CharField(maxlength=200)
slug = models.SlugField(prepopulate_from=('nom',))
class Admin:
pass

def __str__(self):
return self.nom

class SousCategorie(models.Model):
nom = models.CharField(maxlength=200)
slug = models.SlugField(prepopulate_from=('nom',))
categorie = models.ForeignKey('Categorie')
class Admin:
pass

def __str__(self):
return self.nom



Is there a way in django admin, in the Product form, to select the
category, then the subcategories of this category only are shown in
the select list.

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



Re: Looking at objects by year, month

2008-05-02 Thread Ryan Vanasse

I got my data to populate mostly alright.
The key was changing the template example to "{% for month in
months.values %}"
it wasn't working before that.

Now, my problem is that for every month, I want a different color of
image text...
 //blue/orange swap

so that on even months i'd have them come from the blue folder and odd
months they'd come from the orange folder (or something of that
nature). As far as I can tell, none of the default equality comparison
tags (if,ifequal, ifchanged?) would be able to select based on odd/
even. Count wouldn't work, I think, because it would change for each
individual event, instead of monthly.

So I'd be stuck with writing my own template tags, which I may do
eventually, but I'll probably leave for the meantime.

if anyone has suggestions for how to accomplish the alternate months
thing, I'd be much obliged.

Thank you Darryl, for your help on this. I was thankful that someone
else was having the same problem.


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



Is there a way to disable QuerySet caching?

2008-05-02 Thread Cornel Nitu

Hi,

I'm using this manager in order to display only the articles which
have the status "P"(published). By default all the articles have the
status "D" (draft).

class ArticleManager(models.Manager):

def get_query_set(self):
queryset = super(ArticleManager, self).get_query_set()
return queryset.filter(status__exact='P',
created__lte=datetime.now())

When I change the article status from "D" to "P" the changes are not
reflected on the front page. Is there a way to solve this issue?

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



Re: ManyToMany error with new queryset refactoring

2008-05-02 Thread bcurtu

I found it! Karen you are right. I had already a field called
"friends", with a different information. When I was using Attributes
as an OneToOne relationship it was all ok, but when using it in
inheritance, it fails, of course!

Thanks for your help

On 2 mayo, 01:42, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, May 1, 2008 at 5:13 PM, bcurtu <[EMAIL PROTECTED]> wrote:
>
> > Thanks,
>
> > Attributes is just a simple abstract class with some fields. Nothing
> > special.
>
> See, though, I could not recreate any error with a nothing-special abstract
> base class named Attributes that I made up myself.  Guessing what might be
> causing the error, I added a field named friends to the Attributes class,
> and that does trigger the error you report.  (I do not know why the message
> says field of similar name instead of field with the exact same name.)  Per
> the docs 
> (http://www.djangoproject.com/documentation/model-api/#model-inheritan...
>
> "It is an error to have fields in the abstract base class with the same name
> as those in the child (and Django will raise an exception)."
>
> If this is not the cause of your error, please post the details of the
> Attributes definition and perhaps someone can spot what is causing the
> problem.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Services

2008-05-02 Thread Michael Burton

> I'll have to disagree with you here.  I think this is a perfect
> example of Russ's point.  Somewhere on your PYTHONPATH just write a
> function that looks something like this (warning, untested code):
>
> from django.shortcuts import render_to_response as old_rtr
> from django.template import RequestContext
> def render_response(request, *args, **kwargs):
>     kwargs['context_instance'] = RequestContext(request)
>     return old_rtr(*args, **kwargs)
>
> Now all you have to is import your new render_response method and use
> that instead of the default render_to_response.


Very cool.  I must admit I quite like the flexibility of python's
import statements.  I'll give this a try tomorrow but at first glance
it looks quite flexible.  The one catch that I see is that you still
have to go through all your views and make sure that you're now
passing in a request object, and if you miss any then you won't
necessarily know until you notice that your page is rendered funny.
On the other hand, the proposal I put out there earlier didn't really
solve this problem either.

Thanks for the tip!

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: django-tagging or search engine?

2008-05-02 Thread francesco

Thanks a lot for your replies.

So, if I understand correctly from the last two posts, the suggestion
would be to keep the tags but to store them in a full-text-index
engine so that the queries will be more efficient.
In that case I have a few more questions:
would that approach help protecting from spelling mistakes?
will methods of django-tagging (like the one used for retrieving
related objects based on shared tags) have to be reimplemented with
the syntax of the search engine?
and last, if I have two fields to be indexed by the search engine (say
"tags" and "description"), can I specify to give more importance (or a
higher weight) to the tags field than to the description field when
calculating the scores?

Thanks again
Francesco

On May 2, 6:30 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On 2 май, 05:40, Eric <[EMAIL PROTECTED]> wrote:
>
>
>
> > The beauty for using a search engine is you can do tag unions as easy
> > as tag:python OR tag:django
>
> > or a tag intercection as:
> > tag:python AND tag:django
>
> > and you can do:
> > tag:python AND tag:django AND tag:database
>
> > with a sql database in order to do that you'd have to something like
> > this:
>
> > SELECT * from story
> > inner join story2tag s2t1 on s2t1.story_id = story.id
> > inner join story2tag s2t2 on s2t2.story_id = story.id
> > inner join story2tag s2t3 on s2t3.story_id = story.id
> > where s2t1.tag = 'python'
> > and s2t2.tag = 'django'
> > and s2t3.tag = 'database'
>
> > Ever new tag means another join, and it get's worse and worse
>
> > A search engine is built for keyword searches,  so it's much better
> > suited for that kind of thing.
>
> If we talk about possible SQL solution to solve such task, then I
> would suggest storing tags in a full-text-index.
>
> That way you will be able to select them all, with relevance scores,
> via single SQL query without
> joins.
>
> We are using this version of text 
> search:http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/
>
> Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Services

2008-05-02 Thread [EMAIL PROTECTED]

> It's a very good idea, but it suffers from a DRY usability concern
> related to the pervasive use of the render_to_response() shortcut
> commonly employed by Django apps.  Because render_to_response() is a
> static method, there's no good way to pre-configure it to use
> RequestContext instead of Context, which means that you must ensure
> that you must set context_instance in EVERY use of render_to_response
> in your view.  eg. render_to_response(...,
> initial_context=RequestContext(request)). If you ever forget this one
> detail, you might end up with a funny looking page.

I'll have to disagree with you here.  I think this is a perfect
example of Russ's point.  Somewhere on your PYTHONPATH just write a
function that looks something like this (warning, untested code):

from django.shortcuts import render_to_response as old_rtr
from django.template import RequestContext
def render_response(request, *args, **kwargs):
kwargs['context_instance'] = RequestContext(request)
return old_rtr(*args, **kwargs)

Now all you have to is import your new render_response method and use
that instead of the default render_to_response.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Services

2008-05-02 Thread Michael Burton

> Ah.. the singleton... Java's answer to the fact that not everything is
> an object. :-)

Ha ha, fair enough Russ :)  And I don't dispute a certain java-
oriented predisposition to the way i think about these problems.  But
let me bring a point in favor of the Singleton, and why I think it
might actually remain relevant even in the world of python.

[ First though, we're digressing a little off topic, so I wanted to
thank Michael Elsdörfer for his point about a services directory.
That's probably what I'll end up doing here once my services.py module
grows too large.  Cheers]

Static methods are generally speaking not a good replacement for
singletons, in as much as they force you to mix your configuration/
setup with your execution.  There's no good way to pre-configure a
static method (without resorting to globals), and then use that
configured method later.  As a case in point, I was recently reading
James' very good article about using context processors (http://www.b-
list.org/weblog/2006/jun/14/django-tips-template-context-processors/),
where he suggests using RequestContext instead of Context to render
your views.

It's a very good idea, but it suffers from a DRY usability concern
related to the pervasive use of the render_to_response() shortcut
commonly employed by Django apps.  Because render_to_response() is a
static method, there's no good way to pre-configure it to use
RequestContext instead of Context, which means that you must ensure
that you must set context_instance in EVERY use of render_to_response
in your view.  eg. render_to_response(...,
initial_context=RequestContext(request)). If you ever forget this one
detail, you might end up with a funny looking page.

If render_to_response() belonged to a singleton, though, then we could
configure that singleton up front to use RequestContext as its
context_instance, and none of our views would ever need to worry about
that particular detail.  You might imagine something like the
following in django's core library:

class RenderService:
  context_instance = Context()
  def render_to_response(*args, **kwargs):
...

render_instance = RenderService()

In my views.py I might want to use the default config and do something
like the following:

from django.shortcuts import render_instance
def my_view():
  return render_instance.render_to_response(...)

But in my complicated_views.py, I might want to do something a little
fancier using the RequestContext instead:

from django.shorcuts import RenderService
render_instance =
RenderService(initial_context=RequestContext())
def my_complicated_view():
  return render_instance.render_to_response(...)

My views methods never need to know the details about which context is
being used.  They just set up their contexts and render their views as
normal.

(I do recognize that there are a couple of gaps in this example, in
particular how to get the request object to the RequestContext, but
please don't hold that against my defense of the poor concept of the
Singleton. Hopefully the benefits of the singleton still come across.)


Basically, using a Singleton[1] allows us to use the default instance
supplied by the module for most cases, or instead use our own user-
supplied instance if we desire specific configuration, all without
requiring us to painstakingly modify every call to
render_to_response() in all of our views.  And it also protects us
from one module making a global change to the render_to_response()
configuration in a way that unexpectedly affects other modules.[2]

So I think the Singleton is still relevant.  Perhaps it doesn't have
to be a class instance in python, perhaps there is a way to make a
python module be the singleton instead.  I suspect not since I don't
se how you could avoid side-effects in that case, but I'm still new to
the language.

Cheers,
Mike


[1] One might claim that our Singleton in this example is really more
of a pseudo-Singleton, since we allow the user to override the default
instance with one of their own, should they so desire.
[2] It appears that Random in python's core library does something
like this, by using a "hidden" Random instance that you can override
with your own instance if you need to.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---