dynamic tag count

2008-01-29 Thread Chris

Hello I have a Tagging app that I have created which could have a m2m
relation with several other applications suchas a weblog, projects,
articles,etc...

I am trying to do something like this:

tag_list = Tag.objects.all()

for tag in tag_list:
print tag.weblog.count()

Is there a way to dynamically call tag.[this_model].count(). since
this tagging app can be associated with more than one app. (replacing
this_model with the appropriate model name.)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Sexy And nude pic and movies of pakistani young girls

2008-01-29 Thread Saima

http://netmasti.blogspot.com
Get Sexy movies and pictures of pakistani and indian girls and their
mobile number
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

Your problem was solved here:
http://code.djangoproject.com/changeset/5609/django/trunk/django/contrib/markup/templatetags/markup.py

You may have other problems if you mix trunk with 0.96. Many bugs are
solved in trunk - the best strategy is to update everything.

Hope, this helps.
-- Ivan

On Jan 30, 8:25 am, Ivan Illarionov <[EMAIL PROTECTED]> wrote:
> You pass unicode value to textile.textile. I was able to repeat your
> error by doing the same: textile.textile breaks with similar error
> when it recieves a unicode string. It can be fixed by encoding your
> value as utf-8 before passing to textile.textile.
>
> Your error log has:
> return textile.textile(value, encoding=settings.DEFAULT_CHARSET,
> output=settings.DEFAULT_CHARSET)
>
> But current Django trunk has:
> return mark_safe(force_unicode(textile.textile(smart_str(value),
> encoding='utf-8', output='utf-8')))
>
> So you need to update your django/contrib/markup/templatetags/
> markup.py and problem should dessapear.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: *Occasional* PostgreSQL Error

2008-01-29 Thread James Bennett

On Jan 29, 2008 11:18 PM, Mark Green <[EMAIL PROTECTED]> wrote:
> I agree on the loadbalancer front but the overhead for all
> those TCP connections (and pgpool managing them) worries me a bit.

I've used pgpool in production with great success, so I'm not really
sure what overhead you're talking about.

> Furthermore, and much more serious, I see no way to ensure
> graceful degration in case of overload.

And here you completely change the topic of discussion from persistent
pooling of connections to failover when a database reaches its maximum
connection level, so I'm not really sure what it has to do with
anything...

> So, long story short, I see no way out of this without
> proper connection pooling built right into django.
> Or am I missing something?

You're missing the fact that you've switched from asking about pooling
to asking about failover.

Also, your solution would mean that:

1. Django must have its own configuration for the number of
connections it's allowed to use, how long to keep them alive and how
often to retry them in case of failure, and this must be updated if
and when use patterns change.
2. Django must have its own configuration for being notified of what
every other client application of the same database is doing, and this
must be updated if and when use patterns change.
3. Every other client application of the same database must have
similar dual configuration to know what it's allowed to do and what
everybody else is doing, and these must be updated if and when use
patterns change.

Or you could just use a single external utility to manage database
connections, thus keeping all that essentially infrastructural cruft
out of the application layer while giving you a single place to
configure it and a single place to make changes when you need them.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

You pass unicode value to textile.textile. I was able to repeat your
error by doing the same: textile.textile breaks with similar error
when it recieves a unicode string. It can be fixed by encoding your
value as utf-8 before passing to textile.textile.

Your error log has:
return textile.textile(value, encoding=settings.DEFAULT_CHARSET,
output=settings.DEFAULT_CHARSET)

But current Django trunk has:
return mark_safe(force_unicode(textile.textile(smart_str(value),
encoding='utf-8', output='utf-8')))

So you need to update your django/contrib/markup/templatetags/
markup.py and problem should dessapear.

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

2008-01-29 Thread Mark Green


On Tue, 2008-01-29 at 22:07 -0600, James Bennett wrote:
> On Jan 29, 2008 10:04 PM, Mark Green <[EMAIL PROTECTED]> wrote:
> > Just curious, what's the state of connection pooling in django?
> 
> My personal opinion is that the application level (e.g., Django) is
> the wrong place for connection pooling and for the equivalent "front
> end" solution of load balancing your web servers: the less the
> application layer has to know about what's in front of and behind it,
> the more flexible it will be (since you can make changes without
> having to alter your application-layer code).
> 
> So, for example, connection pooling for Postgres would best be handled
> by a dedicated pooling connection manager like pgpool; Django can
> connect to pgpool as if it's simply a Postgres database, which means
> you don't have to go specifying pooling parameters at the application
> level.

Hm, that doesn't sit so well with me.
I agree on the loadbalancer front but the overhead for all
those TCP connections (and pgpool managing them) worries me a bit.

Furthermore, and much more serious, I see no way to ensure
graceful degration in case of overload.

Let's assume we run a local pgpool instance along with django on each
machine. Django goes through the local pgpool for database access.

Now what happens when the database becomes too slow to
keep up with requests for any reason?

I see two options:

a) pgpool is configured without a limit on inbound connections;
   the hanging connections between django and pgpool will
   eventually exhaust the total number of allowed tcp-
   connections for the django-user or even systemwide.

   django will not be able to open new database connections and
   display nasty error pages to the users. Worse yet, if django
   and webserver are running under the same uid then the webserver
   will likely no longer be able to accept new inbound connections
   and the users get funny error messages from their browsers.

b) pgpool is configured with a limit on inbound connections;
   pgpool will hit the limit and refuse subsequent attempts from
   django, which in turn displays nasty error pages to users.

In order to achieve the desired behaviour of django slowing down
gracefully instead of spitting error pages I think we'd have to
teach django to retry database connections. But this would
open a whole new can of worms, such as risking duplicated
requests when users hit reload, etc...

So, long story short, I see no way out of this without
proper connection pooling built right into django.
Or am I missing something?


-mark



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



Apache Subdirectories and Urls

2008-01-29 Thread [EMAIL PROTECTED]

I've been beating my head against this problem for a while now, and I
apologize if I'm asking again (I did look, believe it or not).

I'm working on a development laptop, and I've got Django working on my
apache server. However, the urls don't work like i'd expect them to.

If i have an app at: "localhost/mysite", the urls that it tests will
include the "/mysite" part. I would think that the url should be
truncated to what is used in the   directive. It dosen't
seem to be.

So my question is: Is this the way that Django is expected to act?
should i include "/mysite" as a prefix to all the urls in my `urls.py`?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

You have this in your log:

func

  
  ignore_failures

  False

Maybe try to change this to True. And double check that everything is
converted with 'ignore'.

Another option: store the textiled xhtml in database.

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

2008-01-29 Thread James Bennett

On Jan 29, 2008 10:04 PM, Mark Green <[EMAIL PROTECTED]> wrote:
> Just curious, what's the state of connection pooling in django?

My personal opinion is that the application level (e.g., Django) is
the wrong place for connection pooling and for the equivalent "front
end" solution of load balancing your web servers: the less the
application layer has to know about what's in front of and behind it,
the more flexible it will be (since you can make changes without
having to alter your application-layer code).

So, for example, connection pooling for Postgres would best be handled
by a dedicated pooling connection manager like pgpool; Django can
connect to pgpool as if it's simply a Postgres database, which means
you don't have to go specifying pooling parameters at the application
level.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: *Occasional* PostgreSQL Error

2008-01-29 Thread Mark Green


On Fri, 2008-01-25 at 15:14 -0800, Jacob Kaplan-Moss wrote:
> Hi Doug --
> 
> On 1/24/08, Doug Van Horn <[EMAIL PROTECTED]> wrote:
> > OperationalError: could not connect to server: No such file or
> > directory
> >Is the server running locally and accepting
> >connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.
> > 5432"?
> 
> This means that, for some reason, a connection to the database
> couldn't be established. You'll get this error if the database isn't
> running, but since you only get it under load I'd guess that you're
> hitting PostgreSQL's max connection limit (see the max_connections
> setting in postgresql.conf). You can tell for sure by checking your
> Postgres log; it'll have a message about reaching the connection
> limit.

