Re: How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?

2011-01-03 Thread Daniel Roseman
On Tuesday, January 4, 2011 3:54:25 AM UTC, Chris Seberino wrote:
>
> How configure Django to handle /books URL and yet allow access to PDFs 
> and images in subdirs of /books? 
>
> Specifically, I want /books to be a dynamic page with lots of links to 
> PDFs and images of book covers contained in subdirectories of /books 
> like /books/some_book_1 and /books/some_book_1/book_cover.jpg. 
>
> cs


You'll need to configure your webserver to manage this, with some sort of 
URL rewriting - eg RewriteRule in Apache, or whatever the equivalent is in 
whatever you are using.
--
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-us...@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: Contact form doesn't see user as logged in

2011-01-03 Thread Kenneth Gonsalves
On Tue, 2011-01-04 at 08:38 +0100, Łukasz Rekucki wrote:
> How do you check that user is logged in ? If it's via request.user,
> then it doesn't work 'cause you
> aren't passing the request object to your template's context. The
> recomended way to do this is using RequestContext:
> 
> from django.template import RequestContext
> 
> return render_to_response('forms/contact.html', {'form': form},
> context_instance=RequestContext(request)) 

and add the context processor:
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
)


-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Contact form doesn't see user as logged in

2011-01-03 Thread Łukasz Rekucki
On 4 January 2011 02:27, Catalyst  wrote:
>  I am having trouble with a contact form on my site. Whenever I hit
> the page, it doesn't see that the user is logged in. Here's how my
> code looks.

How do you check that user is logged in ? If it's via request.user,
then it doesn't work 'cause you
aren't passing the request object to your template's context. The
recomended way to do this is using RequestContext:

from django.template import RequestContext

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

>
> 
> #forms.py
>
> from django import forms
> from django.utils.translation import ungettext, ugettext_lazy as _
>
> class ContactForm(forms.Form):
>    subject = forms.CharField()
>    email = forms.EmailField(required=False)
>    message =
> forms.CharField(widget=forms.Textarea(attrs={'rows':'20',
> 'cols':'75'}))
> 
>
>
> 
> #urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('myproject.forms.views',
>    (r'^contact-us/$', 'contact'),
> )
> 
>
>
> 
> #views.py
>
> from django.core.mail import send_mail
> from django.http import HttpResponseRedirect
> from django.shortcuts import render_to_response
> from myproject.forms.forms import ContactForm
>
> def contact(request):
>    if request.method == 'POST':
>        form = ContactForm(request.POST)
>        if form.is_valid():
>            cd = form.cleaned_data
>            send_mail(
>                cd['subject'],
>                cd['message']+'\nUser email '+cd['email'],
>                ('formemailaddr...@email.com'),
>                ['sendaddr...@email.com'],
>            )
>            return HttpResponseRedirect('/forms/thanks/')
>    else:
>        form = ContactForm()
>    return render_to_response('forms/contact.html', {'form': form})
> 
>
>
>  If I hit another page, the user still shows up as being logged in,
> just this one area (the contact form) doesn't. Even the thank you page
> shows the user as being logged in.
>
>  Anyone have any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>



-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Too many items in my drowndown list

2011-01-03 Thread mongoose
Thanks so much I'm going to give this a try!

On Jan 3, 1:54 pm, Greg Turner  wrote:
> Using a raw_id_field instead of a dropdown list will open a popup with a
> 'pseudo' django admin. The reason I call it 'pseudo' is that the list can be
> searched or filtered just like the normal django admin, but when you click
> on an item, it becomes the selected item in your inline, and the window
> closes.
>
> On 3 January 2011 18:55, mongoose  wrote:
>
>
>
> > Hi there,
>
> > I have a drowdown list in my inlines. The problem is that there are
> > over 3500 items which is making is difficult for people to use. Are
> > there eaiser ways perhaps to filter or search within the dropdownlist?
>
> > 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-us...@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.
>
> --
>
> Dr Greg Turner
> Director, the Interaction Consortiumhttp://interaction.net.au
> Phone: +61 2 8060 1067
> skype: gregturner
> Follow us on twitter:
>
> http://twitter.com/theixchttp://twitter.com/gsta

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Multi widget?

2011-01-03 Thread Sam Walters
Hi,

I think you are looking to override the widget render() method to
build multiple HTML form elements?
Here is a good example:

http://k0001.wordpress.com/2007/11/15/dual-password-field-with-django/

I have built heaps of these things, usually a choicefield + charfield,
charfield + charfield, charfield + datefield etc. Anything where you
want to be able to call clean() on multiple form elements because they
have some sort of interdependant logic.

Also for doing this looking directly at the django source code in
forms, fields and widgets is the best way to understand how it works.


cheers

sam_w

On Tue, Jan 4, 2011 at 2:08 AM, Ilian Iliev  wrote:
> Two widgets to one field? Can you specify this little bit more?
>
> On Mon, Jan 3, 2011 at 12:29 PM, robos85  wrote:
>>
>> Hi,
>> what I want to do, is to add 2 widgets to 1 field. So far I have:
>>
>> content =
>> forms.CharField(widget=forms.Textarea(attrs={'class':'add_editor'}),)
>>
>> But I also want to add some medi to it (tinymce .js files). How can I do
>> that?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>
>
>
> --
> eng. Ilian Iliev
> Web Software Developer
>
> Mobile: +359 88 66 08 400
> Website: http://ilian.i-n-i.org
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?

2011-01-03 Thread Chris Seberino
How configure Django to handle /books URL and yet allow access to PDFs
and images in subdirs of /books?

Specifically, I want /books to be a dynamic page with lots of links to
PDFs and images of book covers contained in subdirectories of /books
like /books/some_book_1 and /books/some_book_1/book_cover.jpg.

cs

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



Contact form doesn't see user as logged in

2011-01-03 Thread Catalyst
 I am having trouble with a contact form on my site. Whenever I hit
the page, it doesn't see that the user is logged in. Here's how my
code looks.


#forms.py

from django import forms
from django.utils.translation import ungettext, ugettext_lazy as _

class ContactForm(forms.Form):
subject = forms.CharField()
email = forms.EmailField(required=False)
message =
forms.CharField(widget=forms.Textarea(attrs={'rows':'20',
'cols':'75'}))




#urls.py
from django.conf.urls.defaults import *

urlpatterns = patterns('myproject.forms.views',
(r'^contact-us/$', 'contact'),
)




#views.py

from django.core.mail import send_mail
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from myproject.forms.forms import ContactForm

def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
cd['subject'],
cd['message']+'\nUser email '+cd['email'],
('formemailaddr...@email.com'),
['sendaddr...@email.com'],
)
return HttpResponseRedirect('/forms/thanks/')
else:
form = ContactForm()
return render_to_response('forms/contact.html', {'form': form})



  If I hit another page, the user still shows up as being logged in,
just this one area (the contact form) doesn't. Even the thank you page
shows the user as being logged in.

  Anyone have any ideas?

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



Solved: Re: Still mystified by [not a] mod_wsgi traceback ...

2011-01-03 Thread Stephen Waterbury

Ach, permissions problem.  After I disabled the error message in
d.c.a.m.RemoteUserMiddleware, I got an error message about the
database not being writable -- I'm using sqlite and forgot that
the *directory* containing the db file has to be writable (for the
temp file).  Doh!  So the real problem that the
d.c.a.m.AuthenticationMiddleware message got triggered by was that
the User it tried to create couldn't be saved (I infer) -- not a
very good error message for that!  (mod_wsgi works just fine! ;)

Steve

On 01/03/2011 04:36 PM, Stephen Waterbury wrote:

