Re: Authorization on data level in django admin

2009-04-02 Thread Joshua Partogi

On Apr 3, 11:23 am, Malcolm Tredinnick 
wrote:
> On Fri, 2009-04-03 at 00:26 +1100, Joshua Partogi wrote:
> > Dear all,
>
> > In django admin we can give permission to user to edit, delete or
> > create certain model. But what I want to do now is a user can only
> > edit or delete the data that he/she created.
>
> > Is there any way we can do this in django admin?
>
> Not out of the box, no. The admin is designed for people who are trusted
> to access all the data for models they have access to.
>
> The requirements for row-level permission management are huge and
> complicated (in the sense that they vary a lot for different domains),
> so having a comprehensive solution in Django isn't really on the
> roadmap. I'd imagine it wouldn't be too hard to implement the
> functionality you need via Admin subclasses and the like (although it
> might require the ChangeList class to be over-ridable, which I believe
> is a Django 1.2 feature now)

Hi Malcolm.

First of all thank you for the brief explanation.

So you reckon I shouldn't use django admin for row level
authorization?

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



Re: multiple S3 buckets using David Larlet's S3Storage.py

2009-04-02 Thread wynfred

Thank you for this helpful input, David. Have not been able to focus
on this development task yet, but will soon. Your guidance is very
much appreciated.

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



Re: how to use email instead of username for user authentication?

2009-04-02 Thread Malcolm Tredinnick

On Thu, 2009-04-02 at 19:04 -0700, Timboy wrote:
> What's the best way to add users with an auto generating username? ie:
> Taub.John, Smith.Tim, Smith.Tim2

You can do it however you like, since the user will never see it.
Something as simple as taking the email address, replacing "@" with "AT"
and "." with "DOT" might work.

One thing I did for a client was take the email address, trip off
everything after the "@" and then continue adding a number to the end of
the username until it was unique. So if t...@example.com registered
first, he would be username "tim" and t...@foo.bar.org would be username
"tim1", since "tim" was already in use. Since all registration is
normally done through one or two places, it only required setting up the
registration form handling view and writing a management command tool to
add a user manually. These days, I might also add some admin overrides,
but I didn't need that at the time.

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



Re: how to use email instead of username for user authentication?

2009-04-02 Thread Timboy

What's the best way to add users with an auto generating username? ie:
Taub.John, Smith.Tim, Smith.Tim2


On Apr 1, 3:37 am, johan.u...@student.hpi.uni-potsdam.de wrote:
> Best way is to write your own authentication backend I think.
>
> Check the 
> docs:http://docs.djangoproject.com/en/dev/topics/auth/?from=olddocs#writin...
>
> This article might also give you a good 
> idea:http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-mod...
>
> The actual authenticate function might look something like this:
>
> def authenticate(self, username=None, password=None):
>         # authenticate with email
>         try:
>                 user = self.user_class.objects.get(email=username)
>                 if user.check_password(password):
>                         return user
>         except self.user_class.DoesNotExist:
>                 # authentication with username
>                 try:
>                         user = self.user_class.objects.get(username=username)
>                         if user.check_password(password):
>                                 return user
>                 except self.user_class.DoesNotExist:
>                         # neither nor succesfull, so no user exists
>                         return None
>
> Beware: During registration I have forbidden usernames that might look
> like mail adresses (just unallow character @). Other than that there
> might be the rare possibility that people can not login with their
> username/password credentials if it username is the e-mail-adress used
> by another account.
>
> On Mar 31, 10:03 am, Rama Vadakattu  wrote:
>
> > The authentication model provided along with django is based on
> > username.
>
> > What to do to change the authentication based on email instead of
> > username?
>
> > To be more specific
> > ~~~
> >      With username authentication , to login user  we do the following
>
> >      user = authenticate(name,password)
> >      ...
> >      login(request,user)
>
> >      what to write for the above statements if we are authenticating
> > using email?
>
> >  For form
> >  ~
> > iam planning to write my own form which shows the fields
> > email,password and the validation.
> > Is this the correct approach?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What is the best way to extend the User Model

2009-04-02 Thread Malcolm Tredinnick

On Thu, 2009-04-02 at 18:29 -0700, Dave Fowler wrote:
[...]
> Profile.objects.all().select_related()
> 
> But it seems weird to base everything around the object that isn't
> used for authentication.  Is that what most people do?

"Seems weird" isn't a particularly strong technical reason (and is also
open to debate, since it's just a normal portion of the user
representation) . If you want to cut down your queries, that's the way
to go.

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



Re: How to create ability to send email from the admin with django?

2009-04-02 Thread Timboy

In two lines:

from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)

Mail is sent using the SMTP host and port specified in the EMAIL_HOST
and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD
settings, if set, are used to authenticate to the SMTP server, and the
EMAIL_USE_TLS setting controls whether a secure connection is used.

On Apr 2, 8:42 am, ChrisR  wrote:
> I've been searching and trying to figure this out, but I haven't quite
> found the source that makes it snap in my mind.
>
> I'd like to be able to send an email or emails out from my site
> through the admin.  I have the email settings added to settings.py,
> but not sure where to go next.
>
> I've read the documentation about sending email on the django 
> site:http://docs.djangoproject.com/en/1.0/topics/email/
>
> The "Quick" example that allows you to send email in 2 lines doesn't
> make sense to me:
> "from django.core.mail import send_mail
>
> send_mail('Subject here', 'Here is the message.', 'f...@example.com',
>     ['@example.com'], fail_silently=False)"
>
> Where is that code supposed to live?  How do you actually send it?
> I've seen a few things that imply you did it from the Python API?
>
> Can someone point me in the right direction on how to make this happen
> through the admin?  Do I need to make a model for it?  What triggers
> the actual send then?
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What is the best way to extend the User Model

2009-04-02 Thread Alex Gaynor
On Thu, Apr 2, 2009 at 9:29 PM, Dave Fowler  wrote:

>
> I'm about to do my umpteenth Django app and I'm just wondering if
> there is a new standard (better) way to extend the User model.  I've
> used this method
>
> http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/
>
> And a few others, but all of them keep the User and Profile objects
> separate which consistently adds a lot of extra code for me.  The
> largest issue is a command like this
>
> User.objects.all().select_related()
>
> Results in an N+1 query when you need the profile information.  You
> could base everything off of your profile
>
> Profile.objects.all().select_related()
>
> But it seems weird to base everything around the object that isn't
> used for authentication.  Is that what most people do?
>
> Thanks
> >
>
Yes, the OneToOneField is still the prefered way to extend the user model,
the issue with select related is the subjct of ticket #7270.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Adding a ManyToMany field to existing model

2009-04-02 Thread jjgod

Hi Joey,

On 4月3日, 上午2时07分, Joey Gartin  wrote:
> I am new also, but I noticed right away that you had quotes around Speaker
>
> speakers = models.ManyToManyField("Speaker")
> That may be the problem.  I have added manytomany fields after the fact and
> had no problems.

Thanks, but I did try changing "Speaker" back to Speaker, yet nothing
happened
after I syncdb again.

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



Re: How do i use dojo in my Django application

2009-04-02 Thread Kenneth Gonsalves

On Thursday 02 April 2009 18:20:27 Gath wrote:
>  have downloaded Dojo 1.3, i want to start sampling some examples  in
> the Dojo website using Django, where do i place the package? How do i
> call it in my template?

a template is just html - put dojo where you put your other css and js files 
and load it in the base.html - call it as you would in ordinary html
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: widget=forms.HiddenInput doesn't work

2009-04-02 Thread Michael Rose Jr.

This was fixed by upgrading to the latest version in SVN.

Thanks for your help B