Just curious, what's the state of connection pooling in django?
And what does the user see when such an error occurs, I guess
an error 500 message?


-mark



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



TypeError on forms.ChoiceField

2008-01-29 Thread Patrick J. Anderson

I'm using newforms and ModelForm and I'm getting a TypeError on the 
following code:

class PhotographForm(forms.ModelForm):
album = forms.ChoiceField(choices = PhotoAlbum.objects.all())
class Meta:
model = Photograph


The error message states: "'PhotoAlbum' object is not iterable" 

I had previously thought and Django documentation states that a Queryset 
was an iterable.

The debugging information shows this:

attrs   {'id': u'id_album'}
choices ()
final_attrs {'id': u'id_album', 'name': 'album'}
name 'album'
output [u'']
self 
str_value u'1'
value 1

How can I inject a subset of related photoalbums into this form?



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

2008-01-29 Thread theZero

> I haven't done exactly this, but I've done something similar, and can
> maybe help with some general principles.


Hi Eric. Thanks for the help and advice!


> It's not clear exactly what's going into these pods, but it's usually
> a bad idea to have things like 'style' or 'placement' in the database
> tables: that's presentational logic, not data. I would suggest either
> {% include %}-ing smaller template snippets, or using custom template
> tags. If the snippet/tag can get all its information from the existing
> context, use an include; if it needs its own database queries/extended
> python, use a tag.

Honestly it's not completely clear to me, either. That could be part
of the problem :)

I was trying to make a relatively simple CMS to get to know django
better. I'm loosely recreating a "website builder" app that would
allow non-technical users to edit and update their websites. The
"pods" could be thought of as content blocks or banner ads or
something similar. Incidentally, I don't call them "pods" in the
application, but for the sake of clarity, I wanted a name that didn't
include "block" or "node." That's the best I could do on short
notice.

As for presentation vs. data, I understand your point.


> Still kind of shooting in the dark: information such as how the pods
> are to be displayed should probably come in through the view. Maybe
> via a GET query, maybe via saved user settings. You could create a
> dictionary in the view, where say the keys were snippet/tag names, and
> the values a list of style/presentation parameters that were passed to
> each appropriate snippet. Something like that. Then your template is
> simply a matter of checking if the dict has certain keys, and then
> using the dict values to populate CSS style attributes, or to set
> variables telling a template tag which queries to perform (actually
> that last might not work, can't remember...).

As you can probably tell, I was trying to get by with the least work
possible and that usually spells disaster. I figured I could call
everything with Page.objects.select_related(), and then have the
template sort out the details.

Interesting that you bring up the custom dict - that's what they seem
to do here:
http://www.carthage.edu/webdev/?p=15


> As always, B-List has the 
> goods:http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-tem...
>
> Hope something in there helps,

That's what I started to read before I made my first post. Guess I
should review it :)

Well you got me thinking a little harder! Thanks again!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Graham Dumpleton

On Jan 30, 1:33 pm, Noah <[EMAIL PROTECTED]> wrote:
> It doesn't happen on every page view... the server runs fine for days
> and then POOF collapse, every site

Just a clarification on your configuration for mod_python. Each of
these sites runs in a separate Python interpreter instance. Yes/No?
This would be the case if they are in separate VirtualHost containers
and you have set NameVirtualHost correctly and not set
PythonInterpreter directive.

If this is the case, then it would suggest that the conflict would
have to be occurring in a C extension module, thus possibly that for
postgresql. This would be the only way it could effect the different
sites running in the different Python interpreter instances at the
same time.

Only way of isolating the sites so that at least only the one site
causing the problem is affected, would be to use mod_wsgi daemon mode,
or FASTCGI, SCGI, AJP solutions. That way each site could be run in
separate processes.

Graham

> On Jan 29, 7:06 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote:
>
> > > Our database is utf8 we explicitly convert ignoring errors to utf8
> > > before passing to textile. Also it's not 1 page that poops it's every
> > > site pooping at once.
>
> > That means that the problem is inside something that shows on every
> > page.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best Practice for Ajax and Django. Please share your thoughts.

2008-01-29 Thread Jorge Sousa
Hi,

I do something similar to Julien solution.
Have a "views" directory and put individual files inside this directory.
By individual files I mean, i tend to split views by operations
that apply to a flow for webpages using the same models.
I also put specific ajax view methods inside their own view files.

For URL files. A also started to split these files inside applications,
instead of having
a fat one with all url combinations for the same application/module
 i split them for instance in ajax an non-ajax ones.

I also had
the problem of maintaining 2 very identical view methods doing the same but
refactored these ones into a common method inside a
common_view_methods.py file.
These methods do the bulk work and are called by the view methods.
Then the view return the right content_type to the browser, that way i
have extra imports
but avoid the extra 'if' statement and keep code cleaner.

Im also spliting forms and models. If  i have a complex form (a form that
maps to
more than one model)
i prefer to just have one per file. newforms are great but if you want
a complex form layout
(specific form validations,  html attributes like size, maxlength, styles
and classes applied differently to label and
inputs), you got to get your hands really dirty and type some
code. the default
stock options just do or generate simple and dull html code.

Django is very flexible regarding the way you organize your files and
code, there's
nothing preventing us from using just one file (models, views, urls,
forms) for the all
application/module code. The organization layout presented in the
documentation are
just a simple guideline of how to keeping things simple. But as soon as you add
models and functionalities each file start to grow and i hate to have
to scroll a lot and
search for a specific line /method inside a large file.

In the end we have to IMPORT everything we need to use so we have the
freedom to decide where to put
them, theres no magic paths like other frameworks. And i like this!

Just my thoughts

Jorge

On 1/30/08, Julien <[EMAIL PROTECTED]> wrote:
>
>
> Hey there,
>
> My approach is not so much of an effort, and I do not write two
> versions of every method. My ajax views are purely and only destined
> for Ajax stuff. In this case, for example, you could imagine having a
> DIV refreshing its content every 30 seconds by calling the
> ajax_latest_news view.
>
> Your approach is interesting, on giving the client the choice of
> format for the result (json, XMl or whatever). However, instead of
> adding 'wants' field in POST, maybe should you use different URLs
> (e.g. latest_news/json/, latest_news/xml/, etc.) which would all point
> to the same view but with a different parameter. I'd find it cleaner
> than way.
>
> Cheers,
>
> Julien
>
> On Jan 30, 10:20 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
> > Interesting and organized but it seems like a lot of work. Do you
> > write two versions of every method?
> >
> > For instance
> >
> > def ajax_latest_news(request):
> >...
> >latest_news = ...
> >json = simplejson.dumps(latest_news)
> >return HttpResponse(json, mimetype='application/json')
> >
> > and also
> >
> > def latest_news(request):
> >...
> >latest_news = ...
> >return render_to_response..
> >
> > My personal way to deal with this has to be make all ajax requests
> > POST's and add a wants field to them, then to do something like this:
> >
> > def latest_news(request):
> >
> >   latest_news = 
> >
> >   if request.method == 'POST' and request.POST.has_key('wants'):
> > if request.POST.has_key('wants') == 'json'
> >   json = simplejson.dumps(latest_news)
> >   return HttpResponse(json, mimetype='application/json')
> > else:
> >   normal template stuff
> >
> > It's kinda gludgy but I've not had time work it out yet but it seems
> > the prime way to do this would be to add a custom header to the
> > request that read 'accept-content-type='text/javascript'  and then
> > work off that but
> >
> > I'm of course not happy with my solution so am interested in seeing
> > what other people feed back...
> >
> > Vance
> >
> >   --
> >
> > On Jan 29, 2008 2:37 PM, Julien <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > Hi all,
> >
> > > I've started using Ajax in my Django sites. I'm using Jquery (and I
> > > love it!), but here it doesn't really matter which JS library you use,
> > > I'd just like to know your opinions on the best way to go to handle it
> > > on the server side.
> >
> > > I'm gonna tell you how I do it, then I'd really appreciate if you
> > > could share the way you do it. There are probably many good
> > > approaches, but maybe we could find some common ground that could for
> > > example be put online on the wiki.
> >
> > > What I do is mostly cosmetic to keep things tidy:
> >
> > > 1) I put all my ajax views in a separate file 'ajax-views.py'. By
> > > "ajax views" I mean all views that are called by a javascript, as
> 

Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Noah

