Re: When to use templatetags and how to use views.py

2008-01-10 Thread Darthmahon

Thanks for the reply, I've also just found out about context
processors, which to me sound extremely similar to templatetags. The
only problem I can see with both of these options is that I can't see
how you pass extra options into them, whereas you can if the logic is
contained within views.py

I think Django is great, but there are at least three different ways
to do what I want which I think is almost too many options as I'm left
utterly confused as to which is appropriate for the situation. Your
answer makes sense, but how do context processors fit into all of
this?

On Jan 11, 2:03 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 10-Jan-08, at 8:54 PM, Darthmahon wrote:
>
> > Is there any real difference between passing the data from a views.py
> > file into a template compared with asking for the data using a
> > templatetag?
>
> if you are only using it in one template - do it in the view. If you  
> are doing it in several or all templates, do it in templatetags
>
> --
>
> 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
-~--~~~~--~~--~--~---



Re: advice on table joins

2008-01-10 Thread Sean Perry


Ken wrote:
> I need some advice.  I'm struggling with a query that spans 4 tables.
> "Struggling" is a bad word; I'll explain later.  Django uses a model-
> oriented query system together with a Foreign Key manager to get to
> the "next" joining table.  A query that spans several tables results
> in a deeply nested loop.  Hence, my struggle.  I have an aversion to
> writing deeply nested loops.  It's an indication that I dont quite
> understand my problem.  In SQL, you join the tables you need depending
> on the query and you filter out entries you are interested in with a
> WHERE clause.  It's an idea I'm familiar with; it's "flat", ie, not
> nested.  When I see deeply nested loops, I tend to think recursion.
> But that doesnt work either since at each level, the operation is
> model-specific.  I need some general advice on how folks handle
> queries on joined tables within the django framework.  Since queries
> are model based, is it better to forget about constructing related but
> orthogonal tables and simply throw everything in a model?
> 

I have models: Artist, Track, Album, MultiAlbum (think box set).
Artist.tracks is actually the Django created reverse mapping of 
Track.artist. Once I fully understood the foo__bar__baz notation I found 
it easier to read and create than the equivalent SQL.

The line of code below returns all of the Artists in the chosen 
multi-album where self.title is the box set's title.

Artist.objects.filter(tracks__album__multi__title=self.title).distinct()

Hope this helps. If not, perhaps you have some examples of your own to 
share.

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



win a million doller & make ur life sweeter

2008-01-10 Thread jones

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



Re: django-registration mysterious errror

2008-01-10 Thread [EMAIL PROTECTED]

That's it. That's exactly it, and I remember doing it, now that you
put it that way. All right, now that I know what's going on, maybe I
can figure out where the error's coming from. Thank you. I like this
explanation way more than the possiblility that I was going mad.

On Jan 10, 9:47 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Jan 10, 2008 9:14 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Unless I've gone utterly mad, it IS django-registration. I remember
> > installing django-registration, and most all of the code looks just
> > like django-registration, albeit an older version. Not that any of
> > that explains the error, or where line 35 or 36 came from (they differ
> > from the current django-registration code). I don't remember putting
> > them in. I DO remember changing the import paths.
>
> And yet you must have added those lines (presumably to set up the
> automatic login on activation, which django-registration doesn't
> support and never has); the problem is that you're not checking
> whether the activation actually did anything -- 'account' can and will
> be the boolean False if the activation failed.
>
> --
> "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
-~--~~~~--~~--~--~---



Dev server hangs based on Site settings?

2008-01-10 Thread Andrew

I'm seeing some very strange behavior on my development box...

If I have the current site (the one returned by
Site.get_current_site()) set to the same address as my development
server, the server will hang. The server with run, but stalls when I
try to make a request -- it doesn't even print out the request in the
terminal.

So, if I'm running on 192.168.2.2:8000 and my Site is set to
192.168.2.2:8000, it hangs. But if I run on localhost:8000 or
192.168.2.2 with the Site set to 192.168.2.2:8000, it works.

Does this ring any bells for anyone?

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



Re: django-registration mysterious errror

2008-01-10 Thread James Bennett

On Jan 10, 2008 9:14 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Unless I've gone utterly mad, it IS django-registration. I remember
> installing django-registration, and most all of the code looks just
> like django-registration, albeit an older version. Not that any of
> that explains the error, or where line 35 or 36 came from (they differ
> from the current django-registration code). I don't remember putting
> them in. I DO remember changing the import paths.

And yet you must have added those lines (presumably to set up the
automatic login on activation, which django-registration doesn't
support and never has); the problem is that you're not checking
whether the activation actually did anything -- 'account' can and will
be the boolean False if the activation failed.



-- 
"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: Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Michael Hipp wrote:
> Graham Dumpleton wrote:
>> On Jan 11, 1:13 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
>>> Graham Dumpleton wrote:
 On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
> Hello,
> My "main" Django site is working great. But on my shared hosting account
> (HostMonster) I have multiple sites. Some will be Django, some will be
> plain html.
> How do I set this up (specifically in settings.py, urls.py and .htaccess).
> I'm using FastCGI and a script for the main site. I only have access to
> .htaccess.
> Currently the html sub-pages work fine on the other sites, but not the
> main page. Apache logs this:
> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
> exceeded the limit of 10 internal redirects due to probable
> configuration error. Use 'LimitInternalRecursion' to increase the limit
> if necessary. Use 'LogLevel debug' to get a backtrace.
> Can someone help me get started down the right path on this?
 Looks like your rewrite rule for making a .fcgi script appear as being
 mounted at root of site is not correct. Post your complete .htaccess
 file showing all parts of the directives related to rewrite rule.
