compilemessages invalid multibyte sequence error

2009-10-12 Thread celopes

I have a django.po file containing:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE
package.
# FIRST AUTHOR , YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-10-12 22:28-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: core/templates/index.html:7
msgid "Currently selected language is"
msgstr "A linguagem atualmente selecionada é"

#: core/templates/index.html:8
msgid "Howdy!"
msgstr "E aí?!"

When I try to compile messages, I get an error like:

processing file django.po in .../locale/pt_br/LC_MESSAGES
.../locale/pt_br/LC_MESSAGES/django.po:25:44: invalid multibyte
sequence
.../locale/pt_br/LC_MESSAGES/django.po:29:12: invalid multibyte
sequence
msgfmt: found 2 fatal errors

The problem is obviously related to any accented characters (in the
excerpt above é and í). If I replace those by their non-accented
counterparts or by  and  the compilation works fine
and translation operates normally.

I'm running mac os x 10.6.1 and the accented characters are the result
of me typing using the US International - PC keyboard layout (so, I
press single-quote-e to obtain é; for example).

What am I doing wrong, please?

Thanks,

CE

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



Re: Apache WSGI DJANGO

2009-10-12 Thread Nilesh Patel
here is my apache config file for wsgi,

import os, sys
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
sys.path.append('/var/www')
sys.path.append('/var/www/myproj/cms')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproj.settings'
import django.core.handlers.wsgi
from django.conf import settings
settings.DEBUG=False
application = django.core.handlers.wsgi.WSGIHandler()



2009/10/11 Kenneth Gonsalves 

>
> On Sunday 11 Oct 2009 12:14:13 pm lafada wrote:
> > Apache says,
> >
> > File does not exist: /var/lib/python-support/python2.5/django/contrib/
> > admin/media/js/actions.js
> >
> > When I tried to locate server says,
> > /usr/lib/python2.5/site-packages/django/contrib/admin/media/js/
> > actions.js
> >
> > what may be the cause ???
>
> you have not given the correct path to django/contrib/admin in your apache
> config.
> --
> regards
> kg
> http://lawgon.livejournal.com
>
> >
>


-- 
#Japan Shah
Sent from Gujarat, India

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



FormWizard Passing Data between forms

2009-10-12 Thread valhalla

I am trying to figure out a pythonic way of passing data between the
forms of a formwizard.
I can do it with inital data but I need to access the data in the
clean method of the form.

The only ways I can get working are really messy and wont scale
easily.

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



Re: How to "convert" data of anonymous users who then sign up

2009-10-12 Thread vpotter

Hm.. Using IP for this doesn't seem to be a good idea. What about
proxy users who will have proxy's IP or users of one subnetwork behind
the NAT?
I'd store some kind of id in user's cookies and then use it to detect
posts made by user anonymously

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



Re: Uploading an Image.

2009-10-12 Thread Chirolo

Hi Arthur.
I'm not so experience with linux.
I can get to the directories and files of apparmor, but how do I
stopped.
Thank you.