It doesn't happen on every page view... the server runs fine for days
and then POOF collapse, every site


On Jan 29, 7:06 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote:
> > Our database is utf8 we explicitly convert ignoring errors to utf8
> > before passing to textile. Also it's not 1 page that poops it's every
> > site pooping at once.
>
> That means that the problem is inside something that shows on every
> page.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Having problem using the Syndication Feed Framework

2008-01-29 Thread jeffself

I'm trying to get an understanding of the Feed Framework, so I've
created a simple application to try it out.  I have followed the steps
that are in the documentation but I'm getting the following error when
I go to this URL: "http://127.0.0.1:8000/feeds/news/":

AttributeError at /feeds/news/
'NoneType' object has no attribute 'startswith'

Here are my files:

feeds.py

from django.contrib.syndication.feeds import Feed
from news.models import News

class NewsFeed(Feed):
'''Feed for latest 5 news entries'''
title = "My news"
link = "/sitenews/"
description = "Updates on changes and additions to my news"

def items(self):
return News.objects.order_by('-submit_date')[:5]

urls.py
##
from django.conf.urls.defaults import *
from mysite.news.models import News
from news.feeds import *

site_feeds = {
'news': NewsFeed,
}

news_info = {
"queryset" : News.objects.all().order_by("-submit_date"),
}

urlpatterns = patterns('',
(r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': site_feeds}),
)

models.py
#
class News(models.Model):
title = models.CharField(max_length=50, db_index=True)
submit_date = models.DateTimeField()
story = models.TextField()

And I have two templates in a feeds folder under mysite/templates

news_title.html  ->  {{ obj.title }}
news_description.html  ->  {{ obj.story }}


I've looked over this several times and everything seems to be
correct.  Help!!!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

> Our database is utf8 we explicitly convert ignoring errors to utf8
> before passing to textile. Also it's not 1 page that poops it's every
> site pooping at once.
That means that the problem is inside something that shows on every
page.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

I had A LOT of similar problems when I need to work with cyrillic. I
can easily replay your problem. Fortunately I'm on localized Windows
machine.
So:
>>> path = r'C:\Documents and Settings\vanilla'
>>> os.path.isdir(path)
True
>>> os.listdir(path)[-1]
'\xd8\xe0\xe1\xeb\xee\xed\xfb'
>>> a = os.listdir(path)[-1]
>>> a
'\xd8\xe0\xe1\xeb\xee\xed\xfb'
>>> a.decode('utf-8')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-1:
invalid dat
a

Here it is! Extremely difficult to diagnose problem!

And let's fix it:
>>> import sys
>>> a.decode(sys.getfilesystemencoding())
u'\u0428\u0430\u0431\u043b\u043e\u043d\u044b'
>>> b = a.decode(sys.getfilesystemencoding())
>>> print b
Шаблоны
>>> c = b.encode('utf-8')

Fixed

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Noah

Our database is utf8 we explicitly convert ignoring errors to utf8
before passing to textile. Also it's not 1 page that poops it's every
site pooping at once.

The best idea at this time is that because some apps on the server are
trunk and some are 0.96 it's causing a problem because of this :
http://code.djangoproject.com/ticket/5171
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multimedia helper 4u

2008-01-29 Thread Sriraj Thankaraja
MULTIMEDIA HELPER  4 U
 GFXVoid now running on vBulletin
forum software   By DJRajan


 

It took a bit too long, but GFXVoid is finally running on the vBulletin
forum system. I sincerely apologize for the extended recent downtime, it was
pretty much unavoidable. Thank you to everyone for hanging in there with us
while GFXVoid was offline. I very much appreciated all of your patience and
support. While the temporary replacement forum, GeekBoards, was made
available for GFXVoid members during this downtime - I know that it was
nowhere near the same as the void.

Important: In order to access your account on the new forum system, you will
need to use the lost password recovery form to reset your password. Once you
submit the form you will be sent instructions via email on how to reset your
password so that you can access the new system.

If you are unable to reset your password to access your account, please send
a message using the contact form to request assistance.

Avatars and signatures did not import 100% correctly with the vBulletin
import script, so I felt that it would be best for all avatars and
signatures to be uploaded again for anyone who wants to do so. Avatars and
signatures can be edited from within your user control panel - on the left
side of the user control panel page you will see the links to edit signature
and edit avatar.

Please feel free to contact me, one of the moderators or post in the forums
if you have any questions about the new system.

Aside from all that, Welcome back to GFXVoid

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Ivan Illarionov

It looks that you have encoding problem. You have wrong characters
somewhere. The solution is to find the text that causes problems and
create custom encode and/or decode function that fixes 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: select_related() and Template Logic

2008-01-29 Thread Eric Abrahamsen

> Second, it is obviously and woefully inefficient to do this for
> several blocks on the page. I may have 5 or more, and I may want to
> add some in the future. Is this the place for a custom templatetag?
> Has someone already put something like this together?

I haven't done exactly this, but I've done something similar, and can
maybe help with some general principles.

It's not clear exactly what's going into these pods, but it's usually
a bad idea to have things like 'style' or 'placement' in the database
tables: that's presentational logic, not data. I would suggest either
{% include %}-ing smaller template snippets, or using custom template
tags. If the snippet/tag can get all its information from the existing
context, use an include; if it needs its own database queries/extended
python, use a tag.

Still kind of shooting in the dark: information such as how the pods
are to be displayed should probably come in through the view. Maybe
via a GET query, maybe via saved user settings. You could create a
dictionary in the view, where say the keys were snippet/tag names, and
the values a list of style/presentation parameters that were passed to
each appropriate snippet. Something like that. Then your template is
simply a matter of checking if the dict has certain keys, and then
using the dict values to populate CSS style attributes, or to set
variables telling a template tag which queries to perform (actually
that last might not work, can't remember...).

As always, B-List has the goods:
http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/

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



1.3x-3x Model Instantiation Optimization

2008-01-29 Thread Ivan Illarionov

After discussion on Django developers group about
Model.__init__(*args) deprecation I found the way to dramatically
optimize instantiation of Django models. Here is a code: 
http://pastebin.com/m8e7e365

You may add this code to your Django model class and then instead of
obj = YourModelClass(title='Title', ,
pub_date=datetime.datetime.now() )
use
row = (None, 'Title',..., datetime.datetime.now())
obj = YourModelClass.fromtuple(row) # 1.3x faster then before
or
obj = YourModelClass.fromtuple(row, False) # 3x faster then before
only if you don't need pre_init and post_init signals!

The number of tuple items should be exactly the same that number of
fields.

And, be careful, the code is experimental, untested and relies on deep
black magic of object.__new__(class) which creates the instance
without calling __init__
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Noah

**CORRECTION**
mod_python 3.3.1

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



Re: Best Practice for Ajax and Django. Please share your thoughts.

2008-01-29 Thread Julien

Hey there,

My approach is not so much of an effort, and I do not write two
versions of every method. My ajax views are purely and only destined
for Ajax stuff. In this case, for example, you could imagine having a
DIV refreshing its content every 30 seconds by calling the
ajax_latest_news view.

Your approach is interesting, on giving the client the choice of
format for the result (json, XMl or whatever). However, instead of
adding 'wants' field in POST, maybe should you use different URLs
(e.g. latest_news/json/, latest_news/xml/, etc.) which would all point
to the same view but with a different parameter. I'd find it cleaner
than way.

Cheers,

Julien

On Jan 30, 10:20 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
> Interesting and organized but it seems like a lot of work. Do you
> write two versions of every method?
>
> For instance
>
> def ajax_latest_news(request):
>...
>latest_news = ...
>json = simplejson.dumps(latest_news)
>return HttpResponse(json, mimetype='application/json')
>
> and also
>
> def latest_news(request):
>...
>latest_news = ...
>return render_to_response..
>
> My personal way to deal with this has to be make all ajax requests
> POST's and add a wants field to them, then to do something like this:
>
> def latest_news(request):
>
>   latest_news = 
>
>   if request.method == 'POST' and request.POST.has_key('wants'):
> if request.POST.has_key('wants') == 'json'
>   json = simplejson.dumps(latest_news)
>   return HttpResponse(json, mimetype='application/json')
> else:
>   normal template stuff
>
> It's kinda gludgy but I've not had time work it out yet but it seems
> the prime way to do this would be to add a custom header to the
> request that read 'accept-content-type='text/javascript'  and then
> work off that but
>
> I'm of course not happy with my solution so am interested in seeing
> what other people feed back...
>
> Vance
>
>   --
>
> On Jan 29, 2008 2:37 PM, Julien <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi all,
>
> > I've started using Ajax in my Django sites. I'm using Jquery (and I
> > love it!), but here it doesn't really matter which JS library you use,
> > I'd just like to know your opinions on the best way to go to handle it
> > on the server side.
>
> > I'm gonna tell you how I do it, then I'd really appreciate if you
> > could share the way you do it. There are probably many good
> > approaches, but maybe we could find some common ground that could for
> > example be put online on the wiki.
>
> > What I do is mostly cosmetic to keep things tidy:
>
> > 1) I put all my ajax views in a separate file 'ajax-views.py'. By
> > "ajax views" I mean all views that are called by a javascript, as
> > opposed to the traditional views which are called through the
> > browser's address bar.
> > The structure then looks like this:
> > myapp
> >|_ ajax-views.py
> >|_ models.py
> >|_ urls.py
> >|_ views.py
>
> > 2) In the URLConf I also separate traditional views from ajax views:
>
> > from django.conf.urls.defaults import *
>
> > # Traditional views
> > urlpatterns = patterns('myapp.views',
> >url(r'^$', 'home'),
> >url(r'^news/$', 'list_news'),
> > )
>
> > # AJAX views
> > urlpatterns += patterns('myapp.ajax-views', # Don't forget the
> > '+=' sign here.
> >url(r'^ajax/news/latest/$', 'ajax_latest_news'),
> >url(r'^ajax/news/add/$', 'ajax_add_news'),
> > )
>
> > Note that I also add the prefix "ajax/" in the URLs for the ajax
> > views.
>
> > 3) The ajax views can look like this:
>
> > from django.utils import simplejson
>
> > def ajax_latest_news(request):
> > ...
> > latest_news = ...
> > json = simplejson.dumps(latest_news)
> > return HttpResponse(json, mimetype='application/json')
>
> > def ajax_add_news(request):
> > ...
> > results = {'success':True}
> > json = simplejson.dumps(results)
> > return HttpResponse(json, mimetype='application/json')
>
> > Please let me know your thoughts ;)
> > Cheers!
>
> > Julien
>
> --
> To pretend, I actually do the thing: I have therefore only pretended to 
> pretend.
>   - Jacques Derrida
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



