Re: Serving static files?

2008-08-31 Thread Davor Lučić

If you are using Apache you can use mod_rewrite.

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

On Aug 31, 10:08 pm, Robert <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I just got done reading through the 4 django tutorials and they were
> very helpful. However, I did not find out through the tutorials alone
> how to serve CSS files along with my HTML. I was told in IRC that
> these are not directly handled by django.
>
> Basically, my main concern is keeping my website source code
> centralized. At the moment, I keep my django project & respective apps
> in Subversion, and I want my static files (CSS) to be in there with
> the rest of the django files.
>
> Having said this, I'm not sure how to configure apache to look for
> those CSS files. Say my django project is in /srv/django/myproject,
> and my document root is in /srv/http, what must be done? If this is
> covered in the documentation, I apologize for wasting the community's
> time and would appreciate a direct link to the materials I need to
> read.
>
> Thanks in advance.

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



Djangobook Revisions for 1.0 release

2008-08-31 Thread Benoit

Hi All,

I have two questions, one assuming the other:

1) Will The Django Book (online) be updated to comply with Django 1.0
API changes?

2) In case of an update, will chapter seven be rewritten?

I posted a more detailed grievance at the top of chapter seven in The
Django Book already under the sane name, so there's no need for me to
repeat them alongside the unanimous disapproval found in that chapter
as well.  I appreciate any responses.

- Benoit

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



Re: problem with accessing django from apache2 & mod_python

2008-08-31 Thread cavebird

Hi  Aaron,

I am using mysite.books.views. I dont have mysite.books.urls. I will
worry about mysite.books.models when I can display simple pages
without any models.

thanks,
Hemant