>>> It's pretty much verbatim from the Django docs, but I don't know if such was
>>> intended for multi-site installations:
>>>
>>> AddHandler fcgid-script .fcgi
>>> RewriteEngine On
>>> RewriteCond %{REQUEST_FILENAME} !-f
>>> RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]
>> What happens if you replace the last line with:
>>
>>   RewriteRule ^(.*)$ /some/url/redmule.fcgi/$1 [QSA,PT,L]
>>
>> Where '/some/url/redmule.fcgi' is actually the real URL that you would
>> use to access that fcgi script directly if you were doing it from the
>> browser (excluding the http://host bit of course).
>>
>> I have seen problems where using just the basename of the .fcgi script
>> in a .htaccess file doesn't work and full URL is required instead.
> 
> If I understood correctly, I tried it with just this as the .fcgi script is 
> located in my document root (alongside the old index.html file).
> 
>RewriteRule ^(.*)$ /redmule.fcgi/$1 [QSA,PT,L]

Forgot to add that this didn't make any discernible change.

Michael

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



Re: django-registration mysterious errror

2008-01-10 Thread [EMAIL PROTECTED]

Unless I've gone utterly mad, it IS django-registration. I remember
installing django-registration, and most all of the code looks just
like django-registration, albeit an older version. Not that any of
that explains the error, or where line 35 or 36 came from (they differ
from the current django-registration code). I don't remember putting
them in. I DO remember changing the import paths.

"""
Views which allow users to create and activate accounts.

"""


from django.conf import settings
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth import login
from classic.registration.forms import RegistrationForm
from classic.registration.models import RegistrationProfile


def activate(request, activation_key):
"""
Activates a ``User``'s account, if their key is valid and hasn't
expired.

Context::
account
The ``User`` object corresponding to the account,
if the activation was successful.

expiration_days
The number of days for which activation keys stay valid.

Template::
registration/activate.html

"""
activation_key = activation_key.lower() # Normalize before trying
anything with it.
account =
RegistrationProfile.objects.activate_user(activation_key)
account.backend = 'django.contrib.auth.backends.ModelBackend'
login(request, account)
return render_to_response('registration/activate.html',
  { 'account': account,
'expiration_days':
settings.ACCOUNT_ACTIVATION_DAYS },
 
context_instance=RequestContext(request))


def register(request, success_url='/registration/complete/',
profile_callback=None):
"""
Allows a new user to register an account.

On successful registration, an email will be sent to the new user
with an activation link to click to make the account active. This
view will then redirect to ``success_url``, which defaults to
'/accounts/register/complete/'. This application has a URL pattern
for that URL and routes it to the ``direct_to_template`` generic
view to display a short message telling the user to check their
email for the account activation link.

To enable creation of a site-specific user profile object for the
new user, pass a function which will create the profile object as
the keyword argument ``profile_callback``. See
``RegistrationManager.create_inactive_user`` for details on what
this function should do.

Context::
form
The registration form

Template::
registration/registration_form.html

"""
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
new_user =
RegistrationProfile.objects.create_inactive_user(username=form.cleaned_data['username'],
 
password=form.cleaned_data['password1'],
 
email=form.cleaned_data['email'],
 
profile_callback=profile_callback)
return HttpResponseRedirect(success_url)
else:
form = RegistrationForm()
return render_to_response('registration/registration_form.html',
  { 'form': form },
 
context_instance=RequestContext(request))



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



Re: django-registration mysterious errror

2008-01-10 Thread Karen Tracey
On Jan 10, 2008 9:11 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

>
> Thanks James. So the mystery remains... here's the full error I got,if
> it helps. I can't figure out where it came from. Never happened
> before.
>
> Traceback (most recent call last):
>
>  File "/home/grmadmin/webapps/django/django/core/handlers/base.py",
> line 77, in get_response
>   response = callback(request, *callback_args, **callback_kwargs)
>
>  File "/home/grmadmin/webapps/django/classic/registration/views.py",
> line 35, in activate
>   account.backend = 'django.contrib.auth.backends.ModelBackend'
>
> AttributeError: 'bool' object has no attribute 'backend'
>

More helpful in explaining the error would be the code up to line 35 of
"/home/grmadmin/webapps/django/classic/registration/views.py".  I'd also be
curious what this code is, since it's not part of django-registration.  Do
you know where this code originated?

Karen

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



Re: Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Graham Dumpleton wrote:
> On Jan 11, 1:13 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Graham Dumpleton wrote:
>>> On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
 Hello,
 My "main" Django site is working great. But on my shared hosting account
 (HostMonster) I have multiple sites. Some will be Django, some will be
 plain html.
 How do I set this up (specifically in settings.py, urls.py and .htaccess).
 I'm using FastCGI and a script for the main site. I only have access to
 .htaccess.
 Currently the html sub-pages work fine on the other sites, but not the
 main page. Apache logs this:
 [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
 exceeded the limit of 10 internal redirects due to probable
 configuration error. Use 'LimitInternalRecursion' to increase the limit
 if necessary. Use 'LogLevel debug' to get a backtrace.
 Can someone help me get started down the right path on this?
>>> Looks like your rewrite rule for making a .fcgi script appear as being
>>> mounted at root of site is not correct. Post your complete .htaccess
>>> file showing all parts of the directives related to rewrite rule.
>> It's pretty much verbatim from the Django docs, but I don't know if such was
>> intended for multi-site installations:
>>
>> AddHandler fcgid-script .fcgi
>> RewriteEngine On
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]
> 
> What happens if you replace the last line with:
> 
>   RewriteRule ^(.*)$ /some/url/redmule.fcgi/$1 [QSA,PT,L]
> 
> Where '/some/url/redmule.fcgi' is actually the real URL that you would
> use to access that fcgi script directly if you were doing it from the
> browser (excluding the http://host bit of course).
> 
> I have seen problems where using just the basename of the .fcgi script
> in a .htaccess file doesn't work and full URL is required instead.

If I understood correctly, I tried it with just this as the .fcgi script is 
located in my document root (alongside the old index.html file).

   RewriteRule ^(.*)$ /redmule.fcgi/$1 [QSA,PT,L]

Is that what you meant?

Should there be a separate 'mysite.fcgi' file for each site?

Thanks,
Michael

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

2008-01-10 Thread Eoin

I actually found (few hours later) it was a rehash of :
http://groups.google.com/group/django-users/browse_thread/thread/7f4becc6b0a482d0/669b3e3e68f80f84

the md5 of php conflicting with the md5 python ... i disabled php and
all has been great since
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Multiple sites, shared hosting

2008-01-10 Thread Graham Dumpleton

On Jan 11, 1:13 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
> Graham Dumpleton wrote:
> > On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
> >> Hello,
>
> >> My "main" Django site is working great. But on my shared hosting account
> >> (HostMonster) I have multiple sites. Some will be Django, some will be
> >> plain html.
>
> >> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>
> >> I'm using FastCGI and a script for the main site. I only have access to
> >> .htaccess.
>
> >> Currently the html sub-pages work fine on the other sites, but not the
> >> main page. Apache logs this:
>
> >> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
> >> exceeded the limit of 10 internal redirects due to probable
> >> configuration error. Use 'LimitInternalRecursion' to increase the limit
> >> if necessary. Use 'LogLevel debug' to get a backtrace.
>
> >> Can someone help me get started down the right path on this?
>
> > Looks like your rewrite rule for making a .fcgi script appear as being
> > mounted at root of site is not correct. Post your complete .htaccess
> > file showing all parts of the directives related to rewrite rule.
>
> It's pretty much verbatim from the Django docs, but I don't know if such was
> intended for multi-site installations:
>
> AddHandler fcgid-script .fcgi
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]

What happens if you replace the last line with:

  RewriteRule ^(.*)$ /some/url/redmule.fcgi/$1 [QSA,PT,L]

Where '/some/url/redmule.fcgi' is actually the real URL that you would
use to access that fcgi script directly if you were doing it from the
browser (excluding the http://host bit of course).

I have seen problems where using just the basename of the .fcgi script
in a .htaccess file doesn't work and full URL is required instead.

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



Re: i18n problem: Some template variables "get stuck" in one language

2008-01-10 Thread Peter Rowell

Emil:

> Except that on a couple of pages,
> the language seems to get stuck on the translated language after the
> first time I change languages.

This smells very much like a caching issue. Do you have any form of
caching enabled? If so, turn it off and see if the problem is
magically fixed.

You may need to cache at below-the-page level (ie. component level -
see the cache templatetag) or you may need to add one or more vary-on
variables so that you get different cache values for different
languages (or whatever).


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

2008-01-10 Thread Michael Hipp

Graham Dumpleton wrote:
> On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> My "main" Django site is working great. But on my shared hosting account
>> (HostMonster) I have multiple sites. Some will be Django, some will be
>> plain html.
>>
>> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>>
>> I'm using FastCGI and a script for the main site. I only have access to
>> .htaccess.
>>
>> Currently the html sub-pages work fine on the other sites, but not the
>> main page. Apache logs this:
>>
>> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
>> exceeded the limit of 10 internal redirects due to probable
>> configuration error. Use 'LimitInternalRecursion' to increase the limit
>> if necessary. Use 'LogLevel debug' to get a backtrace.
>>
>> Can someone help me get started down the right path on this?
> 
> Looks like your rewrite rule for making a .fcgi script appear as being
> mounted at root of site is not correct. Post your complete .htaccess
> file showing all parts of the directives related to rewrite rule.

It's pretty much verbatim from the Django docs, but I don't know if such was 
intended for multi-site installations:

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ redmule.fcgi/$1 [QSA,PT,L]

Thansk for any help,
Michael

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



Re: django-registration mysterious errror

2008-01-10 Thread [EMAIL PROTECTED]

Thanks James. So the mystery remains... here's the full error I got,if
it helps. I can't figure out where it came from. Never happened
before.

Traceback (most recent call last):

 File "/home/grmadmin/webapps/django/django/core/handlers/base.py",
line 77, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/grmadmin/webapps/django/classic/registration/views.py",
line 35, in activate
   account.backend = 'django.contrib.auth.backends.ModelBackend'

AttributeError: 'bool' object has no attribute 'backend'


,
POST:,
COOKIES:{},
META:{'AUTH_TYPE': None,
'CONTENT_LENGTH': 0L,
'CONTENT_TYPE': None,
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': '*/*',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-us',
'HTTP_HOST': 'classicmotorsports.net',
'HTTP_MAX_FORWARDS': '10',
'HTTP_UA_CPU': 'x86',
'HTTP_USER_AGENT': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
'HTTP_X_FORWARDED_FOR': '84.32.241.118',
'HTTP_X_FORWARDED_HOST': 'classicmotorsports.net',
'HTTP_X_FORWARDED_SERVER': 'classicmotorsports.net',
'PATH_INFO': '/activate/30730e095fade2449d32e819fefe5635ddd8a434/',
'PATH_TRANSLATED': None,
'QUERY_STRING': None,
'REMOTE_ADDR': '127.0.0.1',
'REMOTE_HOST': None,
'REMOTE_IDENT': None,
'REMOTE_USER': None,
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': None,
'SERVER_NAME': 'web13.webfaction.com',
'SERVER_PORT': 0,
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SOFTWARE': 'mod_python'}>

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

2008-01-10 Thread Kenneth Gonsalves


On 10-Jan-08, at 8:54 PM, Darthmahon wrote:

> Is there any real difference between passing the data from a views.py
> file into a template compared with asking for the data using a
> templatetag?

if you are only using it in one template - do it in the view. If you  
are doing it in several or all templates, do it in templatetags

-- 

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



Re: SESSION_SAVE_EVERY_REQUEST creates new session?

2008-01-10 Thread Peter Rowell

Eoin:

Do you have SESSION_SAVE_EVERY_REQUEST = True in your settings.py
file?

I found that with that set to False, the problem went away. From
something Malcolm said, it may also go away if you explicitly set
SESSION_COOKIE_DOMAIN.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



markdown, html2text & pygments clashes

2008-01-10 Thread mamcxyz

Hi,

I'm building a site where I wanna let insert sourcecode in the
comments, but then I clean everything to markdown using html2text.

I don't wanna force to use markdown syntax and i setup
http://code.google.com/p/mooeditable/ for the end-users.

However, I get the problem that html2text not preserve the
indentation, so:

#!python
def ejemplo(self):
print "hola".

is transformed to

 #!python def ejemplo(self): print "hola".

exist a way to cleanly do this? So a normal End-user editor & markdown
can live side by side?


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



Re: Postgresql setup

2008-01-10 Thread Kenneth Gonsalves


On 10-Jan-08, at 8:20 PM, mjj wrote:

> I need to get a postgresql db sorted out for my django install, having
> never used it before its a little tricky. Postgres etc is installed as
> are the appropriate python bits etc etc, the problem I get is an IDENT
> error when I try to connect. Anyone have any postgres config example
> files perhaps?

pg_hba.conf:

# TYPE  DATABASEUSERCIDR-ADDRESS  METHOD

# "local" is for Unix domain socket connections only
local   all all   trust
# IPv4 local connections:
hostall all 127.0.0.1/32  trust
# IPv6 local connections:
hostall all ::1/128   trust


-- 

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



Re: Basic MySQLdb Install

2008-01-10 Thread David Grant
On Jan 10, 2008 3:24 PM, rob_mazur <[EMAIL PROTECTED]> wrote:

>
> On Jan 10, 2:51 pm, "David Grant" <[EMAIL PROTECTED]> wrote:
> > I would work on it the other way around...tell mysql to put it's socket
> > somewhere else... I'd be surprised if Suse's mysql package would put it
> in
> > /tmp by default. Maybe that's where your compiled version of mysql was
> > putting it (might make sense, then the compiled mysql versions would
> collide
> > with other installed vesions). Remove the mysql rpm, delete /etc/mysql
> (or
> > similar, if it exists), then reinstall the rpm.
> >
> > Dave
>
> Yes, my MySQL binary installation is putting it in /tmp, you are
> correct.  I do not have a MySQL instance installed via RPM.
>
> I am reluctant to change my MySQL config to relocate mysql.sock,
> because I have other apps (Java, Ruby, Perl) dependant on my existing
> MySQL install(s)...not only on my devel boxes, but in production
> (should I ever get that far in my Python venture).  Though, I really
> doubt it would cause a problem.  But I bet my mysql command line
> client would not like it being moved though when I try to connect to
> MySQL without a host directive.
>
> I think that Django looks for the socket file only if it knows that it
> is trying to connect to a local MySQL instance.  So what I did was
> change in settings.py:
> DATABASE_HOST = 'localhost'
> ...to...
> DATABASE_HOST = '192.168.0.100'
>
> ...which is in fact the ip address of my current del box, and it seems
> fine and working now.  Again, I am still in the mode of pasting things
> together to understand how it works, and then I will make some better
> config decisions.
>
> I still want to know (some day) why the compiled version of MySQLdb
> ins't working.  Because if I ever need something newer than v. 1.2.0,
> I will be stuck.  Seems there are plenty of people having trouble with
> that, but few-to-no solutions.  At least, none that I am seeing right
> now.
>
>
Good thinking, changing it to an IP, I wouldn't have thought of that. If you
want to be able to get whatever versions you want of packages try installing
Gentoo. My only remaining gentoo box has an old mysql version (4.x) an old
glibc, an an old gcc (3.x), and everything else including the kernel is very
new. Try doing that with ubuntu or suse. (this is way off topic now for
django-users so I apologize)

-- 
David Grant
http://www.davidgrant.ca

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



Re: django-registration mysterious errror

2008-01-10 Thread James Bennett

On Jan 10, 2008 2:51 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  File "/home/grmadmin/webapps/django/classic/registration/views.py",
> line 35, in activate
>account.backend = 'django.contrib.auth.backends.ModelBackend'

There is not and never has been any such line of code in django-registration.


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



i18n problem: Some template variables "get stuck" in one language

2008-01-10 Thread Emil

Hi folks,

I have a rather peculiar problem. I created translations for my
project, and mostly they work fine. Except that on a couple of pages,
the language seems to get stuck on the translated language after the
first time I change languages.

Example: I visist the site. It's in english (which is the hard-coded
language). I press a link to change to swedish (which is the language
in the .po/.mo-files). It changes to swedish. I visit pages, they're
in swedish. I change back to english. Stuff from the db (from fields
with english text) goes back to english, but variables marked for
translation in templates on certain pages of the site stay in swedish.
Other pages are all in english, as they should.

I haven't got a clue as to why this happens. I tried recompiling the
language files, restarting the server etc. Nothing helps. I even
deleted and redid the translation (an hour of my life I'll never get
back, but I'm glad it's only an hour), recompiled, same problem again.
I have tested this both on my local machine using the dev server and a
testing environment with apache/mod_python, exact same behavior. I'm
using 0.97-PRE.

The only thing in common with the specific pages (2 of them as far as
I can see) where the translation gets stuck that I can think of is
that they use some sort of inclusion tags, one being James Bennet's
Generic Content, the other one a simple one I wrote myself merely
retreiving a list of items.

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

2008-01-10 Thread Eoin

I just started to deploy my app to the webserver, grabbed the latest
svn and am having exactly the same issue, its creating a session entry
per page viewed.
But with a difference the users aren't logged in, they are still
viewing anonymously despite the cookie and a session corresponding.

So 7001 didn't seem to do anything. It it helps following this I tried
to change the backend to 'django.contrib.sessions.backends.file' and
its doing exactly the same thing (not logged in / hundreds of files).


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



Re: django-registration mysterious errror

2008-01-10 Thread [EMAIL PROTECTED]

Yup, it's django-registration... Not sure what version. Probably about
six months old. Maybe it's something James has already seen and
fixed.

On Jan 10, 4:55 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Jan 10, 2008 3:51 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> wrote:
>
>
>
>
>
> > never had any problem with django-registration until today, when I got
> > two of these:
> > Traceback (most recent call last):
>
> >  File "/home/grmadmin/webapps/django/django/core/handlers/base.py",
> > line 77, in get_response
> >   response = callback(request, *callback_args, **callback_kwargs)
>
> >  File "/home/grmadmin/webapps/django/classic/registration/views.py",
> > line 35, in activate
> >   account.backend = 'django.contrib.auth.backends.ModelBackend'
>
> > AttributeError: 'bool' object has no attribute 'backend'
>
> > What is that, and why did it just do it today? I haven't changed
> > anything on that site.
>
> Somehow 'account' is being given a bool value.  I can't tell you why because
> I can't figure out what code you are running.  Is the code in
> .../django/classic/registration some version of this project:
>
> http://code.google.com/p/django-registration/
>
> ?  If so, what version, since the code cited in the exception doesn't match
> what's current for that code?  If not, where did the code in
> .../django/classic/registration come from?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple sites, shared hosting

2008-01-10 Thread Graham Dumpleton

On Jan 11, 8:50 am, Michael Hipp <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My "main" Django site is working great. But on my shared hosting account
> (HostMonster) I have multiple sites. Some will be Django, some will be
> plain html.
>
> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>
> I'm using FastCGI and a script for the main site. I only have access to
> .htaccess.
>
> Currently the html sub-pages work fine on the other sites, but not the
> main page. Apache logs this:
>
> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
> exceeded the limit of 10 internal redirects due to probable
> configuration error. Use 'LimitInternalRecursion' to increase the limit
> if necessary. Use 'LogLevel debug' to get a backtrace.
>
> Can someone help me get started down the right path on this?

Looks like your rewrite rule for making a .fcgi script appear as being
mounted at root of site is not correct. Post your complete .htaccess
file showing all parts of the directives related to rewrite rule.

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



Re: Basic MySQLdb Install

2008-01-10 Thread rob_mazur

On Jan 10, 2:51 pm, "David Grant" <[EMAIL PROTECTED]> wrote:
> I would work on it the other way around...tell mysql to put it's socket
> somewhere else... I'd be surprised if Suse's mysql package would put it in
> /tmp by default. Maybe that's where your compiled version of mysql was
> putting it (might make sense, then the compiled mysql versions would collide
> with other installed vesions). Remove the mysql rpm, delete /etc/mysql (or
> similar, if it exists), then reinstall the rpm.
>
> Dave

Yes, my MySQL binary installation is putting it in /tmp, you are
correct.  I do not have a MySQL instance installed via RPM.

I am reluctant to change my MySQL config to relocate mysql.sock,
because I have other apps (Java, Ruby, Perl) dependant on my existing
MySQL install(s)...not only on my devel boxes, but in production
(should I ever get that far in my Python venture).  Though, I really
doubt it would cause a problem.  But I bet my mysql command line
client would not like it being moved though when I try to connect to
MySQL without a host directive.

I think that Django looks for the socket file only if it knows that it
is trying to connect to a local MySQL instance.  So what I did was
change in settings.py:
DATABASE_HOST = 'localhost'
...to...
DATABASE_HOST = '192.168.0.100'

...which is in fact the ip address of my current del box, and it seems
fine and working now.  Again, I am still in the mode of pasting things
together to understand how it works, and then I will make some better
config decisions.

I still want to know (some day) why the compiled version of MySQLdb
ins't working.  Because if I ever need something newer than v. 1.2.0,
I will be stuck.  Seems there are plenty of people having trouble with
that, but few-to-no solutions.  At least, none that I am seeing right
now.

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



Re: Problem with two applications importing models from each other?

2008-01-10 Thread Josh Ourisman

Ok, that should help. Thanks very much.

On Jan 10, 4:58 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> On Jan 10, 4:00 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > It's for the purpose of defining foreign keys. Basically, ClassA1
> > needs to be able to reference ClassB1 and ClassB2 as foreign keys,
> > while ClassB3 needs to reference ClassA1 as a foreign key.
>
> By now you know why this isn't working (models.py for neither app can
> be loaded by Python because of the circular references.)
>
> You could split your two models.py into multiple files. In particular,
> place each "cross referenced" model into its own file. That way, you
> will be able to import those cross referenced classes by name.
>
> See this:http://code.djangoproject.com/wiki/CookBookSplitModelsToFiles
>
> -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: django-registration mysterious errror

2008-01-10 Thread Karen Tracey
On Jan 10, 2008 3:51 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

>
> never had any problem with django-registration until today, when I got
> two of these:
> Traceback (most recent call last):
>
>  File "/home/grmadmin/webapps/django/django/core/handlers/base.py",
> line 77, in get_response
>   response = callback(request, *callback_args, **callback_kwargs)
>
>  File "/home/grmadmin/webapps/django/classic/registration/views.py",
> line 35, in activate
>   account.backend = 'django.contrib.auth.backends.ModelBackend'
>
> AttributeError: 'bool' object has no attribute 'backend'
>
> What is that, and why did it just do it today? I haven't changed
> anything on that site.
>

Somehow 'account' is being given a bool value.  I can't tell you why because
I can't figure out what code you are running.  Is the code in
.../django/classic/registration some version of this project:

http://code.google.com/p/django-registration/

?  If so, what version, since the code cited in the exception doesn't match
what's current for that code?  If not, where did the code in
.../django/classic/registration come from?

Karen

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



Re: Basic MySQLdb Install

2008-01-10 Thread David Grant
I would work on it the other way around...tell mysql to put it's socket
somewhere else... I'd be surprised if Suse's mysql package would put it in
/tmp by default. Maybe that's where your compiled version of mysql was
putting it (might make sense, then the compiled mysql versions would collide
with other installed vesions). Remove the mysql rpm, delete /etc/mysql (or
similar, if it exists), then reinstall the rpm.

Dave

On Jan 10, 2008 2:11 PM, rob_mazur <[EMAIL PROTECTED]> wrote:

>
> Thanks David.  I believe I am nearly there...one last hurdle I
> believe.  So, I deleted all traces of the compiled version of
> MySQLdb.   Meaning, I deleted it from:
>
> $HOME/.python-eggs/MySQLdb*.egg
> /usr/lib/python2.4/site-packages/MySQLdb*.egg (or whatever it was)
>
> And, I removed my compiled Python2.5.1 and will just use the system-
> installed 2.4.1  OK, so then I installed via YAST (SuSE's package
> manager) python-mysql 1.2.0-4.  In the interpreter I tried "import
> MySQLdb" and it was fine.  Great, on to Django...
>
> I adjusted my settings.py and tried to launch Django, and was told:
> ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.0
>
> Upon searching for something >1.2.0 as a SuSE package (to avoid re-
> entering the problem of compiling MySQLdb), I came up empty.  But I
> see in the docs and release notes that you can use in Django's
> settings.py DATABASE_ENGINE = 'mysql_old'.  Django now launches
> without error.  But in continuing my Django tutorial, when trying to
> use "python manage.py syncdb", I am getting:
>
> _mysql_exceptions.OperationalError: (2002, "Can't connect to local
> MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")
>
> MySQL is in fact running, but the mysql.sock is in /tmp/mysql.sock  .
> So I am now trying to find how to tell Django (or Python) that the
> file is in a different location.
>
> Rob
> >
>


-- 
David Grant
http://www.davidgrant.ca

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Getting exception 'User' object has no attribute 'backend'

2008-01-10 Thread Shev

On a related note, I ran into a situation where I needed to login a
user automatically, without knowing the plaintext password.  So I did:

the_user.backend='django.contrib.auth.backends.ModelBackend'
login(request, the_user)

...and skipped the usage of authenticate().  If this is a terrible
idea, somebody tell me please. :-)

Shev



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

2008-01-10 Thread Prof. William Battersea
Ahh. I eventually did write an inclusion tag. I see I could have saved
myself some time, but it was nice to learn how to do it.

Thanks!

On Jan 10, 2008 9:53 AM, Paul Childs <[EMAIL PROTECTED]> wrote:

>
> Take a look here too...
>
> http://code.djangoproject.com/wiki/PaginatorTag
> >
>

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

2008-01-10 Thread rob_mazur

Thanks David.  I believe I am nearly there...one last hurdle I
believe.  So, I deleted all traces of the compiled version of
MySQLdb.   Meaning, I deleted it from:

$HOME/.python-eggs/MySQLdb*.egg
/usr/lib/python2.4/site-packages/MySQLdb*.egg (or whatever it was)

And, I removed my compiled Python2.5.1 and will just use the system-
installed 2.4.1  OK, so then I installed via YAST (SuSE's package
manager) python-mysql 1.2.0-4.  In the interpreter I tried "import
MySQLdb" and it was fine.  Great, on to Django...

I adjusted my settings.py and tried to launch Django, and was told:
ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.0

Upon searching for something >1.2.0 as a SuSE package (to avoid re-
entering the problem of compiling MySQLdb), I came up empty.  But I
see in the docs and release notes that you can use in Django's
settings.py DATABASE_ENGINE = 'mysql_old'.  Django now launches
without error.  But in continuing my Django tutorial, when trying to
use "python manage.py syncdb", I am getting:

_mysql_exceptions.OperationalError: (2002, "Can't connect to local
MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")

MySQL is in fact running, but the mysql.sock is in /tmp/mysql.sock  .
So I am now trying to find how to tell Django (or Python) that the
file is in a different location.

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



Re: Multiple sites, shared hosting

2008-01-10 Thread [EMAIL PROTECTED]

it's been a long time since I fooled with an fcgi setup, but as I
recall you can setup htaccess to just work on certain folders rather
than root, which sounds like what you want.

On Jan 10, 3:50 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My "main" Django site is working great. But on my shared hosting account
> (HostMonster) I have multiple sites. Some will be Django, some will be
> plain html.
>
> How do I set this up (specifically in settings.py, urls.py and .htaccess).
>
> I'm using FastCGI and a script for the main site. I only have access to
> .htaccess.
>
> Currently the html sub-pages work fine on the other sites, but not the
> main page. Apache logs this:
>
> [Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request
> exceeded the limit of 10 internal redirects due to probable
> configuration error. Use 'LimitInternalRecursion' to increase the limit
> if necessary. Use 'LogLevel debug' to get a backtrace.
>
> Can someone help me get started down the right path on this?
>
> Thanks,
> Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: Restart Django site?

2008-01-10 Thread Fredrik Lundh

Michael Hipp wrote:

> How do I restart my Django site (uses FastCGI and shared hosting via 
> .htaccess)?
> 
> The docs say 'touch mysite.fcgi' but that does not seem to work. Tried 
> touching all the py files as well as .htaccess.
> 
> I can see the python process still running in memory. If I kill it then 
> it re-loads my code and and I can see changes.

looks like you answered your own question, doesn't it? ;-)

a quick googling indicates that the restart behaviour is configurable; 
form the mod_fastcgi documentation:

  -autoUpdate (none)

 Causes mod_fastcgi to check the modification time of the
 application on disk before processing each request. If the
 application on disk has been changed, the process manager is
 notified and all running instances of the application are killed
 off. In general, it's preferred that this type of functionality be
 built-in to the application (e.g. every 100th request it checks to
 see if there's a newer version on disk and exits if so). There may
 be an outstanding problem (bug) when this option is used with
 -restart.

hope this helps!




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



Re: Problem with two applications importing models from each other?

2008-01-10 Thread Rajesh Dhawan

On Jan 10, 4:00 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote:
> It's for the purpose of defining foreign keys. Basically, ClassA1
> needs to be able to reference ClassB1 and ClassB2 as foreign keys,
> while ClassB3 needs to reference ClassA1 as a foreign key.

By now you know why this isn't working (models.py for neither app can
be loaded by Python because of the circular references.)

You could split your two models.py into multiple files. In particular,
place each "cross referenced" model into its own file. That way, you
will be able to import those cross referenced classes by name.

See this:
http://code.djangoproject.com/wiki/CookBookSplitModelsToFiles

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



Restart Django site?

2008-01-10 Thread Michael Hipp

How do I restart my Django site (uses FastCGI and shared hosting via 
.htaccess)?

The docs say 'touch mysite.fcgi' but that does not seem to work. Tried 
touching all the py files as well as .htaccess.

I can see the python process still running in memory. If I kill it then 
it re-loads my code and and I can see changes.

Note that changes to templates and other "data" files are immediately 
recognized but changes to code files (.py) are not (e.g. urls.py).

Michael

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



Multiple sites, shared hosting

2008-01-10 Thread Michael Hipp

Hello,

My "main" Django site is working great. But on my shared hosting account 
(HostMonster) I have multiple sites. Some will be Django, some will be 
plain html.

How do I set this up (specifically in settings.py, urls.py and .htaccess).

I'm using FastCGI and a script for the main site. I only have access to 
.htaccess.

Currently the html sub-pages work fine on the other sites, but not the 
main page. Apache logs this:

[Thu Jan 10 14:37:21 2008] [error] [client 98.134.179.175] Request 
exceeded the limit of 10 internal redirects due to probable 
configuration error. Use 'LimitInternalRecursion' to increase the limit 
if necessary. Use 'LogLevel debug' to get a backtrace.

Can someone help me get started down the right path on this?

Thanks,
Michael

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



Re: django

2008-01-10 Thread Fredrik Lundh

Patricia Ramirez wrote:

> you solve your problem with django, i have the same error message, and i 
> don't not why happend
> 
>   File "", line 1
> django-admin.py startproject mysite
>^
> SyntaxError: invalid syntax

looks like you typed the "django-admin.py" command into the Python 
interpreter, rather than into a command shell.




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

2008-01-10 Thread David Grant
Eggs are totally new to me although I have heard of them. Sorry for
top-quoting, I use gmail and I'm lazy...

Distributions usually clear these issues up by having everything compiled
with the same compiler, everything linked to the right libraries that are
included in the distro, etc... Maybe what's happening here is that the egg
you downloaded contains a shared library (_mysql.so) that was built using a
different compiler version perhaps. The fact that _mysql.so is in a temp
folder makes me think that it was unzipped from the egg or something rather
than being built by typing "python setup.py build" or something like (as one
might do when building a python dist_utils package from source). So maybe
you haven't compiled everything from scratch as you think.

Again I think you should try binary packages from distribution and get rid
of the egg. You clearly never tried installing the python-mysql package from
the distro because the error you show is coming from the egg so try it.
Install delete or hide all traces of your compiled versions and install
python, mysql, and python-mysql packages from the package manager. I'd be
shocked if this didn't work.

Dave


On Jan 10, 2008 12:35 PM, rob_mazur <[EMAIL PROTECTED]> wrote:

>
> On Jan 9, 10:58 pm, "David Grant" <[EMAIL PROTECTED]> wrote:
> > Well it is still trying to import from /root/.python-eggs/...  I would
> also
> > be interested in knowing why you are doing things as root, but I guess
> > that's not important...
> >
> > It's still trying to import from /root/.python-eggs so get that out of
> your
> > python path. Run python and then
> >
> > import sys
> > print sys.path
> >
> > Remove /root/.python-eggs or any other paths.
> >
> > Since it is happening on all three SUSE installs, well I don't know what
> to
> > think. I've never used eggs before and I never compile anyting from
> scratch
> > unless I really have to (except using Gentoo's package manger). Any
> > python/mysql/mysqldb are things you should never need to compile from
> > scratch (unless you really need to). And no offense but if you were
> someone
> > who really needed to compile them from scratchI would have thought
> you
> > would be able to solve this problem yourself. I don't even use Gentoo
> > anymore, too much work.
> >
> > --
>
> Hi David.  Thanks for the responses.
>
> Believe me, I too wondered why I needed to build things from scratch
> to get them to work.  I couldn't imagine every newbie would be forced
> to compile all related software.  But as mentioned previously in this
> thread, when I searched for solutions this error:
>
> ImportError: /home/rmazur/.python-eggs/MySQL_python-1.2.2-py2.5-linux-
> i686.egg-tmp/_mysql.so: undefined symbol: __pure_virtual
>
> ...nearly every one of them (that I looked at) cited the likely cause
> to be MySQL and Python being compiled by different compilers.  This
> was the sole reason I chose to compile myself, and did so as a process
> of elimination.  That being said, I am weary of using the package
> managers of Linux distributons because when things go sideways, it is
> sometimes hard to tell how things are tied together and what
> dependencies might be causing conflict.  Thus my preference is to
> download binaries if possible.
>
> Regarding running as root...I was doing so to initially to remove the
> possibility of permission issues causing my problems.  This is mostly
> due to me being completely new to Python.  As you likely know from
> other langauges, you can ocassionally hit error text from compilers or
> run-time errors that cite a, b or c being an error when in reality all
> it is is a permission problem.  Once I have a handle of how to solve
> my current problem, what caused it, etc, then I will wipe the slate
> clean and set things up properly for long-term usage.
>
> I will try your other suggestion, and thank you again for your
> patience as I dip my toe into the Python world...I am just at the
> beginning of learning what the errors mean, the appropriate config,
> what an egg even isetc.
>
> Thanks for your help.
> Rob
> >
>


-- 
David Grant
http://www.davidgrant.ca

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



Re: django

2008-01-10 Thread Patricia Ramirez
you solve your problem with django, i have the same error message, and i
don't not why happend

>
>   File "", line 1
> django-admin.py startproject mysite
>^
> SyntaxError: invalid syntax
>
>

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

2008-01-10 Thread [EMAIL PROTECTED]

OK, new question along the same lines

I've got
site1/
site2/
shared/ (not utils)
shared/samples/

all in line, the template tags are working, but in trying to implement
the sites framework I'm hitting a snag when I try to syndb or use
sqlall: ImportError: No module named shared

I get the same thing when start python and attempt to import shared.
But shared is there, and functional. I have it in settings, it's in
URLs, I can go to the page and it calls the appropriate template, etc,
and everything works. But manage.py doesn't get it. I tried manually
adding shared to my python path, but saw no difference.



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



Re: Question about views.py

2008-01-10 Thread David Grant
In your case the list comprehensions probably made it more readable. In
other cases list comprehensions can make things less readable (I'm guilty of
doing this sometimes). I thought maybe you were using brackets as I did that
too the first time I wrote a template.

Dave

On Jan 10, 2008 11:28 AM, Matic Žgur <[EMAIL PROTECTED]> wrote:

>
> Thanks for your suggestions. I have managed to get rid of my
> get_entries_list() and pass queryset directly to the template. I made
> the mistake of using {{ entry.get_absolute_path() }} instead of {{
> entry.get_absolute_path }} in the templates. I've also rewritten a lot
> of for loops into list comprehensions (I guess I still have some
> habits from PHP).
>
> Cheers,
> Matic Žgur
>
> On Jan 10, 2008 6:04 PM, David Grant <[EMAIL PROTECTED]> wrote:
> > I think you should be able to access the query sets directly in your
> > template. Not sure why that didn't work for you.
> >
> > Here they pass a queryset to render_to_response:
> >
> http://www.djangoproject.com/documentation/tutorial03/#a-shortcut-render-to-response
> >
> > Put a loop in your template and then access attributes of the loop
> variable
> > and you should be good. Here's another example:
> >
> http://www.djangoproject.com/documentation/tutorial03/#write-views-that-actually-do-something
> > They pass latest_poll_list to the template and then look at the template
> > where they have:
> >
> > {% if latest_poll_list %}
> >  
> >  {% for poll in latest_poll_list %}
> >  {{ poll.question }}
> >  {% endfor %}
> >  
> > {% else %}
> >
> >  No polls are available.
> > {% endif %}
> >
> > You should be able to get rid of your get_tags and get_all_entries
> > functions, or at the very least replace them with something that returns
> a
> > queryset rather than constructing a list of dictionaries.
> >
> > Dave
> >
> >
> >
> > On Jan 10, 2008 4:12 AM, Matic Žgur <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi everybody,
> > >
> > > being new in Django, I'd like to ask you for some tips about what
> > > should be in views.py and what shouldn't be.
> > >
> > > I'm writing a blog app with custom views.py. I know that it would be a
> > > lot easier (and wiser) to use generic views for what I'm trying to
> > > accomplish, but I'd like to learn new things along the way, so I
> > > decided to write my own views.py. Anyway, that's what bugs me:
> > >
> > > def get_all_tags():
> > >
> > >tags = []
> > >tags_db = Tag.objects.all()
> > >
> > >for tag in tags_db:
> > >tags.append({
> > >'tag': tag.tag,
> > >'url': tag.get_absolute_url ()
> > >})
> > >
> > >return tags
> > >
> > > def get_entries_list(entries_list):
> > >
> > >entries = []
> > >
> > >for entry in entries_list:
> > >entries.append({
> > >'body': mark_safe(entry.body ),
> > >'pub_date': entry.pub_date,
> > >'title': entry.title,
> > >'url': entry.get_absolute_url(),
> > >'tags': entry.get_tags(),
> > >})
> > >
> > >return entries
> > >
> > > def show_entries_by_day(request, year, month, day):
> > >now = datetime.datetime.now()
> > >
> > ># Check if day is in the future
> > >if year + month + day > ''.join([str( now.year), str(now.month),
> > > str(now.day)]):
> > >raise Http404
> > >
> > >entries = Entry.objects.filter(pub_date__lte=now,
> > >  pub_date__year=year,
> > >  pub_date__month=month,
> > >  pub_date__day=day,
> > >  status=1)
> > >
> > >return render_to_response('blog_entry.html', {'entries':
> > > get_entries_list(entries), 'tags': get_all_tags()})
> > >
> > > I have a function similar to show_entries_by_year() for month, day,
> > > tag and slug. Now, for get_all_tags(), I'm planning to write a
> > > template tag that would replace this function, but I still don't know
> > > what to do with get_entries_list(). I only made this function in order
> > > to not repeat myself. Is there a way to get rid of get_entries_list()
> > > and somehow make my views.py cleaner? I tried to pass entries directly
> > > to the template but it didn't quite work (maybe I'm missing
> > > something).
> > >
> > > I searched the web for some examples, but it's hard to find apps that
> > > don't use generic views (at least I didn't find them), so I decided to
> > > ask here.
> > >
> > > Thanks
> > > Matic Žgur
> > >
> > >
> > >
> > >
> >
> >
> >
> > --
> > David Grant
> > http://www.davidgrant.ca
> >
> >
> >  >
> >
>
> >
>


-- 
David Grant
http://www.davidgrant.ca

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit 

Re: Problem with two applications importing models from each other?

2008-01-10 Thread Josh Ourisman

It's for the purpose of defining foreign keys. Basically, ClassA1
needs to be able to reference ClassB1 and ClassB2 as foreign keys,
while ClassB3 needs to reference ClassA1 as a foreign key.

More specifically, the project has (among others) a news application
and a portfolio application. An item of news might reference multiple
items from the portfolio application, so we define a m2m relationship
between the news item class and the appropriate portfolio classes
(there are two that are relevant). At the same time, in the portfolio
we want to be able to link to any relevant news items, but we _also_
want to provide a way to prevent specific news items from showing up
when looking at certain portfolio items. So it's not sufficient to
just look at the news items related to a portfolio item through the
existing m2m relationship, we also have to be able to define a
separate list of news items.

It's a little unnecessarily complex, I know, but it's what the client
wants and, if at all possible, I'd like to do it this way rather than
having to justify a change in functionality to the client.

On Jan 10, 3:19 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Jan 10, 12:54 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > I have two models, modelA and modelB. ModelA needs classB1 and classB2
> > from modelB, while modelB needs classA1 from classA.
>
> Can you explain what you mean by "needs"? Is there a class method in
> modelA that needs to instantiate/call classB1? Better yet, include a
> short code snippet showing how ModelA needs classB1 and classB2.
>
> -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
-~--~~~~--~~--~--~---



django-registration mysterious errror

2008-01-10 Thread [EMAIL PROTECTED]

never had any problem with django-registration until today, when I got
two of these:
Traceback (most recent call last):

 File "/home/grmadmin/webapps/django/django/core/handlers/base.py",
line 77, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/home/grmadmin/webapps/django/classic/registration/views.py",
line 35, in activate
   account.backend = 'django.contrib.auth.backends.ModelBackend'

AttributeError: 'bool' object has no attribute 'backend'

What is that, and why did it just do it today? I haven't changed
anything on that site.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Basic MySQLdb Install

2008-01-10 Thread rob_mazur

p.s.  Off-topic, but I noticed that you appear to be up in Vancouver,
and saw at least one reference to [Trevor] Linden on your blog (a
photo).  I'm down here in Seattle, a rabid Canucks fan...counting
minutes til tonight's game.

Thanks for your help from the Northwest.

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



Re: Basic MySQLdb Install

2008-01-10 Thread rob_mazur

On Jan 9, 10:58 pm, "David Grant" <[EMAIL PROTECTED]> wrote:
> Well it is still trying to import from /root/.python-eggs/...  I would also
> be interested in knowing why you are doing things as root, but I guess
> that's not important...
>
> It's still trying to import from /root/.python-eggs so get that out of your
> python path. Run python and then
>
> import sys
> print sys.path
>
> Remove /root/.python-eggs or any other paths.
>
> Since it is happening on all three SUSE installs, well I don't know what to
> think. I've never used eggs before and I never compile anyting from scratch
> unless I really have to (except using Gentoo's package manger). Any
> python/mysql/mysqldb are things you should never need to compile from
> scratch (unless you really need to). And no offense but if you were someone
> who really needed to compile them from scratchI would have thought you
> would be able to solve this problem yourself. I don't even use Gentoo
> anymore, too much work.
>
> --

Hi David.  Thanks for the responses.

Believe me, I too wondered why I needed to build things from scratch
to get them to work.  I couldn't imagine every newbie would be forced
to compile all related software.  But as mentioned previously in this
thread, when I searched for solutions this error:

ImportError: /home/rmazur/.python-eggs/MySQL_python-1.2.2-py2.5-linux-
i686.egg-tmp/_mysql.so: undefined symbol: __pure_virtual

...nearly every one of them (that I looked at) cited the likely cause
to be MySQL and Python being compiled by different compilers.  This
was the sole reason I chose to compile myself, and did so as a process
of elimination.  That being said, I am weary of using the package
managers of Linux distributons because when things go sideways, it is
sometimes hard to tell how things are tied together and what
dependencies might be causing conflict.  Thus my preference is to
download binaries if possible.

Regarding running as root...I was doing so to initially to remove the
possibility of permission issues causing my problems.  This is mostly
due to me being completely new to Python.  As you likely know from
other langauges, you can ocassionally hit error text from compilers or
run-time errors that cite a, b or c being an error when in reality all
it is is a permission problem.  Once I have a handle of how to solve
my current problem, what caused it, etc, then I will wipe the slate
clean and set things up properly for long-term usage.

I will try your other suggestion, and thank you again for your
patience as I dip my toe into the Python world...I am just at the
beginning of learning what the errors mean, the appropriate config,
what an egg even isetc.

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



Re: Problem with two applications importing models from each other?

2008-01-10 Thread Rajesh Dhawan

Hi,

On Jan 10, 12:54 pm, Josh Ourisman <[EMAIL PROTECTED]> wrote:
> I have two models, modelA and modelB. ModelA needs classB1 and classB2
> from modelB, while modelB needs classA1 from classA.

Can you explain what you mean by "needs"? Is there a class method in
modelA that needs to instantiate/call classB1? Better yet, include a
short code snippet showing how ModelA needs classB1 and classB2.

-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: Problem with two applications importing models from each other?

2008-01-10 Thread Josh Ourisman

Nope, that just gets me "AttributeError: 'module' objects has no
attribute 'models'". :/

It doesn't work to just to 'import modelA' and then reference
modelA.Class1 or modelA.models.Class1 either; that just gives me the
same error.

On Jan 10, 2:38 pm, Muchanic <[EMAIL PROTECTED]> wrote:
> import xxx means 'import module xxx' - since Class1 is a class, and
> not a module, that won't work.
>
> If you change the import statements in both modules to something of
> the form 'import modelA.models as models_A' then referencing the
> classes as 'models_A.Class1', does that work?
>
> On Jan 11, 8:27 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > Hmm. That implies that I should be using 'import modelA.models.Class1'
> > rather than 'from modelA.models import Class1'. However, that syntax
> > doesn't seem to actually work. If I remove the circular imports for a
> > moment, 'from modelA.models import Class1' works just fine, but if I
> > use 'import modelA.models.Class1' I get a 'ImportError: No module
> > named Class1'.
>
> > I'm clearly missing _something_ here, and the advice given there
> > doesn't seem to work. Can anyone help me out?
>
> > On Jan 10, 1:40 pm, Muchanic <[EMAIL PROTECTED]> wrote:
>
> > > Check this 
> > > out:http://www.python.org/doc/faq/programming/#what-are-the-best-practice...
>
> > > On Jan 11, 6:54 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > > > I have two models, modelA and modelB. ModelA needs classB1 and classB2
> > > > from modelB, while modelB needs classA1 from classA.
>
> > > > So, in the models.py file for modelA I have 'from modelB.models import
> > > > classB1, classB2'. This worked just fine until I added to the
> > > > models.py file for modelB 'from modelA.models import classA1' after
> > > > also adding the class B3 that needed to reference classA1. Now when I
> > > > try to syncdb it tells me that modelA cannot import class B1.
>
> > > > Is there some particular reason that such cross-importing wouldn't be
> > > > possible? Do I need to use a different importing syntax or something?- 
> > > > Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with two applications importing models from each other?

2008-01-10 Thread Muchanic

import xxx means 'import module xxx' - since Class1 is a class, and
not a module, that won't work.

If you change the import statements in both modules to something of
the form 'import modelA.models as models_A' then referencing the
classes as 'models_A.Class1', does that work?

On Jan 11, 8:27 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
> Hmm. That implies that I should be using 'import modelA.models.Class1'
> rather than 'from modelA.models import Class1'. However, that syntax
> doesn't seem to actually work. If I remove the circular imports for a
> moment, 'from modelA.models import Class1' works just fine, but if I
> use 'import modelA.models.Class1' I get a 'ImportError: No module
> named Class1'.
>
> I'm clearly missing _something_ here, and the advice given there
> doesn't seem to work. Can anyone help me out?
>
> On Jan 10, 1:40 pm, Muchanic <[EMAIL PROTECTED]> wrote:
>
>
>
> > Check this 
> > out:http://www.python.org/doc/faq/programming/#what-are-the-best-practice...
>
> > On Jan 11, 6:54 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > > I have two models, modelA and modelB. ModelA needs classB1 and classB2
> > > from modelB, while modelB needs classA1 from classA.
>
> > > So, in the models.py file for modelA I have 'from modelB.models import
> > > classB1, classB2'. This worked just fine until I added to the
> > > models.py file for modelB 'from modelA.models import classA1' after
> > > also adding the class B3 that needed to reference classA1. Now when I
> > > try to syncdb it tells me that modelA cannot import class B1.
>
> > > Is there some particular reason that such cross-importing wouldn't be
> > > possible? Do I need to use a different importing syntax or something?- 
> > > Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about views.py

2008-01-10 Thread Matic Žgur

Thanks for your suggestions. I have managed to get rid of my
get_entries_list() and pass queryset directly to the template. I made
the mistake of using {{ entry.get_absolute_path() }} instead of {{
entry.get_absolute_path }} in the templates. I've also rewritten a lot
of for loops into list comprehensions (I guess I still have some
habits from PHP).

Cheers,
Matic Žgur

On Jan 10, 2008 6:04 PM, David Grant <[EMAIL PROTECTED]> wrote:
> I think you should be able to access the query sets directly in your
> template. Not sure why that didn't work for you.
>
> Here they pass a queryset to render_to_response:
> http://www.djangoproject.com/documentation/tutorial03/#a-shortcut-render-to-response
>
> Put a loop in your template and then access attributes of the loop variable
> and you should be good. Here's another example:
> http://www.djangoproject.com/documentation/tutorial03/#write-views-that-actually-do-something
> They pass latest_poll_list to the template and then look at the template
> where they have:
>
> {% if latest_poll_list %}
>  
>  {% for poll in latest_poll_list %}
>  {{ poll.question }}
>  {% endfor %}
>  
> {% else %}
>
>  No polls are available.
> {% endif %}
>
> You should be able to get rid of your get_tags and get_all_entries
> functions, or at the very least replace them with something that returns a
> queryset rather than constructing a list of dictionaries.
>
> Dave
>
>
>
> On Jan 10, 2008 4:12 AM, Matic Žgur <[EMAIL PROTECTED]> wrote:
> >
> > Hi everybody,
> >
> > being new in Django, I'd like to ask you for some tips about what
> > should be in views.py and what shouldn't be.
> >
> > I'm writing a blog app with custom views.py. I know that it would be a
> > lot easier (and wiser) to use generic views for what I'm trying to
> > accomplish, but I'd like to learn new things along the way, so I
> > decided to write my own views.py. Anyway, that's what bugs me:
> >
> > def get_all_tags():
> >
> >tags = []
> >tags_db = Tag.objects.all()
> >
> >for tag in tags_db:
> >tags.append({
> >'tag': tag.tag,
> >'url': tag.get_absolute_url ()
> >})
> >
> >return tags
> >
> > def get_entries_list(entries_list):
> >
> >entries = []
> >
> >for entry in entries_list:
> >entries.append({
> >'body': mark_safe(entry.body ),
> >'pub_date': entry.pub_date,
> >'title': entry.title,
> >'url': entry.get_absolute_url(),
> >'tags': entry.get_tags(),
> >})
> >
> >return entries
> >
> > def show_entries_by_day(request, year, month, day):
> >now = datetime.datetime.now()
> >
> ># Check if day is in the future
> >if year + month + day > ''.join([str( now.year), str(now.month),
> > str(now.day)]):
> >raise Http404
> >
> >entries = Entry.objects.filter(pub_date__lte=now,
> >  pub_date__year=year,
> >  pub_date__month=month,
> >  pub_date__day=day,
> >  status=1)
> >
> >return render_to_response('blog_entry.html', {'entries':
> > get_entries_list(entries), 'tags': get_all_tags()})
> >
> > I have a function similar to show_entries_by_year() for month, day,
> > tag and slug. Now, for get_all_tags(), I'm planning to write a
> > template tag that would replace this function, but I still don't know
> > what to do with get_entries_list(). I only made this function in order
> > to not repeat myself. Is there a way to get rid of get_entries_list()
> > and somehow make my views.py cleaner? I tried to pass entries directly
> > to the template but it didn't quite work (maybe I'm missing
> > something).
> >
> > I searched the web for some examples, but it's hard to find apps that
> > don't use generic views (at least I didn't find them), so I decided to
> > ask here.
> >
> > Thanks
> > Matic Žgur
> >
> >
> >
> >
>
>
>
> --
> David Grant
> http://www.davidgrant.ca
>
>
>  >
>

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



Re: Problem with two applications importing models from each other?

2008-01-10 Thread Josh Ourisman

Hmm. That implies that I should be using 'import modelA.models.Class1'
rather than 'from modelA.models import Class1'. However, that syntax
doesn't seem to actually work. If I remove the circular imports for a
moment, 'from modelA.models import Class1' works just fine, but if I
use 'import modelA.models.Class1' I get a 'ImportError: No module
named Class1'.

I'm clearly missing _something_ here, and the advice given there
doesn't seem to work. Can anyone help me out?

On Jan 10, 1:40 pm, Muchanic <[EMAIL PROTECTED]> wrote:
> Check this 
> out:http://www.python.org/doc/faq/programming/#what-are-the-best-practice...
>
> On Jan 11, 6:54 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
>
> > I have two models, modelA and modelB. ModelA needs classB1 and classB2
> > from modelB, while modelB needs classA1 from classA.
>
> > So, in the models.py file for modelA I have 'from modelB.models import
> > classB1, classB2'. This worked just fine until I added to the
> > models.py file for modelB 'from modelA.models import classA1' after
> > also adding the class B3 that needed to reference classA1. Now when I
> > try to syncdb it tells me that modelA cannot import class B1.
>
> > Is there some particular reason that such cross-importing wouldn't be
> > possible? Do I need to use a different importing syntax or something?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with two applications importing models from each other?

2008-01-10 Thread Muchanic

Check this out: 
http://www.python.org/doc/faq/programming/#what-are-the-best-practices-for-using-import-in-a-module

On Jan 11, 6:54 am, Josh Ourisman <[EMAIL PROTECTED]> wrote:
> I have two models, modelA and modelB. ModelA needs classB1 and classB2
> from modelB, while modelB needs classA1 from classA.
>
> So, in the models.py file for modelA I have 'from modelB.models import
> classB1, classB2'. This worked just fine until I added to the
> models.py file for modelB 'from modelA.models import classA1' after
> also adding the class B3 that needed to reference classA1. Now when I
> try to syncdb it tells me that modelA cannot import class B1.
>
> Is there some particular reason that such cross-importing wouldn't be
> possible? Do I need to use a different importing syntax or something?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe 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: shared apps and template tags

2008-01-10 Thread Karen Tracey
On Jan 10, 2008 12:54 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

>
> OK, I've got two sites with a lot of shared code. I'm attempting to
> set up apps something like this:
>
> site1app/
> site2app/
> utils/
>
> Which doesn't seem all that problematic. Where I AM running into is
> accessing code in utils. In particular I have templatetags that don't
> seem to be working with this setup.
>
> utils is on my python path, and I can get some things out of it, but
> my template tags in there don't seem to be registering with the site
> apps.
>
> Ideas?


You might find this message from Malcolm in response to a very similar query
helpful:

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

Karen

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



Re: shared apps and template tags

2008-01-10 Thread [EMAIL PROTECTED]

Disregard. I figured something out:

I created
utils/shared/templatetags

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



Problem with two applications importing models from each other?

2008-01-10 Thread Josh Ourisman

I have two models, modelA and modelB. ModelA needs classB1 and classB2
from modelB, while modelB needs classA1 from classA.

So, in the models.py file for modelA I have 'from modelB.models import
classB1, classB2'. This worked just fine until I added to the
models.py file for modelB 'from modelA.models import classA1' after
also adding the class B3 that needed to reference classA1. Now when I
try to syncdb it tells me that modelA cannot import class B1.

Is there some particular reason that such cross-importing wouldn't be
possible? Do I need to use a different importing syntax or something?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



shared apps and template tags

2008-01-10 Thread [EMAIL PROTECTED]

OK, I've got two sites with a lot of shared code. I'm attempting to
set up apps something like this:

site1app/
site2app/
utils/

Which doesn't seem all that problematic. Where I AM running into is
accessing code in utils. In particular I have templatetags that don't
seem to be working with this setup.

utils is on my python path, and I can get some things out of it, but
my template tags in there don't seem to be registering with the site
apps.

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



Re: Postgresql setup

2008-01-10 Thread David Grant
Your problem is with postgres not django. The permissions of your database
are not set up so a postgres-django config example will not help. Make sure
you can connect to the database from the command line or some UI first
before trying to get django to connect to it.

Dave

On Jan 10, 2008 6:50 AM, mjj <[EMAIL PROTECTED]> wrote:

>
> Hello
>
> I need to get a postgresql db sorted out for my django install, having
> never used it before its a little tricky. Postgres etc is installed as
> are the appropriate python bits etc etc, the problem I get is an IDENT
> error when I try to connect. Anyone have any postgres config example
> files perhaps?
>
> Thanks
>
> mjj
>
> PS
>
> Running Fedora Core 3, Python 2.3, Postgres 7.4, mod_python, pyscopg2
>
>
> >
>


-- 
David Grant
http://www.davidgrant.ca

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



Re: Question about views.py

2008-01-10 Thread David Grant
I think you should be able to access the query sets directly in your
template. Not sure why that didn't work for you.

Here they pass a queryset to render_to_response:
http://www.djangoproject.com/documentation/tutorial03/#a-shortcut-render-to-response

Put a loop in your template and then access attributes of the loop variable
and you should be good. Here's another example:
http://www.djangoproject.com/documentation/tutorial03/#write-views-that-actually-do-something
They pass latest_poll_list to the template and then look at the template
where they have:

{% if latest_poll_list %}

{% for poll in latest_poll_list %}
{{ poll.question }}
{% endfor %}

{% else %}
No polls are available.
{% endif %}


You should be able to get rid of your get_tags and get_all_entries
functions, or at the very least replace them with something that returns a
queryset rather than constructing a list of dictionaries.

Dave

On Jan 10, 2008 4:12 AM, Matic Žgur <[EMAIL PROTECTED]> wrote:

>
> Hi everybody,
>
> being new in Django, I'd like to ask you for some tips about what
> should be in views.py and what shouldn't be.
>
> I'm writing a blog app with custom views.py. I know that it would be a
> lot easier (and wiser) to use generic views for what I'm trying to
> accomplish, but I'd like to learn new things along the way, so I
> decided to write my own views.py. Anyway, that's what bugs me:
>
> def get_all_tags():
>
>tags = []
>tags_db = Tag.objects.all()
>
>for tag in tags_db:
>tags.append({
>'tag': tag.tag,
>'url': tag.get_absolute_url()
>})
>
>return tags
>
> def get_entries_list(entries_list):
>
>entries = []
>
>for entry in entries_list:
>entries.append({
>'body': mark_safe(entry.body),
>'pub_date': entry.pub_date,
>'title': entry.title,
>'url': entry.get_absolute_url(),
>'tags': entry.get_tags(),
>})
>
>return entries
>
> def show_entries_by_day(request, year, month, day):
>now = datetime.datetime.now()
>
># Check if day is in the future
>if year + month + day > ''.join([str(now.year), str(now.month),
> str(now.day)]):
>raise Http404
>
>entries = Entry.objects.filter(pub_date__lte=now,
>  pub_date__year=year,
>  pub_date__month=month,
>  pub_date__day=day,
>  status=1)
>
>return render_to_response('blog_entry.html', {'entries':
> get_entries_list(entries), 'tags': get_all_tags()})
>
> I have a function similar to show_entries_by_year() for month, day,
> tag and slug. Now, for get_all_tags(), I'm planning to write a
> template tag that would replace this function, but I still don't know
> what to do with get_entries_list(). I only made this function in order
> to not repeat myself. Is there a way to get rid of get_entries_list()
> and somehow make my views.py cleaner? I tried to pass entries directly
> to the template but it didn't quite work (maybe I'm missing
> something).
>
> I searched the web for some examples, but it's hard to find apps that
> don't use generic views (at least I didn't find them), so I decided to
> ask here.
>
> Thanks
> Matic Žgur
>
> >
>


-- 
David Grant
http://www.davidgrant.ca

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



Re: Question about views.py

2008-01-10 Thread Wiley

Just off the top, it looks like the get_all_tags function could be re-
written as a list comprehension.  As for the more django oriented
stuff, I'll leave that to the pros.

On Jan 10, 7:12 am, "Matic Žgur" <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> being new in Django, I'd like to ask you for some tips about what
> should be in views.py and what shouldn't be.
>
> I'm writing a blog app with custom views.py. I know that it would be a
> lot easier (and wiser) to use generic views for what I'm trying to
> accomplish, but I'd like to learn new things along the way, so I
> decided to write my own views.py. Anyway, that's what bugs me:
>
> def get_all_tags():
>
> tags = []
> tags_db = Tag.objects.all()
>
> for tag in tags_db:
> tags.append({
> 'tag': tag.tag,
> 'url': tag.get_absolute_url()
> })
>
> return tags
>
> def get_entries_list(entries_list):
>
> entries = []
>
> for entry in entries_list:
> entries.append({
> 'body': mark_safe(entry.body),
> 'pub_date': entry.pub_date,
> 'title': entry.title,
> 'url': entry.get_absolute_url(),
> 'tags': entry.get_tags(),
> })
>
> return entries
>
> def show_entries_by_day(request, year, month, day):
> now = datetime.datetime.now()
>
> # Check if day is in the future
> if year + month + day > ''.join([str(now.year), str(now.month),
> str(now.day)]):
> raise Http404
>
> entries = Entry.objects.filter(pub_date__lte=now,
>   pub_date__year=year,
>   pub_date__month=month,
>   pub_date__day=day,
>   status=1)
>
> return render_to_response('blog_entry.html', {'entries':
> get_entries_list(entries), 'tags': get_all_tags()})
>
> I have a function similar to show_entries_by_year() for month, day,
> tag and slug. Now, for get_all_tags(), I'm planning to write a
> template tag that would replace this function, but I still don't know
> what to do with get_entries_list(). I only made this function in order
> to not repeat myself. Is there a way to get rid of get_entries_list()
> and somehow make my views.py cleaner? I tried to pass entries directly
> to the template but it didn't quite work (maybe I'm missing
> something).
>
> I searched the web for some examples, but it's hard to find apps that
> don't use generic views (at least I didn't find them), so I decided to
> ask here.
>
> Thanks
> Matic Žgur
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



When to use templatetags and how to use views.py

2008-01-10 Thread Darthmahon

Hey,

I've recently stumbled on templatetags as a great way of pulling in
data you need within a specific template file. Previously I would have
done all of the logic to pull in data from within a views.py file and
then just pass that data into a specified template.

Is there any real difference between passing the data from a views.py
file into a template compared with asking for the data using a
templatetag?

Since finding templatetags, I am also starting to question what I
should put within my views.py file and how it fits into the grand
scheme of things when building a site.

Any thoughts/opinions would be great as I want to make sure I'm not
going to kill my server by using too many templatetags!

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



Re: Very Easy Question

2008-01-10 Thread koenb

Especially take note of the hint to use junction.exe [1]. It allows
you to use kind of like symlinks on windows. Especially interesting if
you use different versions and branches.

Koen

[1] http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx

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

2008-01-10 Thread Paul Childs

Take a look here too...

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



Postgresql setup

2008-01-10 Thread mjj

Hello

I need to get a postgresql db sorted out for my django install, having 
never used it before its a little tricky. Postgres etc is installed as 
are the appropriate python bits etc etc, the problem I get is an IDENT 
error when I try to connect. Anyone have any postgres config example 
files perhaps?

Thanks

mjj

PS

Running Fedora Core 3, Python 2.3, Postgres 7.4, mod_python, pyscopg2


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

2008-01-10 Thread Maarten

Hi,

I'm notan expert with django yet, but I do recommend to keep your
models and not throw everything into 1 big model.  The relations are
powerfull, don't throw it out even if it means having to write a nest
or two.

Let's use the following model to look into this:
Models: A, B and C.  C is a part of B and B is a part of C
(A -> B -> C)
If you want to access something in C and you already have A you can
do:
anAobject = A.objects.get(whatever filter you need)
print anAobject.B.C.attribute

which is more straightforward then the sql query approach (at least,
that's how I feel about it)

The other way around would be:  (you have C and what an attribute of
the corresponding A)
aCobject = C.objects.get()
aBobject = B.objects.get(C = aCobject)
anAobject = A.objects.get(B = aBobject)
print anAobject.attribute

This is indeed a little nesting ground, you'd just want to pray you
never have relations that span 10 tables.
Lucky fo us, django developers were thinking the same when they added
the following option:

anAobject = A.objects.get(B__C__id = *)
print anAobject.attribute

note that you probably have a many to one relationship, so you would
have many A's with that C.
==>
Aobjects = A.objects.filter(B__C__id = *)
for a in Aobjects:
print a.attribute

This might give you a more complete look on it:
http://www.djangoproject.com/documentation/models/many_to_one/

cheers

On Jan 10, 4:47 am, Ken <[EMAIL PROTECTED]> wrote:
> I need some advice.  I'm struggling with a query that spans 4 tables.
> "Struggling" is a bad word; I'll explain later.  Django uses a model-
> oriented query system together with a Foreign Key manager to get to
> the "next" joining table.  A query that spans several tables results
> in a deeply nested loop.  Hence, my struggle.  I have an aversion to
> writing deeply nested loops.  It's an indication that I dont quite
> understand my problem.  In SQL, you join the tables you need depending
> on the query and you filter out entries you are interested in with a
> WHERE clause.  It's an idea I'm familiar with; it's "flat", ie, not
> nested.  When I see deeply nested loops, I tend to think recursion.
> But that doesnt work either since at each level, the operation is
> model-specific.  I need some general advice on how folks handle
> queries on joined tables within the django framework.  Since queries
> are model based, is it better to forget about constructing related but
> orthogonal tables and simply throw everything in a model?
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MemoryError with zip file upload

2008-01-10 Thread [EMAIL PROTECTED]

Hello All,

I don't really know if this is django specific or more python related
but i hope someone can help me out here.
I'm currently migrating a application to django and one of the new
requirements is that people can upload zip files. I talked with the
system administrator and he only let's me upload those files when i'm
sure that the contents are of a specific type.

In order to check the file comes in the request variable but when the
zip file is around 20 mb i get the following error message

data = self._sock.recv(recv_size)
MemoryError

followed by
error: (32, 'Broken pipe')

Can this be solved by allocating more memory to python ? if so how do
i do that
or is there a better trick to do something like this ( django specific
or some other method )

thanks in advance,

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



Question about views.py

2008-01-10 Thread Matic Žgur

Hi everybody,

being new in Django, I'd like to ask you for some tips about what
should be in views.py and what shouldn't be.

I'm writing a blog app with custom views.py. I know that it would be a
lot easier (and wiser) to use generic views for what I'm trying to
accomplish, but I'd like to learn new things along the way, so I
decided to write my own views.py. Anyway, that's what bugs me:

def get_all_tags():

tags = []
tags_db = Tag.objects.all()

for tag in tags_db:
tags.append({
'tag': tag.tag,
'url': tag.get_absolute_url()
})

return tags

def get_entries_list(entries_list):

entries = []

for entry in entries_list:
entries.append({
'body': mark_safe(entry.body),
'pub_date': entry.pub_date,
'title': entry.title,
'url': entry.get_absolute_url(),
'tags': entry.get_tags(),
})

return entries

def show_entries_by_day(request, year, month, day):
now = datetime.datetime.now()

# Check if day is in the future
if year + month + day > ''.join([str(now.year), str(now.month),
str(now.day)]):
raise Http404

entries = Entry.objects.filter(pub_date__lte=now,
  pub_date__year=year,
  pub_date__month=month,
  pub_date__day=day,
  status=1)

return render_to_response('blog_entry.html', {'entries':
get_entries_list(entries), 'tags': get_all_tags()})

I have a function similar to show_entries_by_year() for month, day,
tag and slug. Now, for get_all_tags(), I'm planning to write a
template tag that would replace this function, but I still don't know
what to do with get_entries_list(). I only made this function in order
to not repeat myself. Is there a way to get rid of get_entries_list()
and somehow make my views.py cleaner? I tried to pass entries directly
to the template but it didn't quite work (maybe I'm missing
something).

I searched the web for some examples, but it's hard to find apps that
don't use generic views (at least I didn't find them), so I decided to
ask here.

Thanks
Matic Žgur

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



Re: How to deploy a project on apache2.2.6 and mod_wsgi

2008-01-10 Thread Aleš Krištof

gaojiawang wrote:
> Hi,all
> Now I want to deploy my project on apache2.2 and mode_wsgi.
> But no have idea,Can you give me some suggestions?
>
> -- 
> Jiawang Gao(高加旺)
>
> [EMAIL PROTECTED] 
>
> NOTHING IS IMPOSSIBLE
Hi,
have you seen this link: 
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango ?

Ales

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



Re: Forms and non-editable fields

2008-01-10 Thread Matt Hoskins


> Interestingly, I wanted to write very similar request, but you passed
> ahead of me. :) I'm writing form/questionnaire site for our summer
> school and I want to be able render filled forms as text, easy readable
> and easy printable. So, my needs are pretty close to yours.

It struck me as not very DRY (Don't Repeat Yourself) to define two
templates to set out the details of a record where the only real
difference is that in one the field values are editable and the other
they're not (or in some cases where some fields become uneditable and
just have their values shown), and it's messy to put the logic into
the template to alternatively render the value or the field widget.

> My thought was to define two views for each form - one for editing
> and one for viewing filled forms. In latter case in constructor I planned
> to replace all widgets with some "label" widget, which would render
> its value as raw (probably formatted) text.

It's a little easier to work with how django currently does things if
the whole form is to be shown in read mode rather than just part of it
as you can just override the widgets - if you still want some fields
to be editable you hit the issue of django's default form save
processing/validation expecting that if a field exists on the form
then it will have a value submitted!

My current approach to do something that works for me without having
to change django is a slightly messy mix of a my own ModelForm
subclass and my own template tags that get passed the field so the
template tag is what renders the field either as a widget or just as a
display value as appropriate. Obviously I'd prefer something like I
outlined in my previous post!

Regards,
Matt

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

2008-01-10 Thread MariusB

I had the same problem on Vista with v0.96.1...

Following Richards solution, I've copied the django subfolder into   C:
\Pythong25\lib\site-packages\   and I get no error for   import
django
Are there any problems for this solution or is this all there is to
it?

On Dec 20 2007, 9:06 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote:
> Don't know why you're getting that (I've never tried 0.96, only svn), but
> the easiest thing is just to copy the django subfolder into
> C:\Pythong25\lib\site-packages\
>
> To test that it works, enter a python prompt and type:
>
> >>> import django
>
> - Richard
>
> On Dec 19, 2007 3:55 PM, Trev <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi, This should take 2 seconds for an experience Django user.
> > I'm trying to install Django on windows XP. I've installed python 2.5
> > and MySQL with MySQLdb as the interface.
> > However when I try installing django from DOS I get this error
>
> > C:\Django-0.96.1>setup.py install
> > running install
> > running build
> > running build_py
> > error: package directory '\django' does not exist
>
> > There is actually a django subdirectory in Django-0.96.1 so I can't
> > figure it out.
> > Please Help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to deploy a project on apache2.2.6 and mod_wsgi

2008-01-10 Thread gaojiawang
Hi,all
Now I want to deploy my project on apache2.2 and mode_wsgi.
But no have idea,Can you give me some suggestions?

-- 
Jiawang Gao(高加旺)

[EMAIL PROTECTED]

NOTHING IS IMPOSSIBLE

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