We're having an extremely difficult to diagnose problem:

2008-01-29 Thread Noah

We're having an extremely difficult to diagnose problem:

At some point (possibly due to access from the public to a particular
view) our server will crap out.
All 21 Django sites hosted on it will display a very similar error.
There are obviously slight variations in the local variables and
what's going on
They ALL produce a very similar error.

Once the error occurs it takes out every site using our app, the
django admin unaffected just the sites front ends (all powered by our
in-house Django based CMS)
Restarting apache to fix it but it will come back.

We're using PostgreSQL 8.2, Apache 2.2, Python 2.5 and mod_python 2.7
and django 0.96 from svn (the bugfixes branch)

All of the tables in the databases are UTF-8 and many contain
charecter data outside of the ASCII range and the pages work fine.

Here are 4 errors from 4 sites instantly they all experience the same
problem
http://www.pastebin.ca/881636
http://www.pastebin.ca/881640
http://www.pastebin.ca/881643
http://www.pastebin.ca/881646
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Best Practice for Ajax and Django. Please share your thoughts.

2008-01-29 Thread Vance Dubberly

Interesting and organized but it seems like a lot of work. Do you
write two versions of every method?

For instance

def ajax_latest_news(request):
   ...
   latest_news = ...
   json = simplejson.dumps(latest_news)
   return HttpResponse(json, mimetype='application/json')

and also

def latest_news(request):
   ...
   latest_news = ...
   return render_to_response..


My personal way to deal with this has to be make all ajax requests
POST's and add a wants field to them, then to do something like this:

def latest_news(request):

  latest_news = 

  if request.method == 'POST' and request.POST.has_key('wants'):
if request.POST.has_key('wants') == 'json'
  json = simplejson.dumps(latest_news)
  return HttpResponse(json, mimetype='application/json')
else:
  normal template stuff

It's kinda gludgy but I've not had time work it out yet but it seems
the prime way to do this would be to add a custom header to the
request that read 'accept-content-type='text/javascript'  and then
work off that but

I'm of course not happy with my solution so am interested in seeing
what other people feed back...

Vance









  --

On Jan 29, 2008 2:37 PM, Julien <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I've started using Ajax in my Django sites. I'm using Jquery (and I
> love it!), but here it doesn't really matter which JS library you use,
> I'd just like to know your opinions on the best way to go to handle it
> on the server side.
>
> I'm gonna tell you how I do it, then I'd really appreciate if you
> could share the way you do it. There are probably many good
> approaches, but maybe we could find some common ground that could for
> example be put online on the wiki.
>
> What I do is mostly cosmetic to keep things tidy:
>
> 1) I put all my ajax views in a separate file 'ajax-views.py'. By
> "ajax views" I mean all views that are called by a javascript, as
> opposed to the traditional views which are called through the
> browser's address bar.
> The structure then looks like this:
> myapp
>|_ ajax-views.py
>|_ models.py
>|_ urls.py
>|_ views.py
>
> 2) In the URLConf I also separate traditional views from ajax views:
>
> from django.conf.urls.defaults import *
>
> # Traditional views
> urlpatterns = patterns('myapp.views',
>url(r'^$', 'home'),
>url(r'^news/$', 'list_news'),
> )
>
> # AJAX views
> urlpatterns += patterns('myapp.ajax-views', # Don't forget the
> '+=' sign here.
>url(r'^ajax/news/latest/$', 'ajax_latest_news'),
>url(r'^ajax/news/add/$', 'ajax_add_news'),
> )
>
> Note that I also add the prefix "ajax/" in the URLs for the ajax
> views.
>
> 3) The ajax views can look like this:
>
> from django.utils import simplejson
>
> def ajax_latest_news(request):
> ...
> latest_news = ...
> json = simplejson.dumps(latest_news)
> return HttpResponse(json, mimetype='application/json')
>
> def ajax_add_news(request):
> ...
> results = {'success':True}
> json = simplejson.dumps(results)
> return HttpResponse(json, mimetype='application/json')
>
> Please let me know your thoughts ;)
> Cheers!
>
> Julien
> >
>



-- 
To pretend, I actually do the thing: I have therefore only pretended to pretend.
  - Jacques Derrida

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



Best Practice for Ajax and Django. Please share your thoughts.

2008-01-29 Thread Julien

Hi all,