On Aug 29, 11:54 pm, Aaron <[EMAIL PROTECTED]> wrote:
> Hi, strange enough, I was having a similar problem as you just awhile
> ago (w/ mod_wsgi).  The cause as I discovered was that if you have an
> app inside your project, you'll have to include the project name
> before any import statements.  So, for your case, chances are, there
> may be references to books.views/books.urls/book.models that were
> suppose to be mysite.book.views/mysite.book.urls/mysite.book.models.
>
> Hope this help.
>
> Aaron
>
> On Aug 29, 4:53 am, cavebird <[EMAIL PROTECTED]> wrote:
>
> > No :(
>
> > I already tried that.
> > same results.
>
> > cavebird
>
> > On Aug 29, 4:47 pm, Aaron <[EMAIL PROTECTED]> wrote:
>
> > > Hi cavebird,
>
> > > Not sure if this has anything to do with the symbolic link, but I
> > > remember having some path issues on mod_python awhile back.  Try
> > > copying mysite inside htdocs and see if that has any effects.
>
> > > Aaron
>
> > > On Aug 29, 4:32 am, cavebird <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
> > > > I have been learning Django and came across thisproblem
> > > > I am trying to access django apps fromapache2but it just wont work :
> > > > (
> > > > Here is what i did:
> > > > added in /usr/local/apache2/conf/extra/httpd-info.conf:
> > > > 
> > > > SetHandler python-program
> > > > PythonHandler django.core.handlers.modpython
> > > > PythonPath "['/usr/local/apache2/htdocs/'] + sys.path"
> > > > SetEnv DJANGO_SETTINGS_MODULE mysite.settings
> > > > SetEnv PYTHON_EGG_CACHE "/var/cache/www/pythoneggs"
> > > > PythonDebug Off
> > > > PythonAutoReload Off
>
> > > > 
>
> > > > cd /usr/local/apache2/htdocs
> > > > ln -s /home/user/workspace/gui/src/mysite mysite
>
> > > > I started the server.
> > > > it can access url.py because if i give mysite/rubbish it says The
> > > > current URL, /mysite/rubbish/, didn't match any of these.
> > > > it can access functions in mysite.views because mysite/time works
> > > > fine.
> > > > However it cannot access mysite.books.views as even the simplest
> > > > functions returns nothing.
> > > > Meanwhile python manage.py runserver works perfectly fine.
> > > > Please help!!!
> > > > Regards,
> > > > cavebird
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inlineformset_factory and CustomWidget

2008-08-31 Thread multilinux

I solve this problem

 In ImageWithThumbnailField need replace method "formfield"

def formfield(self, **kwargs):
defaults = {'widget': ImageWithThumbnailWidget}
defaults.update(kwargs)
return super(ImageWithThumbnailField,
self).formfield(**defaults)

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



Re: External link hit counter

2008-08-31 Thread Yury Lifshits

Steve,

Thanks for the links!
I will study the tutorial and will try to apply it for my problem.
Looks promising.

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



Re: External link hit counter

2008-08-31 Thread Steve Potter

Your best bet would be to achieve this using Ajax.  Check out these
basic tutorials:

http://www.b-list.org/weblog/2006/jul/31/django-tips-simple-ajax-example-part-1/
http://www.b-list.org/weblog/2006/aug/05/django-tips-simple-ajax-example-part-2/

Steve


On Aug 31, 8:00 pm, Yury Lifshits <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> How can one implement a hit counter for external link in Django?
> I am coding a directory of companies [ it's in 
> Russian,http://shopping2.ru/business
> ].
> Every company profile has an external link to company's website.
> I want to display a number of times this link was clicked.
>
> The link should be direct, not like   /counter?serve=http://
> company.com
>
> Of course, I just add an integer field "clickcounter" in company
> model. So the display part is easy.
> The question is how to "catch" the click event. I know there is
> "onclick" attribute and some javascript code can be called there.
>
> Are there few lines of javascript that will send an "update counter"
> message to django, while user is walking to an external website?
>
> Thanks,
> Yury.
>
> P.S. I've foundhttp://code.google.com/p/django-simplestats/but it is
> a general statistics engine while I only need a thing described above.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Inlineformset_factory and CustomWidget

2008-08-31 Thread multilinux

Hi evebody! :)

How I may change widget in inlineformset_factory ?
I have field (Image with thumbnail - this is Satchmo code), and have
custom widget.

class ImageWithThumbnailWidget(forms.FileInput):
"""
A FileField Widget that shows its current image as a thumbnail if
it has one.
"""
def __init__(self, attrs={}):
super(ImageWithThumbnailWidget, self).__init__(attrs)

def render(self, name, value, attrs=None):
output = []
if value and hasattr(value, "url"):
thumb = make_admin_thumbnail(value.url)
if not thumb:
thumb = value.url
output.append('%s %s ' % \
(thumb, value.url, _('Change:')))
output.append(super(ImageWithThumbnailWidget,
self).render(name, value, attrs))
return mark_safe(u''.join(output))


But if i write
class ImageWithThumbnailField(ImageField):
widget = ImageWithThumbnailWidget

inlineformset_factory don't have thumbnail of image- i see only
standart file input field.

Is there render method don't work with inlineformset ?

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



Fwd: 500 error if django run in scgi mode(fcgi is ok)

2008-08-31 Thread Puzzle Stone
-- Forwarded message --
From: Puzzle Stone <[EMAIL PROTECTED]>
Date: Thu, Aug 28, 2008 at 4:23 PM
Subject: 500 error if django run in scgi mode(fcgi is ok)
To: [EMAIL PROTECTED]


Fcgi and scgi work well in my machine when i use django0.96.2, but scgi
failed when I try to migrate my developing environment from django0.96.2 to
svn version (rev 8643).

I use the shell recommended by the fastcgi.txt to run fastcgi:
exec /usr/bin/env - \
  PYTHONPATH="../python:.." \
  $PROJDIR//manage.py runfcgi protocol=$PROTOCOL socket=$SOCKET
pidfile=$PIDFILE

And i already chmod the .sock file for the permission issue.

It's ok to navigate the web page if i set the PROTOCOL to "fcgi", but there
will be 500 error when i change it to "scgi".
The error messages in /var/log/lighttpd/error.log:
2008-08-28 13:57:42: (mod_fastcgi.c.3281) response not received, request
sent: 920 on socket: unix:/home//workspace/.sock for /.fcgi ,
closing connection
2008-08-28 13:57:43: (mod_fastcgi.c.2471) unexpected end-of-file (perhaps
the fastcgi process died): pid: 0 socket:
unix:/home//workspace/.sock
...

My machine enviroment:
ubuntu: 8.02 en
lighttpd: 1.4.9.19
MySql: 5.0.51a
python: 2.5.2
flup:1.0
django: rev 8643

Are the some defects about scgi in current django or maybe i miss something?

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



Re: Django SVN request.get_full_path() return main.fcgi?

2008-08-31 Thread Jason Cui

Thank you very much, this is the answer.

On Aug 31, 11:13 pm, Michael Richardson
<[EMAIL PROTECTED]> wrote:
> On Aug 30, 11:07 pm, Jason Cui <[EMAIL PROTECTED]> wrote:
>
> > When I update django SVN yestoday, about from 0.97 to 1.0 beta2, the
> > function request.get_full_path() return wrong value sometimes. When I
> > locate urlhttp://domain/detail/list/, this function return /main.fcgi/
> > detail/list/, but should be /detail/list/.
>
> > Who can tell me why? Now I have to add replace function to this value.
>
> > My server config: django+fastcgi 1.4.18+fastcgi, the main.fcgi file in
> > the public directory only has on line:
> > export DJANGO_SETTINGS_MODULE=web.settings_fastcgi
>
> Do you have FORCE_SCRIPT_NAME = '' in your settings.py file? 
> Seehttp://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Chang...
> andhttp://www.djangoproject.com/documentation/fastcgi/#forcing-the-url-p...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inlineformset_factory

2008-08-31 Thread Karen Tracey
On Sun, Aug 31, 2008 at 9:12 PM, cmiller <[EMAIL PROTECTED]> wrote:

>
> Thanks!  That helped.  Is your code working without error?  It looks a
> lot like how I'm doing it.
>
> Here's the error:
>
> Exception Type: KeyError
> Exception Value:
>
> Exception Location: /home/46538/data/python/django/django/forms/
> models.py in save_existing_objects, line 294
>

You may be hitting #8719 (http://code.djangoproject.com/ticket/8719) though
since you didn't include any specifics about your models it is hard to be
sure.  If you are hitting #8719 updating to current trunk should fix it.

Karen

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



Re: How to do this using Django Model

2008-08-31 Thread Karen Tracey
On Sun, Aug 31, 2008 at 2:05 PM, ydjango <[EMAIL PROTECTED]> wrote:

>
> How to implement following create table (mysql) using django model.
>
> CREATE TABLE account_transaction (
> account_id INT NOT NULL,
> acct_trans_number INT NOT NULL AUTO_INCREMENT,
> PRIMARY KEY (account_id,acct_trans_number)
> );
>
>
> The above is mysql script.  Acct_trans_number has to be unique and
> sequential within an account id.
>  this the only way it can be achieved in mysql as far as I am aware.
>
> How  to do it using Django models?
>

You cannot (currently) get Django to generate a CREATE TABLE that looks like
that, Django currently does not support composite primary keys.  See:

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

which near the end has a pointer to the latest discussion regarding adding
this feature.

Karen

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



Re: inlineformset_factory

2008-08-31 Thread cmiller

Thanks!  That helped.  Is your code working without error?  It looks a
lot like how I'm doing it.

Here's the error:

Exception Type: KeyError
Exception Value:

Exception Location: /home/46538/data/python/django/django/forms/
models.py in save_existing_objects, line 294

cmiller

On Aug 30, 2:11 am, patrickk <[EMAIL PROTECTED]> wrote:
> here (http://dpaste.com/71450/) is an example for using
> inlineformset_factory (see better_author_edit). don´t know if this is
> much help though.
>
> maybe you can post your exact error-message.
>
> patrick.
>
> On Aug 30, 12:09 am, cmiller <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
>
> > I have been hitting my head against a wall for way to long on this.
>
> > When I view it on the edit page everything looks great!  But when I
> > try to Save or Update, everything unravels.
>
> > I'm following it just the way the very sparse documentation suggests,
> > and yet I get a "Exception Type:   KeyError".  I've tried it the way
> > listed below and where "ff=BookFormSet(request.POST, instance=a)" and
> > where I first put request.POST into a dictionary.  Nothing works.  Any
> > help would be greatly appreciated.
>
> >     author = request.session.get('author', None)
> >     a = Author.objects.get(id=author.id)
> >     BookFormSet = inlineformset_factory(Author, Books, extra=0)
> >     rf = BookFormSet(instance=a)
>
> >     if request.method == 'POST':
> >         if request.POST['submit']=='Update':
> >             ff = BookFormSet(request.POST)
> >             if ff.is_valid():
> >                 instances = ff.save()
> >                 return HttpResponseRedirect('/profile/books/view/')
>
> > Thanks!
> > cmiller
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



External link hit counter

2008-08-31 Thread Yury Lifshits

Dear All,

How can one implement a hit counter for external link in Django?
I am coding a directory of companies [ it's in Russian, 
http://shopping2.ru/business
].
Every company profile has an external link to company's website.
I want to display a number of times this link was clicked.

The link should be direct, not like   /counter?serve=http://
company.com

Of course, I just add an integer field "clickcounter" in company
model. So the display part is easy.
The question is how to "catch" the click event. I know there is
"onclick" attribute and some javascript code can be called there.

Are there few lines of javascript that will send an "update counter"
message to django, while user is walking to an external website?

Thanks,
Yury.

P.S. I've found http://code.google.com/p/django-simplestats/ but it is
a general statistics engine while I only need a thing described above.

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



Re: How to pass queryset to the next request (e.g., search term refinement)?

2008-08-31 Thread Leaf

You actually wouldn't need to set up the table. The way the sessions
framework works is that it returns info already set up in the
django_session. All you have to do is call some code that looks
something like this to save the session info:

if request.session['querysets']:
request.session['querysets'] += {'randomKey' = random number,
'querySet' = the query set } # obviously, "random number" and "the
query set" aren't actual code
else
   request.session['querysets'] = [ {'randomKey' = random number,
'querySet' = the query set } ]

Django has the "request.session" dictionary set up so that it
automatically does the database processing behind the scenes. As for
why not auto-incrementing, it's because it would be much more complex
- if you use a random number (probably 1 to 65,535 would be better
than 1 to 1000), you don't have to look up previously existing numbers
to increment it. There's still a slight risk that you'd get your
querysets crossed, but it's still not very likely, and it's easier to
implement. And it doesn't really matter from a security standpoint -
if someone could get into your database anyway, it wouldn't matter
what kind of keys you had.

Regards,
Leaf

On Aug 31, 7:57 pm, Egon Esser <[EMAIL PROTECTED]> wrote:
> > First off, the server keeps session data, not the browser,
>
> Ah, great, learned something new!
>
> > but I understand what you're talking about. There's no real way without
> > extra programming to handle that, but here's a scheme that should be
> > fairly minimal:
>
> > (1) On the "Search Results" page, create a new list in the session
> > variable 'refineResultCommands' and put a dictionary in it with two
> > variables - randomKey and querySet. randomKey could just be a random
> > number between 1 and 1000.
> > (2) Use a form for the refinement. Have a hidden field that passes the
> > randomKey.
> > (3) On the refinement page, compare each stored randomKey with the
> > randomKey from the hidden field. If they match, display the refined
> > results. If no randomKeys match, then display a field that says
> > "Search first, then refine."
>
> An interesting concept!
>
> If I understood it correctly, then I would only need to setup a table
> in the database that remembers the respective previous query object
> (or alt.: list of search terms), with the randomKey being the key.
>
> Generally, though, why random? What sec hole would it open if the key
> where an auto-inc num, wrapping back to 0 or so at some point?
>
> EE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Slovkian speakers? Help wanted with #8709

2008-08-31 Thread Malcolm Tredinnick


On Sun, 2008-08-31 at 13:21 -0700, Frantisek Malina wrote:
> Hi Malc,
> I am the author of the language file, I've tested it on a full Satchmo
> installation.
> I wrote to Vlado Labath, who is the original translator of Django to
> Slovak prior to submitting the ticket it directly, but I got no
> answer.
> In case you don't get any answer form someone else please commit it
> anyway.

I will now that I know you're at least reading the email lists. When
somebody posts something on a ticket that is nowhere near the normal
format ("svn diff" is the only way to fly, although some people just
post the PO files) and the only link in the ticket is to a commercial
translation service, it's important to check we're not being spoofed.

You'll probably want to sign up to the django-i18n list (it's very low
volume) if you're planning to do this regularly so that we can avoid
confusion in the future. But thanks for responding. I'll commit it now.

Regards,
Malcolm



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



Re: How to pass queryset to the next request (e.g., search term refinement)?

2008-08-31 Thread Egon Esser

> First off, the server keeps session data, not the browser,

Ah, great, learned something new!

> but I understand what you're talking about. There's no real way without
> extra programming to handle that, but here's a scheme that should be
> fairly minimal:
>
> (1) On the "Search Results" page, create a new list in the session
> variable 'refineResultCommands' and put a dictionary in it with two
> variables - randomKey and querySet. randomKey could just be a random
> number between 1 and 1000.
> (2) Use a form for the refinement. Have a hidden field that passes the
> randomKey.
> (3) On the refinement page, compare each stored randomKey with the
> randomKey from the hidden field. If they match, display the refined
> results. If no randomKeys match, then display a field that says
> "Search first, then refine."

An interesting concept!

If I understood it correctly, then I would only need to setup a table
in the database that remembers the respective previous query object
(or alt.: list of search terms), with the randomKey being the key.

Generally, though, why random? What sec hole would it open if the key
where an auto-inc num, wrapping back to 0 or so at some point?

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



Re: Serving static files?

2008-08-31 Thread djandrow

You may find this useful:

http://groups.google.com/group/django-users/browse_thread/thread/73aae22ae6d20de0/dbfe3a60be00d9bb#dbfe3a60be00d9bb

You should have apache serve the static content because its much
faster. The link I sent you is when I was having problems with it a
few weeks ago, basically you need to set the apache directives so that
for static files the handler is set to none, if you read through that
and use the examples (the ones at the bottom, the ones at the top
where my original attempts) I think you will be able to get a feel of
whats going on. If you struggle with anything let me know. You should
know i'm no expert though.

Regards,

Andrew


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



Re: Installing django on 10.4 os x and i cant figure this one out.

2008-08-31 Thread Graham Dumpleton

How are you running 'django-admin.py' and what is the first line of
that file?

Graham

On Sep 1, 1:23 am, Jason Ourscene <[EMAIL PROTECTED]> wrote:
> when i run ls -las /usr/bin/python i get:
> 8 lrwxr-xr-x   1 root  wheel  9 Jul 21 22:50 /usr/bin/python ->
> python2.3
>
> when run "which python"
> /usr/bin/python
>
> I did not use macports, what i did do was install a later version of
> python using this tutorial
> http://blog.vixiom.com/2006/07/23/how-to-install-django-on-os-
> x-tiger-104/">How To: Install Django on OS X (Tiger 10.4) 
>
> and also, im seem to have profile stuff everywhere.
> my .bash_profile:
> export PATH=/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/django/bin:$PATH
>
> my .profile:
> # Setting PATH for MacPython 2.4
> # The orginal version is saved in .profile.pysave
> PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$
> {PATH}"
> export PATH
>
> my .bash_login:
> export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:
> $PATH"
>
> Can i consolidate these into one? or do they all server different
> purposes?
>
> Thanks in advance.
> Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create a list of months from a date field.

2008-08-31 Thread djandrow

I've added the following to my urls.py, i don't know if they work, my
server only restarts every so often:

 (r'^archive/$', date_based.archive_index, archive_info
{'template_name': 'blog/archive.html'}),
(r'^archive/(?Pd{4})/?$', date_based.archive_year,
archive_info {'template_name': 'blog/archive.html'}),

Do these look about right and how can I can a list of months in
another template, I have a template index html
and a need a list with links for each month something like:

January 2008
Febuary 2008
March 2008

with links to the urls above. I may have misunderstood this whole
thing entirly to be honest.

Regards,

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



Re: How to pass queryset to the next request (e.g., search term refinement)?

2008-08-31 Thread Egon Esser

> First off, the server keeps session data, not the browser,

Ah, great, learned something new!

> but I understand what you're talking about. There's no real way without
> extra programming to handle that, but here's a scheme that should be
> fairly minimal:
>
> (1) On the "Search Results" page, create a new list in the session
> variable 'refineResultCommands' and put a dictionary in it with two
> variables - randomKey and querySet. randomKey could just be a random
> number between 1 and 1000.
> (2) Use a form for the refinement. Have a hidden field that passes the
> randomKey.
> (3) On the refinement page, compare each stored randomKey with the
> randomKey from the hidden field. If they match, display the refined
> results. If no randomKeys match, then display a field that says
> "Search first, then refine."

An interesting concept!

If I understood it correctly, then I would only need to setup a table
in the database that remembers the respective previous query object
(or alt.: list of search terms), with the randomKey being the key.

Generally, though, why random? What sec hole would it open if the key
where an auto-inc num, wrapping back to 0 or so at some point?

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



Re: spanning relationships

2008-08-31 Thread Steve Holden

andro wrote:
> Hello,
> 
> 
> class Org(models.Model):
> person = models.ForeignKey(Person)
> 
> 
> class Person(models.Model):
> address = models.ForeignKey(Address)
> ...
> 
> class Address(models.Model):
> street = models.CharField(max_length=50)
> city = models.CharField(max_length=25)
> ...
> 
> -
> The following does not return any results:
> 
> Org.objects.filter(person__address__city__exact='Boston')
> 
> Can you tell me if this is a correct filter?
> 
Well, it certainly works, if that's what you want to know:

class Address(models.Model):
street = models.CharField(max_length=50)
city = models.CharField(max_length=25)

def __unicode__(self):
return "%s %s" % (self.street, self.city)

class Admin:
pass

class Person(models.Model):
name = models.CharField(max_length=50)
address = models.ForeignKey(Address)

def __unicode__(self):
return self.name

class Admin:
pass

class Org(models.Model):
name = models.CharField(max_length=50)
person = models.ForeignKey(Person)

def __unicode__(self):
   return self.name

class Admin:
pass

In [3]: Org.objects.filter(person__address__city__exact='Fairfax')
Out[3]: []

I should point out, however, that this gives you only one person per
organization, which I suspect is *not* what you want.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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



Re: Slovkian speakers? Help wanted with #8709

2008-08-31 Thread Ivan Sagalaev

Frantisek Malina wrote:
> Sadly, I am not aware of any current Slovak Django users.
> E.g. First 50 results on http://google.sk/search?hl=sk&lr=lang_sk&q=django
> won't return a single blog-post about Django web framework in Slovak.

May be contact one of those: http://djangopeople.net/sk/ ?

Gábor Farkas, for one, is a well-known Django person.

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



Re: How to pass queryset to the next request (e.g., search term refinement)?

2008-08-31 Thread Leaf

First off, the server keeps session data, not the browser, but I
understand what you're talking about. There's no real way without
extra programming to handle that, but here's a scheme that should be
fairly minimal:

(1) On the "Search Results" page, create a new list in the session
variable 'refineResultCommands' and put a dictionary in it with two
variables - randomKey and querySet. randomKey could just be a random
number between 1 and 1000.
(2) Use a form for the refinement. Have a hidden field that passes the
randomKey.
(3) On the refinement page, compare each stored randomKey with the
randomKey from the hidden field. If they match, display the refined
results. If no randomKeys match, then display a field that says
"Search first, then refine."

Regards,
Leaf

On Aug 31, 4:53 pm, Egon Esser <[EMAIL PROTECTED]> wrote:
> > When the user enterssearchtermsand submits the form it doesn't pass
> > a queryset object to the view.  Your view gets called (with a GET or
> > POST) and gets passed in arequestobject.  You grab the parameters
> > out of that (preferably using the spiffy Django forms to help you
> > handle validation) and then you create a queryset in your view method.
>
> OK, I've now looked up some examples for that in the meantime, looks
> pretty much straight-forward.
>
> > But I see what you are asking, which is how to maintain an existing
> > queryset across multiple views.  Seems like you could easily stash
> > that away
> > in the session data.  This is covered here:
>
> >http://www.djangoproject.com/documentation/db-api/#pickling-querysets
>
> Thanks for the pointer, I hadn't encountered this stuff before at all.
>
> > Essentially, you don't pickle the actual QuerySet object, you pickle
> > the "query" attribute of the QuerySet object.
>
> Ah, OK.
>
> I'm just asking myself now: doesn't a browser keep the same session
> data for the same logged-in user?
> I.e., if a user browses the site in two browser tabs of the same
> browser, logs in in both, but places different searches on the site
> between the browser tabs?
>
> Would the browser in some way signal that the next request comes from
> a different tab? I don't think so, but then again, I may not know
> enough of web technologies.
> Even so, I assume it would call for programming some sort of manager
> to handle that (doesn't seem clean) - otherwise, searching first in
> tab1 and then in tab2, and then again refining the search in tab1
> would cause conflicting filtered results.
>
> EE
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Changing the AuthenticationForm username's max_length field (impossible!?)

2008-08-31 Thread keltus

Works great. Thanks Julien.

On Aug 30, 9:32 pm, Julien Phalip <[EMAIL PROTECTED]> wrote:
> Keltus,
>
> The patch I mentioned in that thread solved the problem of validating
> the input. For the rendering of the form, you also need to patch the
> widget as follows:
>
> AuthenticationForm.base_fields['username'].widget.attrs['maxlength'] =
> 75
>
> Note that here 'maxlength' doesn't take an underscore.
>
> Regards,
>
> Julien
>
> On Aug 30, 4:04 pm, keltus <[EMAIL PROTECTED]> wrote:
>
>
>
> > After many frustrating hours, I have yet to monkey patch the
> > form.username variable from:
> > 
> > to
> > 
>
> > In my urls.py file, I added:
> > from django.contrib.auth.forms import AuthenticationForm
> > AuthenticationForm.base_fields['username'].max_length = 75
> > AuthenticationForm.base_fields['username'].label = "Email"
>
> > This is suggested by Julien in his 
> > post:http://groups.google.com/group/django-developers/msg/3420dc565df39fb1
>
> > I found that {{ form.username.label_tag }} will print "Email" as
> > expected, but {{ form.username }} still prints a max_length of 30.
>
> > I tested using:
> > assert False, dir(AuthenticationForm.base_fields['username'])
> > and indeed the max_length field is 75 (and before my code, it's 30 as
> > expected)
>
> > Why won't the maxlength html field change to 75? This perplexes me.
>
> > This is using django 1.0 beta 1, but I've also tried with django 1.0
> > beta 2 and django svn trunk.
>
> > Please advise.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Handy tip for Mac OS X Django users

2008-08-31 Thread Leaf

I've recently discovered how incredibly customizable Mac OS 10.5's
Terminal can be. For example, I created a custom setup that is useful
for Django developers. Whenever it opens, it automatically starts my
Django server, and instead of using Ctrl+C to stop the server, I can
just press End to both shut down the server and exit the window. This
is how I set it up:

1. In Terminal prefs, go to "Settings" and hit the plus below the
settings list.
2. Name it "Django Server".
3. First, in Text, change all fonts to White and the selection to
"Spindrift". (This is just for looks.)
4. Go to the Window group, and change the title to "Django Dev
Server". Change the background to "Moss" (again, just for looks).
5. Move to Shell. Check "Run Command", type in "python /the/location/
of/your/manage.py runserver" and check "Run inside shell" if it's not
already checked. Also, select "Close if the shell exited cleanly" from
"When the shell exits:".
6. Under Keyboard, delete the current entry for end. Add an entry for
"shift + end", telling it to "scroll to end of buffer" (what the old
end did). Then, add another entry for "end". Under "Action:" pick
"Send String to Shell", click the text box, press Ctrl+C, type exit,
and press Return. Click OK.

Hope this is helpful. It's much easier than running manage.py
runserver manually.

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



Re: How to pass queryset to the next request (e.g., search term refinement)?

2008-08-31 Thread Egon Esser

> When the user enterssearchtermsand submits the form it doesn't pass
> a queryset object to the view.  Your view gets called (with a GET or
> POST) and gets passed in arequestobject.  You grab the parameters
> out of that (preferably using the spiffy Django forms to help you
> handle validation) and then you create a queryset in your view method.

OK, I've now looked up some examples for that in the meantime, looks
pretty much straight-forward.

> But I see what you are asking, which is how to maintain an existing
> queryset across multiple views.  Seems like you could easily stash
> that away
> in the session data.  This is covered here:
>
> http://www.djangoproject.com/documentation/db-api/#pickling-querysets

Thanks for the pointer, I hadn't encountered this stuff before at all.

> Essentially, you don't pickle the actual QuerySet object, you pickle
> the "query" attribute of the QuerySet object.

Ah, OK.

I'm just asking myself now: doesn't a browser keep the same session
data for the same logged-in user?
I.e., if a user browses the site in two browser tabs of the same
browser, logs in in both, but places different searches on the site
between the browser tabs?

Would the browser in some way signal that the next request comes from
a different tab? I don't think so, but then again, I may not know
enough of web technologies.
Even so, I assume it would call for programming some sort of manager
to handle that (doesn't seem clean) - otherwise, searching first in
tab1 and then in tab2, and then again refining the search in tab1
would cause conflicting filtered results.


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



Re: Nesting inlines with django-admin

2008-08-31 Thread Bojan Mihelac

If this is impossible/hard to achive is maybe possible to achive this
with virtual attributes on model that are not mapped to database table
and to override save() method on model to save this virtual attributes
in specific tables?

On Aug 31, 6:25 pm, Bojan Mihelac <[EMAIL PROTECTED]> wrote:
> Is it possible to nest inlines with django-admin? Using this type of
> models for example:
>
> Poll
> PollTranslation (this is inline)
> PollAnswer (this is inline)
> PollAnswerTranslation (this should be inline of PollAnswer)
>
> PollAnswerTranslation objects should be editable on same page.
>
> Any hint or solution would be helpful.
>
> Thanks,
> Bojan Mihelac
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Slovkian speakers? Help wanted with #8709

2008-08-31 Thread Frantisek Malina

Hi Malc,
I am the author of the language file, I've tested it on a full Satchmo
installation.
I wrote to Vlado Labath, who is the original translator of Django to
Slovak prior to submitting the ticket it directly, but I got no
answer.
In case you don't get any answer form someone else please commit it
anyway.

Sadly, I am not aware of any current Slovak Django users.
E.g. First 50 results on http://google.sk/search?hl=sk&lr=lang_sk&q=django
won't return a single blog-post about Django web framework in Slovak.

Frank
http://vizualbod.com

On Aug 31, 6:41 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> All,
>
> We're coming down to the wire with 1.0, so I need to throw out a plea to
> the audience...
>
> If anybody speaks Slovakian, could you please have a look at the
> translation diff attached to ticket #8709 and see if it looks
> reasonable. This is a case of somebody who is unknown to me submitting a
> large translation patch and I'm reluctant to just commit it sight-unseen
> this close to a major release. So I'm looking for somebody to have a
> quick read -- just sample a couple of dozen strings and see if they look
> reasonable; it doesn't have to be perfect -- and drop in a comment
> saying so.
>
> Thanks in advance,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Serving static files?

2008-08-31 Thread Robert

Hi,

I just got done reading through the 4 django tutorials and they were
very helpful. However, I did not find out through the tutorials alone
how to serve CSS files along with my HTML. I was told in IRC that
these are not directly handled by django.

Basically, my main concern is keeping my website source code
centralized. At the moment, I keep my django project & respective apps
in Subversion, and I want my static files (CSS) to be in there with
the rest of the django files.

Having said this, I'm not sure how to configure apache to look for
those CSS files. Say my django project is in /srv/django/myproject,
and my document root is in /srv/http, what must be done? If this is
covered in the documentation, I apologize for wasting the community's
time and would appreciate a direct link to the materials I need to
read.

Thanks in advance.

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



Re: Question related to "Writing your first Django app, part 1" tutorial.

2008-08-31 Thread [EMAIL PROTECTED]

You're getting a QuerySet back from filter, so you'll need to index
the result, i.e. c[0].

On Aug 31, 5:26 am, Artemis Fowl <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I was starting out to learn Django and was trying the tutorial
> presented in the website. In the part when the shell is used to create
> Poll and Choice objects, it is mentioned that Choice objects have
> access to Poll and Poll objects have access to Choice. The tutorial
> uses this example
>
> |-|
> |  >>> c = p.choice_set.create(choice='Just hacking again', votes=0)
> |
> |-|
>
> Then, it queries the object 'c' to get the poll it is associated with.
>
> |-|
> |  # Choice objects have API access to their related Poll
> objects.         |
> |  >>>
> c.poll
> |
> |  
> |
> |-|
>
> But if I try it in another way, I get an error. Please help!
>
> |--|
> |  >>> c =
> Choice.objects.filter(choice__startswith='Just')                    |
> |  >>>
> c.poll
> |
> |  Traceback (most recent call
> last):                                                   |
> |    File "", line 1, in
>                                             |
> |  AttributeError: 'QuerySet' object has no attribute
> 'poll'                       |
> |-|
>
> Many Thanks,
> Artemis.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Image thumbnail and save

2008-08-31 Thread julianb

On Aug 31, 6:45 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Can someone please point me in the right direction

I got problems after the refactoring, too:

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



spanning relationships

2008-08-31 Thread andro

Hello,


class Org(models.Model):
person = models.ForeignKey(Person)


class Person(models.Model):
address = models.ForeignKey(Address)
...

class Address(models.Model):
street = models.CharField(max_length=50)
city = models.CharField(max_length=25)
...

-
The following does not return any results:

Org.objects.filter(person__address__city__exact='Boston')

Can you tell me if this is a correct filter?

Thanks!

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



Re: Template tag i18n failing

2008-08-31 Thread Ramiro Morales

On Sun, Aug 31, 2008 at 2:09 PM, Ramiro Morales <[EMAIL PROTECTED]> wrote:
>
> This is a bug and has been reported as ticket |1] #7027, you can track
> the advance of the issue there.
>

This is fixed as of revision 8769.

cheers,

-- 
 Ramiro Morales

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



How to do this using Django Model

2008-08-31 Thread ydjango


How to implement following create table (mysql) using django model.

CREATE TABLE account_transaction (
account_id INT NOT NULL,
acct_trans_number INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (account_id,acct_trans_number)
);



The above is mysql script.  Acct_trans_number has to be unique and
sequential within an account id.
 this the only way it can be achieved in mysql as far as I am aware.

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



Slovkian speakers? Help wanted with #8709

2008-08-31 Thread Malcolm Tredinnick

All,

We're coming down to the wire with 1.0, so I need to throw out a plea to
the audience...

If anybody speaks Slovakian, could you please have a look at the
translation diff attached to ticket #8709 and see if it looks
reasonable. This is a case of somebody who is unknown to me submitting a
large translation patch and I'm reluctant to just commit it sight-unseen
this close to a major release. So I'm looking for somebody to have a
quick read -- just sample a couple of dozen strings and see if they look
reasonable; it doesn't have to be perfect -- and drop in a comment
saying so.

Thanks in advance,
Malcolm


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



Re: how do i do background tasks

2008-08-31 Thread Malcolm Tredinnick


On Sun, 2008-08-31 at 09:00 -0700, sotirac wrote:
> i'm creating an application that will read rss feeds. i'm using the
> universal feed parser library. i have a feed model (has the url to the
> feed) and an entry model (for each individual entry).  Is there a
> method in the model that I have to overwrite that will allow me to
> retrieve rss entries in the background and save it into the model.
> that way the rss feeds from a particular blog are read every hour and
> stored into the database for viewing.

That is something outside the scope of Django. Django handles the
request/response path -- so it's event driven. If you also want to do
background tasks, there are plenty of ways to do that already, so Django
doesn't need to reinvent that wheel. All those solutions are orthogonal
to what Django does: you can still use the Django ORM to insert things
into the database, etc, but you can do that from any script you like.

For your particular case, write a Python script that does what you want
exactly once and then use a cronjob to make it happen every hour.

Regards,
Malcolm



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



Re: Using Django with pache

2008-08-31 Thread Donn

On Sunday, 31 August 2008 16:33:32 Weber Sites wrote:
> The tutorial suggested to keep "mysite" out of the webroot so where do
> i point apache to?
Go to the Django site and read the docs about apache and mod_python. It's not 
that hard really.

\d

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



Re: Template tag i18n failing

2008-08-31 Thread Ramiro Morales

On Sun, Aug 31, 2008 at 1:58 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I would like to use
> {% printformfooter _("Submit Message") "Cancel" %}
>
> as it is documented here:
> http://www.djangoproject.com/documentation/i18n/#in-template-code
>
> but I get the error:
> "
> TemplateSyntaxError at /project/1/message/create/
>
> printformfooter takes 3 arguments
> "
>
> printformfooter is working fine if I don't put _().
>
> Could someone please tell me what I'm doing wrong.
>

This is a bug and has been reported as ticket |1] #7027, you can track
the advance of the issue there.

Also, you can help by applying the latest patch attached to it and posting you
experience there as a comment if you find some problem with it.

Regards,

1. http://code.djangoproject.com/ticket/7027

-- 
 Ramiro Morales

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



user preference: Translate words to equivalent words

2008-08-31 Thread ydjango

I want to let users configure some of the words they see on screens:

Like default is employee, But some users may want to see word "
associate" instead of "employee".
another example is "division" and some users want to see word "
Business unit" or "group instead of default "division"

and I want to make it user preference.

Is I18n message files and ugettext best way to do it ?

Or is there any other feature in django I can use for this translation
and for user preferences.


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



Template tag i18n failing

2008-08-31 Thread [EMAIL PROTECTED]

Hi,

I would like to use
{% printformfooter _("Submit Message") "Cancel" %}

as it is documented here:
http://www.djangoproject.com/documentation/i18n/#in-template-code

but I get the error:
"
TemplateSyntaxError at /project/1/message/create/

printformfooter takes 3 arguments
"

printformfooter is working fine if I don't put _().

Could someone please tell me what I'm doing wrong.

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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Image thumbnail and save

2008-08-31 Thread [EMAIL PROTECTED]

Hello,

before the File storage refactoring I had this code to do the
thumbnail of an image and save it.

from cStringIO import StringIO
from PIL import Image
im = Image.open(StringIO(self.cleaned_data['small_photo'].read()))
picturefile = StringIO()
im.thumbnail((250, 80), Image.ANTIALIAS)
im.save(picturefile, 'JPEG')
edit_user_profile.small_photo.save('pic.jpg', picturefile)

but now this doesn't work.

Can someone please point me in the right direction

Best regards,

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



Re: Adding Relation Without Saving

2008-08-31 Thread TiNo
You probably have a list of products somewhere, right? (from a form or other
input). Couldn't you just do

sum([p.price for p in products])

where products is that list??


On Fri, Aug 29, 2008 at 9:08 PM, Koen Bok <[EMAIL PROTECTED]> wrote:

>
> I'd like to build relations with objects without saving to pre-
> determine the price for a proposed order based on a set of products.
> But when I add a Product project to the Order, I first have to save
> the Order. Is there any way around this?
>
> Example:
>
> class Order(Model):
>id = models.AutoField(primary_key=True)
>number = models.IntegerField()
>
>def total(self):
>return sum([p.price for p in self.product_set])
>
> class Product(Model):
>id = models.AutoField(primary_key=True)
>order = models.ForeignKey(Order)
>price = models.DecimalField()
>
> order = Order(number=1)
>
> # Now the nex line throws an error if we did not save the order here
> order.product_set.create(Product(price=20.0))
>
> assert order.total() == 20.0
> >
>

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



Re: ModelForm, images and exclude

2008-08-31 Thread TiNo
On Fri, Aug 29, 2008 at 6:37 PM, flynnguy <[EMAIL PROTECTED]> wrote:

> ..


> However there are certain fields I want to set manually so I tried
> this:
> class AddPhotoForm(ModelForm):
>class Meta:
>model = Media
>exclude = ('type', 'pet', 'views')
>
> def add_pet_photo(request, pet_id):
>pet = Pet.objects.get(id=pet_id)


It is possible a pet with this id does not exist, so use get_object_or_404,
or catch the DoesNotExist here and raise a 404.


>
>if request.method == 'POST':
>form = AddPhotoForm(data=request.POST, files=request.FILES)
>if form.is_valid():
>added_photo = form.save(commit=False)
>added_photo.pet = pet
>added_photo.type = 'P'
>added_photo.views = 0 # this is a zero and is used as a
> counter


If you add 'blank=True' to 'views = models.IntegerField(default=0)' in your
model, you don't need to add the last line. You also don't need the
'self.views = 0' in the save method below:

>
>def save(self):
>if not self.id:
>self.created = datetime.datetime.today()
>self.views = 0
>self.updated = datetime.datetime.today()
>self.thumbnail = create_thumbnail(self.image, THUMB_WIDTH,
> THUMB_HEIGHT)
>super(Media, self).save()
>

Don't think it will solve your problem, some tips though.

TiNo

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



Nesting inlines with django-admin

2008-08-31 Thread Bojan Mihelac

Is it possible to nest inlines with django-admin? Using this type of
models for example:

Poll
PollTranslation (this is inline)
PollAnswer (this is inline)
PollAnswerTranslation (this should be inline of PollAnswer)

PollAnswerTranslation objects should be editable on same page.

Any hint or solution would be helpful.

Thanks,
Bojan Mihelac

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



Re: Many to Many field Assignment

2008-08-31 Thread Vadivel Kumar
i see that there exists a handy way -- *icontains* does exactly what iam
looking at

On Sun, Aug 31, 2008 at 9:35 PM, Vadivel Kumar <[EMAIL PROTECTED]> wrote:

>  Thanks Michael,
>
> I solved the problem - i had a silly mistake in the way how i handled  to
> check the existing tag. But, now the problem is when i check the given tag
> text against the database, i do it as like below,
>
>newTag = request.POST['tag']
>existingTag = Tags.objects.filter(TagName__exact=newTag)
>
> Now, I wanted to check it more perfectly, I want to check with
> case-insensitve etc., I am not seeing any appropriate django method to do
> this, may be i should check the documentation.
>
> Thanks for your quick help.
>

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



Re: Many to Many field Assignment

2008-08-31 Thread Vadivel Kumar
Thanks Michael,

I solved the problem - i had a silly mistake in the way how i handled  to
check the existing tag. But, now the problem is when i check the given tag
text against the database, i do it as like below,

   newTag = request.POST['tag']
   existingTag = Tags.objects.filter(TagName__exact=newTag)

Now, I wanted to check it more perfectly, I want to check with
case-insensitve etc., I am not seeing any appropriate django method to do
this, may be i should check the documentation.

Thanks for your quick help.

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



how do i do background tasks

2008-08-31 Thread sotirac

i'm creating an application that will read rss feeds. i'm using the
universal feed parser library. i have a feed model (has the url to the
feed) and an entry model (for each individual entry).  Is there a
method in the model that I have to overwrite that will allow me to
retrieve rss entries in the background and save it into the model.
that way the rss feeds from a particular blog are read every hour and
stored into the database for viewing.


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



Using Django with pache

2008-08-31 Thread Weber Sites

I'm going over Tutorial01 and Tutorial02 and I'm not sure how to use
the admin with Apache.
The tutorial suggested to keep "mysite" out of the webroot so where do
i point apache to?

berber

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



Re: Field with RadioSelect widget instead of Select widget

2008-08-31 Thread Bela Hausmann

Thanks, that's a good idea, but if I try it, the choices are gone and
i get an empty field.

I tried:

class ProfileForm(ModelForm):
def __init__(self, *args, **kwars):
super(ModelForm, self).__init__(*args, **kwars)
self.fields['gender'].widget = RadioSelect()
class Meta:
model = Profile
...

Any ideas?

On Aug 22, 12:18 pm, julianb <[EMAIL PROTECTED]> wrote:
>
> Maybe you can change the widget after the form got declared:
>
> form = BlaForm()
> form.fields['field'].widget = forms.RadioSelect()
>
> But I'm not quite sure what it does with the "--" line you have in
> a Select field.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Many to Many field Assignment

2008-08-31 Thread Michael Newman

On Aug 31, 11:14 am, "Vadivel Kumar" <[EMAIL PROTECTED]> wrote:
> I know this might sound very newbie .. its true
>
> How can i assign an exising record of the child table to an parent record.
> For example I have two models,
>
>     class User (models.Model):
>          ... all other fields ...
>         Tags  = models.ManyToManyField(Tag)
>
>      class Tag (models.Mode):
>          .. all fields ..
>
> The problem i am facing is whenever i create a new user and add an existing
> tag object to User.Tags.add() method it creates a new record in Tag table
> instead i need to just map the record with the new user.
>
> I know am missing a paramount thing .. what is that ?

The methods you are using, if I understand you correctly, should work.
I would need to take a look at the exact code that is creating a new
object to help you out. But one thing you can look at is
http://www.djangoproject.com/documentation/models/many_to_many/  . It
is very helpful at showing how the manytomanyfields work. If you are
still having an issue, post the offending code to dpaste.com and we
can take a look.

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



Re: Django 1.0 and Textmate

2008-08-31 Thread Michael Newman

A few people including myself are working on:
http://www.bitbucket.org/bkerr/django-textmate-bundles/

I really hope to get some time to really get it going in the next week
so we can officially announce it. We are definitely looking for more
eyes and recommendations on the project. If you want to contribute,
just let me know and I can get you signed up as a pusher.

Thanks, Michael

On Aug 31, 12:58 am, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
> Has anybody taken a crack at updating the Textmate Django bundles
> (python and template) for version 1.0?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Installing django on 10.4 os x and i cant figure this one out.

2008-08-31 Thread Jason Ourscene

when i run ls -las /usr/bin/python i get:
8 lrwxr-xr-x   1 root  wheel  9 Jul 21 22:50 /usr/bin/python ->
python2.3

when run "which python"
/usr/bin/python

I did not use macports, what i did do was install a later version of
python using this tutorial
http://blog.vixiom.com/2006/07/23/how-to-install-django-on-os-
x-tiger-104/">How To: Install Django on OS X (Tiger 10.4) 

and also, im seem to have profile stuff everywhere.
my .bash_profile:
export PATH=/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/django/bin:$PATH

my .profile:
# Setting PATH for MacPython 2.4
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$
{PATH}"
export PATH

my .bash_login:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:
$PATH"

Can i consolidate these into one? or do they all server different
purposes?

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



Many to Many field Assignment

2008-08-31 Thread Vadivel Kumar
I know this might sound very newbie .. its true

How can i assign an exising record of the child table to an parent record.
For example I have two models,

class User (models.Model):
 ... all other fields ...
Tags  = models.ManyToManyField(Tag)

 class Tag (models.Mode):
 .. all fields ..

The problem i am facing is whenever i create a new user and add an existing
tag object to User.Tags.add() method it creates a new record in Tag table
instead i need to just map the record with the new user.

I know am missing a paramount thing .. what is 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django SVN request.get_full_path() return main.fcgi?

2008-08-31 Thread Michael Richardson

On Aug 30, 11:07 pm, Jason Cui <[EMAIL PROTECTED]> wrote:
> When I update django SVN yestoday, about from 0.97 to 1.0 beta2, the
> function request.get_full_path() return wrong value sometimes. When I
> locate urlhttp://domain/detail/list/, this function return /main.fcgi/
> detail/list/, but should be /detail/list/.
>
> Who can tell me why? Now I have to add replace function to this value.
>
> My server config: django+fastcgi 1.4.18+fastcgi, the main.fcgi file in
> the public directory only has on line:
> export DJANGO_SETTINGS_MODULE=web.settings_fastcgi

Do you have FORCE_SCRIPT_NAME = '' in your settings.py file? See
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
and 
http://www.djangoproject.com/documentation/fastcgi/#forcing-the-url-prefix-to-a-particular-value
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: formset issue

2008-08-31 Thread patrickk

sorry for being so annoying with this issue, but I´m asking this one
more time.

- with using inlineformset_factory, my problem is that limiting the
choices to the currently logged-in user seems impossible. I´ve just
tried to write a custom manger with "use_for_related_fields = True",
but it´s also not possible to limit the basic queryset to the current
user.

so - before going back to pure forms and re-writing the main part of
my application, I´m just asking this question for the last time ...

thanks,
patrick


On Aug 27, 9:04 am, patrickk <[EMAIL PROTECTED]> wrote:
> anyone?
>
> On Aug 26, 12:19 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > scenario: users are uploading documents (e.g. images, files, ...).
> > these documents are saved in a model "Attachment" assigned to the
> > currently logged-in "User". now, every user has the possibility to
> > attach documents to a blog-entry. these attachments are saved in a
> > model "BlogEntryAttachment" assigned to a "BlogEntry".
> > the best way to achieve this is probably using formsets. when writing
> > a BlogEntry, the user has the option to attach his/her documents to
> > that BlogEntry. to achieve this, I have to limit the choices (of a
> > select-field) to the currenlty logged-in User.
>
> > questions & notes:
> > ### how can I limit the choices of a select-field using formsets?
> > ### I've tried inlineformset_factory, but there's no argument
> > "initial". besides that, I´m not sure how to use "initial" for
> > limiting a queryset ...
> > ### with using formset_factory on the other hand, I could use a
> > ModelChoiceField with queryset=Attachment.objects.filter(user=user),
> > but how do I get the "user" there?
> > ### Overriding __init__ within BlogEntryAttachmentForm and passing the
> > currently logged-in user seems possible, but then I also have to
> > override the BaseFormSets __init__ and _construct_form, which just
> > seems ugly and far too complicated.
>
> > MODELS:
>
> > class Attachment(models.Model):
>
> >     user = models.ForeignKey('auth.User')
> >     title = models.CharField('Title', max_length=100, blank=True,
> > null=True)
> >     filename = models.CharField('Filename', max_length=100,
> > blank=True, null=True)
> >     path = models.CharField('Path', max_length=200, blank=True,
> > null=True)
> >     ...
>
> > class BlogEntryAttachment(models.Model):
>
> >     blogentry = models.ForeignKey(BlogEntry)
> >     attachment = models.ForeignKey(Attachment)
> >     
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



User groups and permissions

2008-08-31 Thread Ca Phun Ung

Hello fellow Djangonauts,

I hit a problem with user permissions within the Django admin area. The 
other day I gave a user add/edit/delete user permissions so that they 
could manage staff access on the websites. However, in doing this that 
particular user is now able to create other users with greater 
permissions than himself, even promoting others to superuser status. 
Furthermore that user could also turn himself super by editing his own 
profile. Has anyone come across this problem? Is there a workaround? I 
assume there is a way to lock user permissions so one cannot promote 
oneself or others beyond ones allocated permission level?

Thanks.

-- Ca-Phun Ung


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



Form Wizard template URL

2008-08-31 Thread nss350

Hi,

I'm using a form wizard, but can't quite seem to figure out how to set
the url for it in a template i.e.

what do I put in the {% url %}

Another unrelated question. If I'm using the included login, logout
views, and I'm trying to get the views to redirect to a path set in
the template, how do I do it. I'm passing through the request object
so I can access the path, and doing something like

{% url django.contrib.auth.views.login
redirect_field_name=request.path %}
{% url django.contrib.auth.views.logout next_page=request.path %}

but it doesn't seem to be passing those paths through to the views.

Thanks
Neeraj

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



Re: Question about "Writing your first Django app, part 1"

2008-08-31 Thread patrickk

c = Choice.objects.filter(choice__startswith='Just') results in a
queryset (not a single object).

you could do:
for obj in c:
obj.poll

you have to loop through the items/objects of the queryset, before
getting the related poll-object.

btw: c[0].poll should also work.



On Aug 31, 12:15 pm, Artemis Fowl <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am starting out with Django and was trying out the tutorial. I was
> running the code through the shell as given in the document. But to my
> surprise, I found an anomaly. The tutorial mentions that the Poll
> object can access the Choice object and vice versa. The code given is
>
> >>> c = p.choice_set.create(choice='Just hacking again', votes=0)
>
> # Choice objects have API access to their related Poll objects.>>> c.poll
>
> 
>
> But if I do this instead, I don't get the results.
>
> >>> c = Choice.objects.filter(choice__startswith='Just')
> >>> c.poll
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'QuerySet' object has no attribute 'poll'
>
> Anybody help!
>
> Many Thanks,
> Artemis.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about "Writing your first Django app, part 1"

2008-08-31 Thread gordyt

Howdy Artemis,

> >>> c = Choice.objects.filter(choice__startswith='Just')
> >>> c.poll
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'QuerySet' object has no attribute 'poll'

Here is what is happening to you.  Choice.objects.filter() returns a
QuerySet, not a single Choice object.  Think of your QuerySet like a
list in this case.  For example, you could do this:

>>> c = Choice.objects.filter(choice__startswith='Just')[0]
>>> c.poll

Assuming that you had at least one Choice object whose choice
attribute started with "Just", that would return the first one.  Or
you could do this:

for c in Choice.objects.filter(choice__startswith='Just'):
print c.poll

That would get all of the Choice objects that meet your filter
criteria.

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



Question about "Writing your first Django app, part 1"

2008-08-31 Thread Artemis Fowl

Hello,

I am starting out with Django and was trying out the tutorial. I was
running the code through the shell as given in the document. But to my
surprise, I found an anomaly. The tutorial mentions that the Poll
object can access the Choice object and vice versa. The code given is

>>> c = p.choice_set.create(choice='Just hacking again', votes=0)

# Choice objects have API access to their related Poll objects.
>>> c.poll


But if I do this instead, I don't get the results.

>>> c = Choice.objects.filter(choice__startswith='Just')
>>> c.poll
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'QuerySet' object has no attribute 'poll'

Anybody help!

Many Thanks,
Artemis.

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



Question related to "Writing your first Django app, part 1" tutorial.

2008-08-31 Thread Artemis Fowl

Hello,

I was starting out to learn Django and was trying the tutorial
presented in the website. In the part when the shell is used to create
Poll and Choice objects, it is mentioned that Choice objects have
access to Poll and Poll objects have access to Choice. The tutorial
uses this example

|-|
|  >>> c = p.choice_set.create(choice='Just hacking again', votes=0)
|
|-|

Then, it queries the object 'c' to get the poll it is associated with.

|-|
|  # Choice objects have API access to their related Poll
objects. |
|  >>>
c.poll
|
|  
|
|-|

But if I try it in another way, I get an error. Please help!

|--|
|  >>> c =
Choice.objects.filter(choice__startswith='Just')|
|  >>>
c.poll
|
|  Traceback (most recent call
last):   |
|File "", line 1, in
|
|  AttributeError: 'QuerySet' object has no attribute
'poll'   |
|-|

Many Thanks,
Artemis.

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



Re: Installing django on 10.4 os x and i cant figure this one out.

2008-08-31 Thread Graham Dumpleton



Jason Ourscene wrote:
> I have some minor programming background. mainly php.
> Ive been trying to install python and django for the last 3 hours.
> I've gotten to the point where i have everything working. But when i
> run the django-admin.py script i get the following error
>
> Traceback (most recent call last):
>   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
> python2.4/site-packages/django/bin/django-admin.py", line 2, in ?
> from django.core import management
> ImportError: No module named django.core
>
> I'm assuming it has to do something with my path, but i how can i
> debug this and get it running.

Where is Django itself installed?

The path:

  /Library/Frameworks

indicates you are perhaps using MacPorts Python. If Django was
actually installed in standard operating system Python installation
instead, it would not be found.

So, work out where Django is installed.

Also then work out which 'python' is in your PATH, it looks like
MacPorts Python at the moment.

What does 'ls -las /usr/bin/python' yield and does it make a
difference if you run django-admin explicitly with '/usr/bin/python'.

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



Installing django on 10.4 os x and i cant figure this one out.

2008-08-31 Thread Jason Ourscene

I have some minor programming background. mainly php.
Ive been trying to install python and django for the last 3 hours.
I've gotten to the point where i have everything working. But when i
run the django-admin.py script i get the following error

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/site-packages/django/bin/django-admin.py", line 2, in ?
from django.core import management
ImportError: No module named django.core

I'm assuming it has to do something with my path, but i how can i
debug this and get it running.

Thank you in advance.

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



Re: No "normalize" in locale(?)

2008-08-31 Thread Prairie Dogg

Sorry about the thread hijack there, I mistakenly thought the
problems were related.

I'm using Python 2.5 on Ubuntu Hardy.  It seems to me that the
issue is the project locale directory is in my project folder.

The fact that the locale folder for my project is called
"locale" is causing a name space collision in the line:

from locale import normalize

I suffer from that newbie problem of not knowing what the
best / standard default configurations are.  The locale
directory was placed in the project root by

 ./manage.py makemessages -a

So I was kinda loathe to move it out of there.

Thanks so much for taking the time to look at the issue,
I apologize if this is a simple problem with a simple
solution...


On Aug 24, 1:29 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-08-24 at 10:14 -0700,PrairieDoggwrote:
> > I ran into this problem as well when I upgraded to the most recent
> > django trunk.  I found out about it because my tests failed the
> > following error:
>
> > from locale import normalize
> > ImportError: cannot import name normalize
>
> So you've kind of hijacked the original thread here, since this is a
> separate issue (I've changed the topic for that reason).
>
> What version of Python are you using on which OS/platform? The
> locale.normalize method is certainly in Python 2.3 by default (and later
> versions). Are you running some kind of cut-down Python install?
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---