On Apr 1, 8:57 pm, "Michael Rose Jr."  wrote:
> On Apr 1, 8:40 pm, Brian Neal  wrote:
>
>
>
> > On Apr 1, 10:19 pm, "Michael Rose Jr." 
> > wrote:
>
> > > Brian. Thanks for responding. I mean to post "name". I've been
> > > experimenting with other field types, which why I accidentally pasted
> > > "last". Here is the HTML for "name".
> > > Name: > > type="text" name="name" maxlength="45" />
>
> > > Here's the model.http://dpaste.com/22453/
> > > Thanks again for your help.
>
> > > Riz
>
> > Oh, one more thing. How are you displaying your form in your template?
> > Can you post that part of your template?
>
> > BN
>
> Hi Brian,
>
> Here's the template:http://dpaste.com/22457/
>
> Here's the "view source" (Line 5)http://dpaste.com/22458/
>
> I am seeing this issue in the development server and in production/
> Apache. I restarted both and cleared my cache in my browsers just to
> be sure that wasn't the issue.
>
> Python 2.5.2 (r252:60911, Jan  4 2009, 21:59:32)
> [GCC 4.3.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> import django
> >>> django.VERSION
>
> (1, 0, 2, 'final', 0)
>
>
>
> Thanks,
>
>  Riz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authorization on data level in django admin

2009-04-02 Thread Malcolm Tredinnick

On Fri, 2009-04-03 at 00:26 +1100, Joshua Partogi wrote:
> Dear all,
> 
> In django admin we can give permission to user to edit, delete or
> create certain model. But what I want to do now is a user can only
> edit or delete the data that he/she created.
> 
> Is there any way we can do this in django admin?

Not out of the box, no. The admin is designed for people who are trusted
to access all the data for models they have access to.

The requirements for row-level permission management are huge and
complicated (in the sense that they vary a lot for different domains),
so having a comprehensive solution in Django isn't really on the
roadmap. I'd imagine it wouldn't be too hard to implement the
functionality you need via Admin subclasses and the like (although it
might require the ChangeList class to be over-ridable, which I believe
is a Django 1.2 feature 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Performance Issue: ForeignKey will touch database again!

2009-04-02 Thread Malcolm Tredinnick

On Thu, 2009-04-02 at 00:46 -0700, Zeal wrote:
> 
> 
> On 4月2日, 下午2时39分, Alex Koshelev  wrote:
> > On Thu, Apr 2, 2009 at 10:36 AM, Zeal  wrote:
> >
> >
> > Documentation knows [1]
> >
> > [1]:http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4
> 
> Hi, Alex,
> 
> Really appreciates your prompt response and useful solution, the sql
> queries have been dramatically reduced to the acceptable level.
> 
> However, I still feel that the page which need to handle thousand of
> records is really slow than others,(Firefox is better than IE, IE) .
> Do you have any idease for such performance issues? Thanks!

Don't display or retrieve 1000 records is the obvious speedup. "I feel
it's slow" is useless for performance improvement purposes. Is it slow?
Measure it: how long does it take. Where is the time being spent:
retrieving the data from the database? Rendering it to the template
string? Sending it back to the user? Put some time.time() logging in the
appropriate views and come up with some real numbers so that you can
work out what's going on.

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



Re: Logging out a user when his account is made inactive

2009-04-02 Thread Malcolm Tredinnick

On Wed, 2009-04-01 at 14:13 -0700, christian.oudard wrote:
> I have made a page for admins to set a user account to inactive, but I
> noticed that the user's session continues if he is logged in. It
> appears that the is_active field is only checked when the user logs
> in, not when each request is authenticated.

Terminology point: *Authentication* is what happens when the login check
is performed. On subsequent visits, the session tells you that they're
already *authorised* -- they aren't re-authenticated.


>  Is there an easy way to
> log a user out when his account is made inactive

The difficulty here is that there's no easy way to look up a session
based on a user (there could be more than one, too). Sessions are
pickled data, indexes only by the session identifier. If you knew the
session identifier, you could simply delete that session, but finding
the right session to delete requires a full table scan and a bunch of
unpickling.

>  Also, should the
> auth system check is_active on every authenticated request, and should
> this be considered a bug in the auth app?

No. It's up to you to work out what you want to do with is_active, since
it varies from application to application. Note that is_active doesn't
even prevent you from logging in (as documented).

You might want to add some extra middleware to do that check if it's
part of your logic flow.

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



Re: Problem Installing Django on OS X 10.4.11

2009-04-02 Thread Nick Lo

Hi Scott,

> I'm having an issue confirming that Django is installed properly. I
> did what the Django site said: "You can tell Django is installed by
> running the Python interactive interpreter and typing import django."
> So i typed in import django and got:
>
 import django
> Traceback (most recent call last):
>  File "", line 1, in 
> ImportError: No module named django
>
> What does that mean? Anyone know why it doesn't find django module?

That generally means it can't find the django module as you suggest.  
Try this from the Python interpreter:

 >>> import sys
 >>> sys.path

That should give you a list something like the following:

['', '/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python26.zip', '/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python2.6', '/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python2.6/plat-darwin', '/Library/Frameworks/Python.framework/Versions/ 
2.6/lib/python2.6/plat-mac', '/Library/Frameworks/Python.framework/ 
Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/Library/ 
Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/ 
Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib- 
old', '/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ 
lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.6/lib/ 
python2.6/site-packages', '/Library/Frameworks/Python.framework/ 
Versions/2.6/lib/python2.6/site-packages/PIL']

In it you can see the directory "site-packages" if you then look in  
that directory (here is mine)...

Nicks-Computer:~ nick2$ ls '/Library/Frameworks/Python.framework/ 
Versions/2.6/lib/python2.6/site-packages'
MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg
PIL
PIL.pth
README
beancount
beancount-1.0-py2.6.egg-info
django

...you should be able to see your django installation. If not then it  
hasn't been installed properly and you'll need to give more info as to  
what steps you're taking, such as the output from the above. The basic  
idea is really only that the main django file (the one that contains  
eg contrib, auth, db, etc.) is in that site-packages directory and  
therefore findable.

Nick

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



Re: Trac + Sphinx

2009-04-02 Thread Malcolm Tredinnick

On Wed, 2009-04-01 at 15:14 -0300, Fábio Costa wrote:
> Sorry, what he meant to ask is if the Django project use any kind of
> integration within trac and sphinx, like some kind of plugin.

If you mean djangoproject.com, the answer is "no".
code.djangoproject.com is a Trac installation, www.djangoproject.com is
a set of Django applications and other stuff (including the processed
Sphinx documentation).

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



Re: Setting default values for model options?

2009-04-02 Thread Malcolm Tredinnick

On Wed, 2009-04-01 at 10:58 -0700, jeremias.kangas wrote:
> Hello,
> 
> I noticed that default value when adding a field for a model is
> null=False. This default option is not very good for me, because for
> almost every field needs to be null in my application. Is there a way
> to change these default values for options?

You can add null=True when you write out the field definition. There's
no way to change the Django-wide default. That would break the concept
of being able to use external applications (along with being very
confusing).

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



Re: Error creating test database

2009-04-02 Thread Russell Keith-Magee

On Thu, Apr 2, 2009 at 9:23 PM, Andrew G.  wrote:
>
> I have a django app that is built against an existing database.  In
> the database, there are a couple tables used as the many-to-many
> relation lookup table.  However, I have mapped models to the many-to-
> many lookup table, since I have a need for accessing these entries
> directly.  Since the tables already exists, manage.py syncdb has no
> problems, but when running manage.py test, the attempt to create the
> test database complains that the many-to-many table already exists and
> fails out.
>
> Is there a way to specify ignoring the creation of this table
> somewhere, or another way to circumvent this problem?  Should this be
> considered a bug?

I'm not sure I understand your situation here. When you run manage.py
test, Django creates an entirely new, clean database. There shouldn't
be any pre-existing tables. Can you elaborate on exactly what you are
doing to generate this error?

Yours,
Russ Magee %-)

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



Re: Mysql?

2009-04-02 Thread Chris O'Donnell

To install Django on the server, if it isn't there already.

On Mar 31, 11:33 pm, Wiiboy  wrote:
> Why do you need shell access?  Aren't you supposed to do all the
> coding and stuff on the local server, and then upload it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: upgrading django

2009-04-02 Thread John Baker

I did this over dec/jan for an inherited app.. it was an absolute
nightmare.. i had to rewrite huge chunks of it..

It really would depend on how many hacks the original app had though.
Unfortunately, I inherited lots of obscure shortcuts and extensions
that became incompatible so most of it stopped working and probably
changed about 2000 lines of code. I very nearly gave up about 2/3 the
way through and rewrote it. That's the trouble when developers try to
be clever rather than clear!

If its cleanly written and everything separated out then it should be
ok. If there are unit test that will help loads. I had no tests so it
took months before all the bugs were ironed out.

On Apr 2, 4:57 pm, Miguel  wrote:
> Hello everybody,
>
> I have seem new django versions improve the performance of web applications.
> I have a huge web aplication and I m thinking about changing it. How hard
> would be to upgrade django 0.96 to the newest one? Has it backward
> compatibility?
>
> thank you very much,
>
> Miguel
>
> Miguel
> Sent from Madrid, Spain
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem Installing Django on OS X 10.4.11

2009-04-02 Thread Scott

I'm having an issue confirming that Django is installed properly. I
did what the Django site said: "You can tell Django is installed by
running the Python interactive interpreter and typing import django."
So i typed in import django and got:

>>> import django
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named django

What does that mean? Anyone know why it doesn't find django module?

Thanks in advance to all with advice.

-Scott

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



RSS producing wrong link from get_absolute url

2009-04-02 Thread John Baker

I have a strange problem with simple RSS feeds. It works fine locally
on my development machine but when I deploy to the test server running
through mod_python on port :81 the blog item links miss out the port
number and so don't work.

Test server with new RSS code..
http://www.adrem.uk.com:81/feeds/blog/

The links become (cutting out the port number!!!)
http://www.adrem.uk.com/blog/79/

Here are code snippets.. Help! Anyone got any ideas?? It is pretty
strange..
--
feeds = {
'blog': BlogFeed,
'jobs': JobsFeed,
}
--
   (r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
   (r'^blog/(?P\d+)/$', adrem.views.news_item),
--
class BlogFeed(Feed):
title = "www.adrem.uk.com blog rss feed"
link = settings.SITE_BASE
description = "The latest adrem blogs"

def items(self, obj):
   return NewsItem.objects.order_by('-posted')[:20]
--
class NewsItem(models.Model):
category  = models.ForeignKey(NewsCategory)
show_in_all   = models.BooleanField(default=False,
help_text="This only applies to the two original news categories (main
and dreamspace)")
posted= models.DateField()
headline  = models.CharField(max_length=200)
story = models.TextField()
primary_picture   = models.ImageField(upload_to="uploads/model/
newsitem_pictures/", blank=True, null=True)
secondary_picture = models.ImageField(upload_to="uploads/model/
newsitem_pictures/", blank=True, null=True)

def get_absolute_url(self):
return urlresolvers.reverse("adremsite.adrem.views.news_item",
kwargs={"newsitem_id": self.id})

def __unicode__(self):
return "%s: %s" % (self.posted, self.headline)



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



Re: ManyToManyField() causes bugs when using 'ModelName' instead of 'self'

2009-04-02 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jumpfroggy wrote:
> Summary: django should throw an exception when a model has its own
> name as the 'to' field of a ManyToMany() insead of 'self'.

> Have I missed anything?  I may be misunderstanding the problem here,
> but I have managed to fix my problem and figure this could save others
> from the same trap.  I'd like to get some input before submitting a
> ticket.

Hey Jumpfroggy!  I can sympathize with you as I spent some time a few
days ago stumbling around on this same problem.  I don't have a problem
with requiring self to be there (though I do think using the model
class's name is more natural, self is OK too), but it would indeed be
helpful if there were an exception.  Perhaps you could bring this up on
django-developers?

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknVLP8ACgkQw3vjPfF7QfUeiACbB9AUfTAEQPdzFacx8drbvgyt
774An0+ccYiqKfQiLy3IO5hHQo2IEvfJ
=UKTq
-END PGP SIGNATURE-

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



django-facebookconnect

2009-04-02 Thread Ryan

Hey folks,

I posted code for a facebook connect django app on google code. I
refactored code from the News Mixer application to use for another
project, and figured it was useful enough that others might want it.

http://code.google.com/p/django-facebookconnect/
http://code.google.com/p/newsmixer/

The app is pretty simple, its just built on top of django.contrib.auth
and pyfacebook. It works along side django-registration and regular
django user accounts. New facebook users can link an existing django
user account when they log in or just use a user account that gets
automatically generated.

News Mixer used the facebook API extensively. So this app handles a
lot of the BS headache problems that we ran into working with facebook
connect. It uses caching extensively to minimize API calls to
facebook, handles session timeouts and a few other things.

Check it out, tell me what you think.

--
Ryan Mark
http://ryan-mark.com
847 691 8271

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



Re: mod_python: "No module named django"

2009-04-02 Thread Jeff Gentry

Err, sorry, I meant to cancel and sent this instead.  I believe I found my
problem while preparing to email about this (wasn't looking close enough
at the error message, and it looks like apache was looking in the wrong
python's site-packages)

On Thu, 2 Apr 2009, Jeff Gentry wrote:

> 
> Ok, so I've managed to get django running using mod_python on some other
> machines, but today I'm being stymied:
> 
> 
> 
> 
> > 
> 


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



mod_python: "No module named django"

2009-04-02 Thread Jeff Gentry

Ok, so I've managed to get django running using mod_python on some other
machines, but today I'm being stymied:




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



ManyToManyField() causes bugs when using 'ModelName' instead of 'self'

2009-04-02 Thread Jumpfroggy

Summary: django should throw an exception when a model has its own
name as the 'to' field of a ManyToMany() insead of 'self'.

I had a field like this:

def Item(Model):
name = CharField(max_length=100)
related_items = ManyToManyField('Item', blank=True)

But this caused some very strange bugs.  For example:

item1 = Item.objects.create(name='First')
item1.save()

item2 = Item.objects.create(name='Second', related_items=[item1])
item2.save()

print item2.related_items
> []
print len(item2.related_items)
> 0

The correct way, as stated in the docs, is to use 'self' for a
recursive relationship.

def Item(Model):
name = CharField(max_length=100)
related_items = ManyToManyField('self', blank=True)

(NOTE: This is pseudo/test code, may contain typos)

When I use this method, it works fine.  However, if the first method
is incorrect and produces functionally invalid results, then there
should be a model validation check for this and an exception if it's
found.  Basically, if a model has a ManyToManyField() with its own
name as the 'to' parameter, an exception should be raised.

I understsand that the current functoinality & docs are working as
they're supposed to.  However, it would also be nice for django to
raies an exception instead of silently failing and producing invalid
results.

Have I missed anything?  I may be misunderstanding the problem here,
but I have managed to fix my problem and figure this could save others
from the same trap.  I'd like to get some input before submitting a
ticket.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



google-transmeta

2009-04-02 Thread phred78

Hello,

Has anyone played with google-transmeta yet?
It's great but I can't seem to understand how to pass the model
building part.

I'm wondering what's the best way to pass variables to templates. For
instance:

def view(request, language, slug):
activate(language)
page = Page.objects.get(slug=slug)
return render_to_response("view.html", {'page' : page})

Will not work. If I send 'es' as the language, it will still give me
the default English version (from the default language in settings, I
suppose).
I've tried sending the language variable to the template and it's
working, but it's not replacing 'slug' with 'slug_es' as it should (or
at least as I think it should).
Documentation is not very clear on how to get past the model work and
implementing in actual views and templates.

Any help will be much appreciated.

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



Re: Adding a ManyToMany field to existing model

2009-04-02 Thread Joey Gartin
gzjjgod

I am new also, but I noticed right away that you had quotes around Speaker

speakers = models.ManyToManyField("Speaker")
That may be the problem.  I have added manytomany fields after the fact and
had no problems.

Good luck!
On Thu, Apr 2, 2009 at 10:02 AM, jjgod  wrote:

>
> Hi,
>
> I'm running Django version 1.1 beta 1 SVN-10368.
>
> I'm having a problem trying to a ManyToMany field to an existing
> model.
>
> In an application called "videos", I created a models.py like this:
>
> from django.db import models
>
> class Speaker(models.Model):
>name = models.CharField(max_length=200)
>localized_name = models.CharField(max_length=200)
>bio = models.TextField()
>
> class Video(models.Model):
>title = models.CharField(max_length=200)
>localized_title = models.CharField(max_length=200)
>description = models.TextField()
>filmed_on = models.DateField('date filmed')
>video_url = models.URLField(verify_exists=False)
>subtitle_url = models.URLField(verify_exists=False)
>
> then I add
>
>speakers = models.ManyToManyField("Speaker")
>
> to the end of Video class.
>
> when I run "python manage.py sql videos", it returns:
>
> BEGIN;
> CREATE TABLE "videos_speaker" (
>"id" integer NOT NULL PRIMARY KEY,
>"name" varchar(200) NOT NULL,
>"localized_name" varchar(200) NOT NULL,
>"bio" text NOT NULL
> )
> ;
> CREATE TABLE "videos_video" (
>"id" integer NOT NULL PRIMARY KEY,
>"title" varchar(200) NOT NULL,
>"localized_title" varchar(200) NOT NULL,
>"description" text NOT NULL,
>"filmed_on" date NOT NULL,
>"video_url" varchar(200) NOT NULL,
>"subtitle_url" varchar(200) NOT NULL
> )
> ;
> CREATE TABLE "videos_video_speakers" (
>"id" integer NOT NULL PRIMARY KEY,
>"video_id" integer NOT NULL REFERENCES "videos_video" ("id"),
>"speaker_id" integer NOT NULL REFERENCES "videos_speaker" ("id"),
>UNIQUE ("video_id", "speaker_id")
> )
> ;
> COMMIT;
>
> which seems to be fine for me. Then I run "python manage.py syncdb",
> yet it does not create any new table for me, and when I try to look
> into the database generated with sqlite3 , it shows:
>
> sqlite> .tables
> auth_group  django_admin_log
> auth_group_permissions  django_content_type
> auth_messagedjango_session
> auth_permission django_site
> auth_user   videos_speaker
> auth_user_groupsvideos_video
> auth_user_user_permissions
>
> which apparently does not have the last table described in "python
> manage.py sql videos". Then I try to add a video object in admin page,
> it gives me error page like this:
>
> OperationalError at /admin/videos/video/1/
> no such table: videos_video_speakers
>
> I'm fairly new to Django, so I really wish to know if I missed
> something. Thanks in advance.
> >
>


-- 
Joey Gartin

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



Re: Search on concatenated fields of qset

2009-04-02 Thread Jesse

Hello Tim,

I gave it a try, no errors, but also no results for the Contact.  I
think I have a problem in the resultsc statement.  How do I filter out
both qset3 and qset3_inner?

query = request.GET['q']
terms = query.split()
# terms = re.findall(r'\w+', query)
if query:   # will eventually add the split to this section
qset = (
Q(pubtitlestrip__icontains=query) |
Q(pubauthors__icontains=query)|
Q(journal__journal__icontains=query)
)
pubresults = Publication.objects.exclude(active = 0).filter
(qset).distinct()
qset3=Q()
for term in terms:
qset3_inner = Q()
for (field_to_search, how) in (
('firstname', 'icontains'),
('lastname', 'icontains'),
):
name = "%s__%s" % (field_to_search, how)
qset3_inner |= Q(**{name: term})
qset3 &= qset3_inner  # AND them together
resultsc = Contact.objects.filter(qset3).distinct()

Thanks!!

On Apr 1, 1:12 pm, Tim Chase  wrote:
> > My model has firstname and lastname as separate fields.  In a search
> > box if a person types in one name say "Bunny" then based on the
> > following query they will find Bunny:
>
> > qset = (
> >             Q(firstname__icontains=query) |
> >             Q(lastname__icontains=query)  |
> >         )
>
> > If a person types in "Bunny Foo" to find first and last name they
> > won't find anything using the above query.  How can I concatenate
> > firstname || lastname to make contactname and use it in the qset?
>
> The typical way to do this is to split the search-string into
> words on which you want to search.  You also have to decide
> whether you want to require that both terms match (AND) or a
> match can be found either way (OR):
>
>    search = "Bunny Foo"
>    terms = search.split()
>    # terms = re.findall(r'\w+', search)
>
>    qset = Q()
>    for term in terms:
>      qset_inner = Q()
>      for (field_to_search, how) in (
>          ('firstname', 'icontains'),
>          ('lastname', 'icontains'),
>          ):
>        name = "%s__%s" % (field_to_search, how)
>        qset_inner |= Q(**{name: term})
>      qset &= qset_inner  # AND them together
>      #qset |= qset_inner # OR them together
>
> -tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding a ManyToMany field to existing model

2009-04-02 Thread jjgod

Hi,

I'm running Django version 1.1 beta 1 SVN-10368.

I'm having a problem trying to a ManyToMany field to an existing
model.

In an application called "videos", I created a models.py like this:

from django.db import models

class Speaker(models.Model):
name = models.CharField(max_length=200)
localized_name = models.CharField(max_length=200)
bio = models.TextField()

class Video(models.Model):
title = models.CharField(max_length=200)
localized_title = models.CharField(max_length=200)
description = models.TextField()
filmed_on = models.DateField('date filmed')
video_url = models.URLField(verify_exists=False)
subtitle_url = models.URLField(verify_exists=False)

then I add

speakers = models.ManyToManyField("Speaker")

to the end of Video class.

when I run "python manage.py sql videos", it returns:

BEGIN;
CREATE TABLE "videos_speaker" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(200) NOT NULL,
"localized_name" varchar(200) NOT NULL,
"bio" text NOT NULL
)
;
CREATE TABLE "videos_video" (
"id" integer NOT NULL PRIMARY KEY,
"title" varchar(200) NOT NULL,
"localized_title" varchar(200) NOT NULL,
"description" text NOT NULL,
"filmed_on" date NOT NULL,
"video_url" varchar(200) NOT NULL,
"subtitle_url" varchar(200) NOT NULL
)
;
CREATE TABLE "videos_video_speakers" (
"id" integer NOT NULL PRIMARY KEY,
"video_id" integer NOT NULL REFERENCES "videos_video" ("id"),
"speaker_id" integer NOT NULL REFERENCES "videos_speaker" ("id"),
UNIQUE ("video_id", "speaker_id")
)
;
COMMIT;

which seems to be fine for me. Then I run "python manage.py syncdb",
yet it does not create any new table for me, and when I try to look
into the database generated with sqlite3 , it shows:

sqlite> .tables
auth_group  django_admin_log
auth_group_permissions  django_content_type
auth_messagedjango_session
auth_permission django_site
auth_user   videos_speaker
auth_user_groupsvideos_video
auth_user_user_permissions

which apparently does not have the last table described in "python
manage.py sql videos". Then I try to add a video object in admin page,
it gives me error page like this:

OperationalError at /admin/videos/video/1/
no such table: videos_video_speakers

I'm fairly new to Django, so I really wish to know if I missed
something. 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



upgrading django

2009-04-02 Thread Miguel
Hello everybody,

I have seem new django versions improve the performance of web applications.
I have a huge web aplication and I m thinking about changing it. How hard
would be to upgrade django 0.96 to the newest one? Has it backward
compatibility?


thank you very much,

Miguel


Miguel
Sent from Madrid, Spain

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



How to create ability to send email from the admin with django?

2009-04-02 Thread ChrisR

I've been searching and trying to figure this out, but I haven't quite
found the source that makes it snap in my mind.

I'd like to be able to send an email or emails out from my site
through the admin.  I have the email settings added to settings.py,
but not sure where to go next.

I've read the documentation about sending email on the django site:
http://docs.djangoproject.com/en/1.0/topics/email/

The "Quick" example that allows you to send email in 2 lines doesn't
make sense to me:
"from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)"


Where is that code supposed to live?  How do you actually send it?
I've seen a few things that imply you did it from the Python API?

Can someone point me in the right direction on how to make this happen
through the admin?  Do I need to make a model for it?  What triggers
the actual send then?

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



How to create ability to send email from the admin with django?

2009-04-02 Thread ChrisR

I've been searching and trying to figure this out, but I haven't quite
found the source that makes it snap in my mind.

I'd like to be able to send an email or emails out from my site
through the admin.  I have the email settings added to settings.py,
but not sure where to go next.

I've read the documentation about sending email on the django site:
http://docs.djangoproject.com/en/1.0/topics/email/

The "Quick" example that allows you to send email in 2 lines doesn't
make sense to me:
"from django.core.mail import send_mail

send_mail('Subject here', 'Here is the message.', 'f...@example.com',
['t...@example.com'], fail_silently=False)"


Where is that code supposed to live?  How do you actually send it?
I've seen a few things that imply you did it from the Python API?

Can someone point me in the right direction on how to make this happen
through the admin?  Do I need to make a model for it?  What triggers
the actual send then?

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



Re: How do i use dojo in my Django application

2009-04-02 Thread Rob Goedman
Gath,

Attached at the end of this email an exchange from a few months back  
about Dojo & Django using the dojango application.

I've been using this and have been happy with it.

http://code.google.com/p/dojango/

Rob


On Apr 2, 2009, at 7:55 AM, Dougal Matthews wrote:

> It kinds depends what you want to do really.
>
> JavaScript is run inside the browser and Django is running on your  
> website. So it doesn't even know what Django or Python is, however  
> they can communicate and pass data.
>
> By using it with Django, do you mean you want to do some Ajax stuff?  
> If that's the case then you will want to decide how you are going to  
> pass data. You can then just make your views return the appropriate  
> data, be that chunks of HTML, JSON or XML etc.
>
> Dougal
>
> ---
> Dougal Matthews - @d0ugal
> http://www.dougalmatthews.com/
>
>
>
> 2009/4/2 Gath 
>
> All,
>
> I have downloaded Dojo 1.3, i want to start sampling some examples  in
> the Dojo website using Django, where do i place the package? How do i
> call it in my template?
>
> Gath
>
>
>
> >



On Nov 2, 2008, at 12:42 AM, Wolfram Kriesing wrote:

>
> awesome :-)
> Glad I could help.
> Feel free to ask anything, I will try to help!
>
> -- 
> cu
>
> Wolfram
>
> http://uxebu.com - web consultancy
> You need AJAX, RIA, JavaScript and all this modern stuff? We got it!
>
>
>
> On Sun, Nov 2, 2008 at 1:14 AM, Rob Goedman  wrote:
>>
>> Wolfram,
>>
>> You bet I've read your blogs! Wouldn't have gotten where I got to
>> without them!
>>
>> Clearly I had missed the to_dojo_data(), that's exactly what I was
>> looking for.
>>
>> This works super.
>>
>> Thanks a lot,
>> Rob
>>
>> On Nov 1, 2008, at 4:45 PM, Wolfram Kriesing wrote:
>>
>>>
>>> Hi Rob,
>>>
>>> aehm, maybe what you were looking for was this:
>>>
>>> @json_response
>>> def send_toxids_list(request):
>>>   ret = Toxid.objects.all()
>>>   return to_dojo_data(ret, identifier='docno')
>>>
>>> the json_response decorator takes care of extrcting only the
>>> fields form the model, you dont have to do this
>>> by hand. And the to_dojo_data() function converts the
>>> data into a dojo.data store compatible format.
>>>
>>> See also this blog post about more info
>>> about the json_response decorator/function
>>> and insight details.
>>> http://wolfram.kriesing.de/blog/index.php/2007/json-serialization-for-django
>>>
>>>
>>> --
>>> cu
>>>
>>> Wolfram
>>>
>>> http://uxebu.com - the AJAX experts
>>> You need AJAX, RIA, JavaScript and all this modern stuff? We got it!
>>
>>
>>> On Nov 1, 2008, at 4:34 PM, Wolfram Kriesing wrote:

 Hi Rob,

 did you see the blog article
 http://blog.uxebu.com/2008/07/26/ajax-with-dojango/
 and the examples in
 http://code.google.com/p/dojango/source/browse/trunk/dojango/views.py

 tbh I don't really understand what you are using the JSON
 serializer for.
 Could you may be explain, if the links above dont help?

 --
 cu

 Wolfram

 http://uxebu.com - the AJAX experts
 You need AJAX, RIA, JavaScript and all this modern stuff? We got  
 it!
>>
>>
 On Sat, Nov 1, 2008 at 11:31 PM, Rob Goedman   
 wrote:

 Hi,

 Just for Django & Dojo users.

 Working through the 'Mastering Dojo' book, updating the examples
 where
 applicable to Dojo 1.2 (i.e. grids) and making them work with  
 Django
 svn has gone pretty smoothly. I wonder if below method is a
 reasonable
 way to generate fairly generic xhr* responses?

 I use something like (e.g. from the dojo.data chapter on
 QueryReadStore):

 @json_response
 def send_toxids_list(request):
  """
  Creates a JSON/Dojo hash with the filtered contents
  for a grid. This method is called by Dojo xhr*.

  To do:

  1)  Change ...all() into ...filter()
 according to qDict info.

  """

  qDict = request.GET
  print qDict['user'], qDict.get('query', None)

  queryset = Toxid.objects.all()
  json_serializer = serializers.get_serializer("json")()
  toxids_json = json_serializer.serialize(queryset,
 ensure_ascii=True)
  t = eval(toxids_json)
  a = []
  for i in t: a.append(i['fields'])
  ret = {
  "identifier": "docno",
  "label": "substance",
  "items": a,
  }
  return ret

 It seems a frequently recurring pattern in my views, so I would  
 like
 to do it right and efficient. Particularly the 'eval' step feels
 weird.

 I did have a look at dojox.dtl (Django Templating Language) but
 haven't (yet?) figured out if that is applicable for this.

 Thanks,
 Rob



>

>>>

>>
>>
>>>
>>
>
> 

Re: How do i use dojo in my Django application

2009-04-02 Thread Dougal Matthews
It kinds depends what you want to do really.
JavaScript is run inside the browser and Django is running on your website.
So it doesn't even know what Django or Python is, however they can
communicate and pass data.

By using it with Django, do you mean you want to do some Ajax stuff?
If that's the case then you will want to decide how you are going to pass
data. You can then just make your views return the appropriate data, be that
chunks of HTML, JSON or XML etc.

Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/2 Gath 

>
> All,
>
> I have downloaded Dojo 1.3, i want to start sampling some examples  in
> the Dojo website using Django, where do i place the package? How do i
> call it in my template?
>
> Gath
> >
>

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



Re: Django Tutorial, Part 3

2009-04-02 Thread Dougal Matthews
Daniel and everybody else can see my reply like I can see your reply to him
;)
Just so you know you don't need to reply to each of us individually...

Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/2 Loewe, Rosemarie 

> Hello Daniel,
>
> just I got a mail of another user, he had the correct answer and now it
> works.
> I have no further need for help.
>
> Best regards
> Rosemarie
>
>
> 
>
> Von: django-users@googlegroups.com im Auftrag von Daniel Roseman
> Gesendet: Do 02.04.2009 12:53
> An: Django users
> Betreff: Re: Django Tutorial, Part 3
>
>
>
>
> On Apr 2, 8:35 am, rorocam  wrote:
> > Hello ...,
> >
> > I have problems with the "Decoupling the URLconfs". I did, as Django
> > Tutorial (Part 3) shows me, but it does not work, the browser shows
> > following error:
> >
> > > ImportError at /polls/
> > > Import by filename is not supported.
> >
> > What is wrong with my application? I have installed Python 2.6 and
> > Django 1.0.2 at Windows XP.
> >
> > Thanks, for giving me an answer.
> >
> > Best regards
> > Rosemarie Loewe
>
> You haven't given nearly enough information for us to solve this
> problem. What is the full traceback? What is the code where the
> problem occurs?
> --
> DR.
>
>
>
>
> >
>

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



Re: FormSet in Wizard

2009-04-02 Thread Yuka

Hi Austin,

I dont know if you still need a solution, but I did, and someone else
might -- also for the sake of completion, here is what i cooked up:
Just inherit from below class, instead of FormWizard, and start
feeding it FormSet classes as one sees fit. Also, there might be
better solutions, e.g. one could probably get away with only
overriding the get_form method, but i figured that would be a little
bit trickier.
This suited my needs just fine. Alas, enjoy.

--
from django.contrib.formtools.utils import security_hash

try:
import cPickle as pickle
except ImportError:
import pickle

from django.conf import settings
from django.utils.hashcompat import md5_constructor
from django.forms import BooleanField

class FormSetWizard(FormWizard):
def render(self, form, request, step, context=None):
old_data = request.POST
prev_fields = []
if old_data:
hidden = forms.HiddenInput()
for i in range(step):
old_form = self.get_form(i, old_data)
hash_name = 'hash_%s' % i
if isinstance(old_form, BaseFormSet):
for f in old_form.forms +
[old_form.management_form]:
prev_fields.extend([bf.as_hidden() for bf in
f])
else:
prev_fields.extend([bf.as_hidden() for bf in
old_form])
prev_fields.append(hidden.render(hash_name,
old_data.get(hash_name, self.security_hash(request, old_form
return self.render_template(request, form, ''.join
(prev_fields), step, context)

def security_hash(self, request, form):
def security_func(request, form, *args):
data = []
for f in form.forms + [form.management_form]:
data.extend([(bf.name, bf.field.clean(bf.data) or '')
for bf in f])
data.extend(args)
data.append(settings.SECRET_KEY)
pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
return md5_constructor(pickled).hexdigest()
if isinstance(form, BaseFormSet):
return security_func(request, form)
return security_hash(request, form)
--
Best Regards, Yuka Poppe.

On Feb 4, 5:18 pm, Austin Gabel  wrote:
> Hello,
>
> I am trying to set up a Django FormWizard to add users to my site.  On one
> of the steps I need to be able to enter more than one address.  I was hoping
> to use a FormSet on this step but it does not seem to work as I had
> expected.  The FormSet displays correctly initially, but when I submit the
> form I get an error saying that the FormSet is not iterable.  Has anyone
> made this work 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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error creating test database

2009-04-02 Thread Andrew G.

Even if an abstract class was added as an intermediary, wouldn't the
derived class still try to create the table?  There is no solution
along the lines of a meta option "donotcreatetable" or the like?

On Apr 2, 10:06 am, Adam N  wrote:
> I'm pretty sure you'll need to make it an abstract model.  You could
> make the model that accords to the existing table abstract and then
> subclass that model with no additional attributes (except a different
> name) - that will give you access to the data directly if you need it
> while leaving the existing table intact. This will duplicate data
> though - are these highly accessed tables?
>
> I think.
>
> -Adam
>
> On Apr 2, 9:23 am, "Andrew G."  wrote:
>
> > I have a django app that is built against an existing database.  In
> > the database, there are a couple tables used as the many-to-many
> > relation lookup table.  However, I have mapped models to the many-to-
> > many lookup table, since I have a need for accessing these entries
> > directly.  Since the tables already exists, manage.py syncdb has no
> > problems, but when running manage.py test, the attempt to create the
> > test database complains that the many-to-many table already exists and
> > fails out.
>
> > Is there a way to specify ignoring the creation of this table
> > somewhere, or another way to circumvent this problem?  Should this be
> > considered a bug?
>
> > I know about the abstract Meta keyword, but I didn't think that should
> > apply since the many-to-many model still should be db mapped and
> > accessible.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error creating test database

2009-04-02 Thread Adam N

I'm pretty sure you'll need to make it an abstract model.  You could
make the model that accords to the existing table abstract and then
subclass that model with no additional attributes (except a different
name) - that will give you access to the data directly if you need it
while leaving the existing table intact. This will duplicate data
though - are these highly accessed tables?

I think.

-Adam

On Apr 2, 9:23 am, "Andrew G."  wrote:
> I have a django app that is built against an existing database.  In
> the database, there are a couple tables used as the many-to-many
> relation lookup table.  However, I have mapped models to the many-to-
> many lookup table, since I have a need for accessing these entries
> directly.  Since the tables already exists, manage.py syncdb has no
> problems, but when running manage.py test, the attempt to create the
> test database complains that the many-to-many table already exists and
> fails out.
>
> Is there a way to specify ignoring the creation of this table
> somewhere, or another way to circumvent this problem?  Should this be
> considered a bug?
>
> I know about the abstract Meta keyword, but I didn't think that should
> apply since the many-to-many model still should be db mapped and
> accessible.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Fixtures for django.contrib.sites.Site

2009-04-02 Thread Adam N

Thanks a ton - that's exactly what the issue was.

On Apr 1, 8:28 pm, Russell Keith-Magee  wrote:
> On Thu, Apr 2, 2009 at 5:49 AM,AdamNelson  wrote:
> > How do I do a fixture for the Site model?  I've tried all sorts of different
> > model names
> > [
> >   {
> >     "model": "sites.site",
> >     "pk": 1,
> >     "fields": {
> >       "domain": "example.com",
> >       "name": "Example"
> >     }
> >   },
> > ]
> > And I get this error:
> > ...
> >   File
> > "/Library/Python/2.5/site-packages/django/utils/simplejson/decoder.py", line
> > 221, in JSONArray
> >     raise ValueError(errmsg("Expecting object", s, end))
> > ValueError: Expecting object: line 10 column 1 (char 124)
> > Any ideas for the correct model name?  I've tried every possibility I can
> > think of.
>
> Unlike Python, JSON is very fussy about commas. In particular, Python
> allows redundant commas in lists (i.e., [1,2,3,] - the comma after the
> 3), but JSON doesn't. The problem here is the comma on the second last
> line. That comma leads SimpleJSON to believe that line 10 should start
> a new element in the list, but instead, the list is ended. Hence, line
> 10, column 1 reports an error. Delete the comma and you'll be fine.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Error creating test database

2009-04-02 Thread Andrew G.

I have a django app that is built against an existing database.  In
the database, there are a couple tables used as the many-to-many
relation lookup table.  However, I have mapped models to the many-to-
many lookup table, since I have a need for accessing these entries
directly.  Since the tables already exists, manage.py syncdb has no
problems, but when running manage.py test, the attempt to create the
test database complains that the many-to-many table already exists and
fails out.

Is there a way to specify ignoring the creation of this table
somewhere, or another way to circumvent this problem?  Should this be
considered a bug?

I know about the abstract Meta keyword, but I didn't think that should
apply since the many-to-many model still should be db mapped and
accessible.

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



Re: Mod_wsgi and mod_python

2009-04-02 Thread Adam N

You should definitely consider Nginx with FastCGI.  Something like
this:

http://wiki.nginx.org/NginxDjangoFastCGI

On Apr 2, 2:20 am, Pythoni  wrote:
> I am using Django with mod_python and it works but during peak times
> ( heavy loads about 50 Apache jobs), the system is almost hanged
> Is it  worth changing from mod_python into mod_wsgi?
> What would I get or lose?
> Is it possible to use both mod_python and mod_wsgi on one computer?
> Thank you for replies
> L.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Json Serialization / Form Validation error

2009-04-02 Thread Bro

But before, is it possible to serialize a form in JSON ?

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



Re: Json Serialization / Form Validation error

2009-04-02 Thread Bro

But beforce, is it possible to serialise a form in JSON ?

Thanks

On 11 fév, 00:50, adrian  wrote:
> Thank you all for posting this.  You saved me probably hours of head
> scratching.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authorization on data level in django admin

2009-04-02 Thread Joshua Partogi

Dear all,

In django admin we can give permission to user to edit, delete or
create certain model. But what I want to do now is a user can only
edit or delete the data that he/she created.

Is there any way we can do this in django admin?

Thank you very much in advance

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

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



Re: How do i use dojo in my Django application

2009-04-02 Thread Briel

Hi.

The docs explain in great detail how you can serve static files like
the
dojo library. Take a look at it here:
http://docs.djangoproject.com/en/dev/howto/static-files/

~Jakob

On 2 Apr., 14:50, Gath  wrote:
> All,
>
> I have downloaded Dojo 1.3, i want to start sampling some examples  in
> the Dojo website using Django, where do i place the package? How do i
> call it in my template?
>
> Gath
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How do i use dojo in my Django application

2009-04-02 Thread Gath

All,

I have downloaded Dojo 1.3, i want to start sampling some examples  in
the Dojo website using Django, where do i place the package? How do i
call it in my template?

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



AW: Django Tutorial, Part 3

2009-04-02 Thread Loewe, Rosemarie
Hello Daniel,
 
just I got a mail of another user, he had the correct answer and now it works.
I have no further need for help.
 
Best regards
Rosemarie
 



Von: django-users@googlegroups.com im Auftrag von Daniel Roseman
Gesendet: Do 02.04.2009 12:53
An: Django users
Betreff: Re: Django Tutorial, Part 3




On Apr 2, 8:35 am, rorocam  wrote:
> Hello ...,
>
> I have problems with the "Decoupling the URLconfs". I did, as Django
> Tutorial (Part 3) shows me, but it does not work, the browser shows
> following error:
>
> > ImportError at /polls/
> > Import by filename is not supported.
>
> What is wrong with my application? I have installed Python 2.6 and
> Django 1.0.2 at Windows XP.
>
> Thanks, for giving me an answer.
>
> Best regards
> Rosemarie Loewe

You haven't given nearly enough information for us to solve this
problem. What is the full traceback? What is the code where the
problem occurs?
--
DR.




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

<>

AW: Django Tutorial, Part 3

2009-04-02 Thread Loewe, Rosemarie
Hallo Dougal,
 
many many thanks for your quick response. Now it works fine.
 
Best regards
Rosemarie
 



Von: django-users@googlegroups.com im Auftrag von Dougal Matthews
Gesendet: Do 02.04.2009 14:28
An: django-users@googlegroups.com
Betreff: Re: Django Tutorial, Part 3


You error is in urls.py 

You have; include('mysite/polls/urls')),
you should have; include('mysite.polls.urls')),

The path is written python module style (with dots) rather than directory style 
(with slashes)


Dougal


---
Dougal Matthews - @d0ugal 
http://www.dougalmatthews.com/




2009/4/2 Loewe, Rosemarie 


Hello django-user Daniel Roseman,

many thanks for your quick response. In the attachment are
- and the error messages displayed in Browser (Firefox).
- the django project, what I have generated like shown in Django 
Tutorial (until part 3)

I hope you can do something with this information.

Best regards
R. Loewe (rorocam)



Von: django-users@googlegroups.com im Auftrag von Daniel Roseman
Gesendet: Do 02.04.2009 12:53
An: Django users
Betreff: Re: Django Tutorial, Part 3





On Apr 2, 8:35 am, rorocam  wrote:
> Hello ...,
>
> I have problems with the "Decoupling the URLconfs". I did, as Django
> Tutorial (Part 3) shows me, but it does not work, the browser shows
> following error:
>
> > ImportError at /polls/
> > Import by filename is not supported.
>
> What is wrong with my application? I have installed Python 2.6 and
> Django 1.0.2 at Windows XP.
>
> Thanks, for giving me an answer.
>
> Best regards
> Rosemarie Loewe

You haven't given nearly enough information for us to solve this
problem. What is the full traceback? What is the code where the
problem occurs?
--
DR.












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

<>

Re: Django Tutorial, Part 3

2009-04-02 Thread Dougal Matthews
You error is in urls.py
You have; *include('mysite/polls/urls')),*
you should have; *include('mysite.polls.urls')),*

The path is written python module style (with dots) rather than directory
style (with slashes)


Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/2 Loewe, Rosemarie 

> Hello django-user Daniel Roseman,
>
> many thanks for your quick response. In the attachment are
> - and the error messages displayed in Browser (Firefox).
> - the django project, what I have generated like shown in Django Tutorial
> (until part 3)
>
> I hope you can do something with this information.
>
> Best regards
> R. Loewe (rorocam)
>
> 
>
> Von: django-users@googlegroups.com im Auftrag von Daniel Roseman
> Gesendet: Do 02.04.2009 12:53
> An: Django users
> Betreff: Re: Django Tutorial, Part 3
>
>
>
>
> On Apr 2, 8:35 am, rorocam  wrote:
> > Hello ...,
> >
> > I have problems with the "Decoupling the URLconfs". I did, as Django
> > Tutorial (Part 3) shows me, but it does not work, the browser shows
> > following error:
> >
> > > ImportError at /polls/
> > > Import by filename is not supported.
> >
> > What is wrong with my application? I have installed Python 2.6 and
> > Django 1.0.2 at Windows XP.
> >
> > Thanks, for giving me an answer.
> >
> > Best regards
> > Rosemarie Loewe
>
> You haven't given nearly enough information for us to solve this
> problem. What is the full traceback? What is the code where the
> problem occurs?
> --
> DR.
>
>
>
>
> >
>

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



Re: Controlling html display of Charfield length on forms...(newforms?)

2009-04-02 Thread NoviceSortOf


text = forms.CharField(label="text", max_length=10,
  widget=forms.TextInput(
attrs={'size':'10', 'class':'inputText'}))

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



Re: Mysterious "=32" for all strings extracted from list showing up via send_mail

2009-04-02 Thread NoviceSortOf


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



Re: Django Tutorial, Part 3

2009-04-02 Thread Daniel Roseman

On Apr 2, 8:35 am, rorocam  wrote:
> Hello …,
>
> I have problems with the „Decoupling the URLconfs”. I did, as Django
> Tutorial (Part 3) shows me, but it does not work, the browser shows
> following error:
>
> > ImportError at /polls/
> > Import by filename is not supported.
>
> What is wrong with my application? I have installed Python 2.6 and
> Django 1.0.2 at Windows XP.
>
> Thanks, for giving me an answer.
>
> Best regards
> Rosemarie Loewe

You haven't given nearly enough information for us to solve this
problem. What is the full traceback? What is the code where the
problem occurs?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django ImageField url not relative to MEDIA_ROOT

2009-04-02 Thread pielgrzym

Thanks to pagenoare on #django-pl there is some progress:

If I create a modelform, and instead of manually invoking model
instance and saving it, I just do:

new_image = form.save()

Things work like expected. Why? :)

On 2 Kwi, 12:18, pielgrzym  wrote:
> Hi there,
>
> Before explanation here is the link to problematic 
> code:http://wklej.org/hash/968a35feef/
>
> If one creates a model with imageField and uses it via admin
> everything is just fine - model instances have the image field with
> correct url:
>
> photo = Image.objects.get(pk=1)
> photo.image.url
> '/media/blabla/photo.jpg'
>
> If I upload the file manually, not via admin interface the image.url
> is an absolute path to the image file:
>
> photo2 = Image.objects.get(pk=1)
> photo2.image.url
> '/home/user/django_projects/myproject/media/blabla/photo.jpg'
>
> Could someone explain me what am I doing wrong?
> This happens on django 1.0 and latest django svn snapshot :(((
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How Do I Extend Model form

2009-04-02 Thread mahesh

Hi,

I am trying to create a (single) comprehensive form with UserProfile +
some Fields from User to be given as form_class arguments for django
module "django-profiles"

I think my next alternative (without above module) is FormSets ? (is
it ?, please advise )

Thx/Mahesh


On Apr 2, 3:04 pm, Oli Warner  wrote:
> I'm not entirely sure why you want to do this (so please excuse me if this
> doesn't apply) but you should know that you're allowed more than one django
> Form inside a single HTML  element.
>
> So you can easily have several ModelForms (or mix them with regular Forms)
> inside a single  tag.
>
> I hope that makes sense.
>
> On Thu, Apr 2, 2009 at 10:51 AM, mahesh  wrote:
>
> > How Do I Extend Model form. I need to generate a form with some fields
> > from User + UserProfile; However I see nothing ..
>
> > class UserForm(ModelForm) :
> >        class Meta:
> >                model = User
>
> > class BigForm(UserForm):
> >        class Meta(UserForm.Meta):
> >                model = MySiteProfile
> >                exclude = ['user']
>
> > Thank you/Mahesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django ImageField url not relative to MEDIA_ROOT

2009-04-02 Thread pielgrzym

Hi there,

Before explanation here is the link to problematic code:
http://wklej.org/hash/968a35feef/


If one creates a model with imageField and uses it via admin
everything is just fine - model instances have the image field with
correct url:

photo = Image.objects.get(pk=1)
photo.image.url
'/media/blabla/photo.jpg'

If I upload the file manually, not via admin interface the image.url
is an absolute path to the image file:

photo2 = Image.objects.get(pk=1)
photo2.image.url
'/home/user/django_projects/myproject/media/blabla/photo.jpg'

Could someone explain me what am I doing wrong?
This happens on django 1.0 and latest django svn snapshot :(((
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How Do I Extend Model form

2009-04-02 Thread Oli Warner
I'm not entirely sure why you want to do this (so please excuse me if this
doesn't apply) but you should know that you're allowed more than one django
Form inside a single HTML  element.

So you can easily have several ModelForms (or mix them with regular Forms)
inside a single  tag.

I hope that makes sense.

On Thu, Apr 2, 2009 at 10:51 AM, mahesh  wrote:

>
> How Do I Extend Model form. I need to generate a form with some fields
> from User + UserProfile; However I see nothing ..
>
> class UserForm(ModelForm) :
>class Meta:
>model = User
>
>
>
> class BigForm(UserForm):
>class Meta(UserForm.Meta):
>model = MySiteProfile
>exclude = ['user']
>
> Thank you/Mahesh
> >
>

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



Re: Inheriting attributes from a model

2009-04-02 Thread Denis

Thanks! Problem solved, here's how to do it:

class QuoteItemManager(models.Manager):
def from_product(self, product):
i = QuoteItem(current_product=product)
i.product_serialized = serializers.serialize('json',
Product.objects.filter(id=product.id))
try:
i.productinfo_serialized = serializers.serialize('json',
product.productinfo_set.all())
except ProductInfo.DoesNotExist:
i.productinfo_serialized = ''
return i

def to_product(self, quoteitem):
p = serializers.deserialize('json',
quoteitem.product_serialized).next().object
if quoteitem.productinfo_serialized != '':
p.productinfo_set.add(serializers.deserialize('json',
quoteitem.productinfo_serialized).next().object)
return p
QuoteItem.objects = QuoteItemManager()
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How Do I Extend Model form

2009-04-02 Thread mahesh

How Do I Extend Model form. I need to generate a form with some fields
from User + UserProfile; However I see nothing ..

class UserForm(ModelForm) :
class Meta:
model = User



class BigForm(UserForm):
class Meta(UserForm.Meta):
model = MySiteProfile
exclude = ['user']

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



Re: FileField - Forms - upload to not available

2009-04-02 Thread Lior

I've got the same problem. I'm using signals, so I guess your problem
will not be solved with signals.
I'm also using pre_save. It seems that the attribute upload_to isn't
(yet) set when in pre_save.

I still don't know if it's a bug, or a 'new feature', as my code works
perfectly on Django 1.0.2.

Lior

On Mar 25, 5:13 pm, tom  wrote:
> thanks for the update. So it seems, that save(commit=False) does not
> work here. What I try to do is:
>
> create a track object without saving, because I need two more objects
> (Artist, Album). These two offers will be created out of the mp3 tags
> of the file, if there are any. I assign than those two opjects as
> foreign key to the Track object and than I call save.
>
> Do you think switching to signals may solve this problem?
>
> On 13 Mrz., 03:46, lucy  wrote:
>
> > Fixed. It turned out I was reading my error log wrong. It wasn't the
> > image field itself that was having trouble saving, but a pre_save
> > signal that attempted to open the image and create a thumbnail. Yeah,
> > instance.image.path doesn't exist yet. I moved that to a post_save
> > signal and everything works great. I'm not really sure how this worked
> > on the mac/sqlite3 combo.
>
> > On Mar 12, 2:55 pm, lucy  wrote:
>
> > > I have a similar problem in that upload_to is not being respected,
> > > even when saving. That is, the system tries to save the file directly
> > > in my MEDIA_ROOT folder, rather than the upload_to path. An error
> > > occurs, and the file does not appear to be saved anywhere.
>
> > > It works fine on Mac OS X.4 with sqlite3, django r8970.
>
> > > The problem occurs on ubuntu 8.04(lts) with postgresql 8.3, django
> > > r (i tried different django versions).
>
> > > The problem occurs with both dynamic (callable) upload_to and static
> > > (simple path) upload_to. Regardless of upload_to, the error is exactly
> > > the same.
>
> > > If someone could help me redirect standard out to a log file with
> > > apache2/fastcgi then I could try to print something more useful. I'm
> > > having trouble debugging this.
>
> > > L.
>
> > > On Mar 7, 6:10 am, tom  wrote:
>
> > > > Unfortunatly I still haven't found a solution and I tryed it with and
> > > > without a trailing /.
> > > > No difference.
>
> > > > I will post the solution, if there is one and if I find it. :)
>
> > > > -Tom
>
> > > > On 5 Mrz., 16:39, Francis  wrote:
>
> > > > > Did you found any solution?
>
> > > > > Because I have the same problem, but on opposite side (works on mac
> > > > > but not on linux).
>
> > > > > I think that you need a trailing "/" to your upload_to path though.
>
> > > > > Francis
>
> > > > > On Mar 1, 8:21 pm, tom  wrote:
>
> > > > > > here is some more information, maybe that helps. These are just
> > > > > > different lines of code from different files, but they actually
> > > > > > describe what's happening:
>
> > > > > > settings.py
> > > > > > MEDIA_ROOT = '/Library/WebServer/Documents/media/indiebreed/'
>
> > > > > > models.py
> > > > > > file = models.FileField(upload_to="tmp/tracks", max_length = 1000)
>
> > > > > > json_views.py
> > > > > >     if request.method == 'POST':
> > > > > >         form = TrackForm(request.POST, request.FILES)
> > > > > >         if form.is_valid():
> > > > > >             new_track = form.save(commit = False)
> > > > > >             print new_track.file.path
>
> > > > > > error:
> > > > > > IOError at /music/tracks/testupload/
> > > > > > [Errno 2] No such file or directory: u'/Library/WebServer/Documents/
> > > > > > media/indiebreed/03 Magical Box.mp3'
>
> > > > > > actually the path should be like this:
> > > > > > /Library/WebServer/Documents/media/indiebreed/tmp/tracks/03 Magical
> > > > > > Box.mp3
>
> > > > > > any ideas?
> > > > > > ah, i am on a mac and it works under linux
>
> > > > > > many thanks.
> > > > > > tom
>
> > > > > > Path: .
> > > > > > URL:http://code.djangoproject.com/svn/django/trunk
> > > > > > Repository Root:http://code.djangoproject.com/svn
> > > > > > Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
> > > > > > Revision: 9912
> > > > > > Node Kind: directory
> > > > > > Schedule: normal
> > > > > > Last Changed Author: russellm
> > > > > > Last Changed Rev: 9911
> > > > > > Last Changed Date: 2009-02-27 14:14:59 +0100 (Fr, 27 Feb 2009)
> > > > > > On 28 Feb., 01:47, tom  wrote:
>
> > > > > > > Hi,
>
> > > > > > > I am somehow confused. I am using this in a model:
> > > > > > > file = models.FileField(upload_to="tmp/tracks/", max_length = 
> > > > > > > 1000)
>
> > > > > > > and than I am doing this in a form:
> > > > > > > new_track = form.save(commit = False)
>
> > > > > > > after that I want to access the file to do some stuff with it, 
> > > > > > > like
> > > > > > > print new_track.file.path
>
> > > > > > > when I do this, the path to the file is 

Re: forming email body

2009-04-02 Thread Oli Warner
Yeah I've used the template engine for this before and it has worked well.
No complaints and it's relatively simple:

from django.core.mail import send_mail
from django.template import loader, Context

t = loader.get_template('my/template.txt')

send_mail('subject', t.render(Context(template_variables_dict)),
'f...@domain.com', recipient_list)

Just remember you can exclude a lot of that to outside the loop (eg: you
don't want to reload the template for every user and you might be able to
generate some of the template dictionary beforehand too)

And recipient_list will probably want to be just one person at a time -- but
it still has to be in list format. I'm saying all this, not because I think
you don't know this, but people that read this in the future (haha - users
searching before they ask!) might find it useful.


On Thu, Apr 2, 2009 at 2:58 AM, Joey Gartin  wrote:

> Newbie question:
>
> In a view I am sending out a few emails to users.  The email format is
> identical for each user, with the users information being dynamic.
>
> My question is regarding forming a long email and using it as the body over
> and over (in a loop for each user).  What is the best way to do this?  If
> the email were just one or two lines then I would build a string prior to
> the send_email call, but this is about 18 lines with 11 variables.  Is there
> a standard way to do this?  Using a separate file as a template and in my
> loop plugging the user information into the template and then making the
> send_email body the template seems like the ideal thing, but I am not sure
> if that is the proper Django way???
>
> Thank you!
>
> >
>

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



Re: forming email body

2009-04-02 Thread Daniel Roseman

On Apr 2, 2:58 am, Joey Gartin  wrote:
> Newbie question:
>
> In a view I am sending out a few emails to users.  The email format is
> identical for each user, with the users information being dynamic.
>
> My question is regarding forming a long email and using it as the body over
> and over (in a loop for each user).  What is the best way to do this?  If
> the email were just one or two lines then I would build a string prior to
> the send_email call, but this is about 18 lines with 11 variables.  Is there
> a standard way to do this?  Using a separate file as a template and in my
> loop plugging the user information into the template and then making the
> send_email body the template seems like the ideal thing, but I am not sure
> if that is the proper Django way???
>
> Thank you!

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



Re: JQuery magic in admin?

2009-04-02 Thread Briel

Hi,

If you don't need the form elements themselves, as you do everything
in the save method, you don't need to do anything with the form.
All you need to do, is to create the visual effect, which can be done
with jQuery quite easily. You could just hide the fields if you prefer
them
empty and create some of your own fields to display then stuff in, or
just
use the form fields.

I would suggest a blur trigger that check if values on the needed
fields
have been filled. Then all you need to to, is to make a ajax get
request
where you send along the values. Create a view that handles the calc
and sends the data back. You could also if you prefer do the
calculation
in javascript. But I don't see how this should break your setup.

~Jakob

On 2 Apr., 09:59, Alfonso  wrote:
> Hi,
>
> I've got two very unremarkable models, Invoice Order that has a
> foreign key to an Invoice model.  There are some tax calculations that
> happen on the save of the order model that populate and update the
> corresponding fields in the Invoice model.  All works fine and in fact
> all calculations in the system happen within a custom save function.
>
> So as far as the user is concerned they see a few fields that are
> empty but populated when the form is saved.  The client has requested
> to see if we can improve that functionality and populate the necessary
> fields as the user fills in the form, so once a price and tax rate are
> added the final price field is populated also.  Along with that the
> form will be populated with the relevent prices when a user selects
> the product to add to the order.  complicated I think.
>
> My question centers around how I would implement such functionality,
> it screams to me JQuery or similar doing it's magic to perform the
> necessary calcs and then django reverts to a normal save function.
>
> Obviously that is a pretty big rewrite and I'd like to avoid making
> things complicated and losing what coding I've done.
>
> Does anyone have any better suggestions for how I might accomplish
> that sort of functionality fairly cleanly?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



JQuery magic in admin?

2009-04-02 Thread Alfonso

Hi,

I've got two very unremarkable models, Invoice Order that has a
foreign key to an Invoice model.  There are some tax calculations that
happen on the save of the order model that populate and update the
corresponding fields in the Invoice model.  All works fine and in fact
all calculations in the system happen within a custom save function.

So as far as the user is concerned they see a few fields that are
empty but populated when the form is saved.  The client has requested
to see if we can improve that functionality and populate the necessary
fields as the user fills in the form, so once a price and tax rate are
added the final price field is populated also.  Along with that the
form will be populated with the relevent prices when a user selects
the product to add to the order.  complicated I think.

My question centers around how I would implement such functionality,
it screams to me JQuery or similar doing it's magic to perform the
necessary calcs and then django reverts to a normal save function.

Obviously that is a pretty big rewrite and I'd like to avoid making
things complicated and losing what coding I've done.

Does anyone have any better suggestions for how I might accomplish
that sort of functionality fairly cleanly?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Tutorial, Part 3

2009-04-02 Thread rorocam

Hello …,


I have problems with the „Decoupling the URLconfs”. I did, as Django
Tutorial (Part 3) shows me, but it does not work, the browser shows
following error:

> ImportError at /polls/
> Import by filename is not supported.


What is wrong with my application? I have installed Python 2.6 and
Django 1.0.2 at Windows XP.

Thanks, for giving me an answer.



Best regards
Rosemarie Loewe



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



Re: Performance Issue: ForeignKey will touch database again!

2009-04-02 Thread Zeal



On 4月2日, 下午2时39分, Alex Koshelev  wrote:
> On Thu, Apr 2, 2009 at 10:36 AM, Zeal  wrote:
>
>
> Documentation knows [1]
>
> [1]:http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4

Hi, Alex,

Really appreciates your prompt response and useful solution, the sql
queries have been dramatically reduced to the acceptable level.

However, I still feel that the page which need to handle thousand of
records is really slow than others,(Firefox is better than IE, IE) .
Do you have any idease for such performance issues? Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Mod_wsgi and mod_python

2009-04-02 Thread Graham Dumpleton



On Apr 2, 5:20 pm, Pythoni  wrote:
> I am using Django with mod_python and it works but during peak times
> ( heavy loads about 50 Apache jobs), the system is almost hanged
> Is it  worth changing from mod_python into mod_wsgi?
> What would I get or lose?

Read:

  http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

> Is it possible to use both mod_python and mod_wsgi on one computer?

Yes, but would only recommend it until you can transition to mod_wsgi.
Having mod_python at same time places various limitations on mod_wsgi
because of mod_python code being a bit broken and not supporting as
many configuration options related to Python initialisation.

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



Re: Performance Issue: ForeignKey will touch database again!

2009-04-02 Thread Alex Koshelev

On Thu, Apr 2, 2009 at 10:36 AM, Zeal  wrote:
>
> Hi, All,
>
[skip]
>
> Does every body know this issue and know how to solve it? Your any
> suggestion or solution will be highly appreciated!
>
> Regards,
>
> Zeal
>

Documentation knows [1]

[1]: http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4

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



Performance Issue: ForeignKey will touch database again!

2009-04-02 Thread Zeal

Hi, All,

I have a question about ForeignKey in Django. Say, I have a model like
this,

++
class test(models.Model):
 no=models.CharField(_('No.'),max_length=6,.)
 nat=models.ForeignKey(Code,verbose_name=_
('Nationality'),related_name='b_nat',
limit_choices_to=
{'cat':'1','status':'Y'})

++

Say, there are 3,000 records in postgreql database. When I try to list
all objects in one page, the sql queries will be pretty high, like
more than 3000 times queries in backend.

Then, I just installed debug-toolbar, and try to find the reason of
why so many sql queries executed in backend. Finally, I found that
each record will trigger another sql query if there is a ForeignKey
field.  Because of this reason, my django application is really slow
on showing large records in one page, is this a performance issue in
Django and Postgresql?

Does every body know this issue and know how to solve it? Your any
suggestion or solution will be highly appreciated!

Regards,

Zeal


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



Mod_wsgi and mod_python

2009-04-02 Thread Pythoni

I am using Django with mod_python and it works but during peak times
( heavy loads about 50 Apache jobs), the system is almost hanged
Is it  worth changing from mod_python into mod_wsgi?
What would I get or lose?
Is it possible to use both mod_python and mod_wsgi on one computer?
Thank you for replies
L.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages variables

2009-04-02 Thread Wiiboy

Oh.  Ok, I just read the docs.  I'm going to use process_request.

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