I've started using Ajax in my Django sites. I'm using Jquery (and I
love it!), but here it doesn't really matter which JS library you use,
I'd just like to know your opinions on the best way to go to handle it
on the server side.

I'm gonna tell you how I do it, then I'd really appreciate if you
could share the way you do it. There are probably many good
approaches, but maybe we could find some common ground that could for
example be put online on the wiki.

What I do is mostly cosmetic to keep things tidy:

1) I put all my ajax views in a separate file 'ajax-views.py'. By
"ajax views" I mean all views that are called by a javascript, as
opposed to the traditional views which are called through the
browser's address bar.
The structure then looks like this:
myapp
   |_ ajax-views.py
   |_ models.py
   |_ urls.py
   |_ views.py

2) In the URLConf I also separate traditional views from ajax views:

from django.conf.urls.defaults import *

# Traditional views
urlpatterns = patterns('myapp.views',
   url(r'^$', 'home'),
   url(r'^news/$', 'list_news'),
)

# AJAX views
urlpatterns += patterns('myapp.ajax-views', # Don't forget the
'+=' sign here.
   url(r'^ajax/news/latest/$', 'ajax_latest_news'),
   url(r'^ajax/news/add/$', 'ajax_add_news'),
)

Note that I also add the prefix "ajax/" in the URLs for the ajax
views.

3) The ajax views can look like this:

from django.utils import simplejson

def ajax_latest_news(request):
...
latest_news = ...
json = simplejson.dumps(latest_news)
return HttpResponse(json, mimetype='application/json')

def ajax_add_news(request):
...
results = {'success':True}
json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')

Please let me know your thoughts ;)
Cheers!

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: Unittest test-database not empty

2008-01-29 Thread Russell Keith-Magee

On Jan 30, 2008 5:36 AM, rock <[EMAIL PROTECTED]> wrote:
>
> Thanks Russ, for your helpful comments!
>
> I'm now searching for the initial_data fixture. I have looked through
> all files in this project without success.  When I run
>
> python manage.py test
>
> there is no such sentence as "Loading 'initial_data' fixtures", but
> maybe there shouldn't be one? I've also looked in all files named
> initial_data.* on my system without luck.

You won't see any loading messages during the test run; you only see
that message when you syncdb, or if you manually call 'loaddata
initial_data'

> I have a vague memory of creating these users (testuser and testuser2)
> a long time ago, possibly under another project. Does anybody know how
> to find (or delete) this fixture that is hiding somewhere?

Crank up the verbosity - pass in -v 2 as an argument to ./manage.py
loaddata, and it will tell you every location that it is checking for
fixtures, and what it finds there.

Yours,
Russ Magee %-)

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



Re: Have get_profile() delegate to one of several profile models depending on type of user

2008-01-29 Thread forgems

What is the criteria in the User model that gives you users profile
model ? If you don't have such a criteria in User's model then you
have answered your question,

On Jan 28, 9:11 pm, Chris Pratt <[EMAIL PROTECTED]> wrote:
> This question has been asked a few times before, but doesn't seem to
> be getting any responses.
>
> I'm working on a project where we have three types of users, each
> requiring vastly different profile models. The AUTH_PROFILE_MODULE
> setting, obviously, allows only one profile to be specified.
>
> One response to this question suggested branching from an intermediate
> profile model. Thereby, you could call something like:
>
> request.user.get_profile().get_for_user()
>
> and it would return the appropriate profile. This seems like a fair
> enough approach, but it's a bit kludgy, and certainly doesn't lend
> itself towards DRY code that anyone can manipulate. What happens if
> someone comes along later and doesn't know they're supposed to tack on
> the extra method call?
>
> It would be easy enough to rewrite the get_profile() method to pull
> the right profile and then monkey patch the User model, but this feels
> wrong.
>
> What would be considered best practice here?
>
> Thanks,
> Chris Pratt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Question

2008-01-29 Thread Ivan Illarionov

> Fortnately, Python makes this very easy with the built-in
> property() call:
>
>   class MyModel(Model):
> surname = CharField(...)
> forenames = CharField(...)
> def _get_name(self):
>   return self.forenames + ' ' + self.surname
> name = property(fget=_get_name)

Python (2.4+) makes it even easier with decorator:
class MyModel(Model):
surname = CharField(...)
forenames = CharField(...)
@property
def name(self):
return 'self.forenames + ' ' + self.surname
or, better:
   @property
   def name(self):
return '%s %s' % (self.forenames, self.surname)

or one-liner (not very good):
name = property(lambda self: '%s %s' % (self.forenames, self.surname))


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



Re: Newbie Question

2008-01-29 Thread Tim Chase

>> your __str__ returns a function...you omitted the call to that
>> function:
>>
>>   def __str__(self):
>> return self.name()
> 
> Ah - knew it would be obvious.  Thanks.  Simple typo on my part, I've just 
> split the name field in two, so it used to be a property.

Fortnately, Python makes this very easy with the built-in
property() call:

  class MyModel(Model):
surname = CharField(...)
forenames = CharField(...)
def _get_name(self):
  return self.forenames + ' ' + self.surname
name = property(fget=_get_name)

This will expose "name" as an attribute such that you don't have
to call it.  Having done my share of Java, this ability to write
code as if everything is just an attribute, then go back later
and retrofit get/set behaviors with minimal fuss is a blessing.
Thus, there's almost never a Java-esque need in Python to make
mountains of getters/setters to future-proof your code in case
you _might_ want to _maybe_ make access to an attribute be done
programatically.

-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: Newbie Question

2008-01-29 Thread Tim Sawyer

On Tuesday 29 Jan 2008, Tim Chase wrote:
> your __str__ returns a function...you omitted the call to that
> function:
>
>   def __str__(self):
> return self.name()

Ah - knew it would be obvious.  Thanks.  Simple typo on my part, I've just 
split the name field in two, so it used to be a property.

On Tuesday 29 Jan 2008, Krzysztof Ciesielski wrote:
> No problem, but better read Dive into python first :D

I read the O'Reilly python book ages ago...am rusty!  

I'm a java developer really, experimenting with something better.  Er, I'll 
get my coat...

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: Newbie Question

2008-01-29 Thread Krzysztof Ciesielski

On Jan 29, 2008 10:03 PM, Tim Sawyer <[EMAIL PROTECTED]> wrote:
>
> My model includes:
>
> surname = models.CharField(maxlength=50)
> forenames = models.CharField(maxlength=50)
>
> def __str__(self):
> return self.name
>
> def name(self):
> return self.forenames + ' ' + self.surname
>
>
> Referencing name in a template works fine, but in the admin site I get
>
>__str__ returned non-string (type instancemethod)
>
> when displaying a list of my object.
>
> why is this?
>

Read carefully the info you get ...
__str__ method is about to return instance of string objects (or
string like object), You pass a method ... name,
you either should use something like

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

or read something about @property and use it

> Thanks,
>
> Tim.
No problem, but better read Dive into python first :D


-- 
Greets,
Chris Ciesielski
--
mob. +48 791457074
email: [EMAIL PROTECTED]
skype: mi_yagi
jabber: [EMAIL PROTECTED]
www: http://www.pydev.pl/
ASI: http://www.asi.pwr.wroc.pl/

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



Re: Newbie Question

2008-01-29 Thread Tim Chase

> surname = models.CharField(maxlength=50)
> forenames = models.CharField(maxlength=50)  
> 
> def __str__(self):
> return self.name
> 
> def name(self):
> return self.forenames + ' ' + self.surname
> 
> 
> Referencing name in a template works fine, but in the admin site I get 
> 
>__str__ returned non-string (type instancemethod)


your __str__ returns a function...you omitted the call to that
function:

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

-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: 'admin_list' is not a valid tag library

2008-01-29 Thread David Sauve

Thanks, I figured out the problem.

