Re: default _ storage path

2011-01-12 Thread Tonton
thanks but i do like that

i saved file i generate in /media/directory so the path is
path="directory/filename.ext"

and in var/www/ link  ln-s /home/project/media/directory directory

so my other program could acces to configuration file in /var/www/directory
store in media in real !

regards
tonton

On Tue, Jan 11, 2011 at 5:10 PM, prasad iyer  wrote:

> Give www-data rwx permission /va/www/dir and start the application
> using the user who is member of www-data
>
> On Jan 11, 4:56 am, Tonton  wrote:
> > hello
> > may we use default storage to write outside of project or only in media
> > because i can writ in media path ...
> >
> > my porject : /home/user/project
> >
> > and i 'd like to write in
> >
> > /var/www/myoutputdirectory  own by what ever you want but i've truy
> www-data
> > and the user in my WSGIDaemon in apache conf for mod wsgi ...
> >
> > so i 've SuspiciousOperation
> >
> > attempte access '/var/www/myoutpudirectory/myfilename ' denied
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: upload files via ajax

2011-01-12 Thread Mauro Del Rio
On Tue, Jan 11, 2011 at 1:12 PM, Jani Tiainen  wrote:

>
> http://valums.com/ajax-upload/
>
> There is one standalone version how to do it pretty much browser
> independently.
>
>
>
> --
>
> Jani Tiainen
>

It seems to be what i am looking for, thanks!
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



CSRF cookie not being sent over HTTPS

2011-01-12 Thread Burhan
I'm developing an app that is only going to be used over HTTPS, when I
try to login to the admin backend, I keep getting 'Looks like your
browser isn't configured to accept cookies. Please enable cookies,
reload this page, and try again.'

I inspected the cookies being sent and noticed that the csrftoken is
not being sent via HTTPS (its not a secure cookie), even though I have
SESSION_COOKIE_SECURE as True in settings.

The 'sessionid' cookie is being sent correctly (over HTTPS).

Does anyone know of a way to fix this? I can sometimes login by
clearing all the cookies, and restarting the server + browser, but
this is hit and miss.

Thanks.

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



Re: Django's documention is horrible

2011-01-12 Thread ashwoods
Although it might be nice to have api docs online, you have to say
that django has excellent high level docs (django docs site) and low
lvl docs (code is well py-documented -in the source). Epydocs, and
other doc alternatives - automatic or semi automatic doc generators
like pydoctor, sphinx (a quick google search revealed quite a few free
and nonfree python doc generators) are what i consider standard
(python) programming tools, and it actually makes sense for the
developer to do this "client" side (3rd party libaries, etc... all in
one interface, and for the code version you are using, for example).
The difficult, hard to write human documentation in django is
excellent, btw :p

all that said, maybe we can take a look at trac plugins...
http://trac-hacks.org/wiki/PyDocPlugin
http://trac.edgewall.org/wiki/TracDev/ApiDocs

i have no experience with them, maybe someone here has used them
before?

cheers,
ashley

On Jan 11, 9:59 am, Masklinn  wrote:
> On 2011-01-11, at 09:36 , mrmclovin wrote:> If you bought a game, would you 
> rather like to get info on how to
> > compile the game in order to play it.. or just install it and play it?
>
> This analogy makes no sense whatsoever, I fear.

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



Re: login failed with correct username and password

2011-01-12 Thread bruno desthuilliers
On 12 jan, 04:03, "Lin Tao\(EXT-VanceInfo/Beijing\)"
 wrote:
> Hi,
>
> I encounter this problem that I failed to login to my app with correct
> username and password. I'm wondering if there is something wrong with my
> login form. Here is what it looks like:

(snip code - seems mostly ok)

>
> Every time I tried to login with correct username and password, it would go
> back to login page with error message "Your username or password is
> incorrect".
>
> I guess there is something wrong with authenticate function.

I guess someone would have noticed this long ago. The first thing I'd
try would be to fire the django shell and run this:

# > from django.contrib import auth
# > user = auth.authenticate(username="yourusername",
password="yourpassword")
# > print user

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



Re: Django's documention is horrible

2011-01-12 Thread Mike Dewhirst
OK - so we need an intro to the documention which describes the timeline 
of a typical* developer transitioning from beginner to guru and the docs 
which should be of interest at successive stages during that transition.


*typical - I know there ain't such a person. However, there ought to be 
a "target audience" the Django Foundation wants to reach. That person 
becomes the target audience for the intro and gets described in the 
intro to the intro.


If the intro works other "typical" devs can be described for alternative 
intros. Too meta huh?


Problem is there are too many small operators who need more than Django. 
Such as aesthetic guidance, CSS etc etc


It's a quite daunting curve but really all anyone needs is to know where 
to find the docs appropriate to their current stage.


How about a survey where people tick boxes which describe where they 
currently sit on the continuum so that existing gurus can see how the 
first "typical" dev can be described.


BTW - Django docs rock.

Mike

On 12/01/2011 6:16pm, Doug Ballance wrote:

The reason I chose django in the first place was the documentation.
Compared to everything out there, it was incredible.  Back then it
also had a helpful comments section on each page where people chimed
in to clarify various parts of the document.  It reads like a text
book, which is a big help when learning the framework.

Unfortunately it reads like a text book, which is a big pain when you
know the story and just need the details.  The wonderful code snippets
lose their context.  The lengthy explanations and sequential
introduction of facts becomes more hinderence than help when trying to
find that one bit you know is in there somewhere, but it's a needle in
a haystack.  It's designed for reading, not so much for reference.
It's also definitely not for the impatient.

After several years with Django, I usually find it easier to just poke
around the source. It's all layed out logically and, and if you have a
general overview of the framework it's much faster than trying to scan
through the online docs.  Unfortunately this approach requires a
certain level of familiarity with how django works to get the most out
of it.

A few things I think would help make a big difference (they would have
to me at least):

1) A couple of complete reference examples.  Not just snippets
introduced a few lines at a time, but full working examples you can
unzip and expect to work and provide a simple reference to the basics.
I've been using django for 3 years now in developing a fairly complex
project.  I'm still not 100% clear on the best way to layout a
project.  What I have obviously works, and I'm stuck with it now...
but it was a guess back when I first started.I realize there is no
one size fits all answer for that type of question, but a tiny working
example with one project and two apps would go along way to providing
someone first starting out, especially if the projects did simple
introductions to all the major topics: a view, a view with an
authentication decorator, a good example of template inheritance use
to 'theme' a site, a few of forms, severa of which don't use a helper
(ie no ModelForm) and requires some inter-field validation, maybe a
simple middlware that reads/writes a cookie.  A custom tag/filter or
two.  Something that showcases the "admin is not your app" principle.
I really would love to do this, but I'm a little concerned it would
turn out to be a bad example here and there!  If there is interest I'd
volunteer to give it a go though.

2) An overview of how django processes a request.  From start to
finish, concise on one page with links to the appropriate details if
necessary.  Possibly a paragraph or two explaining how it differs from
say php.  In my opinion this should be the first page of the
documentation, well before the tutorial. The following page is
ancient, but a good example of what I mean. It wasn't until I read it
that everything just kinda clicked. Too bad it took a good 6 months
for me to run across it more or less on accident.

http://www.b-list.org/weblog/2006/jun/13/how-django-processes-request/

3) The page comments for the existing documentation.  I really miss
that feature.  The comment system PHP uses improves their
documentation many times over.  With Django's great community I'm sure
we'd get a lot of good additions, though moderating the comments makes
more work for someone.

4) A small 'best practices' reference not about the django details,
but the big picture.  Using virtualev.  Project layout.  Admin vs
app.  Considerations to keep in mind for writing reusable apps.
Production vs Development configurations and switching. Handling
timezone conversions.  Avoiding performance pitfalls when using orm
queries.  Signals, how they can be useful.








--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe fro

Overcoming Django 1.2.4's "no query string in the URL"?

2011-01-12 Thread Derek
Unfortunately my existing web app relies heavily on what I now see is a
feature that was "was never documented or supported" i.e. the ability to
filter a change list in the Admin by passing in field:value items in the
URL.  e.g. of the type admin/app/model/?foo=bar&eggs=spam

So... from now on this is "banned", but I still need to be able to create
these arbitrarily filtered lists, with the ability to link to them via
embedded URLs, created in various templates.