I posted the traceback I'm getting -- http://dpaste.com/293813/
I'm still completely mystified. The traceback directs me to:
"Edit your MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware'
before the RemoteUserMiddleware class." But looking further
up in the traceback, it sees that d.c.a.m.AuthenticationMiddleware
*is* there, and it's true -- I already have it in my
MIDDLEWARE_CLASSES setting before the RemoteUserMiddleware class,
so how could mod_wsgi possibly not be finding it?

See below for more details on my configuration ...

Steve

On 12/30/2010 06:17 PM, Stephen Waterbury wrote:

I am baffled, and it's probably something simple I'm missing ...
I just need to send a message for help and then I'll see it ...
(maybe ... ;)

My set up:
* apache2 on Ubuntu 10.04
* mod_wsgi 3.3, compiled with python 2.6.5 (the system python)
(but Ubuntu's mod_wsgi package was apparently not the problem)
* django installed in a virtualenv with python 2.6.5 also
* 2 django apps, one running on ':80' virtual host and one on
':8000' virtual host, each with a separate wsgi script (of course)
* apache server config (apache.conf) has WSGIPythonHome directive:
'WSGIPythonHome [path to virtualenv directory]'
* virtualenv directory has python interpreter in its bin dir and
python packages installed in its lib dir, including all django
libs
* I have verified that AuthenticationMiddleware can be imported
successfully from the command line within the virtualenv using
the virtualenv's python intepreter
* both django apps live within the virtualenv directory,
each in its own "project" directory there
* both apps are configured in apache with WSGIDaemonProcess directive

The error I continue to get is:

"ImproperlyConfigured at /

"The Django remote user auth middleware requires the
authentication middleware to be installed. Edit your
MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware' before
the RemoteUserMiddleware class."

The relevant sections of the settings.py files for the apps are:
--
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
---

Ultimately I'll be using Active Directory (Kerberos) auth, but for
purposes of testing the REMOTE_USER stuff I've configured Basic
Authentication, and it is working (I authenticate successfully
before seeing that error message).

Any suggestions welcome! (I can send the whole error page if it
would help, but I'll need to launder it a little.)

TIA!
Steve





--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Can't use dumpdata and loaddata to migrate non-ASCII data between databases

2011-01-03 Thread Eric Chamberlain
Or is there a better way to migrate a database from postgres to MySQL?


On Jan 3, 2011, at 6:35 PM, Eric Chamberlain wrote:

> Hi,
> 
> We are trying to migrate between databases and we are running into a problem 
> while trying to use dumpdata.  We've tried:
> 
>   ./manage.py dumpdata --natural --indent 2 > dump.json
> 
> and:
> 
>   ./manage.py dumpdata --natural --format xml --indent 2 > dump.xml
> 
> Both return the following error:
> 
>   Error: Unable to serialize database: 'ascii' codec can't encode 
> character u'\xe9' in position 18: ordinal not in range(128)
> 
> Is there a way to dump and load non-ASCII data?
> 
> 
> --
> Eric Chamberlain, Founder
> RF.com - http://RF.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-us...@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.



Can't use dumpdata and loaddata to migrate non-ASCII data between databases

2011-01-03 Thread Eric Chamberlain
Hi,

We are trying to migrate between databases and we are running into a problem 
while trying to use dumpdata.  We've tried:

./manage.py dumpdata --natural --indent 2 > dump.json

and:

./manage.py dumpdata --natural --format xml --indent 2 > dump.xml

Both return the following error:

Error: Unable to serialize database: 'ascii' codec can't encode 
character u'\xe9' in position 18: ordinal not in range(128)

Is there a way to dump and load non-ASCII data?


--
Eric Chamberlain, Founder
RF.com - http://RF.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-us...@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.



Bug when OR'ing an empty Q() with a non-empty Q()?

2011-01-03 Thread Margie Roginski
I find that if I filter by ORing an empty Q() with a non-empty Q()
that I don't get the expected result.  I would expect that this should
return all objects of the specified model that the empty Q() would
return.  Let me use an example to be more clear:

I have a single Task object with its name set to foo.

Task.objects.filter(Q()) gives me that one object:
[]

But:

Task.objects.filter(Q()|Q(name="bar"))

returns []

Is this a bug or am I misunderstanding something?  This is on Django
1.2.1

Thanks for any pointers,

Margie

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: to execute executable.py from view.py

2011-01-03 Thread gintare
One more related question.

Is it possible to use string in views.py as a function ( string from
textarea (in search.html ))

i.e.
# search.html

 input function name 



this search.html after being registered in urls.py shows input text
area.
I prompt to write the name of function.

I get this name as string in views.py in function def
search2(request):
query=request.GET.get('q',' ' )
i would like now to run this function, which was written in textarea,
 i.e to run function Word.objects.all()

One of ways is to use Sqlite cursor and execute strings.
Another way is to use case type structure, which match function name
in string with function name in cases.

How to run this function, which was written in textarea as string,
without sqlite and case structures?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 raise an error on django admin

2011-01-03 Thread Acorn
I'd like to know this too.

On 3 January 2011 17:25, rahul jain  wrote:
> Hi,
>
> How to display an error in django admin (the error should be displayed in
> red just like in forms)
>
> Something of this form
>
> http://groups.google.com/group/django-users/browse_thread/thread/68d4ea1915654134/447ef8473cf86672
>
> Thanks.
>
> Rahul
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django dev server issue

2011-01-03 Thread daniels
Just tried latest version of Django 1.2.4 and same issue
I'll try that. Never used pdb before so let's see how things will go.
I'll reply with updates.

On Jan 3, 11:35 pm, Shawn Milochik  wrote:
> On Jan 3, 2011, at 4:28 PM, Brian Bouterse wrote:
>
> > Have you tried using pdb to debug the call as it arrives?  You could step 
> > through the code, line by line that way to see what is hanging.
>
> > My 2 cents,
> > Brian
>
> I enthusiastically second this. If you're unfamiliar with pdb, check out this 
> slice of awesome:
>
> http://blog.doughellmann.com/2010/09/pymotw-pdb-interactive-debugger
>
> Incidentally, the Python doc page has just a bit that's not in the tutorial. 
> The only thing that springs to mind is the 'skip' argument, but you might 
> want to skim it. The debugger is a fantastic tool to have in your toolbox.
>
> http://docs.python.org/library/pdb
>
> Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Some problem with modelform save

2011-01-03 Thread robos85
THANKS. I overlooked it.

To work around this problem, every time you save a form using commit=False, 
Django adds a save_m2m() method to yourModelForm subclass. After you've 
manually saved the instance produced by the form, you can invoke save_m2m() to 
save the many-to-many form data.

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



Still mystified by mod_wsgi traceback ...

2011-01-03 Thread Stephen Waterbury

I posted the traceback I'm getting -- http://dpaste.com/293813/
I'm still completely mystified.  The traceback directs me to:
"Edit your MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware'
before the RemoteUserMiddleware class."  But looking further
up in the traceback, it sees that d.c.a.m.AuthenticationMiddleware
*is* there, and it's true -- I already have it in my
MIDDLEWARE_CLASSES setting before the RemoteUserMiddleware class,
so how could mod_wsgi possibly not be finding it?

See below for more details on my configuration ...

Steve

On 12/30/2010 06:17 PM, Stephen Waterbury wrote:

I am baffled, and it's probably something simple I'm missing ...
I just need to send a message for help and then I'll see it ...
(maybe ... ;)

My set up:
* apache2 on Ubuntu 10.04
* mod_wsgi 3.3, compiled with python 2.6.5 (the system python)
(but Ubuntu's mod_wsgi package was apparently not the problem)
* django installed in a virtualenv with python 2.6.5 also
* 2 django apps, one running on ':80' virtual host and one on
':8000' virtual host, each with a separate wsgi script (of course)
* apache server config (apache.conf) has WSGIPythonHome directive:
'WSGIPythonHome [path to virtualenv directory]'
* virtualenv directory has python interpreter in its bin dir and
python packages installed in its lib dir, including all django
libs
* I have verified that AuthenticationMiddleware can be imported
successfully from the command line within the virtualenv using
the virtualenv's python intepreter
* both django apps live within the virtualenv directory,
each in its own "project" directory there
* both apps are configured in apache with WSGIDaemonProcess directive

The error I continue to get is:

"ImproperlyConfigured at /

"The Django remote user auth middleware requires the
authentication middleware to be installed. Edit your
MIDDLEWARE_CLASSES setting to insert
'django.contrib.auth.middleware.AuthenticationMiddleware' before
the RemoteUserMiddleware class."

The relevant sections of the settings.py files for the apps are:
--
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.RemoteUserMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.RemoteUserBackend',
)
---

Ultimately I'll be using Active Directory (Kerberos) auth, but for
purposes of testing the REMOTE_USER stuff I've configured Basic
Authentication, and it is working (I authenticate successfully
before seeing that error message).

Any suggestions welcome! (I can send the whole error page if it
would help, but I'll need to launder it a little.)

TIA!
Steve



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Django dev server issue

2011-01-03 Thread Shawn Milochik

On Jan 3, 2011, at 4:28 PM, Brian Bouterse wrote:

> Have you tried using pdb to debug the call as it arrives?  You could step 
> through the code, line by line that way to see what is hanging.
> 
> My 2 cents,
> Brian

I enthusiastically second this. If you're unfamiliar with pdb, check out this 
slice of awesome:

http://blog.doughellmann.com/2010/09/pymotw-pdb-interactive-debugger.html

Incidentally, the Python doc page has just a bit that's not in the tutorial. 
The only thing that springs to mind is the 'skip' argument, but you might want 
to skim it. The debugger is a fantastic tool to have in your toolbox.

http://docs.python.org/library/pdb

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Some problem with modelform save

2011-01-03 Thread Daniel Roseman
On Monday, January 3, 2011 9:25:00 PM UTC, robos85 wrote:
>
> I use modelform. All works fine. Validation is ok and I want to save my 
> form. Before saving I need to populate user_id into my modelform so i make 
> something like this:
> if form.is_valid():
>
> obj = form.save(commit=False)
>
>   obj.user = request.user
>   obj.save()
>
> It seems to be ok. Form is saved to DB BUT!: I use 
> categories = models.ManyToManyField(Category)
>
> When I use the method above - categories aren't saved into DB :(
> When I do form.save() - categories are added but User object not :(
>
> Am I something missing?
>

This is explicitly documented here:
http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#the-save-method
(third paragraph after the green box).
--
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-us...@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: Django dev server issue

2011-01-03 Thread Brian Bouterse
Have you tried using pdb to debug the call as it arrives?  You could step
through the code, line by line that way to see what is hanging.

My 2 cents,
Brian

On Mon, Jan 3, 2011 at 4:26 PM, daniels  wrote:

> I just tested with sock Python 2.6.6 from the link you gave me and
> also tried with Python 2.7
> and I'm still having this issue. It is really weird. Like i said 3 out
> of 5 page refresh the browser hangs,
> and if i press stop button i get the same exception trowed.
>
> :(
>
> On Jan 3, 9:36 pm, "W. Craig Trader"  wrote:
> > I'm currently developing on Windows 7 (64-bit) with stock Python 2.6.6
> > (32-bit) and Django 1.2.3, and having no problems when running the Django
> > development server from the command line.
> >
> > I'd recommend using the normal Python (
> http://www.python.org/download/releases/2.6.6/) instead of ActivePython
> and
> > see if that improves things.
> >
> > - Craig -
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jan 3, 2011 at 14:09, daniels  wrote:
> > > Hi,
> > > Unfortunately i did not found the case, and i'm getting it pretty
> > > often, about 3 out of 5 times i refresh the page.
> > > If i leave it loading and i don't stop it it stays like that for about
> > > 30-40 seconds and then the page loads.
> > > I just don't understand what is causing this.
> > > I've restarted the server like 10 time or more from the first time i
> > > got this and i'm still getting it every time i run it.
> >
> > > My Python version is : ActivePython 2.6.6.17 (ActiveState Software
> > > Inc.) based on
> > > Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit
> > > (Intel)] on
> > > win32
> >
> > > and Django: (1, 2, 3, 'final', 0)
> >
> > > I did a lot of dev on Windows 7 before but i never had this issue. So
> > > my thoughts are that this is either
> > > related to this Django version or Python version.
> >
> > > On Jan 3, 5:43 pm, Tiago Almeida  wrote:
> > > > Hi,
> >
> > > > Your files seem fine, I believe.
> > > > Have you found the cause? What version of python and django are you
> > > > using? I also have this issue but it is not often enough for me to
> > > > worry too much. Killing the server and restarting it solves it for
> > > > me..
> >
> > > > BR,
> > > > 
> >
> > > > On 3 Jan, 08:00, daniels  wrote:
> >
> > > > > Here are the relevant files:
> >
> > > > > myproject/urls.py
> > > > > --
> > > > > from django.conf.urls.defaults import *
> > > > > from django.conf import settings
> >
> > > > > # Uncomment the next two lines to enable the admin:
> > > > > # from django.contrib import admin
> > > > > # admin.autodiscover()
> >
> > > > > urlpatterns = patterns('',
> > > > > (r'^$', include('myproject.apps.acasa.urls')),
> >
> > > > > # Dev only
> > > > > (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > > {'document_root': settings.MEDIA_ROOT}),
> >
> > > > > # Uncomment the admin/doc line below to enable admin
> > > > > documentation:
> > > > > # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> >
> > > > > # Uncomment the next line to enable the admin:
> > > > > # (r'^admin/', include(admin.site.urls)),
> > > > > )
> >
> > > > > myproject/apps/acasa/urls.py
> > > > > ---
> > > > > from django.conf.urls.defaults import *
> >
> > > > > urlpatterns = patterns('myproject.apps.acasa.views',
> > > > > (r'^$', 'index'),
> > > > > )
> >
> > > > > myproject/apps/acasa/views.py
> > > > > -
> > > > > from django.template  import RequestContext
> > > > > from django.shortcuts import render_to_response
> >
> > > > > def index(request):
> > > > > return render_to_response('acasa/default.html',
> > > > > context_instance=RequestContext(request))
> >
> > > > > myproject/templates/base.html
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > Myproject - {% block title %}{% endblock %}
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > >  > > > > media="all" />
> > > > > 

Re: Django dev server issue

2011-01-03 Thread daniels
I just tested with sock Python 2.6.6 from the link you gave me and
also tried with Python 2.7
and I'm still having this issue. It is really weird. Like i said 3 out
of 5 page refresh the browser hangs,
and if i press stop button i get the same exception trowed.

:(

On Jan 3, 9:36 pm, "W. Craig Trader"  wrote:
> I'm currently developing on Windows 7 (64-bit) with stock Python 2.6.6
> (32-bit) and Django 1.2.3, and having no problems when running the Django
> development server from the command line.
>
> I'd recommend using the normal Python 
> (http://www.python.org/download/releases/2.6.6/) instead of ActivePython and
> see if that improves things.
>
> - Craig -
>
>
>
>
>
>
>
> On Mon, Jan 3, 2011 at 14:09, daniels  wrote:
> > Hi,
> > Unfortunately i did not found the case, and i'm getting it pretty
> > often, about 3 out of 5 times i refresh the page.
> > If i leave it loading and i don't stop it it stays like that for about
> > 30-40 seconds and then the page loads.
> > I just don't understand what is causing this.
> > I've restarted the server like 10 time or more from the first time i
> > got this and i'm still getting it every time i run it.
>
> > My Python version is : ActivePython 2.6.6.17 (ActiveState Software
> > Inc.) based on
> > Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit
> > (Intel)] on
> > win32
>
> > and Django: (1, 2, 3, 'final', 0)
>
> > I did a lot of dev on Windows 7 before but i never had this issue. So
> > my thoughts are that this is either
> > related to this Django version or Python version.
>
> > On Jan 3, 5:43 pm, Tiago Almeida  wrote:
> > > Hi,
>
> > > Your files seem fine, I believe.
> > > Have you found the cause? What version of python and django are you
> > > using? I also have this issue but it is not often enough for me to
> > > worry too much. Killing the server and restarting it solves it for
> > > me..
>
> > > BR,
> > > 
>
> > > On 3 Jan, 08:00, daniels  wrote:
>
> > > > Here are the relevant files:
>
> > > > myproject/urls.py
> > > > --
> > > > from django.conf.urls.defaults import *
> > > > from django.conf import settings
>
> > > > # Uncomment the next two lines to enable the admin:
> > > > # from django.contrib import admin
> > > > # admin.autodiscover()
>
> > > > urlpatterns = patterns('',
> > > >     (r'^$', include('myproject.apps.acasa.urls')),
>
> > > >     # Dev only
> > > >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > {'document_root': settings.MEDIA_ROOT}),
>
> > > >     # Uncomment the admin/doc line below to enable admin
> > > > documentation:
> > > >     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> > > >     # Uncomment the next line to enable the admin:
> > > >     # (r'^admin/', include(admin.site.urls)),
> > > > )
>
> > > > myproject/apps/acasa/urls.py
> > > > ---
> > > > from django.conf.urls.defaults import *
>
> > > > urlpatterns = patterns('myproject.apps.acasa.views',
> > > >     (r'^$', 'index'),
> > > > )
>
> > > > myproject/apps/acasa/views.py
> > > > -
> > > > from django.template  import RequestContext
> > > > from django.shortcuts import render_to_response
>
> > > > def index(request):
> > > >     return render_to_response('acasa/default.html',
> > > >         context_instance=RequestContext(request))
>
> > > > myproject/templates/base.html
> > > > 
> > > > 
> > > > 
> > > > 
> > > >     Myproject - {% block title %}{% endblock %}
> > > >     
> > > >     
> > > >     
> > > >     
> > > >      > > > media="all" />
> > > >     

Some problem with modelform save

2011-01-03 Thread robos85
I use modelform. All works fine. Validation is ok and I want to save my 
form. Before saving I need to populate user_id into my modelform so i make 
something like this:
if form.is_valid():

obj = form.save(commit=False)

  obj.user = request.user
  obj.save()

It seems to be ok. Form is saved to DB BUT!: I use 
categories = models.ManyToManyField(Category)

When I use the method above - categories aren't saved into DB :(
When I do form.save() - categories are added but User object not :(

Am I something missing?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 with validating ModelForm

2011-01-03 Thread robos85
I've written that part of form subclass:
def clean_title(self):
data = self.cleaned_data['title']
counter = Article.objects.filter(title__iexact = data).count()
if counter > 0:
raise forms.ValidationError('my message')
return data

Is that right?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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, unobtrusive JavaScript and cross-site scripting

2011-01-03 Thread Mo Mughrabi
Hi,
am wondering if there is a manual/tutorial that talks about advance use
of JavaScripting and django, using existing frameworks such as JQuery or
Prototype, generating unobtrusive JavaScripting with no inline
Javascripting.

Another question, is there a place where I can read about cross-site
scripting and how I can protect my django project from such a thing?

Regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 with validating ModelForm

2011-01-03 Thread robos85
Could You give me some frame, how it should be? I've never done it before:/
I have that added:
def clean_title(self):
data = self.cleaned_data['title']
return data
But how to check if that field is unique? Is there some special way, or just 
to write simple query to check it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 with validating ModelForm

2011-01-03 Thread robos85
Could You give me some frame, how it should be? I've never done it before:/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 with validating ModelForm

2011-01-03 Thread Shawn Milochik
You can do this by creating a custom clean function for your field:

http://docs.djangoproject.com/en/1.2/ref/forms/validation/

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django dev server issue

2011-01-03 Thread W. Craig Trader
I'm currently developing on Windows 7 (64-bit) with stock Python 2.6.6
(32-bit) and Django 1.2.3, and having no problems when running the Django
development server from the command line.

I'd recommend using the normal Python (
http://www.python.org/download/releases/2.6.6/) instead of ActivePython and
see if that improves things.

- Craig -

On Mon, Jan 3, 2011 at 14:09, daniels  wrote:

> Hi,
> Unfortunately i did not found the case, and i'm getting it pretty
> often, about 3 out of 5 times i refresh the page.
> If i leave it loading and i don't stop it it stays like that for about
> 30-40 seconds and then the page loads.
> I just don't understand what is causing this.
> I've restarted the server like 10 time or more from the first time i
> got this and i'm still getting it every time i run it.
>
> My Python version is : ActivePython 2.6.6.17 (ActiveState Software
> Inc.) based on
> Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit
> (Intel)] on
> win32
>
> and Django: (1, 2, 3, 'final', 0)
>
> I did a lot of dev on Windows 7 before but i never had this issue. So
> my thoughts are that this is either
> related to this Django version or Python version.
>
>
> On Jan 3, 5:43 pm, Tiago Almeida  wrote:
> > Hi,
> >
> > Your files seem fine, I believe.
> > Have you found the cause? What version of python and django are you
> > using? I also have this issue but it is not often enough for me to
> > worry too much. Killing the server and restarting it solves it for
> > me..
> >
> > BR,
> > 
> >
> > On 3 Jan, 08:00, daniels  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Here are the relevant files:
> >
> > > myproject/urls.py
> > > --
> > > from django.conf.urls.defaults import *
> > > from django.conf import settings
> >
> > > # Uncomment the next two lines to enable the admin:
> > > # from django.contrib import admin
> > > # admin.autodiscover()
> >
> > > urlpatterns = patterns('',
> > > (r'^$', include('myproject.apps.acasa.urls')),
> >
> > > # Dev only
> > > (r'^media/(?P.*)$', 'django.views.static.serve',
> > > {'document_root': settings.MEDIA_ROOT}),
> >
> > > # Uncomment the admin/doc line below to enable admin
> > > documentation:
> > > # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
> >
> > > # Uncomment the next line to enable the admin:
> > > # (r'^admin/', include(admin.site.urls)),
> > > )
> >
> > > myproject/apps/acasa/urls.py
> > > ---
> > > from django.conf.urls.defaults import *
> >
> > > urlpatterns = patterns('myproject.apps.acasa.views',
> > > (r'^$', 'index'),
> > > )
> >
> > > myproject/apps/acasa/views.py
> > > -
> > > from django.template  import RequestContext
> > > from django.shortcuts import render_to_response
> >
> > > def index(request):
> > > return render_to_response('acasa/default.html',
> > > context_instance=RequestContext(request))
> >
> > > myproject/templates/base.html
> > > 
> > > 
> > > 
> > > 
> > > Myproject - {% block title %}{% endblock %}
> > > 
> > > 
> > > 
> > > 
> > >  > > media="all" />
> > > 

Re: New to Django, sheet music organization site

2011-01-03 Thread Kyle
Thank you Tim! That was the problem! I will remember to post the full
error stack next time.

Thanks again,
Kyle

On Jan 3, 6:00 am, Tim Sawyer  wrote:
> On 03/01/11 03:53, Kyle wrote:
>
> > When I try to access my Object, I get an error "invalid literal for
> > int() with base 10". I know it has something to do with ForeignKeys,
> > but cannot find how to fix it.
>
> It helps if you post the full stack of the error - we can tell which
> line of code it came from then.  However,
>
> > def artist(request, myartist):
> >    myArgs = Song.objects.all().filter(artist=myartist)
> >    return render_to_response('music/index.html', {'artist': myArgs})
>
> I think this is your problem.  What are you passing in on the url for
> myartist?  Is it a slug?
>
> Song.objects.all().filter(artist=myartist)
>
> is expecting myartist to be an Artist instance. Try
>
> Song.objects.all().filter(artist__slug=myartist)
>
> (that's two underscores between artist and slug.)
>
> This says "Select me all the songs where the related Artist's slug is
> whatever was passed in on the url"
>
> Hope that helps,
>
> 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-us...@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.



Pydev, decorators, and breakpoints

2011-01-03 Thread CrabbyPete
I use pydev to debug my python apps, but I can not break on a
decorated function. Anyone know why and how to fix it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: loading the external css file

2011-01-03 Thread Chris Lawlor
If you don't have a staticfiles module, you most likely aren't using
Django 1.3. Make sure you select the correct version of Django when
viewing the docs, as things are often done differently in older
versions, but the doc pages usually default to the latest SVN release.

On Dec 27 2010, 10:43 pm, Bithu  wrote:
> When i was trying to set my static files. When i added the
> 'django.contrib.staticfiles' into INSTALLED_APP in my setting.py the
> development server was not running showing an error  Error: No module
> named staticfiles.
>
> On Dec 27, 7:07 pm, Chris Lawlor  wrote:
>
>
>
>
>
>
>
> > Django doesn't server static files (like your CSS file) by default -
> > but you can configure the development server to do 
> > so:http://docs.djangoproject.com/en/dev/howto/static-files/
>
> > Note that this has changed a lot in Django 1.3, so be sure to view the
> > correct version of that page for the version of Django that you are
> > using.
>
> > In production, you should almost always configure another server to
> > serve static files.
>
> > On Dec 27, 8:29 am, Bithu  wrote:
>
> > > When i was trying to load an external stylesheet it was not working.
> > > But the internal css is working nicely.
>
> > > What should i do to link my .css file to my html template which is
> > > inside my template folder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django dev server issue

2011-01-03 Thread daniels
Hi,
Unfortunately i did not found the case, and i'm getting it pretty
often, about 3 out of 5 times i refresh the page.
If i leave it loading and i don't stop it it stays like that for about
30-40 seconds and then the page loads.
I just don't understand what is causing this.
I've restarted the server like 10 time or more from the first time i
got this and i'm still getting it every time i run it.

My Python version is : ActivePython 2.6.6.17 (ActiveState Software
Inc.) based on
Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit
(Intel)] on
win32

and Django: (1, 2, 3, 'final', 0)

I did a lot of dev on Windows 7 before but i never had this issue. So
my thoughts are that this is either
related to this Django version or Python version.


On Jan 3, 5:43 pm, Tiago Almeida  wrote:
> Hi,
>
> Your files seem fine, I believe.
> Have you found the cause? What version of python and django are you
> using? I also have this issue but it is not often enough for me to
> worry too much. Killing the server and restarting it solves it for
> me..
>
> BR,
> 
>
> On 3 Jan, 08:00, daniels  wrote:
>
>
>
>
>
>
>
> > Here are the relevant files:
>
> > myproject/urls.py
> > --
> > from django.conf.urls.defaults import *
> > from django.conf import settings
>
> > # Uncomment the next two lines to enable the admin:
> > # from django.contrib import admin
> > # admin.autodiscover()
>
> > urlpatterns = patterns('',
> >     (r'^$', include('myproject.apps.acasa.urls')),
>
> >     # Dev only
> >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT}),
>
> >     # Uncomment the admin/doc line below to enable admin
> > documentation:
> >     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> >     # Uncomment the next line to enable the admin:
> >     # (r'^admin/', include(admin.site.urls)),
> > )
>
> > myproject/apps/acasa/urls.py
> > ---
> > from django.conf.urls.defaults import *
>
> > urlpatterns = patterns('myproject.apps.acasa.views',
> >     (r'^$', 'index'),
> > )
>
> > myproject/apps/acasa/views.py
> > -
> > from django.template  import RequestContext
> > from django.shortcuts import render_to_response
>
> > def index(request):
> >     return render_to_response('acasa/default.html',
> >         context_instance=RequestContext(request))
>
> > myproject/templates/base.html
> > 
> > 
> > 
> > 
> >     Myproject - {% block title %}{% endblock %}
> >     
> >     
> >     
> >     
> >      > media="all" />
> >     

Re: Using new messages framework within built-in admin ?

2011-01-03 Thread rahul jain
anyone on this ?

How to display error messages ?

On Thu, May 27, 2010 at 3:49 AM, Nicolas Steinmetz wrote:

> Nobody on this issue ?
>
> On 21 mai, 15:46, Nicolas Steinmetz  wrote:
> > Hi,
> >
> > For some actions I made from the Django built-in admin, I would like
> > to improve the user experience with a better distinction between
> > sucess & error messages.
> >
> > With Django 1.1.x, I used to use Model admin actions [1] with
> > statements like :
> >
> > modeladmin.message_user(request, "%s successfully marked as
> > published." % message_bit)
> >
> > With the new 1.2 version, I was about to use the messages framework
> > and the messages.success() / messages.error() shortcuts to provide a
> > better experience. I now have in my code :
> >
> > messages.success(request, "%s successfully marked as published." %
> > message_bit)
> >
> > So running my own admin/base.html file, I replaced the messages
> > section by the example provided in the doc [2] :
> >
> > {% if messages %}
> > 
> > {% for message in messages %}
> > {{
> message }}
> >
> > {% endfor %}
> > 
> > {% endif %}
> >
> > What happens is that messages.tags is empty.If I understand well the
> > doc, I should have an "error" or "success" tags for my error/success
> > messages.
> >
> > What did I miss ? Or is it a bug ? Or the admin do not use yet the new
> > message framework ?
> >
> > [1]
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#actio...
> > [2]
> http://docs.djangoproject.com/en/1.2/ref/contrib/messages/#ref-contri...
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group athttp://
> groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 get URI in settings.py

2011-01-03 Thread Alonso Geriausias
How to get URI in settings.py

Reason for that is if URI is for admin to disable all languages in
settings.py
if there is no admin in URI to leave all languages.

How to do that ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 get URI in settings.py

2011-01-03 Thread Alonso Geriausias
How to get URI in settings.py

If request goes to admin site I have to have different languages that
front page.

Hot to get URI in settings.py ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 raise an error on django admin

2011-01-03 Thread rahul jain
Hi,

How to display an error in django admin (the error should be displayed in
red just like in forms)

Something of this form

http://groups.google.com/group/django-users/browse_thread/thread/68d4ea1915654134/447ef8473cf86672

Thanks.

Rahul

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Templates Directory Question

2011-01-03 Thread Daniel Hepper
You can put the templates anywhere you want, by a good place is a
directory named templates in the base directory of your project, i.e.

C:\DjangoProjects\mysite\templates\

Don't forget to add this path to the TEMPLATE_DIRS variable in your settings.py.

The template file from the example would be placed at

C:\DjangoProjects\mysite\templates\polls\index.html

You can probably ignore the document root for now, but I'll try to
explain what it means.
The term "document root" refers to the directory that a webserver like
Apache uses to look for files.
Let's say the webserver running on example.com is configured with
document_root = C:\apache\htdocs. If you visit
http://example.com/foo.html, the webserver would serve you the file
C:\apache\htdocs\foo.html.
I hope that makes sense and doesn't add to the confusion.

Daniel

On Mon, Jan 3, 2011 at 3:26 PM, Anthony Pearce  wrote:
> Now I feel stupid. That intelligent comment flew right over my head.
> I'm not sure yet where apache is falling in here yet, nor do I know
> what htdocs is.
>
> I should mention I'm using Windows 7 also, in case any terminology is
> based on another OS.
>
>
> On Jan 3, 10:56 pm, "Mo J. Al-Mughrabi"  wrote:
>> By document root they mean apache public directory, aka htdocs
>>
>> Sent from my iPhone
>>
>> On Jan 3, 2011, at 4:53 PM, Anthony Pearce  wrote:
>>
>>
>>
>> > In Tutorial 2, I was instructed to make a templates directory. It is
>> > located at:
>> >     C:\DjangoProjects\mysite\templates
>>
>> > Now again in Tutorial 3, section "Write views that actually do
>> > something", I am given the instructions:
>> >      create a directory, somewhere on your filesystem, whose
>> > contents Django can access. (Django runs as whatever user your server
>> > runs.) Don't put them under your document root.
>>
>> > I think the document who's root I cannot put them under is the
>> > views.py document, as that's what I had been editing.  It is located
>> > at:
>> >     C:\DjangoProjects\mysite\polls\views.py
>>
>> > I guess my question is, where is the best place for this new templates
>> > directory?  Can I simply make a subdirectory in the templates
>> > directory for the views.py template?  For example, like this:
>> >     C:\DjangoProjects\mysite\templates\views\
>>
>> > Sorry for a question with likely a quite obvious solution, but thanks
>> > again for any assistance.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django dev server issue

2011-01-03 Thread Tiago Almeida
Hi,

Your files seem fine, I believe.
Have you found the cause? What version of python and django are you
using? I also have this issue but it is not often enough for me to
worry too much. Killing the server and restarting it solves it for
me..

BR,


On 3 Jan, 08:00, daniels  wrote:
> Here are the relevant files:
>
> myproject/urls.py
> --
> from django.conf.urls.defaults import *
> from django.conf import settings
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
>     (r'^$', include('myproject.apps.acasa.urls')),
>
>     # Dev only
>     (r'^media/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.MEDIA_ROOT}),
>
>     # Uncomment the admin/doc line below to enable admin
> documentation:
>     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>     # Uncomment the next line to enable the admin:
>     # (r'^admin/', include(admin.site.urls)),
> )
>
> myproject/apps/acasa/urls.py
> ---
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('myproject.apps.acasa.views',
>     (r'^$', 'index'),
> )
>
> myproject/apps/acasa/views.py
> -
> from django.template  import RequestContext
> from django.shortcuts import render_to_response
>
> def index(request):
>     return render_to_response('acasa/default.html',
>         context_instance=RequestContext(request))
>
> myproject/templates/base.html
> 
> 
> 
> 
>     Myproject - {% block title %}{% endblock %}
>     
>     
>     
>     
>      media="all" />
>     

Problem with validating ModelForm

2011-01-03 Thread robos85
I use ModelForm to create my form. All works fine except 1 thing - 
validating the unique field.
Code:
class Article(models.Model):

...

title = models.CharField(max_length=255, unique=True, 
error_messages={'max_length' : 'max translation',
 
   'unique' : 'unique translation',
 
   'required' : 'req translation',})

...


class ArticleForm(ModelForm):

...

title = forms.CharField(max_length=255, min_length=3, 
error_messages={'required' : 'req translation',
 
'min_length' : 'min translation',
 
'max_length' : 'max translation',
 
'unique' : 'unique translation',}) 



But when I save my form with  non-unique title I don't get my custom 
translated error but I get default error. How to fix it, that my unique 
field error is displayed?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Multi widget?

2011-01-03 Thread Ilian Iliev
Two widgets to one field? Can you specify this little bit more?

On Mon, Jan 3, 2011 at 12:29 PM, robos85  wrote:

> Hi,
> what I want to do, is to add 2 widgets to 1 field. So far I have:
>
> content =
> forms.CharField(widget=forms.Textarea(attrs={'class':'add_editor'}),)
>
> But I also want to add some medi to it (tinymce .js files). How can I do
> that?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>



-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: http://ilian.i-n-i.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Cant locate problem with trunk: 'ModelForm' object has no attribute '_meta'

2011-01-03 Thread Martin

> Could you please try again but rolling back your Django trunk  installation to
> revision 14991?.
>

Hi Ramiro,

thank you for your help. It's funny cause I rolled back to 15000 to
check :/ . It works fine with 14991.
With trunk I was able to locate the error-cause down to a url tag of
my template. Hope it helps to solve this Django issue. Too deep for
me, but let me know if I can provide you with more information.

If I remove this from my template, everything is fine: {% url
profile_overview %}
Url is defined as following:
In my main urls.py:

urlpatterns+= patterns('',

(r'^account/', include('foo.pluggables.userprofile.urls')),

userprofile/urls.py:

urlpatterns = patterns('',
url(r'^profile/$', overview, name='profile_overview'),

The function overview can be empty, doesn't affect the error.

Hope that helps you somehow.

Martin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Templates Directory Question

2011-01-03 Thread Anthony Pearce
Now I feel stupid. That intelligent comment flew right over my head.
I'm not sure yet where apache is falling in here yet, nor do I know
what htdocs is.

I should mention I'm using Windows 7 also, in case any terminology is
based on another OS.


On Jan 3, 10:56 pm, "Mo J. Al-Mughrabi"  wrote:
> By document root they mean apache public directory, aka htdocs
>
> Sent from my iPhone
>
> On Jan 3, 2011, at 4:53 PM, Anthony Pearce  wrote:
>
>
>
> > In Tutorial 2, I was instructed to make a templates directory. It is
> > located at:
> >     C:\DjangoProjects\mysite\templates
>
> > Now again in Tutorial 3, section "Write views that actually do
> > something", I am given the instructions:
> >      create a directory, somewhere on your filesystem, whose
> > contents Django can access. (Django runs as whatever user your server
> > runs.) Don't put them under your document root.
>
> > I think the document who's root I cannot put them under is the
> > views.py document, as that's what I had been editing.  It is located
> > at:
> >     C:\DjangoProjects\mysite\polls\views.py
>
> > I guess my question is, where is the best place for this new templates
> > directory?  Can I simply make a subdirectory in the templates
> > directory for the views.py template?  For example, like this:
> >     C:\DjangoProjects\mysite\templates\views\
>
> > Sorry for a question with likely a quite obvious solution, but thanks
> > again for any assistance.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Templates Directory Question

2011-01-03 Thread Mo J. Al-Mughrabi
By document root they mean apache public directory, aka htdocs

Sent from my iPhone

On Jan 3, 2011, at 4:53 PM, Anthony Pearce  wrote:

> In Tutorial 2, I was instructed to make a templates directory. It is
> located at:
> C:\DjangoProjects\mysite\templates
>
> Now again in Tutorial 3, section "Write views that actually do
> something", I am given the instructions:
>  create a directory, somewhere on your filesystem, whose
> contents Django can access. (Django runs as whatever user your server
> runs.) Don't put them under your document root.
>
>
> I think the document who's root I cannot put them under is the
> views.py document, as that's what I had been editing.  It is located
> at:
> C:\DjangoProjects\mysite\polls\views.py
>
> I guess my question is, where is the best place for this new templates
> directory?  Can I simply make a subdirectory in the templates
> directory for the views.py template?  For example, like this:
> C:\DjangoProjects\mysite\templates\views\
>
> Sorry for a question with likely a quite obvious solution, but thanks
> again for any assistance.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>

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



Templates Directory Question

2011-01-03 Thread Anthony Pearce
In Tutorial 2, I was instructed to make a templates directory. It is
located at:
 C:\DjangoProjects\mysite\templates

Now again in Tutorial 3, section "Write views that actually do
something", I am given the instructions:
  create a directory, somewhere on your filesystem, whose
contents Django can access. (Django runs as whatever user your server
runs.) Don't put them under your document root.


I think the document who's root I cannot put them under is the
views.py document, as that's what I had been editing.  It is located
at:
 C:\DjangoProjects\mysite\polls\views.py

I guess my question is, where is the best place for this new templates
directory?  Can I simply make a subdirectory in the templates
directory for the views.py template?  For example, like this:
 C:\DjangoProjects\mysite\templates\views\

Sorry for a question with likely a quite obvious solution, but thanks
again for any assistance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, sheet music organization site

2011-01-03 Thread CrabbyPete
Good Luck. Just start banging it out. You'll see as you go how much
more there is.

On Jan 1, 11:24 pm, Kyle  wrote:
> I am wanting to create an app that helps me organize sheet music. I
> want to be able to sort by the artist. Every piece of sheet music I
> have I want to be scanned in and uploaded as an image file, then when
> I want to open a particular file, it opens as a PDF.
>
> This would be my long terms goals. For now since I am new to Django, I
> just want to simply organize my music and be able to easily sort.
>
> I know I will need:
>
> from django.db import models
>
> class Artist(models.Model):
>         name = models.CharField(max_length=30)
>         genre = models.CharField(max_length=30)
>
> class Song(models.Model):
>         name = models.CharField(max_length=30)
>         artist = models.ForeignKey(Artist)
>
> What else can I do to help me get a start with this? I've gone through
> the tutorial and I understand how Django works, its just a matter of
> getting some hands on experience.
>
> Thanks for any help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Unable to import middleware class 'facebook.djangofb.FacebookMiddleware' with uncaught exception

2011-01-03 Thread PJ
Yes, I believe I installed all the pre-reqs, though let me know if I
should check anything else:
from the console:
>>> import facebook
>>> import facebook.djangofb
>>>
I'm thinking perhaps it's running the wrong version of python? My
server had 2.4 alias'd as python, but I re-alias'd python2.6 as python
in my .profile, however a "which python" gives my nothing, even though
python -V says 2.6.
Thanks

On Jan 3, 8:07 am, Daniel Roseman  wrote:
> On Sunday, January 2, 2011 11:23:30 PM UTC, PJ wrote:
>
> > Disclaimer: I'm new to Django and system administration, though a C++
> > developer.
>
> > following the tutorial on:
> >http://uswaretech.com/blog/2009/02/how-to-build-a-facebook-app-in-dja...
> > I get everything set up. In my settings.py, I have in my
> > MIDDLEWARE_CLASSES:
> >     'facebook.djangofb.FacebookMiddleware',
>
> > When I run this, it renders:
> > "Unhandled Exception
>
> > An unhandled exception was thrown by the application.
> > "
>
> > my logs look like this (note "Error importing middleware" at the top
> > of the stack trace). Any idea how/why it cannot find this "middleware"
> > and why the exception would not be caught? Thank you in advance.
>
> Have you actually installed the pyfacebook library?
> --
> 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-us...@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: Unable to import middleware class 'facebook.djangofb.FacebookMiddleware' with uncaught exception

2011-01-03 Thread Daniel Roseman
On Sunday, January 2, 2011 11:23:30 PM UTC, PJ wrote:
>
> Disclaimer: I'm new to Django and system administration, though a C++ 
> developer. 
>
> following the tutorial on: 
> http://uswaretech.com/blog/2009/02/how-to-build-a-facebook-app-in-django/ 
> I get everything set up. In my settings.py, I have in my 
> MIDDLEWARE_CLASSES: 
> 'facebook.djangofb.FacebookMiddleware', 
>
> When I run this, it renders: 
> "Unhandled Exception 
>
> An unhandled exception was thrown by the application. 
> " 
>
> my logs look like this (note "Error importing middleware" at the top 
> of the stack trace). Any idea how/why it cannot find this "middleware" 
> and why the exception would not be caught? Thank you in advance. 


Have you actually installed the pyfacebook library?
--
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-us...@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: Filter after annotate

2011-01-03 Thread Maxim
Thanks Karen,

It's a pity that this bug isn't fixed for 2 years already.
I'll try to find a workaround...

On Jan 3, 3:38 pm, Karen Tracey  wrote:
> On Mon, Jan 3, 2011 at 7:33 AM, Maxim  wrote:
> > Here's the snippet of my code:
> > Actions.objects.values("context_user").annotate(points =
> > Sum("value")).filter(Q(points__gt = limit) | Q(points__lt = -limit))
>
> > Note using OR in a filter. But to my surprise the SQL query looks
> > like:
> > ... GROUP BY "action"."context_user_id" HAVING (SUM("action"."value")
> > > 0  AND SUM("action"."value") < 0 )
>
> > Somehow Django uses AND instead of OR, thus the result is always
> > empty.
>
> > Can anyone explain this behavior to me and point out the solution if
> > it's not a bug?
>
> I think it is a bug, specifically this 
> one:http://code.djangoproject.com/ticket/11293
>
> Karen
> --http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Filter after annotate

2011-01-03 Thread Karen Tracey
On Mon, Jan 3, 2011 at 7:33 AM, Maxim  wrote:

> Here's the snippet of my code:
> Actions.objects.values("context_user").annotate(points =
> Sum("value")).filter(Q(points__gt = limit) | Q(points__lt = -limit))
>
> Note using OR in a filter. But to my surprise the SQL query looks
> like:
> ... GROUP BY "action"."context_user_id" HAVING (SUM("action"."value")
> > 0  AND SUM("action"."value") < 0 )
>
> Somehow Django uses AND instead of OR, thus the result is always
> empty.
>
> Can anyone explain this behavior to me and point out the solution if
> it's not a bug?
>

I think it is a bug, specifically this one:
http://code.djangoproject.com/ticket/11293

Karen
-- 
http://tracey.org/kmt/

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



Filter after annotate

2011-01-03 Thread Maxim
Hi,

I've come across a weird behavior, just wondering if it is a bug or a
feature.
My task is to group a list of actions by user, count the values sum
and filter them by absolute value. E.g.

user1  5
user1  10
user2  2
user3  -12

and limit = 10, I want to see

user1  15
user3  -12

Here's the snippet of my code:
Actions.objects.values("context_user").annotate(points =
Sum("value")).filter(Q(points__gt = limit) | Q(points__lt = -limit))

Note using OR in a filter. But to my surprise the SQL query looks
like:
... GROUP BY "action"."context_user_id" HAVING (SUM("action"."value")
> 0  AND SUM("action"."value") < 0 )

Somehow Django uses AND instead of OR, thus the result is always
empty.

Can anyone explain this behavior to me and point out the solution if
it's not a bug?

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-us...@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 with translations

2011-01-03 Thread Karen Tracey
On Mon, Jan 3, 2011 at 3:05 AM, Isaac XxX  wrote:

> Recently, i've found a problem with i18n translations in Django.
>
> All my translations are located inside views functions, templates and some
> of them are in a file called forms.py (where i store some of my forms).
>
> The problem arise when I render that forms. First render time, seems that
> locale is applied, but next times the same locale is displayed again,
> without beign able to change it through locale selector. The rest of
> translations are behaving correctly. Any clue about what's happening with
> translations outside of views and templates files?
>
>
Forms would be a likely place where you will need to be using lazy
translation (
http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#lazy-translation).
If you are not, that may be the problem.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, sheet music organization site

2011-01-03 Thread Greg Turner
On 3 January 2011 23:00, Tim Sawyer  wrote:

> On 03/01/11 03:53, Kyle wrote:
>
>> When I try to access my Object, I get an error "invalid literal for
>> int() with base 10". I know it has something to do with ForeignKeys,
>> but cannot find how to fix it.
>>
>
> It helps if you post the full stack of the error - we can tell which line
> of code it came from then.  However,
>
>  def artist(request, myartist):
>>myArgs = Song.objects.all().filter(artist=myartist)
>>return render_to_response('music/index.html', {'artist': myArgs})
>>
>
> I think this is your problem.  What are you passing in on the url for
> myartist?  Is it a slug?
>
> Song.objects.all().filter(artist=myartist)
>
> is expecting myartist to be an Artist instance. Try
>
> Song.objects.all().filter(artist__slug=myartist)
>
> (that's two underscores between artist and slug.)
>
> This says "Select me all the songs where the related Artist's slug is
> whatever was passed in on the url"
>
> And if myartist is an id (and therefore likely an integer or a string of an
integer, as it comes from a URL), then you want:

 Song.objects.all().filter(artist__id=myartist)

(the .all() is unneccessary, by the way).

Greg.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Too many items in my drowndown list

2011-01-03 Thread Greg Turner
Using a raw_id_field instead of a dropdown list will open a popup with a
'pseudo' django admin. The reason I call it 'pseudo' is that the list can be
searched or filtered just like the normal django admin, but when you click
on an item, it becomes the selected item in your inline, and the window
closes.

On 3 January 2011 18:55, mongoose  wrote:

> Hi there,
>
> I have a drowdown list in my inlines. The problem is that there are
> over 3500 items which is making is difficult for people to use. Are
> there eaiser ways perhaps to filter or search within the dropdownlist?
>
>
> 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-us...@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.
>
>


-- 

Dr Greg Turner
Director, the Interaction Consortium
http://interaction.net.au
Phone: +61 2 8060 1067
skype: gregturner
Follow us on twitter:

http://twitter.com/theixc
http://twitter.com/gsta

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

2011-01-03 Thread Greg Turner
Just have my_fnc return a dictionary (or other object), rather than the
whole rendered response:

def search(request):
..
   answ = my_fnc(roots)
   return render_to_response("my_fnc.html", { "answ" : answ['FindWord'] } )

def my_fnc( roots ):
   FindWord=authors.objects.filter("name"__contains=roots)
   return { "FindWord" : FindWord }

(A couple of style points:

   - PEP8 recommends avoiding CamelCase in favour of under_scores
   - In views.py, I lean towards naming functions that aren't views, (my_fnc
   in this case) with an underscore, such as _my_fnc)

)

Hope this helps,

Greg


On 3 January 2011 20:45, gintare  wrote:

>
> How formulate correctly the code below:
>
> [code]
> #views.py
>
> def search(request):
> ..
>answ = my_fnc(roots)
>return render_to_response("my_fnc.html", { "answ" : answ } )
>
> def  my_fnc( roots ):
>FindWord=authors.objects.filter("name"__contains=roots)
>return render_to_response("my_fnc.html", { " FindWord" :
> FindWord } )
>
> [code]
>
> Gives error Manager isn't accessible via FindWord instances
>
> I would like to get result of quesry in separate function.
> How to return this result to initial function in view or print it to
> *.html form from another function?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 

Dr Greg Turner
Director, the Interaction Consortium
http://interaction.net.au
Phone: +61 2 8060 1067
skype: gregturner
Follow us on twitter:

http://twitter.com/theixc
http://twitter.com/gsta

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Too many items in my drowndown list

2011-01-03 Thread Thomas Guettler
Hi,

for the admin interface you can use raw_id.

mongoose wrote:
> Hi there,
> 
> I have a drowdown list in my inlines. The problem is that there are
> over 3500 items which is making is difficult for people to use. Are
> there eaiser ways perhaps to filter or search within the dropdownlist?
> 
> 
> Thanks
> 

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: New to Django, sheet music organization site

2011-01-03 Thread Tim Sawyer

On 03/01/11 03:53, Kyle wrote:

When I try to access my Object, I get an error "invalid literal for
int() with base 10". I know it has something to do with ForeignKeys,
but cannot find how to fix it.


It helps if you post the full stack of the error - we can tell which 
line of code it came from then.  However,



def artist(request, myartist):
myArgs = Song.objects.all().filter(artist=myartist)
return render_to_response('music/index.html', {'artist': myArgs})


I think this is your problem.  What are you passing in on the url for 
myartist?  Is it a slug?


Song.objects.all().filter(artist=myartist)

is expecting myartist to be an Artist instance. Try

Song.objects.all().filter(artist__slug=myartist)

(that's two underscores between artist and slug.)

This says "Select me all the songs where the related Artist's slug is 
whatever was passed in on the url"


Hope that helps,

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-us...@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.



Multi widget?

2011-01-03 Thread robos85
Hi,
what I want to do, is to add 2 widgets to 1 field. So far I have:

content = 
forms.CharField(widget=forms.Textarea(attrs={'class':'add_editor'}),)

But I also want to add some medi to it (tinymce .js files). How can I do 
that?

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



render_to_response

2011-01-03 Thread gintare

How formulate correctly the code below:

[code]
#views.py

def search(request):
..
answ = my_fnc(roots)
return render_to_response("my_fnc.html", { "answ" : answ } )

def  my_fnc( roots ):
FindWord=authors.objects.filter("name"__contains=roots)
return render_to_response("my_fnc.html", { " FindWord" :
FindWord } )

[code]

Gives error Manager isn't accessible via FindWord instances

I would like to get result of quesry in separate function.
How to return this result to initial function in view or print it to
*.html form from another function?

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



Problem with translations

2011-01-03 Thread Isaac XxX
Recently, i've found a problem with i18n translations in Django.

All my translations are located inside views functions, templates and some
of them are in a file called forms.py (where i store some of my forms).

The problem arise when I render that forms. First render time, seems that
locale is applied, but next times the same locale is displayed again,
without beign able to change it through locale selector. The rest of
translations are behaving correctly. Any clue about what's happening with
translations outside of views and templates files?

Thank you in advance

Isaac

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django dev server issue

2011-01-03 Thread daniels
Here are the relevant files:

myproject/urls.py
--
from django.conf.urls.defaults import *
from django.conf import settings

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^$', include('myproject.apps.acasa.urls')),

# Dev only
(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),

# Uncomment the admin/doc line below to enable admin
documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
)



myproject/apps/acasa/urls.py
---
from django.conf.urls.defaults import *

urlpatterns = patterns('myproject.apps.acasa.views',
(r'^$', 'index'),
)



myproject/apps/acasa/views.py
-
from django.template  import RequestContext
from django.shortcuts import render_to_response


def index(request):
return render_to_response('acasa/default.html',
context_instance=RequestContext(request))



myproject/templates/base.html




Myproject - {% block title %}{% endblock %}









{% block content %}
{% endblock %}





myproject/templates/acasa/default.html
-
{% extends "base.html" %}
{% block title %}Acasă{% endblock %}
{% block content %}
Hello World!
{% endblock %}

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