For anyone else that might experience this; in my case I had created a
new app named "calendar" which, obviously, conflicted with the Python
system's calendar module.

I've opened a ticket to have the error message clarified for future
users, if it's possible.  Maybe something that indicates which module
Django tried to read the missing symbols from instead of just an error
indicating it couldn't find them.

We'll see if anyone else agrees with me.

David

On Jan 29, 2008 3:49 PM, George Herndon <[EMAIL PROTECTED]> wrote:
>
> david,
>
> i'm a newbie too, but found this bug report and was able to work
> around the issue.  see my comment for how what worked for me.  it
> would seem the install doesn't move the admin templates correctly.
>
> others more knowledgeable than me should comment.
>
> http://code.djangoproject.com/ticket/653#comment:6
>
> George Herndon
> [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
-~--~~~~--~~--~--~---



Newbie Question

2008-01-29 Thread Tim Sawyer

My model includes:

surname = models.CharField(maxlength=50)
forenames = models.CharField(maxlength=50)  

def __str__(self):
return self.name

def name(self):
return self.forenames + ' ' + self.surname


Referencing name in a template works fine, but in the admin site I get 

   __str__ returned non-string (type instancemethod)

when displaying a list of my object.

why is this?

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: 'admin_list' is not a valid tag library

2008-01-29 Thread George Herndon

david,

i'm a newbie too, but found this bug report and was able to work  
around the issue.  see my comment for how what worked for me.  it  
would seem the install doesn't move the admin templates correctly.

others more knowledgeable than me should comment.

http://code.djangoproject.com/ticket/653#comment:6

George Herndon
[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: Unittest test-database not empty

2008-01-29 Thread rock

Thanks Russ, for your helpful comments!

I'm now searching for the initial_data fixture. I have looked through
all files in this project without success.  When I run

python manage.py test

there is no such sentence as "Loading 'initial_data' fixtures", but
maybe there shouldn't be one? I've also looked in all files named
initial_data.* on my system without luck.

I have a vague memory of creating these users (testuser and testuser2)
a long time ago, possibly under another project. Does anybody know how
to find (or delete) this fixture that is hiding somewhere?

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: Managing the order of subordinate objects

2008-01-29 Thread Nathaniel Whiteinge

On Jan 28, 7:59 pm, Peter Rowell <[EMAIL PROTECTED]> wrote:
> You can also add an 'order' field to the subordinates, but you are
> only looking at one of them at a time in admin, so ... it requires the
> user to do a lot of remembering/note-taking.

I have an app with an order field, and I was thinking on this same
problem last week. I hacked up a quick solution using jQuery to make
Ajax calls from the Admin's list_display. It's nothing special (esp.
if you already are familiar with jQuery) -- but, hey, it does the job.

I just posted a snippet [1] with instructions. Hope it helps or gives
you a better idea.

.. [1] http://www.djangosnippets.org/snippets/568/

- whiteinge
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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_list' is not a valid tag library

2008-01-29 Thread David Sauve

Hi All,

Working my way through the Django tutorials and I've run into a bit of
snag on tutorial 2.  After enabling the admin module, I get the
following error when I try to view any of the items in the interface
(i.e, if I click on "Polls")

"admin_list' is not a valid tag library: Could not load template
library from django.templatetags.admin_list, cannot import name
isleap"

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/polls/poll/
Django Version: 0.97-pre-SVN-7049
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'portablehole.polls']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Template error:
In template 
f:\python25\lib\site-packages\django\contrib\admin\templates\admin\change_list.html,
error at line 2
   'admin_list' is not a valid tag library: Could not load template
library from django.templatetags.admin_list, cannot import name isleap
   1 : {% extends "admin/base_site.html" %}

   2 :  {% load adminmedia admin_list i18n %}

   3 : {% block stylesheet %}{% admin_media_prefix
%}css/changelists.css{% endblock %}

   4 : {% block bodyclass %}change-list{% endblock %}

   5 : {% if not is_popup %}{% block breadcrumbs %}{% trans "Home" %} 
{{ cl.opts.verbose_name_plural|capfirst|escape }}{% endblock
%}{% endif %}

   6 : {% block coltype %}flex{% endblock %}

   7 : {% block content %}

   8 : 

   9 : {% block object-tools %}

   10 : {% if has_add_permission %}

   11 : {% blocktrans with
cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans
%}

   12 : {% endif %}


Traceback:
File "unknown" in ?


Exception Type: TemplateSyntaxError at /admin/polls/poll/
Exception Value: 'admin_list' is not a valid tag library: Could not
load template library from django.templatetags.admin_list, cannot
import name isleap

Has anybody seen this before?  If so, do you know how to fix 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: ForeignKey related bug

2008-01-29 Thread John DeRosa

Chirayu Patel wrote:
> Hi,
> 
> While building a blog type application, I seem to have stumbled upon a
> bug. In a nut shell all object attributes have become read only when I 
> fetch the object from a query set which is fetched using the xxx_set() 
> API.
> 
> Please see the pdb trace for details. I have added comments to depict
> the erroneous logs. (pdb was started from within a unit test). I do 
> get similar behavior when using the shell.
> 
> Any suggestions for debugging this one?

This may not be all of your problem, but pdb had a bug (at least Python 
2.4, maybe it's gone in 2.5) wherein setting a variable at a breakpoint 
worked if and only if you didn't reexamine it after setting it.  E.g., 
this worked:

(Pdb) foobar = "dfdf"
(Pdb) c

But this did not:

(Pdb) foobar = "dfdf"
(Pdb) foobar
'old value'
(Pdb) c


There used to be a post on someone's blog about this, but darned if I 
can find it now.

John

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



Re: ForeignKey related bug

2008-01-29 Thread Rajesh Dhawan

>
> A little weird, maybe someone else can explain exactly what's going
> on. Presumably a QuerySet slice is somehow not being treated as the
> object itself.

Hi,

As Eric correctly pointed out that slicing a QuerySet is not "sticky".
Whenever you take a slice of an exisiting QuerySet, Django clones it
dynamically to a new QuerySet. So every time you reference m[0] you
get a slice from a *clone* of the QuerySet m. It follows that this
clone has a different instance of m[0] from the previous m[0].

As Eric suggested, save m[0] first to a variable if you need to act on
a known single instance of that object for multiple operations.

-Rajesh D

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Have get_profile() delegate to one of several profile models depending on type of user

2008-01-29 Thread [EMAIL PROTECTED]

You could create a UserProfile that is essentially just a single
member with a selectable type.

Depending on the response, go grab that other profile for the user.

Wrap this in a function:

def getRealProfile(user):
  p = user.get_profile()
  if p.Type == 'a':
return AProfile.objects.filter(user=user)[0]
  elif. ...

I don't really like this option too much though.


Ivan

On Jan 28, 12:11 pm, Chris Pratt <[EMAIL PROTECTED]> wrote:
> This question has been asked a few times before, but doesn't seem to
> be getting any responses.
>
> I'm working on a project where we have three types of users, each
> requiring vastly different profile models. The AUTH_PROFILE_MODULE
> setting, obviously, allows only one profile to be specified.
>
> One response to this question suggested branching from an intermediate
> profile model. Thereby, you could call something like:
>
> request.user.get_profile().get_for_user()
>
> and it would return the appropriate profile. This seems like a fair
> enough approach, but it's a bit kludgy, and certainly doesn't lend
> itself towards DRY code that anyone can manipulate. What happens if
> someone comes along later and doesn't know they're supposed to tack on
> the extra method call?
>
> It would be easy enough to rewrite the get_profile() method to pull
> the right profile and then monkey patch the User model, but this feels
> wrong.
>
> What would be considered best practice here?
>
> Thanks,
> Chris Pratt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: template orderby help

2008-01-29 Thread Rajesh Dhawan


>
> The ={{ request.GET.listing }} is the part im having trouble
> with.
>
> In the url the following 
> appearshttp://testsite.com/?orderby=id=test=_filter=
> which does not work

It's not clear what does not work. Do you get an error? What does the
view that receives that URL do with the request parameters you are
passing? Perhaps even include relevant code snippets from that view.

>
> But if i edit the url to this then it 
> works?http://testsite.com/?orderby=id=test

Since the only difference between this working URL and the non-working
one above is that the former has a couple of empty parameters, perhaps
your view needs to be changed so it treats empty parameters as if they
were never supplied?

-Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: A naive question re: text styling tags

2008-01-29 Thread Rajesh Dhawan



On Jan 29, 1:02 pm, LRP <[EMAIL PROTECTED]> wrote:
> Hello,
>
> The models documentation in the Django site 
> (http://www.djangoproject.com/documentation/model-api/)
> shows an admin screen for inputting articles.
>
> Simple enough, but suppose we need to style some of the text in the
> content field, e.g., italicize a word, display a string of words in
> boldface, etc.
>
> Does the person entering the text have to know how to insert the html
> styling tags? Or is there some other method  for handling text styling
> within a content block?

Use a textual markup language like Markdown, Textile, Restructered
Text. Django/ and Pythong support them perfectly. See
http://code.djangoproject.com/wiki/UsingMarkup for some ideas.

You could also embed a WYSIWIG type Javascript editor. See
http://code.djangoproject.com/wiki/CookBookAdminTools

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

2008-01-29 Thread code_berzerker

I'd integrate javascript WYSIWYG editor like FCKEditor or TinyMCE to
edit TextField type fields.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template not getting render after login

2008-01-29 Thread Rajesh Dhawan

Hi,

>
>                         View User
>
>                         
>
>                         Create User
>
>                         

...
>
> But when i am clicking on create user tab I am getting the  following
> page:
> {% extends "templates/base.html" %}  {% block content %}
> {{form.name.error}} Name {{form.name}} {{form.permission.error}}
> Permission {{form.permission}}
>
> {% endblock %}
>
> The page is not getting render.
> Any idea what the problem is?

It looks like "Create User" is linked to a static page: /static/
create_user_form.html rather than a Django view. How are you serving
files under the /static/ directory?

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



A naive question re: text styling tags

2008-01-29 Thread LRP

Hello,

The models documentation in the Django site (http://
www.djangoproject.com/documentation/model-api/)
shows an admin screen for inputting articles.

Simple enough, but suppose we need to style some of the text in the
content field, e.g., italicize a word, display a string of words in
boldface, etc.

Does the person entering the text have to know how to insert the html
styling tags? Or is there some other method  for handling text styling
within a content block?

How do they do it at lawrence.com?

Many thanks,

Lloyd




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



Re: How can I parse and process the contents of an URL?

2008-01-29 Thread Little_Grungy

Wondering if you were able to solve this one?

Trying something similar, can you post the rest of the source, I'm a
newb, thankyou
lg

On Jan 28, 11:19 pm, Michael Elsdörfer <[EMAIL PROTECTED]>
wrote:
>  > but the page seems to load forever and I'm stuck!
>
> I'm pretty sure I ran into this before, and IIRC it's because Django's
> runserver, which I assume you are using, can only handle one request at
> a time - try a different test url.
>
> Michael
>
> MariusB schrieb:
>
> > I'm trying to take a link as an argument, open it, read it's content
> > and then display the first 50 characters from it. First of all, I've
> > tried to put the code in the views.py, but I didn't make it. Now I
> > made a middleware component with this code:
>
> > import urllib2 from django.shortcuts import render_to_response
>
> > TEST_URL = 'http://127.0.0.1:8000/openurl/'
>
> > class Char50(object): def process_view(self, request, view_func,
> > view_args, view_kwargs): query = request.POST.get('q', '') c =
> > urllib2.urlopen(TEST_URL) contents = c.read( ) conturl =
> > contents[0:50] return render_to_response("test.html", { "query":
> > query, "results": conturl })
>
> > but the page seems to load forever and I'm stuck! I've read the
> > chapters from the djangobook, searched on the Internet, but I still
> > haven't found a solution.
>
> > Please help me! >
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



you want online job

2008-01-29 Thread vino

you want online job
http://asiafriendfinder.com/go/g933134
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Have get_profile() delegate to one of several profile models depending on type of user

2008-01-29 Thread Thomas Guettler

Hi,

A profile is like a one to one relation. Since the future of
OneToOneField is unknown I heard you should use ForeignKey() with
unique=True.

You can modify djangos User model (e.g. in your model file), and
give it a property to make the access easier. In this
get_myprofile() method, you can create myprofile, if it does not
exist up to now.

Since you want three different profiles, I would create three
properties. I think this is better than one property which
returns different model instances.

 Thomas


Am Montag, 28. Januar 2008 21:11 schrieb Chris Pratt:
> This question has been asked a few times before, but doesn't seem to
> be getting any responses.
>
> I'm working on a project where we have three types of users, each
> requiring vastly different profile models. The AUTH_PROFILE_MODULE
> setting, obviously, allows only one profile to be specified.
>
> One response to this question suggested branching from an intermediate
> profile model. Thereby, you could call something like:
>
> request.user.get_profile().get_for_user()
>
> and it would return the appropriate profile. This seems like a fair
> enough approach, but it's a bit kludgy, and certainly doesn't lend
> itself towards DRY code that anyone can manipulate. What happens if
> someone comes along later and doesn't know they're supposed to tack on
> the extra method call?
>
> It would be easy enough to rewrite the get_profile() method to pull
> the right profile and then monkey patch the User model, but this feels
> wrong.
>
> What would be considered best practice here?
>
> Thanks,
> Chris Pratt

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

2008-01-29 Thread Eduardo - IdNotFound

Hello,

On Jan 28, 2008 3:09 PM, theZero <[EMAIL PROTECTED]> wrote:
>
[introduction]
>
> Pages are called using select_related(), which retrieves the
> associated Pods. So in the template, I have several areas like this:
>
> {% block leftcolumn %}
> 
> {% for pod in page.pods.all %}
> {% ifequal pod.placement "left" %}
> 
> {{ pod.Title }}
> {{ pod.Content|escape|linebreaks }}
> 
> {% else %}
> {% endifequal %}
> {% endfor %}
> 
> {% endblock %}
>
> It works, but I definitely know it's not the best way to do it. I have
> two primary problems with it.
>
> First, if there are no items in that block, then I don't want to show
> that  on the page at all. How can I choose to
> display the contents of a block depending on if a pod exists that
> meets the select criteria? I know I'm missing something simple, but I
> can't put my finger on it.

If I am not mistaken, {% if page.pods.all %} should evaluate to False
if there are no pods, so you can enclose your  with that and it
should work as you'd like.

> Second, it is obviously and woefully inefficient to do this for
> several blocks on the page. I may have 5 or more, and I may want to
> add some in the future. Is this the place for a custom templatetag?
> Has someone already put something like this together?
>
> If I'm completely off-base and thinking about this wrong, let me know.
> I'm still learning!

I have no experience with this second issue. Sorry!


Hope it helps,
Eduardo.

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

2008-01-29 Thread MariusB

Thanks a lot for the help!

On Jan 29, 3:34 pm, "Remco Gerlich" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Apparently you want an empty list if query has a value, and a list with one
> element otherwise (so the "if query" works).
>
> query_string = request.POST.get('q', '')
> if query_string:
>query = [ query_string ]
> else:
>query = []
>
> Reading the Python tutorial probably wouldn't hurt.
>
> Remco
>
> On Jan 29, 2008 2:19 PM, MariusB <[EMAIL PROTECTED]> wrote:
>
>
>
> > In the view take an URL from the query:
> >query = request.POST.get('q', '')
>
> > and in the template I want to print it out in a list
> >{% if query %}
> >
> >{% for url in query %}
> >{{ url }}
> >{% endfor %}
> >
> >{% else %}
> >No urls found
> >{% endif %}
>
> > How do I turn query from a string into a list with one element
> > (['']) in the view?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: converting string to list

2008-01-29 Thread Remco Gerlich
Hi,

Apparently you want an empty list if query has a value, and a list with one
element otherwise (so the "if query" works).

query_string = request.POST.get('q', '')
if query_string:
   query = [ query_string ]
else:
   query = []

Reading the Python tutorial probably wouldn't hurt.

Remco



On Jan 29, 2008 2:19 PM, MariusB <[EMAIL PROTECTED]> wrote:

>
> In the view take an URL from the query:
>query = request.POST.get('q', '')
>
> and in the template I want to print it out in a list
>{% if query %}
>
>{% for url in query %}
>{{ url }}
>{% endfor %}
>
>{% else %}
>No urls found
>{% endif %}
>
> How do I turn query from a string into a list with one element
> (['']) in the view?
> >
>

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

2008-01-29 Thread Jonathan Ballet

MariusB wrote:
> In the view take an URL from the query:
>   query = request.POST.get('q', '')

> How do I turn query from a string into a list with one element
> (['']) in the view?

I'm not sure I understand what you mean, but if you want to transform your 
"query" variable into a 
single-element list, you can use : query = [query] , or you can split your 
"query" using the 
"split()" method.

  - Jonathan


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



templates CSS free

2008-01-29 Thread VAIO PC

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



converting string to list

2008-01-29 Thread MariusB

In the view take an URL from the query:
query = request.POST.get('q', '')

and in the template I want to print it out in a list
{% if query %}

{% for url in query %}
{{ url }}
{% endfor %}

{% else %}
No urls found
{% endif %}

How do I turn query from a string into a list with one element
(['']) in the view?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: best practice to construct 10x10 grid

2008-01-29 Thread Tim Chase

> I have grid 10x10 populated with int>0.
> Currently I'm avoiding modelforms all together and doing my own
> processing, definining it as array and rendering with
> loop, custom checking with my own validators outside of database
> Model.


Well, you can make a custom template tag that takes your source
data and creates the HTML based on the model you pass to it.  As
an example, you may be interested in my columnize() filter

http://groups.google.com/group/django-users/msg/5cf381778791c605

which columnizes an arbitrary-length list into an arbitrary
number of columns.

You don't give your data, or how it's being presented, but a
similar function could do the trick for you.

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



Help With Table joins pleeeaaassseee

2008-01-29 Thread invisiWeeble

I'm struggling to understand the db api when it comes to nested
relationships, I have three tables 'Channel', 'Category', 'Product'.
Each channel can have one or many categories, and each category can
have 1 or many products, also each product can be listed in 1 or many
categories (so many to many).

What i'm trying to do is select all products that are in a certain
channel, via the categories.

I can get as far as creating the category_set, from the channel
instance, as documented in the api docs, but I get lost when trying to
get all of the resulting querysets from the category_set.

my (simplified) models:-

class Channel(models.Model):#blog
name = models.CharField("Name", maxlength=30)
slug = models.SlugField("URL", prepopulate_from=('name',))

class Admin:
pass

def __unicode__(self):
return self.name

class Category(models.Model):
name = models.CharField("Name", maxlength=100)
slug = models.SlugField("URL", prepopulate_from=('name',))
channel = models.ForeignKey(Channel, verbose_name="Channel")
parent = models.ForeignKey("self", verbose_name="Parent
Category",
blank='true', null='true', related_name="child_set")
desc = models.CharField("Description",
maxlength=500,blank='true')

class Admin:
pass

def __unicode__(self):
if self.parent:
prefix = str(self.parent)
else:
return self.name

return '>'.join((prefix,self.name))

class Prod(models.Model):
title = models.CharField(maxlength=100)
slug = models.SlugField("URL", prepopulate_from=("title",))
precis = models.TextField(maxlength=100)
body = models.TextField(maxlength=5000)
categories = models.ManyToManyField(Category,
verbose_name="Category")

class Admin:
pass

def __unicode__(self):
return self.title

my view:-

def prods_by_channel(request, slug):

try:
ch = Channel.objects.get(slug__iexact=slug)
ct = ch.category_set.all()
except Category.DoesNotExist:
raise Http404

return list_detail.object_list(
request,
queryset = ct.prod_set.all(),
template_name = "prods/prod_by_channel.html",
)

I know the category_set contains further prod_sets, but I don't know
how get
at them, using the view code above raises an attribute error... BTW,
my background is lowly frontend development, and I'm a relative
newbie, so please be gentle with me =0)

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



overwriting GUID in feeds

2008-01-29 Thread Matt Davies
Can anyone tell me if it's possible to overwrite the GUID of a feed item
with something other than the URL?

The ID of the item itself is what I'm after.

Here's how I'm trying to currently.

http://dpaste.com/32970/

Any help would be greatly appreciated.

I can't work out how the main get_object is calling Tags, but then I can
access sub elements of events by referring to item, singular, after
describing items
That is how pubdate is working so I though i could use the same principle,
obviously not quite like that.

Any help greatly appreciated.

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



Re: best practice to construct 10x10 grid

2008-01-29 Thread sircco

yes it is


On Jan 29, 11:58 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 29-Jan-08, at 4:18 PM, sircco wrote:
>
> > I have grid 10x10 populated with int>0.
>
> is the size fixed?
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/
> Foss Conference for the common man:http://registration.fossconf.in/web/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Template not getting render after login

2008-01-29 Thread laspal

Hi,
I have a base template with with tabs like create user, edit user and
so on.
My base.html is as follows:





 

View User



Create User



Edit
User  















{% block content %}{% endblock %}








But when i am clicking on create user tab I am getting the  following
page:
{% extends "templates/base.html" %}  {% block content %}
{{form.name.error}} Name {{form.name}} {{form.permission.error}}
Permission {{form.permission}}

{% endblock %}

The page is not getting render.
Any idea what the problem is?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: best practice to construct 10x10 grid

2008-01-29 Thread Kenneth Gonsalves


On 29-Jan-08, at 4:18 PM, sircco wrote:

> I have grid 10x10 populated with int>0.

is the size fixed?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/
Foss Conference for the common man: http://registration.fossconf.in/web/



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



best practice to construct 10x10 grid

2008-01-29 Thread sircco

I have grid 10x10 populated with int>0.
Currently I'm avoiding modelforms all together and doing my own
processing, definining it as array and rendering with
loop, custom checking with my own validators outside of database
Model.

Any hints how to standardize it and move to django way of thinking?

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

2008-01-29 Thread Anton P. Linevich

Greeting, Christoph!  Mon, Jan 28, 2008 at 08:46:38PM +0100, Christoph.Egger 
wrote: 
>   Invalid Command 'SetEnv', perhapes misspelled or defines by a module
> not included in the server configuration.

Maybe you need load mod_env module before use it:
 LoadModule env_module mod_env.so

-- 
 Anton P. Linevich

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

2008-01-29 Thread Artiom Diomin

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Michael,

You easily may write your own FlatPageMiddleware, that works on
process_request, instead of original that works with process_response.

Take a look at
django.contrib.flatpages.middleware.FlatpageFallbackMiddleware


Michael Newman writes:
| Is there anyway to change the order that the urls are checked? For
| example I have an about us page that is generated by a url conf. I
| want my designer to make his own about us page with flatpages and
| therefore 'overwrite' the url that is autogenerated. I know right now
| flatpages checks the url after a 404 is received, but I want it to
| work the other way around. Any ideas?
|
| Thanks in advance, Mn
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHnuknHoZOXY8LFOARAv3kAKCuyeLfsftf3jGXxl+wNn8PofijRgCgw5+C
6JuHX6BZkI/8nugW0g7e6Pc=
=xxmV
-END PGP SIGNATURE-

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