What should be the "official" way to do this? (For a number of reasons, I do
not want to simply add all of a model's fields to the list_filter tuples)

Thanks
Derek

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



Re: TestCase and fixtures

2011-01-12 Thread Russell Keith-Magee
On Wed, Jan 12, 2011 at 3:29 PM, Simone Dalla  wrote:
> 2011/1/12 Piotr Zalewa 
>>
>> Hi Simone
>>
>> Try fixtures = ['myfix']
>
> Thank Piotr,
> I've already done but same result:
> No fixtures found.
> ...
> --
> Ran 3 tests in 0.419s
> --

Hi Simone,

Have you confirmed that the fixture can actually be loaded? That is,
can you run:

./manage.py loaddata myfix

This uses the same mechanism for discovering fixtures that a testcase
uses, but will provide more debugging information (especially if you
beef up the verbosity by using -v 2).

This will load the fixture into your non-test database, so you might
want to make sure that you are either using a temporary database, or
you don't mind the fixture being loaded.

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



Re: TestCase and fixtures

2011-01-12 Thread Xavier Ordoquy
Hi,

Out of curiosity, do you run your tests in a multi database setting ?

Regards,
Xavier.

Le 11 janv. 2011 à 23:36, Simone Dalla a écrit :

> Hi!
> I'm testing a part of my application with a TestCase class specifing the 
> 'fixtures' attributes like
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Overcoming Django 1.2.4's "no query string in the URL"?

2011-01-12 Thread Ramiro Morales
On Wed, Jan 12, 2011 at 9:24 AM, Derek  wrote:
> Unfortunately my existing web app relies heavily on what I now see is a
> feature that was "was never documented or supported" i.e. the ability to
> filter a change list in the Admin by passing in field:value items in the
> URL.  e.g. of the type admin/app/model/?foo=bar&eggs=spam
>
> So... from now on this is "banned", but I still need to be able to create
> these arbitrarily filtered lists, with the ability to link to them via
> embedded URLs, created in various templates.
>
> What should be the "official" way to do this? (For a number of reasons, I do
> not want to simply add all of a model's fields to the list_filter tuples)

Override the method used to do that lookups validation in your ModelAdmin.
See this very recent blog post for a description of the clever idea:

http://chris.improbable.org/2010/12/23/custom-admin-filters-django-124/

-- 
Ramiro Morales

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



Need HELP urgently

2011-01-12 Thread gupta-django
I have two application

1. App1 - It has a Model Class "Entry" that has 20 entries
2. App2 - It has a Model Class "Priority"

In Priority class I am defining a Foreign Key Relationship as

from App1.models import Entry

class Priority(models.Model):
entry = models.ForeignKey(Entry)
priority = models.CharField(max_length=2)

And in App2/admin.py I am simply registering Priority

admin.site.register(Priority)

But on Admin website when I try to add a priority - the control hangs
up and only a blank page is returned after a long time gap.

Can anyone please look into the issue that why it is not letting me
add priorities through Admin? I am able to add from backend,

Thanks

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



Help with Imagefile

2011-01-12 Thread nlub...@gmail.com
hello, i have a very simple question. its about imagefiles

my model
 class Usuario(models.Model):
 ImagenEmpresa = models.ImageField(upload_to = 'perfil/',
null=True)

my template
   
  

and my save method
nuevo = Usuario(ImagenEmpresa =
request.FILES['ImagenEmpresa'])
nuevo.save()

this save the image im uploading to the file folder correctly but i
want to change the name of the image
example.

if im uploading a "testofimage.gif"
i would like to save it as "Profileoduser.gif"

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



Django op Servage.net

2011-01-12 Thread MarJo
I want to use Django on Servage.net. Servage support team ask me to
search for a webpackage of Django.
Some people managed to install Django at Servage.net.
Is somebody able to help me?

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



Re: Overcoming Django 1.2.4's "no query string in the URL"?

2011-01-12 Thread Derek
Thanks Ramiro - I have *just* found that blog and was about to report
back here on it.

There are, unfortunately, a few "gotchas" that need some clever coder
to help resolve... see my reply on the blog.

(PS I hope that this approach finds its way into the official docs
sometime.)

On Jan 12, 2:54 pm, Ramiro Morales  wrote:
> On Wed, Jan 12, 2011 at 9:24 AM, Derek  wrote:
> > Unfortunately my existing web app relies heavily on what I now see is a
> > feature that was "was never documented or supported" i.e. the ability to
> > filter a change list in the Admin by passing in field:value items in the
> > URL.  e.g. of the type admin/app/model/?foo=bar&eggs=spam
>
> > So... from now on this is "banned", but I still need to be able to create
> > these arbitrarily filtered lists, with the ability to link to them via
> > embedded URLs, created in various templates.
>
> > What should be the "official" way to do this? (For a number of reasons, I do
> > not want to simply add all of a model's fields to the list_filter tuples)
>
> Override the method used to do that lookups validation in your ModelAdmin.
> See this very recent blog post for a description of the clever idea:
>
> http://chris.improbable.org/2010/12/23/custom-admin-filters-django-124/
>
> --
> Ramiro Morales

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



Re: upload files via ajax

2011-01-12 Thread Eugene MechanisM
I'm using Plopload http://plupload.com it's very nice!!

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



Re: Help with Imagefile

2011-01-12 Thread Piotr Kilczuk
Hi,

2011/1/12 nlub...@gmail.com 

>
> if im uploading a "testofimage.gif"
> i would like to save it as "Profileoduser.gif"
>

I think you can code your own field that inherit's from imagefield.

You possibly could also modify the save method and rename the file/image
field raw value there (just before saving).

Regards,
Piotr

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



Re: Need HELP urgently

2011-01-12 Thread Burhan
It could be that the query to populate the drop down for the FK is
timing out, causing the page to hang. You should try it with
raw_id_fields, something like this in App2 admin.py:

from django.contrib import admin
from App2.models import Priority

class PriorityAdmin(admin.ModelAdmin):
   raw_id_fields = ('entry',)

admin.site.register(Priority,PriorityAdmin)

Regards,
--
Burhan Khalid

On Jan 12, 8:27 am, gupta-django  wrote:
> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 20 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
>     entry = models.ForeignKey(Entry)
>     priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
>
> Thanks

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



Re: Help with Imagefile

2011-01-12 Thread Daniel Roseman
On Wednesday, January 12, 2011 6:11:27 AM UTC, nlub...@gmail.com wrote:
>
> hello, i have a very simple question. its about imagefiles 
>
> my model 
>  class Usuario(models.Model): 
>  ImagenEmpresa = models.ImageField(upload_to = 'perfil/', 
> null=True) 
>
> my template 
> enctype="multipart/form-data" onSubmit="return check(this);"> 
>
>  
> and my save method 
> nuevo = Usuario(ImagenEmpresa = 
> request.FILES['ImagenEmpresa']) 
> nuevo.save() 
>
> this save the image im uploading to the file folder correctly but i 
> want to change the name of the image 
> example. 
>
> if im uploading a "testofimage.gif" 
> i would like to save it as "Profileoduser.gif"


upload_to can be a callable, ie a function that handles the uploaded file. 
This is passed the image file and original filename, and should return the 
absolute path. See the documentation:
http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.FileField.upload_to
So you could use that to rename the file appropriately.
--
DR.

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



Re: Need HELP urgently

2011-01-12 Thread Xavier Ordoquy
Hi,

I am not sure the admin is designed for handling so many entries in a foreign 
key.
When you try to display Priority, you'll have a combo box with 200.000 entries 
which will takes a lot of time to get computed especially if you want to 
display entries information in the string representation.
Even if the admin interface would render it, you'll suffer a really poor user 
experience.

Maybe you could describe what you are trying to achieve in order to get the 
right way to do it ?

Regards,
Xavier.

Le 12 janv. 2011 à 06:27, gupta-django a écrit :

> I have two application
> 
> 1. App1 - It has a Model Class "Entry" that has 20 entries
> 2. App2 - It has a Model Class "Priority"
> 
> In Priority class I am defining a Foreign Key Relationship as
> 
> from App1.models import Entry
> 
> class Priority(models.Model):
>entry = models.ForeignKey(Entry)
>priority = models.CharField(max_length=2)
> 
> And in App2/admin.py I am simply registering Priority
> 
> admin.site.register(Priority)
> 
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
> 
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
> 
> Thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: Need HELP urgently

2011-01-12 Thread Piotr Kilczuk
Hi,

2011/1/12 gupta-django 

> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 20 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
>entry = models.ForeignKey(Entry)
>priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>

It's quite obvious why or rather what is IMO wrong here. Are you (or the end
user) really satisfied with a  that contains 20 
elements? That's at least 3,5 MB of plain HTML.

P.S. This is one to one relation, isn't it?

Regards,
Piotr

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



Re: Help with Imagefile

2011-01-12 Thread Piotr Kilczuk
Hi,


> upload_to can be a callable, ie a function that handles the uploaded file.
> This is passed the image file and original filename, and should return the
> absolute path. See the documentation:
>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.FileField.upload_to
> So you could use that to rename the file appropriately.
>

Ah, didn't notice that. Thanks :)

Regards,
Piotr

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



Re: Need HELP urgently

2011-01-12 Thread Matias Aguirre
The given answers are correct, that's your issue without doubt, create an admin
class for your Priority model and setup a raw_id_field[1]:

class PriorityOptions(admin.ModelAdmin):
raw_id_fields = ('entry',)
register(Priority, PriorityOptions)

Regards,
Matías

[1]: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

Excerpts from gupta-django's message of Wed Jan 12 03:27:17 -0200 2011:
> I have two application
> 
> 1. App1 - It has a Model Class "Entry" that has 20 entries
> 2. App2 - It has a Model Class "Priority"
> 
> In Priority class I am defining a Foreign Key Relationship as
> 
> from App1.models import Entry
> 
> class Priority(models.Model):
> entry = models.ForeignKey(Entry)
> priority = models.CharField(max_length=2)
> 
> And in App2/admin.py I am simply registering Priority
> 
> admin.site.register(Priority)
> 
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
> 
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
> 
> Thanks
> 
-- 
Matías Aguirre 

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



Re: upload files via ajax

2011-01-12 Thread Masklinn
On 2011-01-11, at 13:12 , Jani Tiainen wrote:
> 
> I think Dojotoolkit and ExtJS both have nice mechanisms to do this ootb so no 
> need to reinvent the wheel. I've never been fan of jquery so I don't know is 
> there something for them (or for other similiar pure js frameworks)
For jquery, the `jquery-forms` plugin handles that, though it's not entirely 
transparent (I don't expect it to be on Dojo or Ext) when it has to rely on 
iframes, as it's e.g. not possible to set headers on iframe requests.

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



Re: Configure LAMPP with Django

2011-01-12 Thread Javier Guerra Giraldez
On Tue, Jan 11, 2011 at 9:00 PM, Kenneth Gonsalves
 wrote:
> I do not think it does - django is not a webserver or server like zope
> for example. So what does 'stays up' mean?

it is.  depending on how you deploy, it's a FastCGI server, or a WSGI server.

in any case, the process is started once, lots of initializations are
done, and it starts receiving user's requests (after some translations
from the frontend web server).  If you modify non-local resources in
memory, they are available for the next request.

Of course, most schemas start more than one process or thread, and you
never know which one will service the next request, so you can't rely
on that being available.  Still, it's the base of the 'memory' cache
backend: simply a global Python variable that holds data from previous
requests.

Another complication is that usually there's a request counter, and
after it goes to zero, the thread/process is killed and another one is
started.  That's usually done to limit any memory leak or similar
degradation, but it's done after several (sometimes hundreds of)
requests, not for each and every one like on PHP.

Why is that important? because all the models and urls and similar
scaffolding are done once and used afterwards.  If you do funny things
there and/or don't take in account the lazy nature of Querysets, you
might see some strange things happening.

At the same time, it means Django is free of the "the most classes you
initialize, the slower your app is" effect in PHP.

-- 
Javier

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



Re: Need HELP urgently

2011-01-12 Thread Piotr Zalewa
I'd also take a look at XHR requests (Web Console or Firebug's Net panel)


On 01/12/11 13:53, Matias Aguirre wrote:
> The given answers are correct, that's your issue without doubt, create an 
> admin
> class for your Priority model and setup a raw_id_field[1]:
> 
> class PriorityOptions(admin.ModelAdmin):
> raw_id_fields = ('entry',)
> register(Priority, PriorityOptions)
> 
> Regards,
> Matías
> 
> [1]: 
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields
> 
> Excerpts from gupta-django's message of Wed Jan 12 03:27:17 -0200 2011:
>> I have two application
>>
>> 1. App1 - It has a Model Class "Entry" that has 20 entries
>> 2. App2 - It has a Model Class "Priority"
>>
>> In Priority class I am defining a Foreign Key Relationship as
>>
>> from App1.models import Entry
>>
>> class Priority(models.Model):
>> entry = models.ForeignKey(Entry)
>> priority = models.CharField(max_length=2)
>>
>> And in App2/admin.py I am simply registering Priority
>>
>> admin.site.register(Priority)
>>
>> But on Admin website when I try to add a priority - the control hangs
>> up and only a blank page is returned after a long time gap.
>>
>> Can anyone please look into the issue that why it is not letting me
>> add priorities through Admin? I am able to add from backend,
>>
>> Thanks
>>


-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Help with a somewhat complex reverse ForeignKey lookup.

2011-01-12 Thread Peter
If I have a couple of models like these (just an example)

class Parent(models.Model):
name = models.CharField(max_length=100)

class Gender(models.Model):
name = models.CharField(max_length=100)

class Child(models.Model):
entity = models.ForeignKey(Entity, related_name=’children’)
gender = models.ForeignKey(Gender)
name = models.CharField(max_length=100)


How can i get a list of parents that _doesn't_ have a child of a
certain gender?

>>> gender = Gender.objects.get(name='female')
>>> Parent.objects.filter(#whatever that gets parents that doesn't have a child 
>>> with gender=gender#)

I'm completely lost here so please help me out.
If it was about getting parents with no children then
"children__isnull=True" should do it but now I don't know.
The answer is probably obvious but I'm suffering from a mental block
right here.

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



Re: Flatten template?

2011-01-12 Thread Peter
Please add to djangosnippets I'm somewhat interested in what you have 
done.


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



Re: QuerySetManager breakage with r14389

2011-01-12 Thread Russell Keith-Magee
On Thu, Jan 6, 2011 at 5:29 AM, Ian Clelland  wrote:
> Hi,
>
> I've been using Simon Willison's QuerySetManager[1] pattern for a
> while now, and since upgrading to Django 1.2.4, it has been breaking
> when I try to call a method on a RelatedManager constructed from it.
>
> There was a change in r14389 (14390 in the 1.2.X branch) which causes
> this code to break -- where there was a simple delegation before from
> the RelatedManager to the QuerySetManager to the model, there now
> appears to be an infinite recursion, with the RelatedManager and
> QuerySetManager trying to call each other's get_query_set methods.
>
> Has anybody seen this before? I am presuming that the change to
> Django's related.py is correct, and that the QuerySetManager code just
> needs to be updated to properly support Multi-db, but I don't know
> where to start fixing it.

Hi Ian,

Sorry for taking so long to get back to you.

No - I haven't seen this before; and I can't see an obvious reason
that the snippet should have stopped working.

If you want to make sure this is addressed, you should open a ticket
in Trac. What you are report is an apparent regression in a recent
changeset, so it would constitute a release-blocking bug for 1.3.

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



Re: Help with a somewhat complex reverse ForeignKey lookup.

2011-01-12 Thread Daniel Roseman
On Wednesday, January 12, 2011 2:04:28 PM UTC, Peter wrote:
>
> If I have a couple of models like these (just an example) 
>
> class Parent(models.Model): 
> name = models.CharField(max_length=100) 
>
> class Gender(models.Model): 
> name = models.CharField(max_length=100) 
>
> class Child(models.Model): 
> entity = models.ForeignKey(Entity, related_name=’children’) 
> gender = models.ForeignKey(Gender) 
> name = models.CharField(max_length=100) 
>
>
> How can i get a list of parents that _doesn't_ have a child of a 
> certain gender? 
>
> >>> gender = Gender.objects.get(name='female') 
> >>> Parent.objects.filter(#whatever that gets parents that doesn't have a 
> child with gender=gender#) 
>
> I'm completely lost here so please help me out. 
> If it was about getting parents with no children then 
> "children__isnull=True" should do it but now I don't know. 
> The answer is probably obvious but I'm suffering from a mental block 
> right here. 
>
>
Your question is a bit confusing because the Parent model doesn't seem to be 
related to anything. Should the FK to 'Entity' in Child actually be to 
Parent? Assuming yes, does this give you what you want?

Parent.objects.exclude(child__gender='female') 
--
DR.

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



Re: Help with a somewhat complex reverse ForeignKey lookup.

2011-01-12 Thread Peter Magnusson
Yes of course my mistake when "washing" my original messy code

Peter Magnusson

MUSTADFORS BRUKS AB | Sågbrovägen 1 | SE66010 Dals Långed | Phone +46
(0)531-71 435 | Mobile +46 (0)76-824 96 04  | http://www.mustad.se


On Wed, Jan 12, 2011 at 15:32, Daniel Roseman  wrote:

> On Wednesday, January 12, 2011 2:04:28 PM UTC, Peter wrote:
>>
>> If I have a couple of models like these (just an example)
>>
>> class Parent(models.Model):
>> name = models.CharField(max_length=100)
>>
>> class Gender(models.Model):
>> name = models.CharField(max_length=100)
>>
>> class Child(models.Model):
>> entity = models.ForeignKey(Entity, related_name=’children’)
>> gender = models.ForeignKey(Gender)
>> name = models.CharField(max_length=100)
>>
>>
>> How can i get a list of parents that _doesn't_ have a child of a
>> certain gender?
>>
>> >>> gender = Gender.objects.get(name='female')
>> >>> Parent.objects.filter(#whatever that gets parents that doesn't have a
>> child with gender=gender#)
>>
>> I'm completely lost here so please help me out.
>> If it was about getting parents with no children then
>> "children__isnull=True" should do it but now I don't know.
>> The answer is probably obvious but I'm suffering from a mental block
>> right here.
>>
>>
> Your question is a bit confusing because the Parent model doesn't seem to
> be related to anything. Should the FK to 'Entity' in Child actually be to
> Parent? Assuming yes, does this give you what you want?
>
> Parent.objects.exclude(child__gender='female')
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Help with a somewhat complex reverse ForeignKey lookup.

2011-01-12 Thread Peter
And your example of course worked It's obvious really and just stupid of 
me.
Thanks

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



Re: Email and activation key in django.contrib.auth

2011-01-12 Thread Micah Carrick
Thanks for the great information. I've tinkered with it and it seems to be
working pretty good. Still need to make the email unique but all in all a
pretty good solution.

What do you think about using django-registration instead? Does anybody know
of a pro/con comparison of the built-in auth versus django-registration?

On Tue, Jan 11, 2011 at 5:42 PM, Shawn Milochik  wrote:

> Yes, it's very easy to do.
>
> For the e-mail address as the login, all you have to do is create your own
> auth backend. That is a LOT simpler than it sounds -- just a few lines of
> code.
>
>
> http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend
>
> As for the need to activate their account, that's very simply handled in
> your custom auth backend, since you'll be writing it anyway. Just check for
> activation status in your custom authenticate function.
>
> Here's my "custom" auth backend. It uses the e-mail address for the login.
> You'll still have to give the User instance a unique username, but then you
> can ignore it. You can copy this verbatim and be done, other than
> "activating" the account, which you can easily work out.
>
> http://dpaste.com/hold/308215/
>
> Note: If you can work with the 1.3 beta (and eventually the final release),
> then you can just use the e-mail address as the username, as they've
> expanded the allowed characters in the username field of the User model.
> Chances are you can do that, since 1.3 is scheduled for final release in a
> few weeks.
>
> Shawn
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Micah Carrick, Founder

*Green Tackle* - *Environmentally Friendly Fishing Tackle*
www.GreenTackle.com 

 Email: mi...@greentackle.com
 Phone: 971.270.2206
 Toll Free: 877.580.9165
 Fax: 503.946.3106

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



Help optimising database calls

2011-01-12 Thread Matt Henderson
Hello,
I'm new to django, and set up a website recently, (puncut.com). I was hoping 
someone might be able to explain how to optimise database calls because at 
the moment some pages are taking 5 seconds before django responds.
I'll summarise the scenario below:

# models
class Thread(models.Model) :
  ... bunch of fields including title, description, author (linked to User)
  
class Pun(models.Model) :
  thread=   models.ForeignKey(Thread)
  author=   models.ForeignKey(User)
  ... other fields like content etc.

class Like(models.Model) :
  liker =   models.ForeignKey(User)
  pun   =   models.ForeignKey(Pun)

So there are puns in threads, and users can like puns. 
The view which lists latest threads is particularly slow. It sends threads 
to the template, and the template loops through threads and inside it loops 
through the puns which are in that thread. in pseudo code:
for thread in threads 
for pun in thread.pun_set
output pun.content
But I reckon that makes way to many calls to the database. I think I ought 
to use select_related , but I tried it and it didn't speed it up.
Thanks for any help,
Matt
 

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



Re: Help optimising database calls

2011-01-12 Thread Dan Fairs
> Hello,
> I'm new to django, and set up a website recently, (puncut.com). I was hoping 
> someone might be able to explain how to optimise database calls because at 
> the moment some pages are taking 5 seconds before django responds.
> I'll summarise the scenario below:

[snip]


> But I reckon that makes way to many calls to the database. I think I ought to 
> use select_related , but I tried it and it didn't speed it up.

Check out the Django debug toolbar. It will show you exactly what SQL queries 
are being run, and you'll be able to see a stack trace for each, indicating 
what caused the query to happen. You will also be able to see the effect of any 
select_related() calls you make.

Cheers,
Dan
--
Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com


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



Re: Email and activation key in django.contrib.auth

2011-01-12 Thread Shawn Milochik
If you're using 1.3, you can make the e-mail address the username, which will 
automatically require it to be unique.

I haven't used django-registration, but many others have, so maybe they'll be 
able to answer. On face-value, I'd say that your question is a bit off, though; 
django-registration doesn't replace the contrib.auth system. It just provides a 
way for you to create a user-friendly registration system for your users, but 
it still uses contrib.auth on the backend.

Shawn


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



Re: Help optimising database calls

2011-01-12 Thread Matias Aguirre
Try to reduce the queries on your view, select_related won't help a lot if
using Thread model, try to collect Pun values on your view first and group them
by thread, itertools.groupby could be handy in this case. Try something like:

threads = Thread.objects.select_related('user').filter(...)
thread_ids = [th.id for th in threads]
Pun.objects.select_related('thread', 'author').filter(thread__in=thread_ids)

Then group Pun by thread and use that on your template.

Makes sense?

Regards,
Matías

Excerpts from Matt Henderson's message of Wed Jan 12 13:32:37 -0200 2011:
> Hello,
> I'm new to django, and set up a website recently, (puncut.com). I was hoping 
> someone might be able to explain how to optimise database calls because at 
> the moment some pages are taking 5 seconds before django responds.
> I'll summarise the scenario below:
> 
> # models
> class Thread(models.Model) :
>   ... bunch of fields including title, description, author (linked to User)
>   
> class Pun(models.Model) :
>   thread=   models.ForeignKey(Thread)
>   author=   models.ForeignKey(User)
>   ... other fields like content etc.
> 
> class Like(models.Model) :
>   liker =   models.ForeignKey(User)
>   pun   =   models.ForeignKey(Pun)
> 
> So there are puns in threads, and users can like puns. 
> The view which lists latest threads is particularly slow. It sends threads 
> to the template, and the template loops through threads and inside it loops 
> through the puns which are in that thread. in pseudo code:
> for thread in threads 
> for pun in thread.pun_set
> output pun.content
> But I reckon that makes way to many calls to the database. I think I ought 
> to use select_related , but I tried it and it didn't speed it up.
> Thanks for any help,
> Matt
-- 
Matías Aguirre 

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



Re: Help optimising database calls

2011-01-12 Thread Łukasz Rekucki
On 12 January 2011 16:32, Matt Henderson  wrote:
> Hello,
> I'm new to django, and set up a website recently, (puncut.com). I was hoping
> someone might be able to explain how to optimise database calls because at
> the moment some pages are taking 5 seconds before django responds.
> I'll summarise the scenario below:
> # models
> class Thread(models.Model) :
>   ... bunch of fields including title, description, author (linked to User)
>
> class Pun(models.Model) :
>   thread        =   models.ForeignKey(Thread)
>   author        =   models.ForeignKey(User)
>   ... other fields like content etc.
> class Like(models.Model) :
>   liker         =   models.ForeignKey(User)
>   pun           =   models.ForeignKey(Pun)
> So there are puns in threads, and users can like puns.
> The view which lists latest threads is particularly slow. It sends threads
> to the template, and the template loops through threads and inside it loops
> through the puns which are in that thread. in pseudo code:
> for thread in threads
>     for pun in thread.pun_set
>         output pun.content
> But I reckon that makes way to many calls to the database. I think I ought
> to use select_related , but I tried it and it didn't speed it up.
> Thanks for any help,
> Matt

select_related() won't help you as it only traverses relations
"forward" ( you could select all puns with their thread, but not the
other way). AFAIK, this limitation comes from SQL, not the ORM itself.
The solution is to make the join/group_by operation "by-hand":

theads = list(Thread.objects.all()) # Materialize the queryset
threads_map = {}
for t in threads:
threads_map[t.pk] = t
t.pun_collection = []
for pun in Puns.objects.all(): # or if threads are limited:
filter(thread__in=threads)
t[pun.thread_id].pun_collection.append(pun)

# now ``threads`` contains a list of threads with assigned puns.
-- 
Łukasz Rekucki

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



Re: Database Table Locks/unlocks (for reading, writing or both)

2011-01-12 Thread Jagdeep Singh Malhi

> > Is Django automatically done the table locking /unlocking concept in
> > case of Mysql/PostGreSQL?
>
> Depends how backend handles database sessions.
>
> > if not how I done this manually?
>
> Thing you described is called pessimistic locking. What are you trying to
> accomplish with that?

I only want to know is Django is able Lock/Unlock the Database tables,
If yes.
How its possible? how its works

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



Re: Database Table Locks/unlocks (for reading, writing or both)

2011-01-12 Thread Mo J. Al-Mughrabi
You could use custom SQL

Sent from my iPhone

On Jan 12, 2011, at 7:14 PM, Jagdeep Singh Malhi
 wrote:

>
>>> Is Django automatically done the table locking /unlocking concept in
>>> case of Mysql/PostGreSQL?
>>
>> Depends how backend handles database sessions.
>>
>>> if not how I done this manually?
>>
>> Thing you described is called pessimistic locking. What are you trying to
>> accomplish with that?
>
> I only want to know is Django is able Lock/Unlock the Database tables,
> If yes.
> How its possible? how its works
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Help optimising database calls

2011-01-12 Thread Matt Henderson
Thanks Lukasz and Matias,
I've implemented something along those lines in my view:

threads =
list(Thread.objects.select_related('author').all().order_by('-created'))[:150]
  threads_map = {}
  for t in threads:
threads_map[t.pk] = t
t.pun_collection = []
  for pun in Pun.objects.all().filter(thread__in=threads):
threads_map[pun.thread_id].pun_collection.append(pun)
  tpaginator = Paginator(threads, 10)

And I changed the template to loop through thread in threads then pun in
thread.pun_collection.
 But the page still takes about 5 seconds to load : www.puncut.com/latest2
Is there something I've done wrong?
M

On 12 January 2011 15:47, Matias Aguirre  wrote:

> Try to reduce the queries on your view, select_related won't help a lot if
> using Thread model, try to collect Pun values on your view first and group
> them
> by thread, itertools.groupby could be handy in this case. Try something
> like:
>
> threads = Thread.objects.select_related('user').filter(...)
> thread_ids = [th.id for th in threads]
> Pun.objects.select_related('thread',
> 'author').filter(thread__in=thread_ids)
>
> Then group Pun by thread and use that on your template.
>
> Makes sense?
>
> Regards,
> Matías
>
> Excerpts from Matt Henderson's message of Wed Jan 12 13:32:37 -0200 2011:
> > Hello,
> > I'm new to django, and set up a website recently, (puncut.com). I was
> hoping
> > someone might be able to explain how to optimise database calls because
> at
> > the moment some pages are taking 5 seconds before django responds.
> > I'll summarise the scenario below:
> >
> > # models
> > class Thread(models.Model) :
> >   ... bunch of fields including title, description, author (linked to
> User)
> >
> > class Pun(models.Model) :
> >   thread=   models.ForeignKey(Thread)
> >   author=   models.ForeignKey(User)
> >   ... other fields like content etc.
> >
> > class Like(models.Model) :
> >   liker =   models.ForeignKey(User)
> >   pun   =   models.ForeignKey(Pun)
> >
> > So there are puns in threads, and users can like puns.
> > The view which lists latest threads is particularly slow. It sends
> threads
> > to the template, and the template loops through threads and inside it
> loops
> > through the puns which are in that thread. in pseudo code:
> > for thread in threads
> > for pun in thread.pun_set
> > output pun.content
> > But I reckon that makes way to many calls to the database. I think I
> ought
> > to use select_related , but I tried it and it didn't speed it up.
> > Thanks for any help,
> > Matt
> --
> Matías Aguirre 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



list created from a table in my database

2011-01-12 Thread Tony
Hi all,
I want to create a page on my site where I can extract the rows from a
table in my database and allow certain users with the proper access to
be able to add, delete, and change the columns of the rows if they
want.  I think I have the multi-user thing pretty much figured out
(although I dont know if Im doing the best way, Ive just made
customuser model and then used inheritance for the other models that
represent users), but my main question is, what would be the best way
to go about displaing the rows to be edited, deleted, etc.. to a page
on my website.  I know I could display them if I just do queries like
modelname.object.filter(...) but the editing part and all that is
still sort of up in the air.  I appreciate any input on the matter.
thanks,
Tony

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



Re: list created from a table in my database

2011-01-12 Thread Shawn Milochik
Formsets were made for this:

http://docs.djangoproject.com/en/dev/topics/forms/formsets/

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



Re: Database Table Locks/unlocks (for reading, writing or both)

2011-01-12 Thread Christophe Pettus

On Jan 12, 2011, at 8:14 AM, Jagdeep Singh Malhi wrote:
> I only want to know is Django is able Lock/Unlock the Database tables,
> If yes.
> How its possible? how its works

Django by itself doesn't issue locking instructions to the database, and 
doesn't have any built-in primitives to do so.  You can use direct SQL, 
bypassing the ORM, to issue those commands if you really need to.

But the previous commenter's note is right: Pessimistic locking often kills 
database performance, and is rarely the best solution.

--
-- Christophe Pettus
   x...@thebuild.com

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



Re: Email and activation key in django.contrib.auth

2011-01-12 Thread Micah Carrick
Ah yes, thanks again.

I tinkered with the django-registration and was a bit more than I need.

While the username can store an email address, it's 30 character limit
prevents me from relying on that. Looking over an existing database I have,
there are quite a few email addresses over that character limit. I suppose I
could check if an email exists before saving a user creation form, but I
don't like not having that constraint in the DB. Can I alter the DB field at
creation with a fixture or something? I guess then I wouldn't have that nice
DB abstraction.

I have created the custom auth backend to allow users to sign in with an
email address. It works great. I then subclassed the UserCreationForm to add
an email address field which also works. In this case, the web users will
not need access to the admin so I'm not too concerned about what username
shows up there--I could even auto-generate one. So now what I need to do is:

1. Remove the "username" field from my subclassed version of
UserCreationForm. Not sure how to do that. I will then create the username
in the save() method.
2. Rename the "username" field in the login form to "Email Address". I am
using the built-in login view, so I probably will have to write my own view?



On Wed, Jan 12, 2011 at 7:50 AM, Shawn Milochik  wrote:

> If you're using 1.3, you can make the e-mail address the username, which
> will automatically require it to be unique.
>
> I haven't used django-registration, but many others have, so maybe they'll
> be able to answer. On face-value, I'd say that your question is a bit off,
> though; django-registration doesn't replace the contrib.auth system. It just
> provides a way for you to create a user-friendly registration system for
> your users, but it still uses contrib.auth on the backend.
>
> Shawn
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Micah Carrick, Founder

*Green Tackle* - *Environmentally Friendly Fishing Tackle*
www.GreenTackle.com 

 Email: mi...@greentackle.com
 Phone: 971.270.2206
 Toll Free: 877.580.9165
 Fax: 503.946.3106

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



Re: Follow relations on three tables

2011-01-12 Thread gia...@gmail.com
On Tue, Jan 11, 2011 at 2:30 PM, Matias Aguirre  wrote:
> So, basically you want this:
>
> C.objects.filter(Bref__Dref__id=D_id).values_list('Aref')
>

Thanks! it was exactly what I needed

-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

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



ValueError.

2011-01-12 Thread delegbede
How can I work around this ValueError: too many values to unpack. 
I am actually trying to extract certain portion of a csv file. 
I just need an insight into what could be causing such error and I should be 
able to figure out the rest. 

Thanks. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: "gia...@gmail.com" 
Sender: django-users@googlegroups.com
Date: Wed, 12 Jan 2011 18:07:30 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: Follow relations on three tables

On Tue, Jan 11, 2011 at 2:30 PM, Matias Aguirre  wrote:
> So, basically you want this:
>
> C.objects.filter(Bref__Dref__id=D_id).values_list('Aref')
>

Thanks! it was exactly what I needed

-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

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

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



Re: ValueError.

2011-01-12 Thread Shawn Milochik

On Jan 12, 2011, at 12:14 PM, delegb...@dudupay.com wrote:

> How can I work around this ValueError: too many values to unpack. 
> I am actually trying to extract certain portion of a csv file. 
> I just need an insight into what could be causing such error and I should be 
> able to figure out the rest. 
> 
> Thanks. 
> Sent from my BlackBerry wireless device from MTN


It's exactly what the message said. Look at your line of code that attempts to 
read from the CSV. It will be assigning the values to variables.

Then look at the CSV file, and you will find that the number of values in one 
or more of the lines exceeds the number you were expecting.

This is a basic Python question -- not a Django one. Check out the very active 
Python mailing list:
http://mail.python.org/mailman/listinfo/python-list

Shawn

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



Re: Email and activation key in django.contrib.auth

2011-01-12 Thread Shawn Milochik
Without changing or subclassing the User model (which shouldn't be done, 
because it causes problems), I don't know how you can put the unique e-mail 
address constraint on the database, except manually via your database's own 
tool. I don't know if that can cause problems with Django's ORM, and it is 
probably a very complicated question with answers that differ greatly depending 
on the database backend and driver being used. So I can't offer any useful info 
here.

However, on the front end you can certainly override the clean() methods of 
your fields, and gracefully handle checking of duplicates and user-friendly 
error messages. I know you like the DB constraints because it's a 
best-practice, but if no other software will be accessing your database then 
this is all you'll need. 

For your two questions:

You don't need to remove the username from the ModelForm -- just don't include 
it in the template. 
Override the default template (copy the default template and modify your 
changed version).

To change the label on the template, you can change the 'label' property of the 
field in your subclassed ModelForm.
Something like this (in the __init__, after calling the __init__ of super():

self.fields['username'].label = 'E-mail Address'


Shawn

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



custom admin

2011-01-12 Thread Tony
Is there any way to make a custom admin for a site but use parts of
the existing admin.  It has a lot of good features but there are
certaint hings I dont want revealed and yes i know I can limit access,
but what if I want to limit lets say, a teacher to only his/her
student's information, or i want to change the look of the site.

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



Re: custom admin

2011-01-12 Thread Shawn Milochik
If you're comfortable creating views and modifying templates in Django already, 
then you can do whatever you like.

The admin uses views and templates that you can freely copy and modify, then 
have your application use your own instead of the defaults.

Shawn

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



Re: Email and activation key in django.contrib.auth

2011-01-12 Thread Micah Carrick
Shawn,

Thank you so very much. This is coming along quite nicely. Your answers have
been perfect.

On Wed, Jan 12, 2011 at 9:19 AM, Shawn Milochik  wrote:

> Without changing or subclassing the User model (which shouldn't be done,
> because it causes problems), I don't know how you can put the unique e-mail
> address constraint on the database, except manually via your database's own
> tool. I don't know if that can cause problems with Django's ORM, and it is
> probably a very complicated question with answers that differ greatly
> depending on the database backend and driver being used. So I can't offer
> any useful info here.
>
> However, on the front end you can certainly override the clean() methods of
> your fields, and gracefully handle checking of duplicates and user-friendly
> error messages. I know you like the DB constraints because it's a
> best-practice, but if no other software will be accessing your database then
> this is all you'll need.
>
> For your two questions:
>
> You don't need to remove the username from the ModelForm -- just don't
> include it in the template.
>Override the default template (copy the default template and modify your
> changed version).
>
> To change the label on the template, you can change the 'label' property of
> the field in your subclassed ModelForm.
>Something like this (in the __init__, after calling the __init__ of
> super():
>
>self.fields['username'].label = 'E-mail Address'
>
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Micah Carrick, Founder

*Green Tackle* - *Environmentally Friendly Fishing Tackle*
www.GreenTackle.com 

 Email: mi...@greentackle.com
 Phone: 971.270.2206
 Toll Free: 877.580.9165
 Fax: 503.946.3106

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



Re: Email and activation key in django.contrib.auth

2011-01-12 Thread Shawn Milochik
You're welcome. Enjoy!

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



Test cookie and CSRF middleware

2011-01-12 Thread Adam Endicott
I'm migrating a site from Django 1.1 to 1.2 and I can't figure out how
set_test_cookie and test_cookie_worked is supposed to work when using
the CSRF middleware.

I do request.session.set_test_cookie() in my login view, then on POST,
I want to check request.session.test_cookie_worked(), but I never get
the chance, because when cookies are disabled, the CSRF middleware
kicks in and fails with "No CSRF or session cookie." That's not a
surprise, and it's certainly true, but I can't figure out any way to
get to a point where I can check for the test cookie and give a
"cookies required" message.

I feel like I'm missing something painfully obvious here. Help?

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



Re: QuerySetManager breakage with r14389

2011-01-12 Thread Ian Clelland
On Wed, Jan 12, 2011 at 6:23 AM, Russell Keith-Magee
 wrote:
> On Thu, Jan 6, 2011 at 5:29 AM, Ian Clelland  wrote:
>> Hi,
>>
>> I've been using Simon Willison's QuerySetManager[1] pattern for a
>> while now, and since upgrading to Django 1.2.4, it has been breaking
>> when I try to call a method on a RelatedManager constructed from it.
>>
>> There was a change in r14389 (14390 in the 1.2.X branch) which causes
>> this code to break -- where there was a simple delegation before from
>> the RelatedManager to the QuerySetManager to the model, there now
>> appears to be an infinite recursion, with the RelatedManager and
>> QuerySetManager trying to call each other's get_query_set methods.
>>
>> Has anybody seen this before? I am presuming that the change to
>> Django's related.py is correct, and that the QuerySetManager code just
>> needs to be updated to properly support Multi-db, but I don't know
>> where to start fixing it.
>
> Hi Ian,
>
> Sorry for taking so long to get back to you.
>
> No - I haven't seen this before; and I can't see an obvious reason
> that the snippet should have stopped working.
>
> If you want to make sure this is addressed, you should open a ticket
> in Trac. What you are report is an apparent regression in a recent
> changeset, so it would constitute a release-blocking bug for 1.3.

Thanks, Russ --

Looking at the QuerySetManager code, I couldn't tell if it was even
doing the right thing by unconditionally overriding __getattr__, or if
that was an incorrect solution that just happened to work until
related.py was fixed.

I've posted it on Trac, as ticket #15062.

(Glad to know it wasn't just lost in the noise :) )

Regards,
Ian Clelland


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



make an installer of my django project

2011-01-12 Thread Julio Cesar Rodriguez Cruz
Hi all, anyone can suggest me what is the better way that I can build
an .exe, .msi or a .deb, with my installed version of apache, python,
django and a django project that I had developed, with the
configuration enough that allows me to distributed the bundled
application, and once copied to another pc, by double clicking the
installer it start a wizard where even a child could  specify the
paths, etc, and at the end the server run and the project is ready to
use. I know XAMP or LAMP do part of what I want but for php.
Some ideas?
Thanks
Julio Cesar

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



Re: custom admin

2011-01-12 Thread Leandro Ardissone
There's a nice app called 
django-admin-tools, 
it let you create/edit a menu and a custom dashboard with draggable blocks 
of content.

Templating/theming isn't really mature yet, but if you know how to theme 
django's admin, you will figure out how to tune it.

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



ANN: django-widget-tweaks

2011-01-12 Thread Mikhail Korobov
Hi guys,

Designers often want to add some css classes and html attributes to
django form fields. But now they have to either patch the python code
or copy-paste full html widget output and then customize it. In order
to make them happy I just released an app ( 
https://bitbucket.org/kmike/django-widget-tweaks
) that makes it possible to customize html attributes and css classes
of form fields without touching python code.

Example:

{% load widget_tweaks %}
...
{{ form.city|attr:"autocomplete:off"|add_class:"my_css_class" }}

Hope somebody will find it useful.

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



Re: Django's documention is horrible

2011-01-12 Thread Rainy


On Jan 12, 7:18 am, Mike Dewhirst  wrote:
> OK - so we need an intro to the documention which describes the timeline
> of a typical* developer transitioning from beginner to guru and the docs
> which should be of interest at successive stages during that transition.
>
> *typical - I know there ain't such a person. However, there ought to be
> a "target audience" the Django Foundation wants to reach. That person
> becomes the target audience for the intro and gets described in the
> intro to the intro.
>
> If the intro works other "typical" devs can be described for alternative
> intros. Too meta huh?
>
> Problem is there are too many small operators who need more than Django.
> Such as aesthetic guidance, CSS etc etc
>
> It's a quite daunting curve but really all anyone needs is to know where
> to find the docs appropriate to their current stage.
>
> How about a survey where people tick boxes which describe where they
> currently sit on the continuum so that existing gurus can see how the
> first "typical" dev can be described.


I wonder if anyone keeps track of categories of questions asked
on this list and on stackoverflow. Something like:

In last 2 years:

total: x questions

admin:  250/x
views: ...
templates: ...

(but with more detailed subcategories).

If anyone has done this, please share because this would be
very useful to all django doc/tutorial authors.

-ak

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



performance fields in forms.py (province/city problem)

2011-01-12 Thread marco carminati
Dear all,
i'm trying to improve the performance during the modify of one of my
models'

I've the classic province and city structure.

In the 'insert form', using jquery, I can update the city queryset
after the user choice the province.

In the 'update form', I would like to set the city's queryset,
filtering the value I've already got in the province.

How could I get the province's value without using jquery (i.e. could
I get the province's value in forms.py)?

Thanks in advanced



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



Javascript Questions

2011-01-12 Thread hank23
I have a text field on a page which I want to disable when the page is
loaded and enable later when the user selects an entry in a dropdown
box. First how and where do I code the call to my disablefield
function when the page loads? Second what event is generated whenever
I select an entry in a dropdown box(onclick, ondblclick, onchange, or
some other one)?




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



Re: make an installer of my django project

2011-01-12 Thread Gennadiy Zlobin
You can use xampp both on Linux and Windows, just zip it and unzip
On 13 Jan 2011 01:33, "Julio Cesar Rodriguez Cruz" <
juliocesarrodriguezc...@gmail.com> wrote:
> Hi all, anyone can suggest me what is the better way that I can build
> an .exe, .msi or a .deb, with my installed version of apache, python,
> django and a django project that I had developed, with the
> configuration enough that allows me to distributed the bundled
> application, and once copied to another pc, by double clicking the
> installer it start a wizard where even a child could specify the
> paths, etc, and at the end the server run and the project is ready to
> use. I know XAMP or LAMP do part of what I want but for php.
> Some ideas?
> Thanks
> Julio Cesar
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: Javascript Questions

2011-01-12 Thread Piotr Zalewa
Is it in django-admin or completely irrelevant to this mailing list?

zalun

On 01/12/11 20:32, hank23 wrote:
> I have a text field on a page which I want to disable when the page is
> loaded and enable later when the user selects an entry in a dropdown
> box. First how and where do I code the call to my disablefield
> function when the page loads? Second what event is generated whenever
> I select an entry in a dropdown box(onclick, ondblclick, onchange, or
> some other one)?
> 
> 
> 
> 


-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Generate a unique username for django.contrib.auth

2011-01-12 Thread Micah Carrick
I've got my site's authentication working with and email and password
only--no username (thanks to Shawn Milochik for helping me with that).
However, I still need to put in a username to make the User model happy. I
was hoping to have "user" as a prefix and then some unique number.

I cannot simply copy the email to the username because the username must be
less than 30 characters and, after looking into my database, many email
addresses go over that.
I cannot generate a random number because there could be a collision.
I cannot use uuid4().hex because that's 32 characters... I need <30.
I cannot use User.objects.count() because that could result in a collision
if 2 users register at the same time.

Thoughts?

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



Re: Javascript Questions

2011-01-12 Thread hank23
I'm coding a new screen and view which I'm adding to the polls app.
from the django tutorial. I've written some javascript functions for
setting focus and for disabling  a textbox which appears to work when
the page loads which is when its supposed to execute. I've also coded
the dropdown box on the screen to call the enableField() function for
the onchange event and it does not seem to work. So is there anyway to
find out what event(s) are fired by the dropdown box so my code works?
Is it legal to code multiple javascript function calls when an event
fires, by separating them with a semicolon? Please advise. Thanks.

On Jan 12, 2:40 pm, Piotr Zalewa  wrote:
> Is it in django-admin or completely irrelevant to this mailing list?
>
> zalun
>
> On 01/12/11 20:32, hank23 wrote:
>
> > I have a text field on a page which I want to disable when the page is
> > loaded and enable later when the user selects an entry in a dropdown
> > box. First how and where do I code the call to my disablefield
> > function when the page loads? Second what event is generated whenever
> > I select an entry in a dropdown box(onclick, ondblclick, onchange, or
> > some other one)?
>
> --
> blog  http://piotr.zalewa.info
> jobs  http://webdev.zalewa.info
> twit  http://twitter.com/zalun
> face  http://facebook.com/zaloon

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



Re: ANN: django-widget-tweaks

2011-01-12 Thread Leandro Ardissone
Great!

I'll pass it to my designers!
It really simplifies the templating.

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



Re: Generate a unique username for django.contrib.auth

2011-01-12 Thread marco carminati
Hi Micah

On Jan 12, 10:11 pm, Micah Carrick  wrote:
> I've got my site's authentication working with and email and password
> only--no username (thanks to Shawn Milochik for helping me with that).
> However, I still need to put in a username to make the User model happy. I
> was hoping to have "user" as a prefix and then some unique number.
>

couldn't you use the user.id after creating it?
i.e.

prefix = 'user'
###some code to save user###

user.your_field =  prefix + str(user.id)
user.save()

if you don't neet this value in the database you could put in your
mail directly the user.id
hello {{ user.id }}

unfortunately I cannot test this solution now (sorry, i've not django
in this machine)

hoping this help,
marco

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



Re: Generate a unique username for django.contrib.auth

2011-01-12 Thread Eric Chamberlain
We use a base64 or base36 (if you want compatibility with the contrib.admin) 
encoded UUID, or generate a random 30-character string, the odds of a collision 
is quite low.

On Jan 12, 2011, at 1:11 PM, Micah Carrick wrote:

> I've got my site's authentication working with and email and password 
> only--no username (thanks to Shawn Milochik for helping me with that). 
> However, I still need to put in a username to make the User model happy. I 
> was hoping to have "user" as a prefix and then some unique number.
> 
> I cannot simply copy the email to the username because the username must be 
> less than 30 characters and, after looking into my database, many email 
> addresses go over that.
> I cannot generate a random number because there could be a collision.
> I cannot use uuid4().hex because that's 32 characters... I need <30.
> I cannot use User.objects.count() because that could result in a collision if 
> 2 users register at the same time.
> 
> Thoughts?
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



calling django auth from apache RewriteMap

2011-01-12 Thread Brian Craft
I'm interested in using RewriteMap (from mod_rewrite) to check for a
django user session. That is, RewriteMap would invoke some script
which would return session info, which could be used by mod_rewrite to
allow or deny access. Basically, this would require writing a
standalone python script that returns session information about a
request. E.g. apache would write the session credentials (sessionid
cookie?) to the script stdin, and the script would return information
about the session (e.g. whether logged in, group membership, or etc.).

Can anyone point me in the right direction? I need to know what
information django requires to validate a request (look up a session),
and what methods I could use to invoke it standalone.

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



Re: Class based views and form processing

2011-01-12 Thread Justin Murphy
Hi, I still haven't found an answer to this problem so I am shamelessly 
bumping the last updated date.

Thanks in advance for your help!

-Justin

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



Re: Generate a unique username for django.contrib.auth

2011-01-12 Thread Acorn
Why not just use incremental numeric user IDs?

On 12 January 2011 21:23, Eric Chamberlain  wrote:
> We use a base64 or base36 (if you want compatibility with the contrib.admin) 
> encoded UUID, or generate a random 30-character string, the odds of a 
> collision is quite low.
>
> On Jan 12, 2011, at 1:11 PM, Micah Carrick wrote:
>
>> I've got my site's authentication working with and email and password 
>> only--no username (thanks to Shawn Milochik for helping me with that). 
>> However, I still need to put in a username to make the User model happy. I 
>> was hoping to have "user" as a prefix and then some unique number.
>>
>> I cannot simply copy the email to the username because the username must be 
>> less than 30 characters and, after looking into my database, many email 
>> addresses go over that.
>> I cannot generate a random number because there could be a collision.
>> I cannot use uuid4().hex because that's 32 characters... I need <30.
>> I cannot use User.objects.count() because that could result in a collision 
>> if 2 users register at the same time.
>>
>> Thoughts?
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Generate a unique username for django.contrib.auth

2011-01-12 Thread Micah Carrick
Thanks folks.

Here's what I have now. Not the most elegant but it's the best I can come up
with so far. First, I'm generating a random string for the username so that
the form will validate. After the record is saved I change the username to
"user_" and the user ID. This way it looks a little less scary if it pops up
on an admin form somewhere or something.

# in the view for my sign up form
if request.method == 'POST':
data = request.POST.copy()
randstr = ''.join([choice(string.letters) for i in xrange(30)])
data['username'] = 'user_' + randstr
form = SignUpForm(data) # subclass of UserCreationForm
if form.is_valid():
form.save()

# in the save method of SignUpForm which is subclassed from UserCreationForm
user.save()
user.username = 'user_' + str(user.id)
user.save()

What I still hate about this one is that I'm hitting the database twice for
a single registration. But, it seems to work.

On Wed, Jan 12, 2011 at 1:23 PM, Eric Chamberlain  wrote:

> We use a base64 or base36 (if you want compatibility with the
> contrib.admin) encoded UUID, or generate a random 30-character string, the
> odds of a collision is quite low.
>
> On Jan 12, 2011, at 1:11 PM, Micah Carrick wrote:
>
> > I've got my site's authentication working with and email and password
> only--no username (thanks to Shawn Milochik for helping me with that).
> However, I still need to put in a username to make the User model happy. I
> was hoping to have "user" as a prefix and then some unique number.
> >
> > I cannot simply copy the email to the username because the username must
> be less than 30 characters and, after looking into my database, many email
> addresses go over that.
> > I cannot generate a random number because there could be a collision.
> > I cannot use uuid4().hex because that's 32 characters... I need <30.
> > I cannot use User.objects.count() because that could result in a
> collision if 2 users register at the same time.
> >
> > Thoughts?
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Micah Carrick, Founder

*Green Tackle* - *Environmentally Friendly Fishing Tackle*
www.GreenTackle.com 

 Email: mi...@greentackle.com
 Phone: 971.270.2206
 Toll Free: 877.580.9165
 Fax: 503.946.3106

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



Re: Class based views and form processing

2011-01-12 Thread Skylar Saveland
instead of calling super, you could just call FormMixin.form_valid directly, 
yes?

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



Re: Class based views and form processing

2011-01-12 Thread Skylar Saveland
what's wrong with just defining form_valid sth like:


  form_valid(self, form):
self.object = form.save(commit=False)
#ponies
self.object.save()
return HttpResponseRedirect(self.get_success_url())

does that not work?

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



Re: Javascript Questions

2011-01-12 Thread marco carminati

> the onchange event and it does not seem to work. So is there anyway to
> find out what event(s) are fired by the dropdown box so my code works?

if you active the console in firebug you could see anything..
you could always put an alert('hello') in your javascript code

> Is it legal to code multiple javascript function calls when an event
> fires, by separating them with a semicolon? Please advise. Thanks.
>

if you have a dropdown, I suggest to you jquery.
see 
http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/

putting in the end of page

   $("#ComboBox").change(function() {
   alert($("#ComboBox").val());
  /* do something here */
   });


changing the dropdownlist value you'll see the alert with the selected
value.



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



Re: Class based views and form processing

2011-01-12 Thread Justin Murphy
Thanks, Skylar. You're right, it worked. Now I am just shaking my head and 
saying "next time, I'll just read the source..."

-Justin

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



Re: Generate a unique username for django.contrib.auth

2011-01-12 Thread Eric Chamberlain
Because the id is not known until after the record is saved, so you'd have to 
generate some non-colliding filler value anyway.  Using incremental numbers can 
also leak usage information to the users.


On Jan 12, 2011, at 1:52 PM, Acorn wrote:

> Why not just use incremental numeric user IDs?
> 
> On 12 January 2011 21:23, Eric Chamberlain  wrote:
>> We use a base64 or base36 (if you want compatibility with the contrib.admin) 
>> encoded UUID, or generate a random 30-character string, the odds of a 
>> collision is quite low.
>> 
>> On Jan 12, 2011, at 1:11 PM, Micah Carrick wrote:
>> 
>>> I've got my site's authentication working with and email and password 
>>> only--no username (thanks to Shawn Milochik for helping me with that). 
>>> However, I still need to put in a username to make the User model happy. I 
>>> was hoping to have "user" as a prefix and then some unique number.
>>> 
>>> I cannot simply copy the email to the username because the username must be 
>>> less than 30 characters and, after looking into my database, many email 
>>> addresses go over that.
>>> I cannot generate a random number because there could be a collision.
>>> I cannot use uuid4().hex because that's 32 characters... I need <30.
>>> I cannot use User.objects.count() because that could result in a collision 
>>> if 2 users register at the same time.
>>> 
>>> Thoughts?
>>> 
> 

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



Re: empty DateTimeField?

2011-01-12 Thread galago
Yes, I had to remove and make syncdb for that table. All works fine now :)

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



Inlining a reverse foreign key relationship in django admin

2011-01-12 Thread Viktor Kojouharov
Hi,

Consider the following models:

class Foo(models.Model):
   name = models.CharField(max_length=100)

class Bar(models.Model):
   name = models.CharField(max_length=100)
   city = models.ForeignKey(Foo)

How can I inline the admin model form for Foo into Bar, so that I can add 
new Foo items if needed?

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



Re: Help optimising database calls

2011-01-12 Thread Matt Henderson
I managed to improve the speed of the site by using memcached to cache the
rendered Thread views
M

On 12 January 2011 16:23, Matt Henderson  wrote:

> Thanks Lukasz and Matias,
> I've implemented something along those lines in my view:
>
> threads =
> list(Thread.objects.select_related('author').all().order_by('-created'))[:150]
>   threads_map = {}
>   for t in threads:
> threads_map[t.pk] = t
> t.pun_collection = []
>   for pun in Pun.objects.all().filter(thread__in=threads):
> threads_map[pun.thread_id].pun_collection.append(pun)
>   tpaginator = Paginator(threads, 10)
>
> And I changed the template to loop through thread in threads then pun in
> thread.pun_collection.
>  But the page still takes about 5 seconds to load : www.puncut.com/latest2
> Is there something I've done wrong?
> M
>
> On 12 January 2011 15:47, Matias Aguirre  wrote:
>
>> Try to reduce the queries on your view, select_related won't help a lot if
>> using Thread model, try to collect Pun values on your view first and group
>> them
>> by thread, itertools.groupby could be handy in this case. Try something
>> like:
>>
>> threads = Thread.objects.select_related('user').filter(...)
>> thread_ids = [th.id for th in threads]
>> Pun.objects.select_related('thread',
>> 'author').filter(thread__in=thread_ids)
>>
>> Then group Pun by thread and use that on your template.
>>
>> Makes sense?
>>
>> Regards,
>> Matías
>>
>> Excerpts from Matt Henderson's message of Wed Jan 12 13:32:37 -0200 2011:
>> > Hello,
>> > I'm new to django, and set up a website recently, (puncut.com). I was
>> hoping
>> > someone might be able to explain how to optimise database calls because
>> at
>> > the moment some pages are taking 5 seconds before django responds.
>> > I'll summarise the scenario below:
>> >
>> > # models
>> > class Thread(models.Model) :
>> >   ... bunch of fields including title, description, author (linked to
>> User)
>> >
>> > class Pun(models.Model) :
>> >   thread=   models.ForeignKey(Thread)
>> >   author=   models.ForeignKey(User)
>> >   ... other fields like content etc.
>> >
>> > class Like(models.Model) :
>> >   liker =   models.ForeignKey(User)
>> >   pun   =   models.ForeignKey(Pun)
>> >
>> > So there are puns in threads, and users can like puns.
>> > The view which lists latest threads is particularly slow. It sends
>> threads
>> > to the template, and the template loops through threads and inside it
>> loops
>> > through the puns which are in that thread. in pseudo code:
>> > for thread in threads
>> > for pun in thread.pun_set
>> > output pun.content
>> > But I reckon that makes way to many calls to the database. I think I
>> ought
>> > to use select_related , but I tried it and it didn't speed it up.
>> > Thanks for any help,
>> > Matt
>> --
>> Matías Aguirre 
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



RE: login failed with correct username and password

2011-01-12 Thread Lin Tao(EXT-VanceInfo/Beijing)
Thank you bruno. Actually I've tried that method. But that's not where the
problem lies. I reviewed my signup form and found out that there was
something wrong with it. One of my clean_ method returned
self.cleaned_data instead of returning self.cleaned_data[''].
Well it's password field. So the password which was saved was not what I'd
typed in which of course would cause a login failure.
What a stupid mistake I've made. Sorry.

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of bruno desthuilliers
Sent: Wednesday, January 12, 2011 08:00 PM
To: Django users
Subject: Re: login failed with correct username and password

On 12 jan, 04:03, "Lin Tao\(EXT-VanceInfo/Beijing\)"
 wrote:
> Hi,
>
> I encounter this problem that I failed to login to my app with correct
> username and password. I'm wondering if there is something wrong with my
> login form. Here is what it looks like:

(snip code - seems mostly ok)

>
> Every time I tried to login with correct username and password, it would
go
> back to login page with error message "Your username or password is
> incorrect".
>
> I guess there is something wrong with authenticate function.

I guess someone would have noticed this long ago. The first thing I'd
try would be to fire the django shell and run this:

# > from django.contrib import auth
# > user = auth.authenticate(username="yourusername",
password="yourpassword")
# > print user

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



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



django spread

2011-01-12 Thread dezmond phillips
Hello Everyone

Looking to startup a site that is similar to Yipit.

Do I just need to get 2 Django guys, 1 js guy or gal, and a graphic
artist and I am good to go?

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



Meaning for this error

2011-01-12 Thread NavaTux
Hi all,

   I wan to import a method in a model class to another
class as well as that method contains some objects includes self

How to import that method's operation?

it shows the error


>>> from users.models import userprofile
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
models.py", line 6, in 
from django.db import models
  File "/usr/local/lib/python2.6/dist-packages/django/db/__init__.py",
line 14, in 
if not settings.DATABASES:
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
functional.py", line 276, in __getattr__
self._setup()
  File "/usr/local/lib/python2.6/dist-packages/django/conf/
__init__.py", line 38, in _setup
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
>>>

-- 
You received this message because you are subscribed to the Google 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: HTML special chars in form labels

2011-01-12 Thread Derek
Have you tried safe or safeseq tags, applied to those specific labels?
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#safe

On Jan 11, 8:27 pm, Vsevolod  wrote:
> Django known to escape whole form label text.
> Still I have a need to insert special characters (nbsp, dashes etc.)
> into the label text.
> Is there any way to do it or disable escaping?

-- 
You received this message because you are subscribed to the Google 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: Runtime Error: maximum recursion depth exceeded while calling Python object

2011-01-12 Thread Derek
Still not working, but I suspect a recent upgrade to Django 1.2.4
might be the cause.

Does anyone know (or have experience) of this kind of error when
upgrading?

On Jan 12, 9:38 am, Derek  wrote:
> Working with Django 1.2.3
>
> I had an application that was running well.  However, some recent changes
> (not to the models themselves) have caused the "Runtime Error: maximum
> recursion depth exceeded while calling Python object" to start showing up
> everywhere; typically in conjunction with the def __unicode__(self)
> function.  The only major change I have made recently to the system is the
> enabling of flatpages, but i cannot see that this is likely to relate to the
> model's __unicode__ functions...
>
> I realize that this is a very "sloppy" error report, but I am wondering if
> anyone else has encountered this type of problem (code for models working
> and then suddenly generating numbers of the same type of error) and can give
> some general pointers on how to solve this (short of ripping out all the
> recent changes)?
>
> Thanks
> Derek

-- 
You received this message because you are subscribed to the Google 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: Need HELP urgently

2011-01-12 Thread Derek
You could also consider using an AJAX-based "autocomplete" approach;
see:
http://code.djangoproject.com/wiki/AutoCompleteSolutions

On Jan 12, 7:27 am, gupta-django  wrote:
> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 20 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
>     entry = models.ForeignKey(Entry)
>     priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
>
> 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.



max recursion depth exceeded

2011-01-12 Thread vamsy krishna
Hi,

I'm trying to use Django-Cms on my site and I see the below exception
whenever I try to add a page or a group. The below stacktrace repeats
itself indefinitely.

I think this error is independent of the cms system and hence I'm
posting it here instead of the cms forum. The current recursion limit
is set to 1000. Any help would be appreciated.

RuntimeError: maximum recursion depth exceeded

File "/var/www/sites/test/django/core/urlresolvers.py", line 195, in
_get_reverse_dict
self._populate()
  File "/var/www/sites/test/django/core/urlresolvers.py", line 175, in
_populate
for name in pattern.reverse_dict:
  File "/var/www/sites/test/django/core/urlresolvers.py", line 195, in
_get_reverse_dict
self._populate()
  File "/var/www/sites/test/django/core/urlresolvers.py", line 175, in
_populate
for name in pattern.reverse_dict:

-- 
You received this message because you are subscribed to the Google 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: Inlining a reverse foreign key relationship in django admin

2011-01-12 Thread Daniel Roseman
On Thursday, January 13, 2011 12:51:35 AM UTC, Viktor Kojouharov wrote:
>
> Hi,
>
> Consider the following models:
>
> class Foo(models.Model):
>name = models.CharField(max_length=100)
>
> class Bar(models.Model):
>name = models.CharField(max_length=100)
>city = models.ForeignKey(Foo)
>
> How can I inline the admin model form for Foo into Bar, so that I can add 
> new Foo items if needed?
>

You can't, because inlines don't work that way.

However the default representation of the `city` field in the Bar admin will 
be a dropdown with a green + button which allows you to add new Foos in a 
popup.
--
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: ANN: django-widget-tweaks

2011-01-12 Thread sebastien piquemal
Sounds cool !

On Jan 12, 9:48 pm, Mikhail Korobov  wrote:
> Hi guys,
>
> Designers often want to add some css classes and html attributes to
> django form fields. But now they have to either patch the python code
> or copy-paste full html widget output and then customize it. In order
> to make them happy I just released an app 
> (https://bitbucket.org/kmike/django-widget-tweaks
> ) that makes it possible to customize html attributes and css classes
> of form fields without touching python code.
>
> Example:
>
>     {% load widget_tweaks %}
>     ...
>     {{ form.city|attr:"autocomplete:off"|add_class:"my_css_class" }}
>
> Hope somebody will find it useful.

-- 
You received this message because you are subscribed to the Google 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.