On Oct 11, 12:04 pm, Arthur Metasov  wrote:
> If you use distribution with apparmor try to stop it (/etc/init.d/apparmor).
>
> If the problem disappears, find apparmor config for apache and add there
>
> /home/Djangoprojects/ rw,
> /home/Djangoprojects/** rw,
> /home/Djangoprojects/imageupload/** rw,
>
> 2009/10/11 Chirolo 
>
>
>
> > Hi Bayuadji.
> > I already change the permissions for my Djangoprojects directory to
> > rwxrwxrwx, but still couldn't write to my Image directory, which I
> > also changed the permissions.
> > Do I need to change the permissions to my /home directory?
> > Here are the permissions of my home directory -> dwrxr-xr-x
>
> > On Oct 9, 7:31 pm, Bayuadji  wrote:
> > > Hi Chirolo
>
> > > On 10/9/09, Chirolo  wrote:
>
> > > > My question is which file or directory controls this webserverprocess?
> > > > or what can I do to solve my problem.
> > > > Thank you in advance.
> > > > Here is the error output that I get:
> > > > File "/usr/lib/python2.5/os.py" in makedirs
> > > >   164.             makedirs(head, mode)
> > > > File "/usr/lib/python2.5/os.py" in makedirs
> > > >   164.             makedirs(head, mode)
> > > > File "/usr/lib/python2.5/os.py" in makedirs
> > > >   164.             makedirs(head, mode)
> > > > File "/usr/lib/python2.5/os.py" in makedirs
> > > >   171.     mkdir(name, mode)
>
> > > > Exception Type: OSError at /imageupload/
> > > > Exception Value: [Errno 13] Permission denied: '/home/Djangoprojects'
>
> > > I think the error comes when creating a directory though.
> > > have you change the permission for '/home/Djangoprojects'?
>
> > > -djibon-
>
> > > --
> > > --
> >http://www.tumbletooth.org
> > > my linkedin profile :http://www.linkedin.com/in/bayuadji
> > > --
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Uploading an Image.

2009-10-12 Thread Chirolo

The error chows /imageupload/ as directory, but it's the name of the
url which run upload view.

On Oct 11, 8:58 am, andreas schmid  wrote:
> i had the same issue a few days ago and i solved it by simply adding
> write permission to all for the given directory, not for the whole
> /media/ or even home.
>
> your error differs a bit from mine... does the directory /imageupload/
> exist in /home/Djangoprojects ??
>
> Chirolo wrote:
> > Hi Bayuadji.
> > I already change the permissions for my Djangoprojects directory to
> > rwxrwxrwx, but still couldn't write to myImagedirectory, which I
> > also changed the permissions.
> > Do I need to change the permissions to my /home directory?
> > Here are the permissions of my home directory -> dwrxr-xr-x
>
> > On Oct 9, 7:31 pm, Bayuadji  wrote:
>
> >> Hi Chirolo
>
> >> On 10/9/09, Chirolo  wrote:
>
> >>> My question is which file or directory controls this webserverprocess?
> >>> or what can I do to solve my problem.
> >>> Thank you in advance.
> >>> Here is the error output that I get:
> >>> File "/usr/lib/python2.5/os.py" in makedirs
> >>>   164.             makedirs(head, mode)
> >>> File "/usr/lib/python2.5/os.py" in makedirs
> >>>   164.             makedirs(head, mode)
> >>> File "/usr/lib/python2.5/os.py" in makedirs
> >>>   164.             makedirs(head, mode)
> >>> File "/usr/lib/python2.5/os.py" in makedirs
> >>>   171.     mkdir(name, mode)
>
> >>> Exception Type: OSError at /imageupload/
> >>> Exception Value: [Errno 13] Permission denied: '/home/Djangoprojects'
>
> >> I think the error comes when creating a directory though.
> >> have you change the permission for '/home/Djangoprojects'?
>
> >> -djibon-
>
> >> --
> >> --http://www.tumbletooth.org
> >> my linkedin profile :http://www.linkedin.com/in/bayuadji
> >> --
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Rendering - too many values to unpack

2009-10-12 Thread LuisC

Hi!!!

I am having some trouble trying to output a database record to a
form

**My form:
class ClientesFIForm(forms.Form):
ClienteCodigo = forms.IntegerField(label='Codigo Cliente')
ClienteNombre = forms.CharField(label='Nombre Cliente')
ClienteFechaCreacion = forms.DateField(widget=AdminDateWidget,
   label='Fecha',
required=False)

**In my function view I have:
#Update Mode
#Estamos procesando un cliente desde la SB
clienteBuff = Cliente.objects.filter(pk=request.POST
['LineaGrid']).values('ClienteCodigo',
 
'ClienteNombre',
 
'ClienteFechaCreacion')
form = ClientesFIForm(clienteBuff)
return render_to_response('ControlHoras/ClientesFI.html',
{'form': form,})

**In my template:




{{ form.media }}



{{ form.as_p }}



The hidden field is a device to identify the moment the form is
submitted: Add mode-> the forms displays blank, Update mode the forms
"should" display data...

The only thing I am able to see is that QueryList clienteBuff has
square brackets... for example:
[{'ClienteCodigo': 13L, 'ClienteFechaCreacion': datetime.date(2009,
10, 10), 'ClienteNombre': u'trece'}]

Debugging the while the form is being redisplayed because of invalid
data, I do not see those brackets.  Also, the date appears a a
string.  Here is an example of the data bound while in add mode:
{u'ClienteCodigo': u'', u'ClienteFechaCreacion': u'2009-10-12',
u'ClienteNombre': u'prueba', u'formaID': u'ClientesFI'}

Tackling with the binding of the form I have got forms without fields,
only the submit button.  But I have not being able to get rid of the
brackets or datetime.date function...

Thank you

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



There has a login user problem

2009-10-12 Thread zhichao Yun

Model:
class X(models.Model):
user = models.ForeignKey(User, blank=True, null=True)
x= other()

# I want to add current user when add X

Form:
class xForm(forms.ModelForm):
class Meta:
model = X
exclude = ('marker')

View:
def add_X(request):
print request.user#user has the logined user
if request.method == 'POST':
print request.user#user is None
form = XForm(request)
if form.is_valid():
x = form.save(commit=False)
x.user = request.user
x.save()
return HttpResponseRedirect('/x/lists/')
else:
return render_to_response('x/x_form.html', {'form':xForm
()})
else:
return render_to_response('x/x_form.html', {'form':xForm()})

give me a way


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



migrating apps from pre MR branch

2009-10-12 Thread Kenneth Gonsalves

hi,

I had 4 legacy sites running on pre-MR django, written back in 2005. Since 
feature requests were minimal once the apps were complete, there was no reason 
to upgrade them. Recently however, after I started using virtualenv for my 
trunk apps, I was having problem with admin log in on the old apps. Apparently 
admin login was looking in the wrong place for authentication and I was 
getting a postgresql error - a restart of apache usually set this right 
temporarily, but users started complaining. So I migrated the apps to trunk. 
The process may be of interest to someone, so here is a brief documentation of 
the process:

1. models: global search and replace to change 'meta' to 'models', maxlength 
to max_length, lazydate to datetime.now, META to Meta. Then manually moving 
admin to the new admin.py. 

2. views: the basic structure of the views is the same. Only the query syntax 
has changed. This has to be done manually, line by line. '.html' has to be 
added to the template names. Imports have to be changed - just a copy/paste 
from the imports in any uptodate app suffices. template_loader is no longer 
used. I found to my surprise that the forms were made manually - either django 
did not have forms then, or I did not use them. The forms had to be rewritten 
using ModelForms and the corresponding templates also rewritten.

3. urls: no change

4. templates: .html extension was added. obj.get_foo_url changed to 
obj.foo.url for files and images.

5. thumbnails: I had been using nesh thumbnails. The whole nesh code had to be 
removed from templatetags. It was replaced with sorl.thumbnail. Slight change 
in template code to accomodate sorl.thumbnail syntax. Replacement of 
ImageWithThumbnail with ImageField in models did the trick.

6. database: I am using postgresql, and in the various shifts I had done, the 
existing databases were in 8.x. I did a pg_dump using -a (data only) and -D 
(inserts with column names). This sql file had to be massaged with a series of 
document wide search and replace operations - comparison of the output of \dt 
on the old and new databases gave what needed to be changed. Basically 
changing plural to singular. And some name changes, for example 'sites' 
becomes 'django.site', 'core.sessions' becomes django.session. I then did a 
syncdb on the new database and read the massaged file into it. The only errors 
were regarding 'packages' which do not appear to have an equivalent in the 
latest trunk.

On testing the sites, I found that no data was lost (or if anything was lost 
it was not significant). Anyway I retained the old databases in case of need. 
Net result: process was rather tedious, but no real blocks. At first I had done 
a pg_dump using -a and -d, and got into trouble because the order of fields had 
changed. But doing a -D solved this problem.

Hope this helps anyone who is hesitating about such a migration.
-- 
regards
kg
http://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Current Django tests fail?

2009-10-12 Thread Russell Keith-Magee

On Mon, Oct 12, 2009 at 11:18 PM, Tim Chase
 wrote:
>
> I'm not sure why I
> still only get 866 tests (my patch adds one test, bringing it to
> 867) where you get 917, but at least the core passes now.

This isn't necessarily an issue to be concerned about - there are some
conditional tests in the suite that only get added to the suite if you
have certain libraries installed - YAML, memcache, etc. The
contributing docs describe the full set of option libraries. There are
also some tests that only run if BACKEND='sqlite'. My initial reaction
was surprise that there were 50 such tests, but it's not completely
out of the question, I suppose.

> A nice side-effect of having a new infant around the house to
> feed every couple hours during the night -- I can launch the
> tests at one feeding and have the results by the next one ;-)

I too understand the organizational joys of a newborn :-)

Yours,
Russ Magee %-)

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



Re: Running just core regression tests

2009-10-12 Thread Karen Tracey
On Mon, Oct 12, 2009 at 6:24 PM, Tim Chase
wrote:

>
> Last year, the wifey finally convinced me to let go of the even
> older machine (133MHz with 96 megs of memory and a 800x600 CRT :)
> running OpenBSD.
>
>
Yeah, you've got me beat.  I do still have the IBM AT I had in college, with
its roomy 10M (or was it 20M?) hard drive, mono screen, and I don't recall
how much memory, running DOS.  But it's been in a closet for more than a
decade (no, I don't have a good reason for keeping it).


> > Two other ideas -- what else are you running on this when you run the
> > tests?  The 15 minutes in my case was with basically nothing else running
> > (with just 384M memory it's easy to overload this poor box).  I tried a
> 2nd
> > run after starting a couple of browsers so that the memory was
> > overcommitted, and the testing wall clock time went up to 24 minutes.
>
> Thunderbird for mail and Midori for browsing are open in the
> background, but neither should be overly active.  I tried without
> Midori and it came out about 5 mins faster.  I'll try re-running
> with no other big contenders for the CPU, but they lie pretty
> dormant overnight.
>
>
I was more thinking memory than CPU.  Sure if they're idle and memory is
constrained they should get swapped out in favor of what's actively running,
but if they're waking up periodically to see what's happening in the world
that could be causing some swapping, which could be contributing to the
slowness.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to "convert" data of anonymous users who then sign up

2009-10-12 Thread buttman

My first guess would be to just use the IP of the user in place of a
user instance when saving objects as anonymous. Once they signup, give
the user owneship of all objects with the user's IP.

On Oct 12, 4:55 pm, Continuation  wrote:
> I'd like to let new users to do certain things, like submitting a
> forum post as an anonymous user.
>
> And then if the new user decides to sign up after submitting the post,
> I'd like to convert the data submitted while the user was till
> anonymous (like the forum post in this example) so that it now belongs
> to the newly created user account.
>
> What's the best way of doing this? Is there any django app that
> support such functionality?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Simple Sitemap

2009-10-12 Thread Timbadu

Thanks Adam.

I've had a look at the django.contrib.sitemaps process but all
examples I've found relate to dynamic sitemaps created for ever
changing blogs etc.
Most of the info gives an example of a file to create but not what to
call it or where to put it.
So, using my limited knowledge of django and python i cobble something
together and get
... an Unhandled exception.
Arg.



On 12 Oct, 20:30, Adam N  wrote:
> You might as well use django.contrib.sitemaps.
>
> It's not difficult to use that app so there's no more efficient way to
> do this unless you happen to have the sitemaps.xml file already.
>
> On Oct 12, 11:32 am, Timbadu  wrote:
>
> > I need a simple sitemap for 5 URLs. The django sitemaps app seams a
> > bit overkill for such a simple xml file.
> > What's the best way of doing this?
> > Can i simply upload a sitemaps.xml and point to it?
> > Or should i use the django.contrib.sitemaps?
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Running just core regression tests

2009-10-12 Thread Tim Chase

>> On my oldest slowest machine (7 year old WinXP box with 384M of memory),
>> Then you're not far off -- my home work-horse is an 8-year-old
>> Celeron laptop clocked at 800MHz with 384M of memory running
>> Debian off a fairly slow HDD.
> 
> My 800MHz Celeron laptop got retired about a year ago when it quit wanting
> to stay powered on for more than 5 minutes. I thought I'd kept it long past
> its expire date but you've clearly got me beat.

Last year, the wifey finally convinced me to let go of the even 
older machine (133MHz with 96 megs of memory and a 800x600 CRT :) 
running OpenBSD.

> For me, tests for trunk using sqlite ran in 15 minutes.
> 
> My machine is faster than yours, 1.3GHz vs. 800MHz.  But that doesn't seem
> likely to account for your case taking four times longer to run.
> 
> Two other ideas -- what else are you running on this when you run the
> tests?  The 15 minutes in my case was with basically nothing else running
> (with just 384M memory it's easy to overload this poor box).  I tried a 2nd
> run after starting a couple of browsers so that the memory was
> overcommitted, and the testing wall clock time went up to 24 minutes.

Thunderbird for mail and Midori for browsing are open in the 
background, but neither should be overly active.  I tried without 
Midori and it came out about 5 mins faster.  I'll try re-running 
with no other big contenders for the CPU, but they lie pretty 
dormant overnight.

> Second, what version of Python?  The 15 minute result for me was with Python
> 2.6.  Backing off to Python 2.5 (plus keeping the memory overcommitted) made
> the wall clock time go up to 30 minutes.  

It's 2.5 which, if it takes double the time for you, may compound 
the clock-speed difference.  15 minutes * ~2x processor 
difference * ~2x penalty for 2.5 vs. 2.6 comes out to about an hour.

> So, making sure your machine is not swapping, if possible, and updating to a
> recent Python if you are currently running an older one, might help.

I'll see if I can get 2.6 from my Debian repositories which 
sounds like it can save me half the time.

Thanks for all your help!

-tim






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



Re: Querying for objects created on a certain date

2009-10-12 Thread aa56280

Karen,

I'm aware that my 30-days-ago version of the query is current time/
date specific. Good catch :-)

Thanks for the solution. I also found this one:
today = datetime.datetime.today()
Document.objects.filter(created_on__month=today.month,
created_on__day=today.day, created_on__year=today.year)

Thanks again.


On Oct 12, 5:00 pm, Karen Tracey  wrote:
> On Mon, Oct 12, 2009 at 5:07 PM, aa56280  wrote:
>
> > I have a DateTimeField called "created_on" on a model called
> > "Documents". It serves as a timestamp for when the record was added.
>
> > I'm trying to write a query that will return all Documents created_on
> > a particular date, say today. I can make it work if I look for a
> > record within a range of dates...
>
> > 
> > today = datetime.datetime.today()
> > thirty_days_ago = today - datetime.timedelta(days=30)
> > Document.objects.filter(created_on__range=(thirty_days_ago, today))
> > 
>
> > But now, I need to find records that were created on a particular
> > date, like, today.
>
> > How do I do that?
>
> today_end = datetime.datetime.combine(datetime.date.today(),
> datetime.time.max)
> today_start = datetime.datetime.combine(datetime.date.today(),
> datetime.time.min)
> Document.objects.filter(created_on__range=(today_start, today_end))
>
> You realize your 30-days-ago version of the query returns values that depend
> on the current time as well as the current date when the query is run? This
> may be rather surprising behavior for people who would likely expect the
> list of things created within the last 30 days to be constant over the
> course of a day (excepting things added during the day).
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: switching to mod_wsgi from mod_python seems to squash slashes from url

2009-10-12 Thread Graham Dumpleton

Answered in:

  http://groups.google.com/group/modwsgi/browse_frm/thread/46bbc449ca69a659

Graham

On Oct 13, 6:26 am, JSL  wrote:
> Hi, i'm switching an installation over from mod_python to mod_wsgi and
> all seems to have gone well except for one bit. I have a redirect page
> that takes the new url as part of the url, but for some reason the
> slashes are getting squashed. for example
>
> /redirect/http://www.google.com
>
> results in a
> http:/www.google.combeing passed as a parameter using this
> urlpattern:
>
>  (r"^redirect/(?P.*)/", "mysite.views.redirect"),
>
> any ideas?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Job Opportunities

2009-10-12 Thread Hannah Catabia

Currently seeking to hire three programmers for a Boston area stealth
web startup:

(1) Python and Django Programmer:  Must be comfortable enough to
customize Django.   Responsibilities include building the framework
for a social network and interfacing with cloud applications.

(2)  Amazon Web Services Programmer:  Must have Hadoop knowledge.
Experience in genomics and bioinformatics a plus, but not necessary.

(3)  Web Designer and Ajax Programmer:  Responsible for design mock-
ups and ultimate implementation.

Applicants should have good communication skills and be efficient and
self-directed workers.  If interested, please send your resume, cover
letter, and links to any previous work to me at
hannahcata...@gmail.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Querying for objects created on a certain date

2009-10-12 Thread Karen Tracey
On Mon, Oct 12, 2009 at 6:00 PM, phoebebright wrote:

>
> Try this:
>
> from datetime import date
>
> today = date.today()
>
> todays_stuff = Stuff.objects.filter(created_on = today)
>
>
Looking at the SQL that generates for a model that contains a DateTimeField,
not a DateField, I don't believe that will do what's wanted:

>>> from datetime import date
>>> today = date.today()
>>> today
datetime.date(2009, 10, 12)
>>> Document.objects.filter(created_on=today)
[]
>>> from django.db import connection
>>> connection.queries[-1]['sql']
u'SELECT `ttt_document`.`id`, `ttt_document`.`created_on`,
`ttt_document`.`name` FROM `ttt_document` WHERE `ttt_document`.`created_on`
= 2009-10-12 00:00:00  LIMIT 21'
>>>

It will only find stuff created at midnight, exactly.  (Unless the same
use-a-date-for-a-datetime technique is used when adding as well, so that the
times will always be 0, in which case it ought to be just a DateField.)

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Querying for objects created on a certain date

2009-10-12 Thread phoebebright

Try this:

from datetime import date

today = date.today()

todays_stuff = Stuff.objects.filter(created_on = today)



On Oct 12, 10:07 pm, aa56280  wrote:
> I have a DateTimeField called "created_on" on a model called
> "Documents". It serves as a timestamp for when the record was added.
>
> I'm trying to write a query that will return all Documents created_on
> a particular date, say today. I can make it work if I look for a
> record within a range of dates...
>
> 
> today = datetime.datetime.today()
> thirty_days_ago = today - datetime.timedelta(days=30)
> Document.objects.filter(created_on__range=(thirty_days_ago, today))
> 
>
> But now, I need to find records that were created on a particular
> date, like, today.
>
> How do I do that?
>
> Any thoughts greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Querying for objects created on a certain date

2009-10-12 Thread Karen Tracey
On Mon, Oct 12, 2009 at 5:07 PM, aa56280  wrote:

>
> I have a DateTimeField called "created_on" on a model called
> "Documents". It serves as a timestamp for when the record was added.
>
> I'm trying to write a query that will return all Documents created_on
> a particular date, say today. I can make it work if I look for a
> record within a range of dates...
>
> 
> today = datetime.datetime.today()
> thirty_days_ago = today - datetime.timedelta(days=30)
> Document.objects.filter(created_on__range=(thirty_days_ago, today))
> 
>
> But now, I need to find records that were created on a particular
> date, like, today.
>
> How do I do that?
>
>
today_end = datetime.datetime.combine(datetime.date.today(),
datetime.time.max)
today_start = datetime.datetime.combine(datetime.date.today(),
datetime.time.min)
Document.objects.filter(created_on__range=(today_start, today_end))

You realize your 30-days-ago version of the query returns values that depend
on the current time as well as the current date when the query is run? This
may be rather surprising behavior for people who would likely expect the
list of things created within the last 30 days to be constant over the
course of a day (excepting things added during the day).

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Querying for objects created on a certain date

2009-10-12 Thread aa56280

I have a DateTimeField called "created_on" on a model called
"Documents". It serves as a timestamp for when the record was added.

I'm trying to write a query that will return all Documents created_on
a particular date, say today. I can make it work if I look for a
record within a range of dates...


today = datetime.datetime.today()
thirty_days_ago = today - datetime.timedelta(days=30)
Document.objects.filter(created_on__range=(thirty_days_ago, today))


But now, I need to find records that were created on a particular
date, like, today.

How do I do that?

Any thoughts greatly appreciated.


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



switching to mod_wsgi from mod_python seems to squash slashes from url

2009-10-12 Thread JSL

Hi, i'm switching an installation over from mod_python to mod_wsgi and
all seems to have gone well except for one bit. I have a redirect page
that takes the new url as part of the url, but for some reason the
slashes are getting squashed. for example

/redirect/http://www.google.com

results in a
http:/www.google.com being passed as a parameter using this
urlpattern:

 (r"^redirect/(?P.*)/", "mysite.views.redirect"),

any ideas?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Apply decorator to view functions in third-party apps?

2009-10-12 Thread Nan


Well, I'm using a theming system -- each user can choose a theme to
use, and that choice is attached to their account.  Not just the base
template but the inner templates for some parts of the site can vary
from theme to theme, so I want to run something to the following
effect:

def my_r2r(request, template, context):
  # template is a path like 'app/foo.html'
  theme = request.user.get_profile().theme
  theme_template = theme.adjust_theme_path(template)
  t = loader.select_template((template, theme_template))
  return HttpResponse(t.render(RequestContext(request, context)))

A custom template loader would be a really neat solution, but I can't
see any way to pass it the request in order for it to select the
template.




On Oct 12, 3:17 pm, Arthur Metasov  wrote:
> You should carefully look at the code of django template loaders.
> What do you mean? Dou you want template paths to be stored in the database
> and dinamically change? Or do you want to use 3rd-party app but change
> template dirs it is looking for?
>
> 2009/10/12 ringemup 
>
>
>
> > I need to find a way to programmatically change the template path for
> > every view in my project -- a decorator seems like a nice DRY way to
> > accomplish that.  But what's the best way to apply it to views in
> > third-party apps?
>
> > The only way to accomplish this that I can think of is to declare new
> > decorated versions of the view functions in my own views.py and
> > duplicate the urlpatterns into my own urlconf rather than including
> > the apps' url patterns.  The new patterns will call the decorated
> > functions.
>
> > Is there a cleaner or simpler way to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Distance across a LineString in GeoDjango

2009-10-12 Thread buttman

>>> ls.srs.name
'WGS 84'
>>> srs.units
(0.017453292519943282, 'degree')
>>>ls.length
0.88329271346608429

So how do I go from degrees to miles? According to the docs, Distance
does not handle 'degrees' as a unit. Should I somehow convert to
another srs before I calculate distance? Or is there a better way?

On Oct 12, 2:53 am, Jani Tiainen  wrote:
> HARRY POTTRER kirjoitti:
>
>
>
> > I have a model which represents a route. I can use the `make_line()`
> > geoqueryset method to create a LineString like so:
>
>  r = Route.objects.get(pk=33)
>  # a route from Seattle to New York to Miami, a total distance
>  # of about 3043.8 nautical miles
>  r
> > 
>  # a collection of the airports used in the route
>  # turned into a LineString
>  ls = Airport.objects.filter(routebase__route=r).make_line()
>  ls
> > 
>
> > How can I find the total distance of that LineString object, so that
> > it returns a Distance object that I can then convert to nautical
> > miles? the .length() method here just returns a float, which is in who-
> > knows-what units...
>
> It's exactly in the units that are specified in your SRS definition. To
> go beyond that you can use Distance to make math and conversions to
> another units..
>
> Note that "length" gives linear distance, not spherical so in long
> distances you get a distorted length.
>
> --
> Jani Tiainen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to "convert" data of anonymous users who then sign up

2009-10-12 Thread Continuation

I'd like to let new users to do certain things, like submitting a
forum post as an anonymous user.

And then if the new user decides to sign up after submitting the post,
I'd like to convert the data submitted while the user was till
anonymous (like the forum post in this example) so that it now belongs
to the newly created user account.

What's the best way of doing this? Is there any django app that
support such functionality?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: showing user data in a view

2009-10-12 Thread Brian McKeever

You could write a wrapper around it if you wanted.

def x_edit(request, x_id):
x = X.objects.get(id = x_id)
if x.user != request.user:
return HttpResponseRedirect('/you cant edit that/')
return update_object(request, model = X, object_id = x_id,)


On Oct 12, 1:51 pm, "Ed Kawas"  wrote:
> Ah, so there is no way to use 'create_object' when doing this, right?
>
> Thank you,
>
> Eddie
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
>
> On Behalf Of Brian McKeever
> Sent: October-12-09 12:50 PM
> To: Django users
> Subject: Re: showing user data in a view
>
> It's the same thing.
>
> Lets say this is your view:
> def x_edit(request, x_id):
>     x = X.objects.get(id = x_id)
>     if x.user != request.user:
>         return HttpResponseRedirect('/you cant edit that/')
>     if request.method == 'POST':
>         form = XForm(request.POST)
>         if form.is_valid():
>             #whatever you need to do to save an x object here
>             return HttpResponseRedirect('/thanks/')
>     else:
>         form = XForm()
>
>     return render_to_response('x_edit.html', {
>         'form': form,
>     })
>
> You can split that into multiple views if you want, but the idea is to
> do the check before saving the object.
>
> On Oct 12, 1:25 pm, "Ed Kawas"  wrote:
> > That works for retrieving information, but how can I save information too?
>
> > Thanks for your patience,
>
> > Eddie
>
> > -Original Message-
> > From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
>
> > On Behalf Of Brian McKeever
> > Sent: October-12-09 11:52 AM
> > To: Django users
> > Subject: Re: showing user data in a view
>
> > The easy way is to just check that the owner of X is the user logged
> > in.
> > I don't know that you can pass an argument to the decorator, but you
> > could certainly just use an if statement.
>
> >http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-...
> > in-users-that-pass-a-test
>
> > On Oct 12, 11:40 am, Ed  wrote:
> > > Hi All,
>
> > > I am completely lost. I *think* that I have read most of the doc that
> > > i can find and I must be pretty dense, because I cannot figure this
> > > one out ...
>
> > > Let me outline what i have and where i want to go!
>
> > > model:
> > > # an X
> > > class X(db.Model):
> > >    user = models.ForeignKey(User, unique=True)
> > >    name = db.StringProperty(required=True)
>
> > > Form:
> > > class XForm(forms.ModelForm):
> > >     name = models.CharField(max_length=100)
> > >     class Meta:
> > >         model = X
> > >         fields = {'name'}
>
> > > views:
> > > def add_x(request):
> > >   return create_object(request,
> > >                                     form_class=XForm,
> > >                                     post_save_redirect=reverse
> > > ('myapp.views.show_x',
> > > kwargs=dict(key='%(key)s')))
>
> > > I am trying to allow authenticated users the ability to add X. I am
> > > trying to associate a user with a specific X so that only that user
> > > can modify it. How can I do this?
> > > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: showing user data in a view

2009-10-12 Thread Ed Kawas

Ah, so there is no way to use 'create_object' when doing this, right?

Thank you,

Eddie

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Brian McKeever
Sent: October-12-09 12:50 PM
To: Django users
Subject: Re: showing user data in a view


It's the same thing.

Lets say this is your view:
def x_edit(request, x_id):
x = X.objects.get(id = x_id)
if x.user != request.user:
return HttpResponseRedirect('/you cant edit that/')
if request.method == 'POST':
form = XForm(request.POST)
if form.is_valid():
#whatever you need to do to save an x object here
return HttpResponseRedirect('/thanks/')
else:
form = XForm()

return render_to_response('x_edit.html', {
'form': form,
})

You can split that into multiple views if you want, but the idea is to
do the check before saving the object.

On Oct 12, 1:25 pm, "Ed Kawas"  wrote:
> That works for retrieving information, but how can I save information too?
>
> Thanks for your patience,
>
> Eddie
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
>
> On Behalf Of Brian McKeever
> Sent: October-12-09 11:52 AM
> To: Django users
> Subject: Re: showing user data in a view
>
> The easy way is to just check that the owner of X is the user logged
> in.
> I don't know that you can pass an argument to the decorator, but you
> could certainly just use an if statement.
>
> http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-...
> in-users-that-pass-a-test
>
> On Oct 12, 11:40 am, Ed  wrote:
> > Hi All,
>
> > I am completely lost. I *think* that I have read most of the doc that
> > i can find and I must be pretty dense, because I cannot figure this
> > one out ...
>
> > Let me outline what i have and where i want to go!
>
> > model:
> > # an X
> > class X(db.Model):
> >    user = models.ForeignKey(User, unique=True)
> >    name = db.StringProperty(required=True)
>
> > Form:
> > class XForm(forms.ModelForm):
> >     name = models.CharField(max_length=100)
> >     class Meta:
> >         model = X
> >         fields = {'name'}
>
> > views:
> > def add_x(request):
> >   return create_object(request,
> >                                     form_class=XForm,
> >                                     post_save_redirect=reverse
> > ('myapp.views.show_x',
> > kwargs=dict(key='%(key)s')))
>
> > I am trying to allow authenticated users the ability to add X. I am
> > trying to associate a user with a specific X so that only that user
> > can modify it. How can I do this?
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: showing user data in a view

2009-10-12 Thread Brian McKeever

It's the same thing.

Lets say this is your view:
def x_edit(request, x_id):
x = X.objects.get(id = x_id)
if x.user != request.user:
return HttpResponseRedirect('/you cant edit that/')
if request.method == 'POST':
form = XForm(request.POST)
if form.is_valid():
#whatever you need to do to save an x object here
return HttpResponseRedirect('/thanks/')
else:
form = XForm()

return render_to_response('x_edit.html', {
'form': form,
})

You can split that into multiple views if you want, but the idea is to
do the check before saving the object.

On Oct 12, 1:25 pm, "Ed Kawas"  wrote:
> That works for retrieving information, but how can I save information too?
>
> Thanks for your patience,
>
> Eddie
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
>
> On Behalf Of Brian McKeever
> Sent: October-12-09 11:52 AM
> To: Django users
> Subject: Re: showing user data in a view
>
> The easy way is to just check that the owner of X is the user logged
> in.
> I don't know that you can pass an argument to the decorator, but you
> could certainly just use an if statement.
>
> http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-...
> in-users-that-pass-a-test
>
> On Oct 12, 11:40 am, Ed  wrote:
> > Hi All,
>
> > I am completely lost. I *think* that I have read most of the doc that
> > i can find and I must be pretty dense, because I cannot figure this
> > one out ...
>
> > Let me outline what i have and where i want to go!
>
> > model:
> > # an X
> > class X(db.Model):
> >    user = models.ForeignKey(User, unique=True)
> >    name = db.StringProperty(required=True)
>
> > Form:
> > class XForm(forms.ModelForm):
> >     name = models.CharField(max_length=100)
> >     class Meta:
> >         model = X
> >         fields = {'name'}
>
> > views:
> > def add_x(request):
> >   return create_object(request,
> >                                     form_class=XForm,
> >                                     post_save_redirect=reverse
> > ('myapp.views.show_x',
> > kwargs=dict(key='%(key)s')))
>
> > I am trying to allow authenticated users the ability to add X. I am
> > trying to associate a user with a specific X so that only that user
> > can modify it. How can I do this?
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to get back to a view requiring login

2009-10-12 Thread Arthur Metasov
as for me, @login_required decorator redirects to
http://localhost/accounts/login/?next=/path/
if you use generic view to display login page it will automatically redirect
user to /path/ after login.

2009/10/12 Sergio A. 

>
> I've three views each with different URL. They are visible to logged
> in users.
> If a non-logged user tries to access a URL requiring login, I'm able
> to redirect it to the login page.
>
> What I'm missing is how to go back to the initial page, once the user
> log in the system.
>
>
> Cheers, Sergio
> >
>

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



Re: Simple Sitemap

2009-10-12 Thread Adam N

You might as well use django.contrib.sitemaps.

It's not difficult to use that app so there's no more efficient way to
do this unless you happen to have the sitemaps.xml file already.

On Oct 12, 11:32 am, Timbadu  wrote:
> I need a simple sitemap for 5 URLs. The django sitemaps app seams a
> bit overkill for such a simple xml file.
> What's the best way of doing this?
> Can i simply upload a sitemaps.xml and point to it?
> Or should i use the django.contrib.sitemaps?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: showing user data in a view

2009-10-12 Thread Ed Kawas

That works for retrieving information, but how can I save information too?

Thanks for your patience,

Eddie

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Brian McKeever
Sent: October-12-09 11:52 AM
To: Django users
Subject: Re: showing user data in a view


The easy way is to just check that the owner of X is the user logged
in.
I don't know that you can pass an argument to the decorator, but you
could certainly just use an if statement.

http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-logged-
in-users-that-pass-a-test

On Oct 12, 11:40 am, Ed  wrote:
> Hi All,
>
> I am completely lost. I *think* that I have read most of the doc that
> i can find and I must be pretty dense, because I cannot figure this
> one out ...
>
> Let me outline what i have and where i want to go!
>
> model:
> # an X
> class X(db.Model):
>    user = models.ForeignKey(User, unique=True)
>    name = db.StringProperty(required=True)
>
> Form:
> class XForm(forms.ModelForm):
>     name = models.CharField(max_length=100)
>     class Meta:
>         model = X
>         fields = {'name'}
>
> views:
> def add_x(request):
>   return create_object(request,
>                                     form_class=XForm,
>                                     post_save_redirect=reverse
> ('myapp.views.show_x',
> kwargs=dict(key='%(key)s')))
>
> I am trying to allow authenticated users the ability to add X. I am
> trying to associate a user with a specific X so that only that user
> can modify it. How can I do this?
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: __unicode__(self) doesn't work

2009-10-12 Thread Arthur Metasov
2009/10/12 Denis Bahati 

> Hi there i have the problem with unicode function it doesn't give me any
> changes. the poll list is displayed as Poll object and does doesn't give me
> error if i write the models.py like this:from django.db import models
> import datetime
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
> def __unicode__(self):
>  return self.question
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
> was_published_today.short_description = 'Published today?'
>
> this identation makes functions live in module, not class. You should add
one ident to your methods to push them into class body like this:
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
 return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()

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



Re: Apply decorator to view functions in third-party apps?

2009-10-12 Thread Arthur Metasov
You should carefully look at the code of django template loaders.
What do you mean? Dou you want template paths to be stored in the database
and dinamically change? Or do you want to use 3rd-party app but change
template dirs it is looking for?

2009/10/12 ringemup 

>
> I need to find a way to programmatically change the template path for
> every view in my project -- a decorator seems like a nice DRY way to
> accomplish that.  But what's the best way to apply it to views in
> third-party apps?
>
> The only way to accomplish this that I can think of is to declare new
> decorated versions of the view functions in my own views.py and
> duplicate the urlpatterns into my own urlconf rather than including
> the apps' url patterns.  The new patterns will call the decorated
> functions.
>
> Is there a cleaner or simpler way to do this?
> >
>

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



Re: any open source complete django app to use as start

2009-10-12 Thread shreko

Thank you all for your suggestions. I think I'll go with satchmo as it
comes closest to what I'm looking for. In my earlier search I found
satchmo, but I was under impression that it's not based on django 1.1.
Looks like current development release will be, which is great.

Thanks

On Oct 12, 10:12 am, Chris Moffitt  wrote:
> Might as well pile on with Satchmo:http://www.satchmoproject.com
>
> -Chris
>
> On Mon, Oct 12, 2009 at 10:52 AM, Ben Rousch  wrote:
>
> > On Mon, Oct 12, 2009 at 11:50 AM, Daniel Hilton 
> > wrote:
>
> > > 2009/10/12 shreko :
>
> > >> I've been looking all day yesterday to find a complete django open
> > >> source project that is non trivial. Using it as a base for my app
> > >> would greatly speed up my learning and give me a fast start. To give
> > >> you an example, for kohana framework in php you can find
> > >>http://www.argentuminvoice.com/as a full app. I would think that
> > >> Django has been out long enough that these apps would exist. If you
> > >> know of any, could you please let me know?
>
> > You might take a look at Pinax:http://pinaxproject.com/
>
> > --
> >  Ben Rousch
> >  brou...@gmail.com
> >  http://ishmilok.blogspot.com/
> >  http://tech-ishmilok.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Session data passing after login

2009-10-12 Thread Lakshman Prasad
Hi,
On a user login, the session key changes. This makes the data stored in the
session before user logging in, inaccessible.

But the session data before user login is required in so many cases, say for
instance, a shopping cart.

How to pass the session data of the anonymous user to the logged in user?
-

Not exactly the same, but on a related note, when the anonymous user makes a
post request to a @login_required view, how to preserve the post data.
Currently, it seems like the post data is discarded. On googling, I found
that this was a feature in the earlier django release, but removed due to
some security vulnerability:
http://www.djangoproject.com/weblog/2008/sep/02/security/

With signed cookies and the like that are done recently, is it still a
vulnerability?

-- 
Regards,
Lakshman
becomingguru.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



school solutions

2009-10-12 Thread jhugo

Hi,

I was wondering if there is a project based on Django for schools that
manages enrollment, grades, billing, etc.

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



Re: showing user data in a view

2009-10-12 Thread Brian McKeever

The easy way is to just check that the owner of X is the user logged
in.
I don't know that you can pass an argument to the decorator, but you
could certainly just use an if statement.

http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-logged-in-users-that-pass-a-test

On Oct 12, 11:40 am, Ed  wrote:
> Hi All,
>
> I am completely lost. I *think* that I have read most of the doc that
> i can find and I must be pretty dense, because I cannot figure this
> one out ...
>
> Let me outline what i have and where i want to go!
>
> model:
> # an X
> class X(db.Model):
>    user = models.ForeignKey(User, unique=True)
>    name = db.StringProperty(required=True)
>
> Form:
> class XForm(forms.ModelForm):
>     name = models.CharField(max_length=100)
>     class Meta:
>         model = X
>         fields = {'name'}
>
> views:
> def add_x(request):
>   return create_object(request,
>                                     form_class=XForm,
>                                     post_save_redirect=reverse
> ('myapp.views.show_x',
> kwargs=dict(key='%(key)s')))
>
> I am trying to allow authenticated users the ability to add X. I am
> trying to associate a user with a specific X so that only that user
> can modify it. How can I do this?
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



showing user data in a view

2009-10-12 Thread Ed

Hi All,

I am completely lost. I *think* that I have read most of the doc that
i can find and I must be pretty dense, because I cannot figure this
one out ...

Let me outline what i have and where i want to go!

model:
# an X
class X(db.Model):
   user = models.ForeignKey(User, unique=True)
   name = db.StringProperty(required=True)

Form:
class XForm(forms.ModelForm):
name = models.CharField(max_length=100)
class Meta:
model = X
fields = {'name'}

views:
def add_x(request):
  return create_object(request,
form_class=XForm,
post_save_redirect=reverse
('myapp.views.show_x',
kwargs=dict(key='%(key)s')))

I am trying to allow authenticated users the ability to add X. I am
trying to associate a user with a specific X so that only that user
can modify it. How can I do this?
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Running just core regression tests

2009-10-12 Thread Karen Tracey
On Sun, Oct 11, 2009 at 7:40 PM, Tim Chase
wrote:

>
> > On my oldest slowest machine (7 year old WinXP box with 384M of memory),
>
>  Then you're not far off -- my home work-horse is an 8-year-old
> Celeron laptop clocked at 800MHz with 384M of memory running
> Debian off a fairly slow HDD.


My 800MHz Celeron laptop got retired about a year ago when it quit wanting
to stay powered on for more than 5 minutes. I thought I'd kept it long past
its expire date but you've clearly got me beat.


> After "an hour and change" (fairly
> close to your 1.5hr benchmark) at lunch, I aborted on the
> assumption that there had to be a better way.  Especially for
> tight iterations on changes against trunk (working on a patch
> against core/trunk from a ticket I created).  I've svn-up'ed to
> the latest to ensure I've got everything as current as possible,
> but I'm fairly sure that was already the case.  I manually
> specified ":memory:" and sqlite, letting it run to completion
> this time and it took just over an hour:
>
>Ran 867 tests in 3775.195s
>
> I'll try Russel's suggestion to minimize the time spent running
> so I can do some quick(er) iterations before re-running the full
> suite.
>
>
Note my 1.5 hours was for the 1.0.X branch, not trunk.  That's why I was
thinking you must be using a DB that didn't support rollback, but if you are
using sqlite then that is not what's causing things to be so slow.  (You
also should not have to specify memory as the DB for testing sqlite, it
should do that automatically though I haven't verified that is working...so
far as I know it is working.)

For me, tests for trunk using sqlite ran in 15 minutes.

My machine is faster than yours, 1.3GHz vs. 800MHz.  But that doesn't seem
likely to account for your case taking four times longer to run.

Two other ideas -- what else are you running on this when you run the
tests?  The 15 minutes in my case was with basically nothing else running
(with just 384M memory it's easy to overload this poor box).  I tried a 2nd
run after starting a couple of browsers so that the memory was
overcommitted, and the testing wall clock time went up to 24 minutes.

Second, what version of Python?  The 15 minute result for me was with Python
2.6.  Backing off to Python 2.5 (plus keeping the memory overcommitted) made
the wall clock time go up to 30 minutes.  I also recall from running tests
against Python 2.3 to check for 2.3 compatibility that those ran what seemed
to be much slower than later levels (though I don't have Python 2.3 on this
particular machine to put a number on "much").  My general impression from
running tests against 2.3, 2.4, 2.5, 2.6 when doing compatibility testing
was that later Pythons were faster, though I never took specific
measurements to quantify that impression.

So, making sure your machine is not swapping, if possible, and updating to a
recent Python if you are currently running an older one, might help.

Finally as to the 50 missing tests noted in another thread -- some tests are
skipped if you don't have various optional bits (e.g. PIL, markdown, etc.)
installed.  I've got probably nothing optional installed on this machine
I've mentioned here and it is reporting 862 tests run.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Showing unescaped HTML in Admin pages

2009-10-12 Thread Rui Vieira

Thanks for the suggestions everyone.

I went for the "allow_tags = True" solution has it is (possibly?) the
simplest and it's enough for what I need.

Thanks again.

On Oct 12, 5:59 pm, Rui Vieira  wrote:
> Very good solution, works perfectly!
>
> Thanks.
>
> On Oct 12, 5:53 pm, Brian Neal  wrote:
>
>
>
> > On Oct 12, 11:15 am, 
> > "ruidevie...@googlemail.com" wrote:
> > > Hi everyone,
>
> > > Is is possible to render unescaped HTML in admin pages?
>
> > Does this help? Start here:
>
> >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> > and then search for allow_tags.
>
> > Best,
> > BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Showing unescaped HTML in Admin pages

2009-10-12 Thread Michael P. Jung

> Is is possible to render unescaped HTML in admin pages?
> 
> (say) A model has a field "text" which contains HTML markup. Is this
> something that can be changed on the model (ie __unicode__ method) or
> do I have to change the admin templates?

If you're only going to render html for lists it's possible to add an
'allow_tags' attribute to a field to be added to list_display:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display


In order to display RAW html inside the admin change view you have lots
of choices.

(a) either write a custom field that returns a different widget
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#formfield

(b) or use a standard field and specify formfield_overrides
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_overrides

(c) or use a custom form
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form

(d) or just provide a custom template
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.change_form_template


I'd probably go for (a) as it looks the cleanest to me and is reusable.
A HTMLMarkupField could also provide methods like verify(), tidy(), etc.
(b) is a good choice if you generally want to change the way all Char-
and TextFields behave. (c) and (d) provide the most flexibility, while
coming at the cost of being quite verbose.


--mp

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



Re: Showing unescaped HTML in Admin pages

2009-10-12 Thread Rui Vieira

Very good solution, works perfectly!

Thanks.

On Oct 12, 5:53 pm, Brian Neal  wrote:
> On Oct 12, 11:15 am, "ruidevie...@googlemail.com" 
> wrote:
> > Hi everyone,
>
> > Is is possible to render unescaped HTML in admin pages?
>
> Does this help? Start here:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> and then search for allow_tags.
>
> Best,
> BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Showing unescaped HTML in Admin pages

2009-10-12 Thread Karen Tracey
On Mon, Oct 12, 2009 at 12:15 PM, ruidevie...@googlemail.com <
ruidevie...@googlemail.com> wrote:

>
> Hi everyone,
>
> Is is possible to render unescaped HTML in admin pages?
>
> (say) A model has a field "text" which contains HTML markup. Is this
> something that can be changed on the model (ie __unicode__ method) or
> do I have to change the admin templates?
>
>
I assume you mean when the field is included in list_display?

Define a callable that returns the field value, set allow_tags=True on the
callable, and list the callable instead of the field in list_display.

The doc has examples that might help:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Showing unescaped HTML in Admin pages

2009-10-12 Thread Brian Neal

On Oct 12, 11:15 am, "ruidevie...@googlemail.com"
 wrote:
> Hi everyone,
>
> Is is possible to render unescaped HTML in admin pages?
>
Does this help? Start here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

and then search for allow_tags.

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



Re: Limit choices based on a foreign key

2009-10-12 Thread Christian Wittwer

Ok, I found a way, but it's still not perfect.

class GoalForm(forms.ModelForm):

class Meta:
model = Goal

def __init__(self, *args, **kwargs):
super(GoalForm, self).__init__(*args, **kwargs)
self.fields['goal_scorer'].queryset =
Player.objects.filter(gameroster__game=self.instance.game)

class GoalInline(admin.TabularInline):
model = Goal
extra = 4
#form = GoalForm


class GameAdmin(admin.ModelAdmin):
list_display = ('date_time', 'home_team', 'opponent_team',
'is_home_game', 'season', 'league', 'type', 'result')
list_filter = ['league', 'season']
inlines = [GameRosterInline, GoalInline, PenaltyInline]
ordering   = ('date_time',)

That works as long as I edit the model game not inline. The selection
of player gets limited as I want.
When I try to edit it inline in the game, the GoalForm seems not to
work. It's going to be ignored.
When I try to comment in "form = GoalForm", the whole app doesn't run
anymore. I got a DoesNotExist exception, but I think this is because
it can't register the form..

Any ideas who to activate my custom form for the inline mode?

Chris


2009/10/12 Christian Wittwer :
> Hi,
> I have a question regarding the admin interface of django.
>
> My models
>
> class Team(models.Model):
>    name = models.CharField(max_length=10)
>
> class Player(models.Model):
>    lastname = models.CharField(max_length=60)
>
> class Goal(models.Model):
>    game = models.ForeignKey(Game)
>    goal_scorer =
> models.ForeignKey(Player,related_name='goal_scorer',blank=True,null=True)
>
> class Game(models.Model):
>    home_team = models.ForeignKey(Team,related_name='home_team')
>
> class GameRoster(models.Model):
>    player = models.ForeignKey(Player)
>    game = models.ForeignKey(Game)
>
> Each Goal is scored by a Player in a Game. I'm using a inline form to
> insert goals for a game.
> The players are somehow connected to the team (gameroster), and
> therefore to the game.
>
> I found the place to hook in to limit the choices of player.
>
> class GoalInline(admin.TabularInline):
>    model = Goal
>    extra = 4
>
>    def formfield_for_foreignkey(self, db_field, request, **kwargs):
>        if db_field.name == "goal_scorer":
>            kwargs["queryset"] =
> Player.objects.filter(gameroster__game=self.game)
>            return db_field.formfield(**kwargs)
>
>        return super(GoalInline,
> self).formfield_for_foreignkey(db_field, request, **kwargs)
>
>
> The missing point is now: How to access game, which is connected to
> the goal to limit the players?
> I tried self.game as you can see, but that doesn't work.
> How can I access the model from within this function?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Showing unescaped HTML in Admin pages

2009-10-12 Thread ruidevie...@googlemail.com

Hi everyone,

Is is possible to render unescaped HTML in admin pages?

(say) A model has a field "text" which contains HTML markup. Is this
something that can be changed on the model (ie __unicode__ method) or
do I have to change the admin templates?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Limit choices based on a foreign key

2009-10-12 Thread Peter Flood

It might not help your immediate problem but since players and teams
are the fundamental entities involved in team sports I'm sure you'll
need an easy way of linking them at some point.

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



Re: any open source complete django app to use as start

2009-10-12 Thread Chris Moffitt
Might as well pile on with Satchmo: http://www.satchmoproject.com

-Chris

On Mon, Oct 12, 2009 at 10:52 AM, Ben Rousch  wrote:

>
> On Mon, Oct 12, 2009 at 11:50 AM, Daniel Hilton 
> wrote:
> >
> > 2009/10/12 shreko :
> >>
> >> I've been looking all day yesterday to find a complete django open
> >> source project that is non trivial. Using it as a base for my app
> >> would greatly speed up my learning and give me a fast start. To give
> >> you an example, for kohana framework in php you can find
> >> http://www.argentuminvoice.com/ as a full app. I would think that
> >> Django has been out long enough that these apps would exist. If you
> >> know of any, could you please let me know?
> >
>
> You might take a look at Pinax: http://pinaxproject.com/
>
>
> --
>  Ben Rousch
>  brou...@gmail.com
>  http://ishmilok.blogspot.com/
>  http://tech-ishmilok.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Limit choices based on a foreign key

2009-10-12 Thread Christian Wittwer

Hi Peter,
I forgot to post some important relations in the models.
GameRoster is a table in a m2m relation between Player and Game. I
need some extra attributes on the relationship between player and game
(which position they played).

class GameRoster(models.Model):
player = models.ForeignKey(Player)
game = models.ForeignKey(Game)
POSITION_CHOICES = (
('C', 'Coach'),
('G', 'Goalkeeper'),
('D', 'Defense'),
('O', 'Offense'),
)
position = models.CharField(max_length=1,choices=POSITION_CHOICES)

class Game(models.Model):
players = models.ManyToManyField(Player,
through='GameRoster',blank=True,null=True, related_name='players')

> Why not have
>
> class Player(models.Model):
>    lastname = models.CharField(max_length=60)
>    team = models.ForeignKey(Team)

That won't work, because I need to know which position the player
played at the game.
The position can change from game to game. That's the reason I used
the GameRoster.

Chris

> Christian Wittwer wrote:
>> Hi,
>> I have a question regarding the admin interface of django.
>>
>> My models
>>
>> class Team(models.Model):
>>     name = models.CharField(max_length=10)
>>
>> class Player(models.Model):
>>     lastname = models.CharField(max_length=60)
>>
>> class Goal(models.Model):
>>     game = models.ForeignKey(Game)
>>     goal_scorer =
>> models.ForeignKey(Player,related_name='goal_scorer',blank=True,null=True)
>>
>> class Game(models.Model):
>>     home_team = models.ForeignKey(Team,related_name='home_team')
>>
>> class GameRoster(models.Model):
>>     player = models.ForeignKey(Player)
>>     game = models.ForeignKey(Game)
>>
>> Each Goal is scored by a Player in a Game. I'm using a inline form to
>> insert goals for a game.
>> The players are somehow connected to the team (gameroster), and
>> therefore to the game.
>>
>> I found the place to hook in to limit the choices of player.
>>
>> class GoalInline(admin.TabularInline):
>>     model = Goal
>>     extra = 4
>>
>>     def formfield_for_foreignkey(self, db_field, request, **kwargs):
>>         if db_field.name == "goal_scorer":
>>             kwargs["queryset"] =
>> Player.objects.filter(gameroster__game=self.game)
>>             return db_field.formfield(**kwargs)
>>
>>         return super(GoalInline,
>> self).formfield_for_foreignkey(db_field, request, **kwargs)
>>
>>
>> The missing point is now: How to access game, which is connected to
>> the goal to limit the players?
>> I tried self.game as you can see, but that doesn't work.
>> How can I access the model from within this function?
>>
>> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: any open source complete django app to use as start

2009-10-12 Thread Ben Rousch

On Mon, Oct 12, 2009 at 11:50 AM, Daniel Hilton  wrote:
>
> 2009/10/12 shreko :
>>
>> I've been looking all day yesterday to find a complete django open
>> source project that is non trivial. Using it as a base for my app
>> would greatly speed up my learning and give me a fast start. To give
>> you an example, for kohana framework in php you can find
>> http://www.argentuminvoice.com/ as a full app. I would think that
>> Django has been out long enough that these apps would exist. If you
>> know of any, could you please let me know?
>

You might take a look at Pinax: http://pinaxproject.com/


-- 
  Ben Rousch
  brou...@gmail.com
  http://ishmilok.blogspot.com/
  http://tech-ishmilok.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: any open source complete django app to use as start

2009-10-12 Thread Daniel Hilton

2009/10/12 shreko :
>
> I've been looking all day yesterday to find a complete django open
> source project that is non trivial. Using it as a base for my app
> would greatly speed up my learning and give me a fast start. To give
> you an example, for kohana framework in php you can find
> http://www.argentuminvoice.com/ as a full app. I would think that
> Django has been out long enough that these apps would exist. If you
> know of any, could you please let me know?

Everyblock?
http://code.google.com/p/ebcode/


>
> Thanks
>
> >
>



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


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



any open source complete django app to use as start

2009-10-12 Thread shreko

I've been looking all day yesterday to find a complete django open
source project that is non trivial. Using it as a base for my app
would greatly speed up my learning and give me a fast start. To give
you an example, for kohana framework in php you can find
http://www.argentuminvoice.com/ as a full app. I would think that
Django has been out long enough that these apps would exist. If you
know of any, could you please let me know?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Limit choices based on a foreign key

2009-10-12 Thread pe...@whywouldwe.com

Seems odd to connect Player to Team via Goal and GameRoster (only for 
hometeam, presumably you have away team as well) - what about players 
that don't score, don't you want those details as well? Maybe you show 
an edited version of your models.

Why not have

class Player(models.Model):
lastname = models.CharField(max_length=60)
team = models.ForeignKey(Team)


This way players, teams and goals are all tied closely. And you could rename 
GameRoster to PlayerGames or something a little more intuitive.


Hope this helps.


Christian Wittwer wrote:
> Hi,
> I have a question regarding the admin interface of django.
>
> My models
>
> class Team(models.Model):
> name = models.CharField(max_length=10)
>
> class Player(models.Model):
> lastname = models.CharField(max_length=60)
>
> class Goal(models.Model):
> game = models.ForeignKey(Game)
> goal_scorer =
> models.ForeignKey(Player,related_name='goal_scorer',blank=True,null=True)
>
> class Game(models.Model):
> home_team = models.ForeignKey(Team,related_name='home_team')
>
> class GameRoster(models.Model):
> player = models.ForeignKey(Player)
> game = models.ForeignKey(Game)
>
> Each Goal is scored by a Player in a Game. I'm using a inline form to
> insert goals for a game.
> The players are somehow connected to the team (gameroster), and
> therefore to the game.
>
> I found the place to hook in to limit the choices of player.
>
> class GoalInline(admin.TabularInline):
> model = Goal
> extra = 4
>
> def formfield_for_foreignkey(self, db_field, request, **kwargs):
> if db_field.name == "goal_scorer":
> kwargs["queryset"] =
> Player.objects.filter(gameroster__game=self.game)
> return db_field.formfield(**kwargs)
>
> return super(GoalInline,
> self).formfield_for_foreignkey(db_field, request, **kwargs)
>
>
> The missing point is now: How to access game, which is connected to
> the goal to limit the players?
> I tried self.game as you can see, but that doesn't work.
> How can I access the model from within this function?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Simple Sitemap

2009-10-12 Thread Timbadu

I need a simple sitemap for 5 URLs. The django sitemaps app seams a
bit overkill for such a simple xml file.
What's the best way of doing this?
Can i simply upload a sitemaps.xml and point to it?
Or should i use the django.contrib.sitemaps?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Current Django tests fail?

2009-10-12 Thread Tim Chase

> I just ran the full suite usine SQLite on r11603, and got 100% pass on
> 917 tests.
> 
> I can't think of an obvious cause, but the fact that you're getting
> errors in runtests.py is mighty suspicious. The fact that you've got
> 50 less tests than you should is also suspicious.
> 
> My first guess would be to look at PYTHONPATH issues - are you sure
> that Python isn't picking up a runtests.py and/or a Django install
> from somewhere other than the trunk checkout you are trying to test?

Looks like PYTHONPATH issues were part of the problem.  I had 
several branches checked out and a soft-link (on the PYTHONPATH) 
pointing to the flavor of the month.  However, the link pointed 
to trunk/django/ not just trunk/   I adjusted the link to point 
purely at trunk/ and all tests pass now.  I'm not sure why I 
still only get 866 tests (my patch adds one test, bringing it to 
867) where you get 917, but at least the core passes now.

Just to be sure, I blew away my whole trunk/ directory and 
re-checked-out a fresh copy of the tree (there was some chaff in 
there as it's been upgraded since .96 or so and a "svn st" 
returned some now-untracked items) and that didn't make a 
difference in my test-count.


t...@rubbish:~/code/django/trunk/tests$ python runtests.py 
--settings=settings
--
Ran 866 tests in 3552.017s

OK


A nice side-effect of having a new infant around the house to 
feed every couple hours during the night -- I can launch the 
tests at one feeding and have the results by the next one ;-)

Thanks for your help!

-tim



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



Limit choices based on a foreign key

2009-10-12 Thread Christian Wittwer

Hi,
I have a question regarding the admin interface of django.

My models

class Team(models.Model):
name = models.CharField(max_length=10)

class Player(models.Model):
lastname = models.CharField(max_length=60)

class Goal(models.Model):
game = models.ForeignKey(Game)
goal_scorer =
models.ForeignKey(Player,related_name='goal_scorer',blank=True,null=True)

class Game(models.Model):
home_team = models.ForeignKey(Team,related_name='home_team')

class GameRoster(models.Model):
player = models.ForeignKey(Player)
game = models.ForeignKey(Game)

Each Goal is scored by a Player in a Game. I'm using a inline form to
insert goals for a game.
The players are somehow connected to the team (gameroster), and
therefore to the game.

I found the place to hook in to limit the choices of player.

class GoalInline(admin.TabularInline):
model = Goal
extra = 4

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "goal_scorer":
kwargs["queryset"] =
Player.objects.filter(gameroster__game=self.game)
return db_field.formfield(**kwargs)

return super(GoalInline,
self).formfield_for_foreignkey(db_field, request, **kwargs)


The missing point is now: How to access game, which is connected to
the goal to limit the players?
I tried self.game as you can see, but that doesn't work.
How can I access the model from within this function?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



edit unique slug field

2009-10-12 Thread Ali Rıza Keleş

I have a slug field(let's call A) which is prepopulated from another
charfield(let's call B) and unique. On the admin page, when I want to
edit B, at the same time A, A would not be changed. I try manually, it
doesn't let me to edit it. 

How can I edit unique, prepopulated slug fields on admin page? 

Thank you..

--
Ali Rıza



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



Re: Foreign language in View Model.

2009-10-12 Thread Karen Tracey
On Sat, Oct 10, 2009 at 6:43 PM, Rizwan  wrote:

>
> I am trying to extend flatpage view...I have added custom code
> here..you can see navigation showing question mark here
> http://beta.rmansuri.net/homepage/
>
>
> [snip]
>#custom code start
>db = MySQLdb.connect
> (user='rmansuri_gq',db='rmansuri_gq',passwd='riz#wan1712',host='localhost')
>cursor = db.cursor()
>cursor.execute("SELECT * from django_flatpage where id != 2")
>details = [row for row in cursor.fetchall()]
>db.close()
>

Why are you bypassing the Django ORM and creating your own DB connection,
etc. for this?  That's a whole lot of work and you lose all the nice things
the ORM provides you with, including setting up the DB connection so that
MySQL returns data utf-8 encoded instead of its default latin1.  The
question marks are coming from the fact that the data you have can't be
encoded in latin1, so MySQL returns ? for each Unicode character it can't
send over a connection that only accepts latin1.

You could fix your db connection to return utf8, but this whole chunk would
be much more simply written as:

details = FlatPage.objects.exclude(pk=2)

and then in your template instead of:

   {% for id,url, title,content in details %}
   {{title|safe}}
   {% endfor %}

you would use:

   {% for fp in details %}
   {{fp.title|safe}}
   {% endfor %}

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Redirect home page

2009-10-12 Thread ashbii

I second Graeme's suggestion.  It should make your life easier
regarding translations.

On Oct 11, 1:54 pm, Graeme Glass  wrote:
> On Oct 11, 12:24 am, Caisys  wrote:
>
> > Hi,
> > I would like visitors to my site homepagewww.example.comtobe
> > redirected towww.example.com/en/inorder to allow for translations
> > in the future.
>
> > What is the most efficient way?
>
> > 1- Use apache mod-rewrite?
> > 2- I know i could use the HttpResponseRedirect function in django but
> > i felt it might be wasteful to create a view only for this purpose.
> > 3- Use a response header?
>
> > Thanks
>
> Is that not what the trans tags and internationalization are 
> for?http://docs.djangoproject.com/en/dev/topics/i18n/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Logging mechanism in Django

2009-10-12 Thread Robert Mela
If you're running standalone WSGI you could pipe output to Apache's 
rotatelogs or to cronolog.   There may be other generic log rotation 
subprocesses you can use.   They're very reliable.

For a straight WSGI server I wrote a logging handler to synchronize 
logging between threads & processes, which doesn't involve rename for 
log file rotation ( logs instead to files created with date or time 
stamps as part of their filenames -- the alternative was a log.lck file 
to synchronize log file rotation/creation).

The same method ( indeed the same code -- since it plugs into Python's 
standard logging framework ) would be fine for Django as well.

Perhaps I didn't dig deeply enough -- these things aren't hard to write 
-- but the python std logging library doesn't seem to offer a 
multiprocessing safe logging handler -- which is odd, since it is 
essential in a multiprocess environment.   ( A multiprocess environment 
in turn is essential due to the impairment Python's GIL places on 
concurrency )


Lokesh Maremalla wrote:
> Hi,
>
> Included django-logging as described in the link.
>
> From the django-logging I can view the log messages on the screen at 
> run time. But, I am not sure on saving the log messages from 
> django-logging.
> Can I capture the log messages into my log file on a daily basis 
> instead of redirecting to screen.
>
> Regards,
> Lokesh
>
> On Mon, Aug 17, 2009 at 9:16 PM, Mike Ramirez  > wrote:
>
> On Monday 17 August 2009 07:56:48 am Lokesh wrote:
> > Hi,
> >
> > I am trying to implement the logging (Code flow tracking) for my
> > Django application.
> > I would like to store the log messages on daily basis for my
> > applications.
> >
> > Need help or suggestions on how we can implement the logging
> mechanism
> > for an application.
> >
> > Regards,
> > Lokesh
>
>
> You can look at django-logging [1], it intergrates the python
> logging module
> with django as middleware.
>
> [1] http://code.google.com/p/django-logging/wiki/Overview
>
> Mike
>
> --
> I feel like I am sharing a ``CORN-DOG'' with NIKITA KHRUSCHEV ...
>
>
>
>
> -- 
> Thanks & Regards,
> Lokesh.
> lokeshmarema...@gmail.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---

<>

Re: Commercial Photo App?

2009-10-12 Thread Phoebe Bright gmail

Daniel,
Was hoping more for a good photo app that had a checkout rather than a  
shop that could sell photos.
They will take 100s of photos at each event, so handling the photos -  
tagging, viewing etc. is important.

Phoebe.

On 12 Oct 2009, at 12:52, Daniel Roseman wrote:

>
> On Oct 12, 10:33 am, phoebebright  wrote:
>> Are there any django apps suitable for a events photographer who  
>> wants
>> to sell their photos online?
>
> I believe Satchmo has the facility to sell downloads as well as
> physical products.
> --
> DR.
> >


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



Re: __unicode__(self) doesn't work

2009-10-12 Thread Ramiro Morales

On Mon, Oct 12, 2009 at 2:19 AM, Denis Bahati  wrote:
> if i change the code like the one shown below it gives me the traceback
> about indents, i also included below.
> from django.db import models
> import datetime
> class Poll(models.Model):
>     question = models.CharField(max_length=200)
>     pub_date = models.DateTimeField('date published')
> def __unicode__(self):
> return self.question
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
> was_published_today.short_description = 'Published today?'
>
> class Choice(models.Model):
>     poll = models.ForeignKey(Poll)
>     choice = models.CharField(max_length=200)
>     votes = models.IntegerField()
> def __unicode__(self):
> return self.choice

No, it is stell wrong. Your model definitions need to
look like this:

  http://dpaste.com/hold/106119/

Note how the methods are indented at the same level of the model
field definitions because both of them pertain th the same class
(the model).

I'd suggest to read some Python material to familiarize yourself
with indentation rules and class definitions.

Regards,

-- 
Ramiro Morales  |  http://rmorales.net

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



Re: Commercial Photo App?

2009-10-12 Thread Daniel Roseman

On Oct 12, 10:33 am, phoebebright  wrote:
> Are there any django apps suitable for a events photographer who wants
> to sell their photos online?

I believe Satchmo has the facility to sell downloads as well as
physical products.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin url error

2009-10-12 Thread A_Swtos

Thank you DR for your useful help :)

On Oct 12, 2:40 pm, Daniel Roseman  wrote:
> On Oct 12, 11:28 am, A_Swtos  wrote:
>
>
>
>
>
> > I'm new in django and i try to do what tutorial says about activating
> > the admin site but i take the following error:
>
> > IndentationError at /admin/
> > ('unexpected indent', ('/home/sotathan/mysite/../mysite/urls.py', 4,
> > 1, ' from django.contrib import admin\n'))
> > Request Method: GET
> > Request URL:    http://127.0.0.1:8000/admin/
> > Exception Type: IndentationError
> > Exception Value:
> > ('unexpected indent', ('/home/sotathan/mysite/../mysite/urls.py', 4,
> > 1, ' from django.contrib import admin\n'))
> > Exception Location:     /usr/local/lib/python2.6/dist-packages/django/
> > utils/importlib.py in import_module, line 35
> > Python Executable:      /usr/bin/python
> > Python Version: 2.6.2
>
> > my code:
>
> > settings.py:
> > ...
> > INSTALLED_APPS = (
> >     'django.contrib.admin',
> >     'django.contrib.auth',
> >     'django.contrib.contenttypes',
> >     'django.contrib.sessions',
> >     'django.contrib.sites',
> > )
>
> > urls.py:
>
> > from django.conf.urls.defaults import *
>
> >  from django.contrib import admin
> >  admin.autodiscover()
>
> > urlpatterns = patterns('',
> >      (r'^admin/', include(admin.site.urls)),
> > )
>
> > Any help?
>
> Like the message says, you have indentation problems in urls.py. From
> the code you've pasted above, it looks like you've got extra spaces at
> the start of these lines:
>  from django.contrib import admin
>  admin.autodiscover()
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin url error

2009-10-12 Thread Daniel Roseman

On Oct 12, 11:28 am, A_Swtos  wrote:
> I'm new in django and i try to do what tutorial says about activating
> the admin site but i take the following error:
>
> IndentationError at /admin/
> ('unexpected indent', ('/home/sotathan/mysite/../mysite/urls.py', 4,
> 1, ' from django.contrib import admin\n'))
> Request Method: GET
> Request URL:    http://127.0.0.1:8000/admin/
> Exception Type: IndentationError
> Exception Value:
> ('unexpected indent', ('/home/sotathan/mysite/../mysite/urls.py', 4,
> 1, ' from django.contrib import admin\n'))
> Exception Location:     /usr/local/lib/python2.6/dist-packages/django/
> utils/importlib.py in import_module, line 35
> Python Executable:      /usr/bin/python
> Python Version: 2.6.2
>
> my code:
>
> settings.py:
> ...
> INSTALLED_APPS = (
>     'django.contrib.admin',
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
> )
>
> urls.py:
>
> from django.conf.urls.defaults import *
>
>  from django.contrib import admin
>  admin.autodiscover()
>
> urlpatterns = patterns('',
>      (r'^admin/', include(admin.site.urls)),
> )
>
> Any help?

Like the message says, you have indentation problems in urls.py. From
the code you've pasted above, it looks like you've got extra spaces at
the start of these lines:
 from django.contrib import admin
 admin.autodiscover()
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



admin url error

2009-10-12 Thread A_Swtos

I'm new in django and i try to do what tutorial says about activating
the admin site but i take the following error:

IndentationError at /admin/
('unexpected indent', ('/home/sotathan/mysite/../mysite/urls.py', 4,
1, ' from django.contrib import admin\n'))
Request Method: GET
Request URL:http://127.0.0.1:8000/admin/
Exception Type: IndentationError
Exception Value:
('unexpected indent', ('/home/sotathan/mysite/../mysite/urls.py', 4,
1, ' from django.contrib import admin\n'))
Exception Location: /usr/local/lib/python2.6/dist-packages/django/
utils/importlib.py in import_module, line 35
Python Executable:  /usr/bin/python
Python Version: 2.6.2


my code:

settings.py:
...
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
)


urls.py:

from django.conf.urls.defaults import *

 from django.contrib import admin
 admin.autodiscover()

urlpatterns = patterns('',
 (r'^admin/', include(admin.site.urls)),
)


Any help?

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



Commercial Photo App?

2009-10-12 Thread phoebebright

Are there any django apps suitable for a events photographer who wants
to sell their photos online?


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



Django-ModelStore: Turn your Django models into Dojo data stores

2009-10-12 Thread BenW

I've been working on a reusable app to easily serialize my Django
models into JSON data that can be used in Dojo data stores.

The result is a set of classes that allow you to define a Store nearly
the same as you define a Model or a Form.  It also includes a JSON-RPC
v1.1 service method dispatcher and rpc API to easily add remote
functionality to your stores.

The code's hosted here:
https://launchpad.net/django-modelstore

The docs are here:
http://sites.google.com/site/djangomodelstore/

I'd really love some feedback!

Thanks,

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



Re: Current Django tests fail?

2009-10-12 Thread Russell Keith-Magee

On Mon, Oct 12, 2009 at 4:14 PM, Tim Chase
 wrote:
>
> Got the following while testing latest trunk and haven't touched
> this file (runtests.py).
>
> t...@rubbish:~/code/django/trunk/tests$ python runtests.py
> --settings=settings
> ==
> ERROR: runTest (__main__.InvalidModelTestCase)
> --
> Traceback (most recent call last):
>   File "runtests.py", line 80, in runTest
>     expected = module.model_errors.split('\n')
> AttributeError: 'NoneType' object has no attribute 'model_errors'
>
> --
> Ran 867 tests in 3245.410s
>
> FAILED (errors=1)
>
>
>
> Is there something obvious I missed?

I just ran the full suite usine SQLite on r11603, and got 100% pass on
917 tests.

I can't think of an obvious cause, but the fact that you're getting
errors in runtests.py is mighty suspicious. The fact that you've got
50 less tests than you should is also suspicious.

My first guess would be to look at PYTHONPATH issues - are you sure
that Python isn't picking up a runtests.py and/or a Django install
from somewhere other than the trunk checkout you are trying to test?

Yours,
Russ Magee %-)

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



announcing django-selectreverse

2009-10-12 Thread koenb

It is quite common to have templates with lists traversing reverse
foreignkey relationships or m2m relationships, which generate a lot of
queries, for example:

{% for building in buildinglist %}
  Building: {{ building }}
  Appartments:
  
{% for appartment in building.appartment_set.all %}
  {{ appartment.number }}
{% endfor %}
  
{% endfor %}

to reduce the querycount you can use some tricks to fetch the child
items for each parent in a separate query.

I abstracted these tricks into a custom manager and created a project
for it, called django-selectreverse.

It allows you to reduce the querycount in the example above to only
two queries, regardless of the number of buildings.

All you need to do is use this custom manager and in your view use it
to prefetch the child elements like this:
buildinglist = Building.objects.select_reverse({'appartments':
'appartment_set'})

Want to know more? Check out django-selectreverse at
http://code.google.com/p/django-selectreverse/ .
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to get back to a view requiring login

2009-10-12 Thread Rama Vadakattu

Very simple:

1.Once you are in login page you need to store url to which you need
to go.

   How should you do that?

   protected view
   ===
def protected_view(request) :
  if user is not authenticated :
  url = request.getpath()  # method which actually
gives you the url of the protected page
   #pass this url to the login page

  render_to_response(...,
{'url':url} .}

login page.html
===
 http://www.tumbletooth.org
> my linkedin profile :http://www.linkedin.com/in/bayuadji
> --
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Current Django tests fail?

2009-10-12 Thread Chris Withers

Tim Chase wrote:
> Is there something obvious I missed?

Hi Tim,

I do wonder if you might get more help with these problems on the Django 
developers list?

cheers,

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

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



Re: Foreign language in View Model.

2009-10-12 Thread Rizwan

I did change my encoding to utf-8. As its showing character very well
in flatpages. I would like extend this flatpage view code. so I have
lookup from database which render foreign string which not displaying
as it should be.

Thanks,

On 11 Oct, 11:59, Joshua Russo  wrote:
> You may want to check how the encoding is set in your database. Make sure
> you are using utf-8.
>
> On Sat, Oct 10, 2009 at 9:43 PM, Rizwan  wrote:
>
> > I am trying to extend flatpage view...I have added custom code
> > here..you can see navigation showing question mark here
> >http://beta.rmansuri.net/homepage/
>
> > from django.contrib.flatpages.models import FlatPage
> > from django.template import loader, RequestContext
> > from django.shortcuts import get_object_or_404
> > from django.http import HttpResponse, HttpResponseRedirect
> > from django.conf import settings
> > from django.core.xheaders import populate_xheaders
> > from django.utils.safestring import mark_safe
> > import datetime, MySQLdb
> > DEFAULT_TEMPLATE = 'flatpages/default.html'
>
> > def flatpage(request, url):
> >    """
> >    Flat page view.
>
> >    Models: `flatpages.flatpages`
> >    Templates: Uses the template defined by the ``template_name``
> > field,
> >        or `flatpages/default.html` if template_name is not defined.
> >    Context:
> >        flatpage
> >            `flatpages.flatpages` object
> >    """
> >    if not url.endswith('/') and settings.APPEND_SLASH:
> >        return HttpResponseRedirect("%s/" % request.path)
> >    if not url.startswith('/'):
> >        url = "/" + url
> >    f = get_object_or_404(FlatPage, url__exact=url,
> > sites__id__exact=settings.SITE_ID)
> >    # If registration is required for accessing this page, and the
> > user isn't
> >    # logged in, redirect to the login page.
> >    if f.registration_required and not request.user.is_authenticated
> > ():
> >        from django.contrib.auth.views import redirect_to_login
> >        return redirect_to_login(request.path)
> >    if f.template_name:
> >        t = loader.select_template((f.template_name,
> > DEFAULT_TEMPLATE))
> >    else:
> >        t = loader.get_template(DEFAULT_TEMPLATE)
>
> >    # To avoid having to always use the "|safe" filter in flatpage
> > templates,
> >    # mark the title and content as already safe (since they are raw
> > HTML
> >    # content in the first place).
> >    f.title = mark_safe(f.title)
> >    f.content = mark_safe(f.content)
>
> >    #custom code start
> >    db = MySQLdb.connect
> > (user='rmansuri_gq',db='rmansuri_gq',passwd='riz#wan1712',host='localhost')
> >    cursor = db.cursor()
> >    cursor.execute("SELECT * from django_flatpage where id != 2")
> >    details = [row for row in cursor.fetchall()]
> >    db.close()
> >    # custom code ends
> >    c = RequestContext(request, {
> >        'flatpage': f, 'details':details,
> >    })
> >    response = HttpResponse(t.render(c))
> >    populate_xheaders(request, response, FlatPage, f.id)
> >    return response
>
> > HTML CODE
>
> >  >www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> > http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">
> > 
> >   
> >        
> >        
> >        
> >        {{flatpage.title}}
> >         > media="screen" />
> >        
> >        
> >        
> > 
>
> > 
> > 
> > 
> > Gujarati Quran > h2>
> > 
> > 
> > home
> > about
> > contact
> > 
> > 
> > 
> > 
> > [+] |
> >  > href="javascript:ts('body',-1)">[-]
> > 
> >  {{flatpage.title}}
> >  {{flatpage.content}}
> >  
> > 
> > 
> > 
>
> >    {% for id,url, title,content in details %}
> >        {{title|safe}}
> >    {% endfor %}
>
> > 
> >        
> >                Recent Entries
> >                
> >                        Recent Entries1 01 Des
> > 06
> >                        Recent Entries2 01 Des
> > 06
> >                        Recent Entries3 01 Des
> > 06
> >                        Recent Entries4 01 Des
> > 06
> >                        Recent Entries5 01 Des
> > 06
> >                
> >        
> > 
> > 
> > 
> > http://www.rmansuri.net/;
> > rel="external">rMansuri.net. Valid http://jigsaw.w3.org/
> > css-validator/check/referer" rel="external">CSS   > href="http://validator.w3.org/check?uri=referer; rel="external">XHTML > a>
> > 
> > 
>
> > 
> > 
>
> > On 10 Oct, 20:40, Joshua Russo  wrote:
> > > On Sat, Oct 10, 2009 at 9:15 AM, Rizwan 
> > wrote:
>
> > > > Hello Djangoer,
>
> > > > I am trying to create website with foreign language in it. I have
> > > > created model for content type and added one page in it. It saving
> > > > fine in database. When I have tried to write view model for this page.
> > > > Its showing me "?" rather then foreign character. I am new born
> > > > baby in django world. any help or suggestion would be great.
>
> > > > you can see the this question mark athttp://
> > beta.rmansuri.net/surah/001/
>
> > > Without the code from your view (and 

Re: reverse() and Django with fastcgi behind lighty with sockets

2009-10-12 Thread Almad

On Oct 12, 1:32 am, sleepyjames  wrote:
> you need to set FORCE_SCRIPT_NAME in your settings.
>
> http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name


Missed that - thanks!

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



Re: regex infinite loop with 100% cpu use in django.forms.fields.email_re - DOS hole?

2009-10-12 Thread Tom Evans

On Fri, 2009-10-09 at 12:21 -0700, davisd wrote:
> Sorry for the public disclosure...  I did email django security after
> I posted.  I'm just getting into this open source goodness and I'm not
> really sure how it's supposed to operate yet.
> 
> I did consult the documentation: 
> http://docs.djangoproject.com/en/dev/internals/contributing/
> 
> Jacob:
> I'm running django from SVN
> Python 2.6.2
> I believe the Operating system is moot- it's all in the python.
> Linux kernel 2.6.31-11, but also 2.6.18.8 -
> 
> I'm wondering if a multithreaded webserver setup would be more guarded
> against this sort of thing?
> 

This bug has no effect on FreeBSD systems I've tested, so it looks like
it is OS specific.

FreeBSD 7.0, 7.1, 7.2 + python 2.5.4 work fine.

> $ time python -c "from django.forms.fields import email_re; 
> email_re.match('viewx3dtextx26q...@yahoo.comx26latlngx3d15854521645943074058');
>  import django; print django.VERSION"
(1, 1, 0, 'final', 0)

real0m0.086s
user0m0.055s
sys 0m0.029s


Linux 2.6.27 + python 2.5.4 fails.

> $ time python -c "from django.forms.fields import email_re; 
> email_re.match('viewx3dtextx26q...@yahoo.comx26latlngx3d15854521645943074058');
>  import django; print django.VERSION"
^CTraceback (most recent call last):
  File "", line 1, in 
KeyboardInterrupt

real0m21.317s
user0m21.173s
sys 0m0.044s


Cheers

Tom


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



Current Django tests fail?

2009-10-12 Thread Tim Chase

Got the following while testing latest trunk and haven't touched 
this file (runtests.py).

t...@rubbish:~/code/django/trunk/tests$ python runtests.py 
--settings=settings
==
ERROR: runTest (__main__.InvalidModelTestCase)
--
Traceback (most recent call last):
   File "runtests.py", line 80, in runTest
 expected = module.model_errors.split('\n')
AttributeError: 'NoneType' object has no attribute 'model_errors'

--
Ran 867 tests in 3245.410s

FAILED (errors=1)



Is there something obvious I missed?

-tim





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



Re: Hi All: __unicode__(self)

2009-10-12 Thread Kenneth Gonsalves

On Monday 12 Oct 2009 11:25:27 am Russell Keith-Magee wrote:
> On Mon, Oct 12, 2009 at 1:44 PM, Kenneth Gonsalves
>
>  wrote:
> > On Monday 12 Oct 2009 11:05:38 am Denis Bahati wrote:
> >> class Poll(models.Model):
> >> question = models.CharField(max_length=200)
> >> pub_date = models.DateTimeField('date published')
> >> def __unicode__(self):
> >> return self.question
> >> def was_published_today(self):
> >> return self.pub_date.date() == datetime.date.today()
> >> def was_published_today(self):
> >> return self.pub_date.date() == datetime.date.today()
> >> was_published_today.short_description = 'Published today?'
> >
> > please learn some python!
>
> Kenneth - please learn some manners. You have repeatedly demonstrated
> on this list that you have a deep yearning for brevity. However, let
> me assure you that it really doesn't take that much effort to write in
> whole sentences (with capitalization and everything). If you throw in
> some politeness while you are at it, all the better.

I think this is uncalled for - granted I tend to be brief. In this case, I 
replied once, he re-posted and (using the word 'please') I pointed out that 
his problem is due to lack of python knowledge. What is rude about it? Maybe 
the solution I gave is wrong. Or maybe I should not have given a solution and 
just stopped with asking him to learn some python? Anyway, I do not want to 
make an issue of this - at least I hope *this* post correctly follows 
grammatical rules.
-- 
regards
kg
http://lawgon.livejournal.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Hi All: __unicode__(self)

2009-10-12 Thread Denis Bahati
Thank in advance for the advices.

On Mon, Oct 12, 2009 at 8:55 AM, Russell Keith-Magee  wrote:

>
> On Mon, Oct 12, 2009 at 1:44 PM, Kenneth Gonsalves
>  wrote:
> >
> > On Monday 12 Oct 2009 11:05:38 am Denis Bahati wrote:
> >> class Poll(models.Model):
> >> question = models.CharField(max_length=200)
> >> pub_date = models.DateTimeField('date published')
> >> def __unicode__(self):
> >> return self.questiona
> >> def was_published_today(self):
> >> return self.pub_date.date() == datetime.date.today()
> >> def was_published_today(self):
> >> return self.pub_date.date() == datetime.date.today()
> >> was_published_today.short_description = 'Published today?'
> >
> > please learn some python!
>
> Kenneth - please learn some manners. You have repeatedly demonstrated
> on this list that you have a deep yearning for brevity. However, let
> me assure you that it really doesn't take that much effort to write in
> whole sentences (with capitalization and everything). If you throw in
> some politeness while you are at it, all the better.
>
> Yours,
> Russ Magee %-)
>
> >
>

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



Re: FlatPage.objects.filter method: content_icontains attribute does not exist

2009-10-12 Thread Russell Keith-Magee

On Mon, Oct 12, 2009 at 2:41 PM, chris  wrote:
>
> Hello,
>
> I am trying to work my way through Practical Django Projects (a book
> by James Bennett 1st edition 2008).  I'm on chapter 3 page 28 where a
> search function is being added to the 'cms' project.  The
> results=FlatPage.objects.filter(content_icontains=query) does not
> work; it looks like the content_icontains attribute isn't recognize by
> the 'filter' method.  I've tried looking through the django api but
> don't understand how it's set up.  What is the fix required here?

Have you typed content_icontains like your email suggests, or
content__icontains (note the double underscore)? Django uses a double
underscore to separate joins and query conditions from attribute
names.

Yours,
Russ Magee %-)

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



Re: Problem - sometimes I get blank pages

2009-10-12 Thread Roodie

Nothing at all, that's the main problem we face diagnosing the
problem.

Roodie

On okt. 11, 19:10, akonsu  wrote:
> hello,
>
> is there anything in the web server logs?
>
> konstantin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FlatPage.objects.filter method: content_icontains attribute does not exist

2009-10-12 Thread chris

Hello,

I am trying to work my way through Practical Django Projects (a book
by James Bennett 1st edition 2008).  I'm on chapter 3 page 28 where a
search function is being added to the 'cms' project.  The
results=FlatPage.objects.filter(content_icontains=query) does not
work; it looks like the content_icontains attribute isn't recognize by
the 'filter' method.  I've tried looking through the django api but
don't understand how it's set up.  What is the fix required here?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Distance across a LineString in GeoDjango

2009-10-12 Thread Jani Tiainen

HARRY POTTRER kirjoitti:
> I have a model which represents a route. I can use the `make_line()`
> geoqueryset method to create a LineString like so:
> 
 r = Route.objects.get(pk=33)
 # a route from Seattle to New York to Miami, a total distance
 # of about 3043.8 nautical miles
 r
> 
 # a collection of the airports used in the route
 # turned into a LineString
 ls = Airport.objects.filter(routebase__route=r).make_line()
 ls
> 
> 
> How can I find the total distance of that LineString object, so that
> it returns a Distance object that I can then convert to nautical
> miles? the .length() method here just returns a float, which is in who-
> knows-what units...

It's exactly in the units that are specified in your SRS definition. To 
go beyond that you can use Distance to make math and conversions to 
another units..

Note that "length" gives linear distance, not spherical so in long 
distances you get a distorted length.

-- 
Jani Tiainen

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