Re: Performance Issue: ForeignKey will touch database again!

2009-04-01 Thread Alex Koshelev

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

Documentation knows [1]

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

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



Performance Issue: ForeignKey will touch database again!

2009-04-01 Thread Zeal

Hi, All,

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

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

++

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

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

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

Regards,

Zeal


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



Mod_wsgi and mod_python

2009-04-01 Thread Pythoni

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



Re: Flatpages variables

2009-04-01 Thread Wiiboy

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

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



Re: Images dose not upload , unless it the admin !

2009-04-01 Thread Hamza

got it fixed it mins ago , Thanks Alex ,
( I need to slp 38 hours so far )

On Apr 2, 7:49 am, Alex Gaynor  wrote:
> On Thu, Apr 2, 2009 at 1:38 AM, Hamza  wrote:
>
> > Hello
>
> > am having a problem in uploading images , which i set ImageField to
> > upload the image to /Photo/ directory , however it works , and
> > uploaded the photos as expected , but now its not working : and
> > display a message :
> > This field is required.  ,
> > when i submit a photo in it , it repeat the message as nothing
> > submitted !!
>
> > Though as i go to the admin , i notice the submitted item there
> > without a photo , so i submit the Photo with the admin form and its
> > working perfectly !!!
>
> > i don't know exactly what is wrong , which display this error :
>
> > " Caught an exception while rendering: The  +attribute has no file
> > associated with it. "
>
> > Any help !
>
> > Regards
>
> Are you properly setting the enctype on the HTML form and passing
> request.FILES to the form object?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Images dose not upload , unless it the admin !

2009-04-01 Thread Alex Gaynor
On Thu, Apr 2, 2009 at 1:38 AM, Hamza  wrote:

>
> Hello
>
> am having a problem in uploading images , which i set ImageField to
> upload the image to /Photo/ directory , however it works , and
> uploaded the photos as expected , but now its not working : and
> display a message :
> This field is required.  ,
> when i submit a photo in it , it repeat the message as nothing
> submitted !!
>
> Though as i go to the admin , i notice the submitted item there
> without a photo , so i submit the Photo with the admin form and its
> working perfectly !!!
>
> i don't know exactly what is wrong , which display this error :
>
> " Caught an exception while rendering: The  +attribute has no file
> associated with it. "
>
> Any help !
>
> Regards
>
>
> >
>
Are you properly setting the enctype on the HTML form and passing
request.FILES to the form object?

Alex

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

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



Images dose not upload , unless it the admin !

2009-04-01 Thread Hamza

Hello

am having a problem in uploading images , which i set ImageField to
upload the image to /Photo/ directory , however it works , and
uploaded the photos as expected , but now its not working : and
display a message :
This field is required.  ,
when i submit a photo in it , it repeat the message as nothing
submitted !!

Though as i go to the admin , i notice the submitted item there
without a photo , so i submit the Photo with the admin form and its
working perfectly !!!

i don't know exactly what is wrong , which display this error :

" Caught an exception while rendering: The  +attribute has no file
associated with it. "

Any help !

Regards


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



Re: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Michael Rose Jr.

On Apr 1, 8:40 pm, Brian Neal  wrote:
> On Apr 1, 10:19 pm, "Michael Rose Jr." 
> wrote:
>
>
>
> > Brian. Thanks for responding. I mean to post "name". I've been
> > experimenting with other field types, which why I accidentally pasted
> > "last". Here is the HTML for "name".
> > Name: > type="text" name="name" maxlength="45" />
>
> > Here's the model.http://dpaste.com/22453/
> > Thanks again for your help.
>
> > Riz
>
> Oh, one more thing. How are you displaying your form in your template?
> Can you post that part of your template?
>
> BN

Hi Brian,

Here's the template:
http://dpaste.com/22457/

Here's the "view source" (Line 5)
http://dpaste.com/22458/

I am seeing this issue in the development server and in production/
Apache. I restarted both and cleared my cache in my browsers just to
be sure that wasn't the issue.

Python 2.5.2 (r252:60911, Jan  4 2009, 21:59:32)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 0, 2, 'final', 0)
>>>

Thanks,

 Riz


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



Re: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Brian Neal

On Apr 1, 10:19 pm, "Michael Rose Jr." 
wrote:
>
> Brian. Thanks for responding. I mean to post "name". I've been
> experimenting with other field types, which why I accidentally pasted
> "last". Here is the HTML for "name".
> Name: type="text" name="name" maxlength="45" />
>
> Here's the model.http://dpaste.com/22453/
> Thanks again for your help.
>
> Riz

Oh, one more thing. How are you displaying your form in your template?
Can you post that part of your template?

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



Re: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Brian Neal

On Apr 1, 10:19 pm, "Michael Rose Jr." 
wrote:
>
> Brian. Thanks for responding. I mean to post "name". I've been
> experimenting with other field types, which why I accidentally pasted
> "last". Here is the HTML for "name".
> Name: type="text" name="name" maxlength="45" />
>
> Here's the model.http://dpaste.com/22453/
> Thanks again for your help.
>
> Riz

Hmmm, I don't see anything obviously wrong. I just did something like
this myself with a model form and it worked fine for me.

What version of Django are you using? And sorry to have to ask this,
but are you using the development server? (Just ruling out that the
code is getting reloaded after you make changes.)

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



inlineformset_factory ordering

2009-04-01 Thread Paddy Joy

Is it possible to order the forms in an inlineformset_factory?

I have tried ordering the forms in the template using the following
but I still see a different order everytime I refresh the page.

{% for form in formset.initial_forms|dictsort:"id" %}


I'm on SVN 10361.

Anyone any ideas?

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



Re: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Michael Rose Jr.

On Apr 1, 6:53 pm, Brian Neal  wrote:
> On Apr 1, 8:16 pm, rizzoo  wrote:
>
> > How do I make a field hidden when using ModelForm?  I tried
> > HiddenInput but it appears to be ignored.
>
> > code:http://dpaste.com/22290/
> > Line 9
>
> > Here's what View Source shows for that line in the browners:
> > Last: > name="last" maxlength="45">
>
> Well it looks like you are trying to hide the field "name". So why are
> you showing us the HTML for the field named "last"?
>
> I just did this the other day and it worked for me.
>
> Can you post your model code too?
>
> BN

Brian. Thanks for responding. I mean to post "name". I've been
experimenting with other field types, which why I accidentally pasted
"last". Here is the HTML for "name".
Name:

Here's the model. http://dpaste.com/22453/
Thanks again for your help.

Riz

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



Re: how can I change(update) an existing avatar to a new one?

2009-04-01 Thread TTear1943

Thank you for you reply. Now I have slove the problem. But the
solution is very strange.
In fact, there is a clean function in my update form, as following:
def clean_user_avatar(self):
if not self.cleaned_data["user_avatar"]:
raise forms.ValidationError("Image Path is in none")
After I remove it, then it works. Maybe there is some problem in this
function, but I cannot figure it out.
Anyway, thanks for your reply in advance. :)

On 4月1日, 下午11时39分, Karen Tracey  wrote:
> 2009/4/1 TTear1943 <1943@gmail.com>
>
>
>
> > I seems it doesnot work when update an ImageField.
>
> Certainly ImageFields can be updated.
>
> You've omitted from the code you posted what exactly is done by the function
> user.handle_upload_user_avatar(), which is my first guess as to where the
> problem is.  If you want help solving the problem, you will need to include
> more of what your code is doing (dpaste.com is likely a better place for
> than inline in email for any large block of code) , and also it would help
> if you were very specific about the error messages, tracebacks, or whatever
> you are encountering.
>
> For example you say "the avatar cannot be uploaded to AVATAR_TEMP_DIR".  Why
> not?  What exactly happens?
>
> You also appear to be drawing conclusions from what you are seeing, when you
> state things like: "It seems that, after create the user. the
> AVATAR_TEMP_DIR set to upload_to is lost, so the program doesn't know where
> to upload the file."  I don't believe this conclusion is valid, but I'm not
> sure what you saw that made you come to that conclusion, so I'm having a
> hard time guessing what might be the real problem.
>
> Karen
>
>
>
> > On 4月1日, 下午5时37分, TTear1943 <1943@gmail.com> wrote:
> > > Hi, I encounter a problem.
> > > In my user models there is an atrrbution: user.avatar = ImageField
> > > ('avatar', upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
> > > then i use a modelform as an create user form. And the avatar is
> > > uploaded corrcet. Which upload to AVATAR_TEMP_DIR, then I move the
> > > avatar into AVATAR_ORIGINAL_PATH and make user.avatar._name as
> > > AVATAR_ORIGINAL_PATH % user.id
> > > After this, then I try to change an avatar. So I user another
> > > modelform to update. however, this time the avatar cannot be uploaded
> > > to AVATAR_TEMP_DIR, so I also cannot move the avatar to
> > > AVATAR_ORIGINAL_PATH.
> > > It seems that, after create the user. the AVATAR_TEMP_DIR set to
> > > upload_to is lost, so the program doesn't know where to upload the
> > > file.
> > > Can anyone help me to solve this problem? Thank you very much.
>
> > > class UserForm(forms.ModelForm):
> > > class Meta:
> > > model = User
> > > fields = ('name', 'user_avatar', 'description')
>
> > > class UserAvatarForm(forms.ModelForm):
> > > class Meta:
> > > model = User
> > > fields = ('user_avatar')
>
> > > @login_required
> > > def user_create(request):
> > > if request.method == 'POST':
> > > form = UserForm(request.POST, request.FILES)
> > > if form.is_valid():
> > > user = form.save(commit=False)
> > > user.save()
> > > user.handle_upload_user_avatar() # move image from
> > > AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
> > > user.save()
> > > return HttpResponseRedirect(user.url)
>
> > > else:
> > > form = UserForm()
>
> > > return render_to_response('user/user_create.html', locals())
>
> > > @login_required
> > > def settings_user_avatar(request, user_name):
> > > user = get_object_or_404(User, name=user_name)
> > > if request.method == 'POST':
> > > form = UserAvatarForm(request.POST, request.FILES,
> > > instance=user)
> > > if form.is_valid():
> > > user = form.save()
> > > user.handle_upload_user_avatar() # move image from
> > > AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
> > > user.save()
> > > return HttpResponseRedirect(user.url)
> > > else:
> > > form = UserAvatarForm(instance=user)
>
> > > return render_to_response('user/user_avatar.html', locals())
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



forming email body

2009-04-01 Thread Joey Gartin
Newbie question:

In a view I am sending out a few emails to users.  The email format is
identical for each user, with the users information being dynamic.

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

Thank you!

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



Re: widget=forms.HiddenInput doesn't work

2009-04-01 Thread Brian Neal

On Apr 1, 8:16 pm, rizzoo  wrote:
> How do I make a field hidden when using ModelForm?  I tried
> HiddenInput but it appears to be ignored.
>
> code:http://dpaste.com/22290/
> Line 9
>
> Here's what View Source shows for that line in the browners:
> Last: name="last" maxlength="45"
>

Well it looks like you are trying to hide the field "name". So why are
you showing us the HTML for the field named "last"?

I just did this the other day and it worked for me.

Can you post your model code too?

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



widget=forms.HiddenInput doesn't work

2009-04-01 Thread rizzoo

How do I make a field hidden when using ModelForm?  I tried
HiddenInput but it appears to be ignored.

code: http://dpaste.com/22290/
Line 9

Here's what View Source shows for that line in the browners:
Last:http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sync db and model

2009-04-01 Thread Russell Keith-Magee

On Thu, Apr 2, 2009 at 7:58 AM, MartinBorthiry
 wrote:
>
> Hello:
>
>  We are using django-evolution to sync our model with the db, but we
> have some issues.
>
>  Which is the best way to keep synchronized our model and db?
>
>  We want to keep the previous data into db.

You're going to need to be a little more specific here.

If you're having problems with django-evolution - what problems are
you having? Have you sought a solution on the django-evolution mailing
lists (Unless I'm mistaken, the answer to this one is no).

If you're not happy with django-evolution - Are you looking for
recommendations of other schema migration frameworks? Have you
considered http://www.lmgtfy.com/?q=django+schema+evolution ?

Yours,
Russ Magee %-)

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



Re: Fixtures for django.contrib.sites.Site

2009-04-01 Thread Russell Keith-Magee

On Thu, Apr 2, 2009 at 5:49 AM, Adam Nelson  wrote:
> How do I do a fixture for the Site model?  I've tried all sorts of different
> model names
> [
>   {
>     "model": "sites.site",
>     "pk": 1,
>     "fields": {
>       "domain": "example.com",
>       "name": "Example"
>     }
>   },
> ]
> And I get this error:
> ...
>   File
> "/Library/Python/2.5/site-packages/django/utils/simplejson/decoder.py", line
> 221, in JSONArray
>     raise ValueError(errmsg("Expecting object", s, end))
> ValueError: Expecting object: line 10 column 1 (char 124)
> Any ideas for the correct model name?  I've tried every possibility I can
> think of.

Unlike Python, JSON is very fussy about commas. In particular, Python
allows redundant commas in lists (i.e., [1,2,3,] - the comma after the
3), but JSON doesn't. The problem here is the comma on the second last
line. That comma leads SimpleJSON to believe that line 10 should start
a new element in the list, but instead, the list is ended. Hence, line
10, column 1 reports an error. Delete the comma and you'll be fine.

Yours,
Russ Magee %-)

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



Sync db and model

2009-04-01 Thread MartinBorthiry

Hello:

 We are using django-evolution to sync our model with the db, but we
have some issues.

 Which is the best way to keep synchronized our model and db?

 We want to keep the previous data into db.

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



Re: Django Developers Wanted

2009-04-01 Thread Hernan Olivera

Hi, Liam!

2009/1/24 Info Cascade :

> This will probably be of most interest to Django developers in the San
> Francisco Bay Area,
> but the company is open to hearing from anyone who might be interested.

Remote off-shore freelancers too?

regards

-- 
Hernan Olivera

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



Django Developers Wanted

2009-04-01 Thread Info Cascade

Hi, Joe,

We're looking for a Django developer, and I happened upon your profile
at DjangoGigs.
If this looks like it might be of interest, please contact me for more
information.

Best,
Liam Kirsher
415.456.4420


--

Hi --

This will probably be of most interest to Django developers in the San
Francisco Bay Area (our office is located in San Francisco), but the
company is open to hearing
from anyone who might be interested.  This is a new product already
getting great press, over 400,000 downloads, and a fun development team.

Feel free to contact me if you have any questions or would like to be
considered.

Best,
Liam



Subject: Internet Developers Wanted for Unique Mobile Application

We're looking for great developers to join our team producing a unique
mobile application for consumers.  We recently launched on the iPhone and
we're getting great traction.  Now it's time to step it up and add the right
people to help accelerate development and porting to other clients.

Our product integrates a number of next generation mobile device and web 2.0
capabilities, including geolocation, mapping, media streaming and
social-networking.  This is your opportunity to apply your skills to a
killer mobile experience unlike anything else and help take us to the next
level.

Our implementation incorporates agile, flexible, and elegant execution of
standard technologies.  While we will consider anyone with a burning desire
to code, the following knowledge/skills are a good indication of our
environment and what we desire:

* Python
* Django (and GeoDjango)
* Memcached
* POSTGRES Replication/Clustering
* Javascript Libraries like jQuery or Dojo
* Database administrator experience
* HTML, CSS, JavaScript, AJAX, XML
* Page Load Optimization
* SEO

Both client and server-side experience are preferred, but not required. If
your experience includes UI and graphic design, that's a plus. We are open
to full-time independent contractors and those looking to take on side
projects outside of their fulltime job.

We are currently looking to close on additional financing so flexibility
around near term compensation is desired.



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



Re: Fixtures for django.contrib.sites.Site

2009-04-01 Thread Paul Menzel
Am Mittwoch, den 01.04.2009, 17:49 -0400 schrieb Adam Nelson:
> How do I do a fixture for the Site model?  I've tried all sorts of
> different model names
> 
> 
> [
>   {
> "model": "sites.site",
> "pk": 1,
> "fields": {
>   "domain": "example.com",
>   "name": "Example"
> }
>   },
> ]
> 
> 
> And I get this error:
> ...
>   File
> "/Library/Python/2.5/site-packages/django/utils/simplejson/decoder.py", line 
> 221, in JSONArray
> raise ValueError(errmsg("Expecting object", s, end))
> ValueError: Expecting object: line 10 column 1 (char 124)
> 
> 
> Any ideas for the correct model name?  I've tried every possibility I
> can think of.

Is the last colon }, correct?

If that does not help, use dump the data of the database and see how the
syntax is.


Thanks,

Paul



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


Re: admin permissions i18n

2009-04-01 Thread Alex Gaynor
On Wed, Apr 1, 2009 at 6:06 PM, Killarny  wrote:

>
> I am also running across this issue. I had simply assumed that
> permission names would require ugettext_lazy to be localized, but it
> isn't working. In trying to understand this, I am left wondering why
> the permission name field is not stored in the database in such a
> fashion to allow lookup from the .po files? Isn't that how Django
> accomplishes i18n for other strings?
>
> On Feb 20, 6:27 pm, Malcolm Tredinnick 
> wrote:
> > On Fri, 2009-02-20 at 11:04 -0800, eleom wrote:
> > > Hello, does somebody know if there's a way tolocalizeadmin
> > > permission names, so that, for example, in the user change form,
> > > instead of 'Can add ' a localized version of it is showed?
> >
> > There isn't any way at the moment. Django itself does not provide any
> > localisation of database content. Maybe one day, but not today.
> >
> > Regards,
> > Malcolm
> >
>
Nope, django doesn't handle i18n for any string stored in the DB, there are
a couple of external projects that do it though.

Alex

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

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



Re: admin permissions i18n

2009-04-01 Thread Killarny

I am also running across this issue. I had simply assumed that
permission names would require ugettext_lazy to be localized, but it
isn't working. In trying to understand this, I am left wondering why
the permission name field is not stored in the database in such a
fashion to allow lookup from the .po files? Isn't that how Django
accomplishes i18n for other strings?

On Feb 20, 6:27 pm, Malcolm Tredinnick 
wrote:
> On Fri, 2009-02-20 at 11:04 -0800, eleom wrote:
> > Hello, does somebody know if there's a way tolocalizeadmin
> > permission names, so that, for example, in the user change form,
> > instead of 'Can add ' a localized version of it is showed?
>
> There isn't any way at the moment. Django itself does not provide any
> localisation of database content. Maybe one day, but not today.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Fixtures for django.contrib.sites.Site

2009-04-01 Thread Adam Nelson
How do I do a fixture for the Site model?  I've tried all sorts of different
model names
[
  {
"model": "sites.site",
"pk": 1,
"fields": {
  "domain": "example.com",
  "name": "Example"
}
  },
]

And I get this error:
...
  File
"/Library/Python/2.5/site-packages/django/utils/simplejson/decoder.py", line
221, in JSONArray
raise ValueError(errmsg("Expecting object", s, end))
ValueError: Expecting object: line 10 column 1 (char 124)

Any ideas for the correct model name?  I've tried every possibility I can
think of.

Regards,
Adam
-- 
Adam Nelson

http://unhub.com/varud

--~--~-~--~~~---~--~~
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: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Miguel
Hi Karen,
i didn't want to bother you too much (because of that I dindnt send too much
code).

I think these model are bad implemented. I have put the raw_id_admin
parameter to true but the point is that I have too many queries:

>>> len(connection.queries)
53


and some of them, all that goes to sportsound_plantilla_metodo_embebido, are
really slow (around 1.7 seconds):

{'time': '1.788', 'sql': u'SELECT
`sportsound_plantilla_metodo_embebido`.`id`,`sportsound_plantilla_metodo_embebido`.`orden`,`sportsound_plantilla_metodo_embebido`.`ejercicio_id`,`sportsound_plantilla_metodo_embebido`.`numero_repeticiones`,`sportsound_plantilla_metodo_embebido`.`repeticiones_maximas`,`sportsound_plantilla_metodo_embebido`.`hasta_extenuacion`,`sportsound_plantilla_metodo_embebido`.`distancia`,`sportsound_plantilla_metodo_embebido`.`tiempo_ejecucion_m`,`sportsound_plantilla_metodo_embebido`.`tiempo_ejecucion_sg`,`sportsound_plantilla_metodo_embebido`.`altura`,`sportsound_plantilla_metodo_embebido`.`velocidad_excentrica`,`sportsound_plantilla_metodo_embebido`.`velocidad_concentrica`,`sportsound_plantilla_metodo_embebido`.`tipo_contraccion`,`sportsound_plantilla_metodo_embebido`.`ritmo_carrera`,`sportsound_plantilla_metodo_embebido`.`unidad_ritmo_carrera`,`sportsound_plantilla_metodo_embebido`.`frecuencia_cardiaca`,`sportsound_plantilla_metodo_embebido`.`frecuencia_cardiaca_1m`,`sportsound_plantilla_metodo_embebido`.`frecuencia_cardiaca_3m`,`sportsound_plantilla_metodo_embebido`.`porcentaje_carga`,`sportsound_plantilla_metodo_embebido`.`intensidad_subjetiva`,`sportsound_plantilla_metodo_embebido`.`peso`,`sportsound_plantilla_metodo_embebido`.`evaluar_numero_repeticiones`,`sportsound_plantilla_metodo_embebido`.`evaluar_distancia`,`sportsound_plantilla_metodo_embebido`.`evaluar_tiempo_ejecucion`,`sportsound_plantilla_metodo_embebido`.`evaluar_altura`,`sportsound_plantilla_metodo_embebido`.`evaluar_peso`,`sportsound_plantilla_metodo_embebido`.`evaluar_ritmo_carrera`,`sportsound_plantilla_metodo_embebido`.`evaluar_frecuencia_cardiaca`,`sportsound_plantilla_metodo_embebido`.`evaluar_frecuencia_cardiaca_1m`,`sportsound_plantilla_metodo_embebido`.`evaluar_frecuencia_cardiaca_3m`,`sportsound_plantilla_metodo_embebido`.`evaluar_intensidad`
FROM `sportsound_plantilla_metodo_embebido`'}

Actually these queries select all the parameters, that doesnt make any sense
( maybe is  the behaviour of manytomanyfield)


Thank you very much karen for your patient and support.

tomorrow it will be a better day :)

Miguel
Sent from Madrid, Spain

On Wed, Apr 1, 2009 at 8:33 PM, Karen Tracey  wrote:

> On Wed, Apr 1, 2009 at 1:35 PM, Miguel  wrote:
>
>> sorry karen. I have tried both. First I put in teh forma_parte_de foreing
>> key field but it has no discernible effect on performance. I even execute it
>> via python console and you can see clearly that it takes long time to
>> response.
>>
>> Then I tried to put the raw parameter in the many to many fields but I
>> observe no effect .
>>
>> Maybe, the more of 10 entries of Plantilla_metodo_embebido are the
>> responsible of the long time ...
>>
>
> Well you still haven't shared much beyond little snippets of the model
> involved here so it's getting a little hard to know what else to suggest.
> The number of rows in the related table doesn't matter if you specify
> raw_id_admin=True.  Consider this model from my own app:
>
> class Clues(models.Model):
> ID = models.AutoField(primary_key=True)
> Theme = models.CharField(maxlength=3, choices=YESNO_CHOICES,
> verbose_name='Theme?', core=True)
> EntryID = models.ForeignKey(Entries, verbose_name='Entry', db_column =
> 'Entry ID', edit_inline=models.TABULAR, num_in_admin=3, core=True,
> raw_id_admin=True)
> PuzzleID = models.ForeignKey(Puzzles, verbose_name='Puzzle', db_column
> = 'Puzzle ID', edit_inline=models.TABULAR, num_in_admin=3,
> raw_id_admin=True)
> Clue = models.CharField(maxlength=150, core=True)
> Num = models.IntegerField(null=True, blank=True, core=True)
> Dir = models.CharField(maxlength=1, core=True)
> Derived = models.BooleanField()
> [remainder deleted]
>
> If I remove the raw_id_admin=True from the EntryID (table with approx.
> 130,000 rows) and PuzzleID (table with approx. 10,000 rows) fields and try
> to create a ChangeManipulator for this model (which itself has approx.
> 830,000 rows in the DB) from a shell, it takes about 30 seconds.  If I have
> DEBUG set to True I can use django.db.connection.queries to see where much
> of that time is coming from:
>
> Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from crossword.models import Clues
> >>> from django.db import connection
> >>> x = Clues.ChangeManipulator(2432)
> >>> len(connection.queries)
> 3
> >>> connection.queries[0]
> {'time': '0.000', 'sql': 'SELECT
> `Clues`.`ID`,`Clues`.`Theme`,`Clues`.`Ent

Logging out a user when his account is made inactive

2009-04-01 Thread christian.oudard

I have made a page for admins to set a user account to inactive, but I
noticed that the user's session continues if he is logged in. It
appears that the is_active field is only checked when the user logs
in, not when each request is authenticated. Is there an easy way to
log a user out when his account is made inactive? Also, should the
auth system check is_active on every authenticated request, and should
this be considered a bug in the auth app?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inheriting attributes from a model

2009-04-01 Thread Rajesh D



On Apr 1, 3:42 pm, Denis  wrote:
> Now I've got serialization to json working thanks to your advice.
> I still have problems with converting the data back into an object,
> but I don't have time to look into that now. It'll have to wait
> tomorrow.

http://docs.djangoproject.com/en/dev/topics/serialization/

-Rajesh D

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



Re: Comments custom form made easier to add captcha

2009-04-01 Thread Michel Thadeu Sabchuk

Hi,

> You don't say what version of Django you are using. This sounds like you
> want exactly the kind of customization described here:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/

Yes, I already following it, but with 1.0.2 django version :)

> That page doesn't exist in the 1.0 docs so I'm guessing it's new in 1.1 (I
> haven't actually used comments myself at all, nor followed in detail what's
> been added lately).  So -- are you using 1.0.x?  In which case you might
> want to try 1.1 beta to get this added customization ability.

I try it and all worked well!

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
-~--~~~~--~~--~--~---



Problem saving dynamically added form in formset

2009-04-01 Thread Brandon Taylor

Hi everyone,

I'm using an inline formset on a model. I have some jQuery that adds
an additional form to the page, and augments the TOTAL_FORMS parameter
by 1.

The problem is that the dynamically added form is not present in the
collection of forms when I save the formset. All of the name and ID
parameters follow the pattern established by the formset factory for
the inputs, but if I iterate over the instances in the formset, those
dynamically added forms are nowhere to be found.

Does anyone have any ideas on what could be wrong? I have verified the
number of TOTAL_FORMS in the management form matches the number of
forms present after adding the new form, but I'm not sure what else to
check.

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



Re: Search on concatenated fields of qset

2009-04-01 Thread Tim Chase

> My model has firstname and lastname as separate fields.  In a search
> box if a person types in one name say "Bunny" then based on the
> following query they will find Bunny:
> 
> qset = (
> Q(firstname__icontains=query) |
> Q(lastname__icontains=query)  |
> )
> 
> If a person types in "Bunny Foo" to find first and last name they
> won't find anything using the above query.  How can I concatenate
> firstname || lastname to make contactname and use it in the qset?

The typical way to do this is to split the search-string into 
words on which you want to search.  You also have to decide 
whether you want to require that both terms match (AND) or a 
match can be found either way (OR):

   search = "Bunny Foo"
   terms = search.split()
   # terms = re.findall(r'\w+', search)

   qset = Q()
   for term in terms:
 qset_inner = Q()
 for (field_to_search, how) in (
 ('firstname', 'icontains'),
 ('lastname', 'icontains'),
 ):
   name = "%s__%s" % (field_to_search, how)
   qset_inner |= Q(**{name: term})
 qset &= qset_inner  # AND them together
 #qset |= qset_inner # OR them together

-tim






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



Re: Wrong link to uploaded file in admin...

2009-04-01 Thread Dan Jewett



On Apr 1, 3:12 pm, Karen Tracey  wrote:
> On Wed, Apr 1, 2009 at 2:52 PM, Dan Jewett  wrote:
>
> > I'm using the following settings:
>
> > MEDIA_ROOT = '/Users/dan/projects/some_project/files/'
>
> > # static files
> >        (r'^files/(?P.*)$', 'django.views.static.serve',
> > {'document_root': '/Users/dan/projects/some_project/files'}),
>
> > In an app called 'collaborate' I have a model that looks like this:
> > class Resource(models.Model):
> >    topic = models.ForeignKey('Topic')
> >    name = models.CharField(max_length=150)
> >    description = models.CharField(blank=True, max_length=250)
> >    resource_file = models.FileField(upload_to='resource_files')
>
> > The file uploads properly but the link to it in the admin looks like
> > this:
> >http://localhost:8000/admin/collaborate/resource/1/resource_files/rhi...
>
> > But this is where it lives:
> >http://localhost:8000/files/resource_files/rhino.png
>
> > Is this only an issue in development with serving static files? If
> > not, do I have a settings error?
>
> You need to set MEDIA_URL 
> (http://docs.djangoproject.com/en/dev/ref/settings/#media-url) to match the
> url prefix you've chosen for serving up your uploaded files.  That is:
>
> MEDIA_URL = '/files/'
>
> in your case.
> .
> Karen

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



Re: FileField cannot save file with chinese filenames.

2009-04-01 Thread 夏恺

Karen Tracey 写道:
> On Wed, Apr 1, 2009 at 5:12 AM, 夏恺  > wrote:
>
>
> Hi all!
>
> I wrote a model to hold files uploaded by users, it goes like this:
>
>
> This is ticket #10254: http://code.djangoproject.com/ticket/10254
>
> It has a patch you can try.  I'm waiting on feedback as to whether 
> there is good reason to maintain the very restrictive set of allowed 
> characters in file names before checking that patch in.  I don't see 
> the reason for it, but it is code that has been in Django since 
> forever so there may be some reason for it that I don't understand.
>
> Karen
>
Thanks Karen!

Yeah, I cannot understand why they will substitute all those character 
out there too. Anyway, I removed that line from get_valid_filename in 
django/utils/text.py and my app is happily running now. However, I got 
that hack from this ticket:

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

which, I believe, is more instructive.

Thank you again for your help!


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



Search on concatenated fields of qset

2009-04-01 Thread Jesse

My model has firstname and lastname as separate fields.  In a search
box if a person types in one name say "Bunny" then based on the
following query they will find Bunny:

qset = (
Q(firstname__icontains=query) |
Q(lastname__icontains=query)  |
)

If a person types in "Bunny Foo" to find first and last name they
won't find anything using the above query.  How can I concatenate
firstname || lastname to make contactname and use it in the qset?
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inheriting attributes from a model

2009-04-01 Thread Denis

Now I've got serialization to json working thanks to your advice.
I still have problems with converting the data back into an object,
but I don't have time to look into that now. It'll have to wait
tomorrow.

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



Re: Comments custom form made easier to add captcha

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 3:05 PM, Michel Thadeu Sabchuk wrote:

> I created a custom comments app to make use of captcha. I didn't
> change the mode, I just change the form to make use of django-simple-
> captcha [1].
>
> To make all magic works I need to do some hacks in django comments
> framework. I want to use the existing views, I don't want to write it
> myself, the problem is that the views refer to the form and the model
> as:
>
># Construct the comment form
>form = [django.contrib.]comments.get_form()(target, data=data)
>
> Even with all settings configured and following the django docs, I can
> find a way to make the views use COMMENTS_APP.get_form() reather than
> comments.get_form(), so I did the hack:
>
># Construct the comment form
>module = comments.get_comment_app()
>form = module.get_form()(target, data=data)
>
> This way, all the things work like a charm, the form used to validate
> the comments is my form and not comments form.
>
> Am I missing something? Is there a correct way to do what I want?
>

You don't say what version of Django you are using. This sounds like you
want exactly the kind of customization described here:

http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/

specifically here:

http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#django.contrib.comments.get_form

That page doesn't exist in the 1.0 docs so I'm guessing it's new in 1.1 (I
haven't actually used comments myself at all, nor followed in detail what's
been added lately).  So -- are you using 1.0.x?  In which case you might
want to try 1.1 beta to get this added customization ability.

Karen

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



Re: Comments custom form made easier to add captcha

2009-04-01 Thread Michel Thadeu Sabchuk

I found a better way to hack :)

In the django.contrib.comments.__init__ file, I changed the get_model,
get_form and get_form_target method to something like:

def get_form():
if get_comment_app_name() != __name__ and hasattr(get_comment_app
(), "get_form"):
return get_comment_app().get_form()
else:
from django.contrib.comments.forms import CommentForm
return CommentForm

This is used to define the get_xxx_url functions, I use the same idea.

I still looking for a solution without the hack. If there is no way, I
can propose my solution on the delepers list ;)

By the way, I using django1.0.2...

Thanks

--
Michel Sabchuk
--~--~-~--~~~---~--~~
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: Wrong link to uploaded file in admin...

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 2:52 PM, Dan Jewett  wrote:

>
> I'm using the following settings:
>
> MEDIA_ROOT = '/Users/dan/projects/some_project/files/'
>
> # static files
>(r'^files/(?P.*)$', 'django.views.static.serve',
> {'document_root': '/Users/dan/projects/some_project/files'}),
>
> In an app called 'collaborate' I have a model that looks like this:
> class Resource(models.Model):
>topic = models.ForeignKey('Topic')
>name = models.CharField(max_length=150)
>description = models.CharField(blank=True, max_length=250)
>resource_file = models.FileField(upload_to='resource_files')
>
> The file uploads properly but the link to it in the admin looks like
> this:
> http://localhost:8000/admin/collaborate/resource/1/resource_files/rhino.png
>
> But this is where it lives:
> http://localhost:8000/files/resource_files/rhino.png
>
> Is this only an issue in development with serving static files? If
> not, do I have a settings error?


You need to set MEDIA_URL (
http://docs.djangoproject.com/en/dev/ref/settings/#media-url) to match the
url prefix you've chosen for serving up your uploaded files.  That is:

MEDIA_URL = '/files/'

in your case.

Karen

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



Re: Sessions living through HttpResponseRedirect

2009-04-01 Thread Joshua K

Daniel, thanks for the note - I found out that it does work as I
expected.

Bro, thanks for the hint - but in this case a 'client' is not the same
person who is logged in.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Comments custom form made easier to add captcha

2009-04-01 Thread Michel Thadeu Sabchuk

Hi Guys,

I created a custom comments app to make use of captcha. I didn't
change the mode, I just change the form to make use of django-simple-
captcha [1].

To make all magic works I need to do some hacks in django comments
framework. I want to use the existing views, I don't want to write it
myself, the problem is that the views refer to the form and the model
as:

# Construct the comment form
form = [django.contrib.]comments.get_form()(target, data=data)

Even with all settings configured and following the django docs, I can
find a way to make the views use COMMENTS_APP.get_form() reather than
comments.get_form(), so I did the hack:

# Construct the comment form
module = comments.get_comment_app()
form = module.get_form()(target, data=data)

This way, all the things work like a charm, the form used to validate
the comments is my form and not comments form.

Am I missing something? Is there a correct way to do what I want?

Thanks for any help!

[1] http://code.google.com/p/django-simple-captcha/

--
Michel Sabchuk
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Choicefield - Dynamic update

2009-04-01 Thread AsiSoudai

Good morning,

I'm new to django, and in need for a little pointers:

I've a bunch of Choicefields that I want to update ( similar to
Country-city-street, type of behavior ).

How would I go about updating those fileds, without reloading the
page?
Javascript? Ajax? or django have a way to update only given form/
objects:

Here's the code I've so far, it works by reloading the entire page.

** just to make sense: *pipeline is the frontend DataBase handler.

# THE VIEW 
def index( request ):

if request.method == 'POST': # If the form has been submitted...

assetMgr = AssetManager( request.POST )
assetMgr.update( request.POST )

else:
assetMgr = AssetManager()

return render_to_response('inventory/templateSeq.html', {'asset':
assetMgr,
  'post': 
request.POST})


# THE FORM ###

class AssetManager( forms.Form ):

## Get productions
listProd  = [ ( x ,x ) for x in pipeline.productions() ]

## Create fields and onchange calls.
project   = forms.ChoiceField( choices = listProd, label='',
initial=None )
project.widget.attrs["onchange"]="this.form.submit()"

type  = forms.ChoiceField( required=False, label='',
initial=None )
type.widget.attrs["onchange"]="this.form.submit()"



def update( self, POST ):
   """ Update Project & Type fields """

proj = pipeline.getChildren( POST.get('project') )
self.fields['type'].choices = [ ( str(x.name), str(x.name) ) 
for x
in proj.children ]

if POST.get('type'):

path = "/%s/%s"%( POST.get('project'), POST.get('type') 
)
children = pipeline.getChildren(path)
self.fields[ 'type' ].choices = [ ( x, x ) for x in
children ]



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Wrong link to uploaded file in admin...

2009-04-01 Thread Dan Jewett

I'm using the following settings:

MEDIA_ROOT = '/Users/dan/projects/some_project/files/'

# static files
(r'^files/(?P.*)$', 'django.views.static.serve',
{'document_root': '/Users/dan/projects/some_project/files'}),

In an app called 'collaborate' I have a model that looks like this:
class Resource(models.Model):
topic = models.ForeignKey('Topic')
name = models.CharField(max_length=150)
description = models.CharField(blank=True, max_length=250)
resource_file = models.FileField(upload_to='resource_files')

The file uploads properly but the link to it in the admin looks like
this:
http://localhost:8000/admin/collaborate/resource/1/resource_files/rhino.png

But this is where it lives:
http://localhost:8000/files/resource_files/rhino.png

Is this only an issue in development with serving static files? If
not, do I have a settings error?
--~--~-~--~~~---~--~~
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: Using _default_manager in a model causes many idle MySQL connections. (Django 1.0)

2009-04-01 Thread Guillaume Carbonneau

I too am interested in seeing this patch. I'm getting lots of idle
connections in postgres

On Mar 31, 5:26 am, J  wrote:
> Hello Michael,
>
> Would you share your temp patch here?
>
> TIA,
>
> J
>
> On Mar 20, 12:52 am, MikeL  wrote:
>
> > I wasn't sure where this stuff was being tracked, but I did find a
> > circular reference in the database wrapper. The DatabaseCreation and
> > DatabaseIntrospection objects being created in the MySQL wrapper where
> > passing references of itself, but there wasn't a per-defined method
> > for removing those references.
>
> > Should BaseDatabaseIntrospection and BaseDatabaseCreation be holding a
> > weakref of the database wrapper instead?
> > Or is there some connection pooling system that needs to be aware of
> > the Mulit-db stuff?
> > Does any of this seem sane?
>
> > My _hack_ (temp and not perfect I know) involved a class wrapping
> > around QuerySet and monitoring the clone counts (split per wrapper
> > instance) so when the final QuerySet was deleted it would clear the
> > two references allowing the database wrapper to be garbage collected.
>
> > TIA,
>
> > Michael LaRue
>
> > On Mar 19, 2:10 pm, Alex Gaynor  wrote:
>
> > > On Thu, Mar 19, 2009 at 5:06 PM, MikeL  wrote:
>
> > > > I'm using the code from:
>
> > > >http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/
>
> > > > After repeated use, there can be over a hundred idling connection to
> > > > MySQL for both production and development builds. Removing the
> > > > Multiple DB in the model causes the symptoms to stop.
>
> > > > I've been trying to track down where the circular reference (if it's
> > > > that) is causing the connections to not be closed/deleted without much
> > > > luck. Is this use of _default_manager just plain flawed? If not, does
> > > > anyone know if there is a working fix?
>
> > > > TIA,
>
> > > > Michael LaRue
>
> > > It's not a default manager issue, the issue is by default django closes 
> > > the
> > > connection at the end of the request, but it only tracks the default
> > > connection, so your cusotm multidb support isn't tracked.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right 
> > > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
>

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



non-existent models.py treatment

2009-04-01 Thread Leo

I ran into a situation recently where I was trying to do syncdb on a
project that included an application with initial_data but no
models.py. The syncdb failed silently and it took me a little while to
understand what was going on.

Is it an explicit design decision to fail on encountering no models.py
in a project rather than treating it as an empty 'models.py'?

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



Re: Trac + Sphinx

2009-04-01 Thread Fábio Costa
Sorry, what he meant to ask is if the Django project use any kind of
integration within trac and sphinx, like some kind of plugin.
Sorry for bothering again, but i don't know anywhere else to get this kind
of information.
Thanks in advance.


Fábio Miranda Costa
Engenheiro de Computação
http://meiocodigo.com


On Tue, Mar 31, 2009 at 8:47 PM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Tue, 2009-03-31 at 17:34 -0300, Vinicius Mendes wrote:
> > Hi all,
> >
> > Does anyone here integrate trac and sphinx? How do you take advantages
> > from this?
>
> Can we keep this list on-topic for Django, please? Yes, we're a helpful
> group, but it's busy enough without random questions about other Python
> applications as well.
>
> Thanks,
> Malcolm
>
>
>
> >
>

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



Re: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 1:35 PM, Miguel  wrote:

> sorry karen. I have tried both. First I put in teh forma_parte_de foreing
> key field but it has no discernible effect on performance. I even execute it
> via python console and you can see clearly that it takes long time to
> response.
>
> Then I tried to put the raw parameter in the many to many fields but I
> observe no effect .
>
> Maybe, the more of 10 entries of Plantilla_metodo_embebido are the
> responsible of the long time ...
>

Well you still haven't shared much beyond little snippets of the model
involved here so it's getting a little hard to know what else to suggest.
The number of rows in the related table doesn't matter if you specify
raw_id_admin=True.  Consider this model from my own app:

class Clues(models.Model):
ID = models.AutoField(primary_key=True)
Theme = models.CharField(maxlength=3, choices=YESNO_CHOICES,
verbose_name='Theme?', core=True)
EntryID = models.ForeignKey(Entries, verbose_name='Entry', db_column =
'Entry ID', edit_inline=models.TABULAR, num_in_admin=3, core=True,
raw_id_admin=True)
PuzzleID = models.ForeignKey(Puzzles, verbose_name='Puzzle', db_column =
'Puzzle ID', edit_inline=models.TABULAR, num_in_admin=3, raw_id_admin=True)
Clue = models.CharField(maxlength=150, core=True)
Num = models.IntegerField(null=True, blank=True, core=True)
Dir = models.CharField(maxlength=1, core=True)
Derived = models.BooleanField()
[remainder deleted]

If I remove the raw_id_admin=True from the EntryID (table with approx.
130,000 rows) and PuzzleID (table with approx. 10,000 rows) fields and try
to create a ChangeManipulator for this model (which itself has approx.
830,000 rows in the DB) from a shell, it takes about 30 seconds.  If I have
DEBUG set to True I can use django.db.connection.queries to see where much
of that time is coming from:

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from crossword.models import Clues
>>> from django.db import connection
>>> x = Clues.ChangeManipulator(2432)
>>> len(connection.queries)
3
>>> connection.queries[0]
{'time': '0.000', 'sql': 'SELECT `Clues`.`ID`,`Clues`.`Theme`,`Clues`.`Entry
ID`,`Clues`.`Puzzle
ID`,`Clues`.`Clue`,`Clues`.`Num`,`Clues`.`Dir`,`Clues`.`Derived` FROM
`Clues` WHERE (`Clues`.`ID` = 2432)'}
>>> connection.queries[1]
{'time': '13.560', 'sql': 'SELECT `Entries`.`Entry
ID`,`Entries`.`Entry`,`Entries`.`Exclude` FROM `Entries` ORDER BY
`Entries`.`Entry` ASC'}
>>> connection.queries[2]
{'time': '0.901', 'sql': 'SELECT `Puzzles`.`Puzzle ID`, [remainder deleted
for readability]}
>>> quit()

So the unrestricted query on the >130,000 row Entries table needed to
contruct the drop down list for the select box for the EntryID field takes
nearly 14 seconds all by itself (this is not my actual production DB, it's
an old test copy on an old Windows box, perfect for exacerbating performance
issues).  The corresponding query for the Puzzles table (an order of
magnitude smaller) only takes nearly a second.  Apparently the processing
required to massage those results into the proper format within the
ChangeManipulator means the actual time to create the change manipulator is
about double the time required for the queries.

If I restore the raw_id_admin=True for both those fields, creating the
change manipulator becomes nearly instantaneous, as those expensive queries
are no longer needed:

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from crossword.models import Clues
>>> from django.db import connection
>>> x = Clues.ChangeManipulator(8232)
>>> len(connection.queries)
1
>>> connection.queries[0]
{'time': '0.051', 'sql': 'SELECT `Clues`.`ID`,`Clues`.`Theme`,`Clues`.`Entry
ID`,`Clues`.`Puzzle
ID`,`Clues`.`Clue`,`Clues`.`Num`,`Clues`.`Dir`,`Clues`.`Derived` FROM
`Clues` WHERE (`Clues`.`ID` = 8232)'}
>>>

Perhaps you could look at what queries are being generated in your case --
that might give you a clue where the time is being spent in your case.

Karen

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



Re: Can I use Components and Classes in Django for views/controllers?

2009-04-01 Thread Ariel Mauricio Nunez Gomez
Yes, Class Based Views are nice, here is a fresh blog post about it:
http://www.screeley.com/entries/2009/apr/01/class-based-views-and-reusable-apps/

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Setting default values for model options?

2009-04-01 Thread jeremias.kangas

Hello,

I noticed that default value when adding a field for a model is
null=False. This default option is not very good for me, because for
almost every field needs to be null in my application. Is there a way
to change these default values for options?

- Jeremias
--~--~-~--~~~---~--~~
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: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Adam Stein

I wound up doing it that way as well except I used the model name rather
than the ID:

data_type = models.ForeignKey(ContentType,
limit_choices_to = {"model__in": ("model1", "model2")},
)

On Wed, 2009-04-01 at 10:34 -0700, Lee wrote:
> Actually I tried to do as I suggested and I couldn't get it to
> work...  I ended up using the following:
> 
> from MyProject.MyApp.models import MyModel
> 
> CONTENT_TYPE_CHOICES = (ContentType.objects.get_for_model
> (MyModel).id,)
> 
> class My_Other_Model(models.Model):
> content_type = models.ForeignKey(ContentType, limit_choices_to=
> {'id__in': CONTENT_TYPE_CHOICES})
> 
> 
> On Apr 1, 11:48 am, Lee  wrote:
> > You're close...
> >
> > change your method in CHOICES to get_for_model( _model_ )
> >
> > So it should be
> > CHOICES = (
> > (ContentType.objects.get_for_model(My_Model), "Model 1"),
> > (ContentType.objects.get_for_model(My_Other_Model), "Model
> > 2"),
> > )
> >
> > Obviously, make sure you import your model before you try to use it.
> >
> > On Mar 23, 3:26 pm, Adam Stein  wrote:
> >
> > > Trying to create a generic FK using ContentType.  In admin, the menu
> > > lists all the models.  Since I only ever need to select 1 of 2 different
> > > models, anyway to limit the choice?
> >
> > > Setting the choices attribute as Django complains
> >
> > > must be a "ContentType" instance
> >
> > > ContentType.objects.get() returns an instance of a particular model, not
> > > ContentType (as one would expect), so I'm not sure how to create an
> > > instance with the particulars I need to point to something specific in
> > > the choices list.  Here's what I have:
> >
> > > from django.db import models
> > > from django.contrib.contenttypes.models import ContentType
> > > from django.contrib.contenttypes import generic
> >
> > > class GenericFKExample(models.Model):
> > > CHOICES = (
> > > (ContentType.objects.get(model="model1"), "Model 1"),
> > > (ContentType.objects.get(model="model2"), "Model 2"),
> > > )
> >
> > > content_type = models.ForeignKey(ContentType,
> > > choices = CHOICES,
> > > null = True,
> > > )
> >
> > > object_id = models.PositiveIntegerField(
> > > null = True,
> > > )
> >
> > > content_object = generic.GenericForeignKey(
> > > "content_type", "object_id"
> > > )
> >
> > > Obviously, if I don't use choices, it works but then I have a very long
> > > list of model choices.
> >
> > > --
> > > Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com
> >
> > > Disclaimer: Any/All views expressed
> > > here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
> -- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


--~--~-~--~~~---~--~~
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: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Miguel
sorry karen. I have tried both. First I put in teh forma_parte_de foreing
key field but it has no discernible effect on performance. I even execute it
via python console and you can see clearly that it takes long time to
response.

Then I tried to put the raw parameter in the many to many fields but I
observe no effect .

Maybe, the more of 10 entries of Plantilla_metodo_embebido are the
responsible of the long time ...




Miguel
Sent from Madrid, Spain

On Wed, Apr 1, 2009 at 7:16 PM, Karen Tracey  wrote:

> On Wed, Apr 1, 2009 at 1:03 PM, Miguel  wrote:
>
>> umm, raw_id_admin takes no effect. I think I have found the problem. As
>> you said it may be in the model:
>>
>> Pattern_method model has this entry definition:
>>
>> metodos_embebidos =
>> models.ManyToManyField('Plantilla_metodo_embebido',blank=True,null=True)
>>
>> and Plantilla_metodo_embebido has more than 100 000 entries.
>>
>> Could be this the reason to take so much time? I try to use the raw_id but
>> no time is saved
>
>
> In the previous note you were considering putting raw_id_admin on the
> forma_parte_de ForeignKey field, that defined a relation to
> 'Plantilla_bloque'.  It isn't clear from what you have written here if you
> tried only that and it has no discernible effect on performance, or if you
> also tried specifying raw_id_admin=True on this ManyToManyField?
>
> Karen
>
> >
>

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



Re: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Lee

Actually I tried to do as I suggested and I couldn't get it to
work...  I ended up using the following:

from MyProject.MyApp.models import MyModel

CONTENT_TYPE_CHOICES = (ContentType.objects.get_for_model
(MyModel).id,)

class My_Other_Model(models.Model):
content_type = models.ForeignKey(ContentType, limit_choices_to=
{'id__in': CONTENT_TYPE_CHOICES})


On Apr 1, 11:48 am, Lee  wrote:
> You're close...
>
> change your method in CHOICES to get_for_model( _model_ )
>
> So it should be
> CHOICES = (
>         (ContentType.objects.get_for_model(My_Model), "Model 1"),
>         (ContentType.objects.get_for_model(My_Other_Model), "Model
> 2"),
>     )
>
> Obviously, make sure you import your model before you try to use it.
>
> On Mar 23, 3:26 pm, Adam Stein  wrote:
>
> > Trying to create a generic FK using ContentType.  In admin, the menu
> > lists all the models.  Since I only ever need to select 1 of 2 different
> > models, anyway to limit the choice?
>
> > Setting the choices attribute as Django complains
>
> >         must be a "ContentType" instance
>
> > ContentType.objects.get() returns an instance of a particular model, not
> > ContentType (as one would expect), so I'm not sure how to create an
> > instance with the particulars I need to point to something specific in
> > the choices list.  Here's what I have:
>
> > from django.db import models
> > from django.contrib.contenttypes.models import ContentType
> > from django.contrib.contenttypes import generic
>
> > class GenericFKExample(models.Model):
> >     CHOICES = (
> >         (ContentType.objects.get(model="model1"), "Model 1"),
> >         (ContentType.objects.get(model="model2"), "Model 2"),
> >     )
>
> >     content_type = models.ForeignKey(ContentType,
> >         choices = CHOICES,
> >         null = True,
> >     )
>
> >     object_id = models.PositiveIntegerField(
> >         null = True,
> >     )
>
> >     content_object = generic.GenericForeignKey(
> >         "content_type", "object_id"
> >     )
>
> > Obviously, if I don't use choices, it works but then I have a very long
> > list of model choices.
>
> > --
> > Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> > Disclaimer: Any/All views expressed
> > here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
--~--~-~--~~~---~--~~
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: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Adam Stein

Thanks for the info.  I also ran across 'limit_choices_to' which also
works.

On Wed, 2009-04-01 at 08:48 -0700, Lee wrote:
> You're close...
> 
> change your method in CHOICES to get_for_model( _model_ )
> 
> So it should be
> CHOICES = (
> (ContentType.objects.get_for_model(My_Model), "Model 1"),
> (ContentType.objects.get_for_model(My_Other_Model), "Model
> 2"),
> )
> 
> Obviously, make sure you import your model before you try to use it.
> 
> On Mar 23, 3:26 pm, Adam Stein  wrote:
> > Trying to create a generic FK using ContentType.  In admin, the menu
> > lists all the models.  Since I only ever need to select 1 of 2 different
> > models, anyway to limit the choice?
> >
> > Setting the choices attribute as Django complains
> >
> > must be a "ContentType" instance
> >
> > ContentType.objects.get() returns an instance of a particular model, not
> > ContentType (as one would expect), so I'm not sure how to create an
> > instance with the particulars I need to point to something specific in
> > the choices list.  Here's what I have:
> >
> > from django.db import models
> > from django.contrib.contenttypes.models import ContentType
> > from django.contrib.contenttypes import generic
> >
> > class GenericFKExample(models.Model):
> > CHOICES = (
> > (ContentType.objects.get(model="model1"), "Model 1"),
> > (ContentType.objects.get(model="model2"), "Model 2"),
> > )
> >
> > content_type = models.ForeignKey(ContentType,
> > choices = CHOICES,
> > null = True,
> > )
> >
> > object_id = models.PositiveIntegerField(
> > null = True,
> > )
> >
> > content_object = generic.GenericForeignKey(
> > "content_type", "object_id"
> > )
> >
> > Obviously, if I don't use choices, it works but then I have a very long
> > list of model choices.
> >
> > --
> > Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com
> >
> > Disclaimer: Any/All views expressed
> > here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]
> 
> -- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


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



Re: problem customizing comments app

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 1:04 PM, laird18  wrote:

>
> Hello all,
>
> I'm trying to follow the "example custom comments app" exercise as
> documented here:
>
> http://docs.findjango.com/ref/contrib/comments/custom.html#ref-contrib-comments-custom
>
> It looks simple enough but I've hit a complete dead end with it, and I
> don't have any idea how to debug the problem!  Basically the comments
> form isn't changing as it should.  I have noticed that when I copy the
> methods in to __init__.py and try to run syncdb I'm getting an error
> message.  So maybe the problem lies there?
>

Certainly sounds like it could be the problem.  But since you don't say what
the error message is, exactly, I don't see how anyone will be able to help
other than to say you need to fix whatever is causing the error message.  If
you want help with that, you'll need to share the error message with us.

Karen

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



Re: how to django to request a page of the other domain

2009-04-01 Thread Doug B

It might be better to use the rewrite/proxy capability of your
webserver rather than try to proxy using django.  If you do end up
trying to do it in python, I found pycurl to be much easier to deal
with for any requests requiring cookies, authentication, or anything
besides a simple url get despite being it being advertised as having a
'somewhat steep learning curve'.
--~--~-~--~~~---~--~~
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: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 1:03 PM, Miguel  wrote:

> umm, raw_id_admin takes no effect. I think I have found the problem. As you
> said it may be in the model:
>
> Pattern_method model has this entry definition:
>
> metodos_embebidos =
> models.ManyToManyField('Plantilla_metodo_embebido',blank=True,null=True)
>
> and Plantilla_metodo_embebido has more than 100 000 entries.
>
> Could be this the reason to take so much time? I try to use the raw_id but
> no time is saved


In the previous note you were considering putting raw_id_admin on the
forma_parte_de ForeignKey field, that defined a relation to
'Plantilla_bloque'.  It isn't clear from what you have written here if you
tried only that and it has no discernible effect on performance, or if you
also tried specifying raw_id_admin=True on this ManyToManyField?

Karen

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



Re: Can I use Components and Classes in Django for views/controllers?

2009-04-01 Thread matehat

Hi,

You do have a couple of options, as mentioned by others earlier. One
of them is creating a base callable class view for your entire site
and have it subclassed for specific cases, but I think that would be a
bit heavy to work with here. Keep in mind that's entirely possible,
but you might find yourself writing more code just to make everything
work (with inheritance and all), unless it really fits your need.
Also, you could subclass the Context class itself, which I think could
be a nice option if you do include the same template variable over and
over and cannot put them in a context_processor.

Check out that example : http://dpaste.com/hold/22238/

As you know, adding more and more reusable variables would only be a
matter of trivial subclassing. Oh, and BTW, if you do need
context_processors, you should subclass RequestContext instead of
Context.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem customizing comments app

2009-04-01 Thread laird18

Hello all,

I'm trying to follow the "example custom comments app" exercise as
documented here:
http://docs.findjango.com/ref/contrib/comments/custom.html#ref-contrib-comments-custom

It looks simple enough but I've hit a complete dead end with it, and I
don't have any idea how to debug the problem!  Basically the comments
form isn't changing as it should.  I have noticed that when I copy the
methods in to __init__.py and try to run syncdb I'm getting an error
message.  So maybe the problem lies there?

This is the code I'm copying in to __init__.py:

from internal.models import CommentWithTitle
from internal.forms import CommentFormWithTitle

def get_model():
return CommentWithTitle

def get_form():
return CommentFormWithTitle


I'm running Django 1.0.2.

Any help would be massively appreciated.  Even if you could give me a
clue as to how to debug.

Thanks,
Michael

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



Re: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Miguel
umm, raw_id_admin takes no effect. I think I have found the problem. As you
said it may be in the model:

Pattern_method model has this entry definition:

metodos_embebidos =
models.ManyToManyField('Plantilla_metodo_embebido',blank=True,null=True)

and Plantilla_metodo_embebido has more than 100 000 entries.

Could be this the reason to take so much time? I try to use the raw_id but
no time is saved ...



Miguel
Sent from Madrid, Spain

On Wed, Apr 1, 2009 at 6:04 PM, Karen Tracey  wrote:

> On Wed, Apr 1, 2009 at 10:52 AM, Miguel  wrote:
>
>> I don really understand the raw_id_admin issue. I have read the api but
>> it is still not clear.
>>
>> You meant  I could improve the behaviour by adding this paramter?
>>
>> forma_parte_de =
>> models.ForeignKey('Plantilla_bloque',related_name='dentro_de',blank=True,null=True,
>> raw_ide_admin=true)
>>
>
> You'd need to remove the e in '_ide_' and capitalize True, but that's the
> general idea.
>
>
>> And making the same method call to changemanipulator?
>>
>
> Yes.
>
>
>>
>> should I synchronize the database?
>>
>>
>
> No, this doesn't affect what's stored in the database.  It just affects
> whether the ChangeManipulator needs to go retrieve all rows from the
> 'Plantilla_bloque' table in order to create a Select box with a drop-down
> listing all valid choices.  Depending on how big that table is, this could
> make creating the ChangeManipulator much faster.
>
> Karen
>
> >
>

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



RE: trouble uploading mp3 file

2009-04-01 Thread shelah johnson



I took a look at the file and you may have hit on it... the file size is
1.04 KB. 

Thanks!

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of creecode
Sent: Tuesday, March 31, 2009 10:52 PM
To: Django users
Subject: Re: trouble uploading mp3 file


Hello oregon10,

I wonder if the field you are using to upload is an ImageField or a
FileField.  If it's an ImageField you would have problems trying to
upload an mp3 file.  I would think you would get an error message but
it might be masked by the code.

Are you able to upload images with this form?

Ariel is correct that the person who programmed your system would be
the best person to help you.  Are you able to contact them?

Another thought occurs.  How large is this mp3 file?  If it is really
large, that might be a source of trouble.

On Mar 31, 5:44 pm, oregon10  wrote:

> I'm trying to upload a mp3 file to our my list of documents - so our
> views can assess it online. It goes through the motions of uploading
> but never appears in my list of docs. That tells me that the format
> might be wrong. If so, does anyone know what format options I should
> be converting the file to?

Toodle-loo..
creecode


--~--~-~--~~~---~--~~
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: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 10:52 AM, Miguel  wrote:

> I don really understand the raw_id_admin issue. I have read the api but it
> is still not clear.
>
> You meant  I could improve the behaviour by adding this paramter?
>
> forma_parte_de =
> models.ForeignKey('Plantilla_bloque',related_name='dentro_de',blank=True,null=True,
> raw_ide_admin=true)
>

You'd need to remove the e in '_ide_' and capitalize True, but that's the
general idea.


> And making the same method call to changemanipulator?
>

Yes.


>
> should I synchronize the database?
>
>

No, this doesn't affect what's stored in the database.  It just affects
whether the ChangeManipulator needs to go retrieve all rows from the
'Plantilla_bloque' table in order to create a Select box with a drop-down
listing all valid choices.  Depending on how big that table is, this could
make creating the ChangeManipulator much faster.

Karen

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



Re: adding views to admin site

2009-04-01 Thread Oli Warner
Surely you need an ^admin/myapp/ rule in your main urls.py?

(Your myapp/urls.py cannot attach to the /admin/ path because it is locked
into the ^myapp path)

Or you could switch it around and go for /myapp/admin/ (^admin/...) in your
myapp/urls.py

Both would be perfectly valid.

On Wed, Apr 1, 2009 at 12:13 PM, MarcoS  wrote:

>
> Hi, I've a problem adding views to my admin site using Django 1.1
> beta.
> I've defined inside my admin.py:
>
> class SeasonAdmin(admin.ModelAdmin):
>
>def get_urls(self):
>urls = super(SeasonAdmin, self).get_urls()
>my_urls = patterns('',
>(r'check_calendar/$', 'myapp.admin_views.check_calendar',)
>)
>return my_urls + urls
>
> (admin_views.py contains my customs views for admin)
>
> In my project I defined urls.py:
>
> urlpatterns = patterns('',
>(r'^myapp/', include('myapp.urls')),
>('^admin/', include(admin.site.urls)),
> )
>
> but, when i call : http://localhost:8000/admin/myapp/check_calendar i
> get a "page not found" that tell me "admin/myapp/check_calendar,
> didn't match any of these"
>
> where I'm wrong?
>
> >
>

--~--~-~--~~~---~--~~
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: Modifying contrib.auth

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 10:30 AM, jeremias.kangas
wrote:

>
> Hi,
>
> I want to modify contrib.auth so that "username" validates as an email
> field and can be longer than 30 characters. Is the only way to do this
> to make my own version of contrib.auth (contrib.myauth) or is there
> some handier way?
>

This same question was just asked and answered yesterday:

http://groups.google.com/group/django-users/browse_thread/thread/c943ede66e6807c

Karen

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



Re: Flatpages variables

2009-04-01 Thread Oli Warner
Same principal stands; you'll need to use middleware to check the current
user has what they need on their session and interrupt the request if they
don't.

If that doesn't make sense, read up on what middleware can do for you.

On Wed, Apr 1, 2009 at 4:47 PM, Wiiboy  wrote:

>
> Sorry, should've pointed out: I'm not using Django's user system,
> because I've got a PHP forum that I have to integrate with.
> >
>

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



Re: how to django to request a page of the other domain

2009-04-01 Thread Oli Warner
Look at urllib2 (google)

You should be able to do something like
return HttpResponse(urllib2.urlopen('http://www.your-url.ext/uri'))


2009/4/1 Albert 

>
> cross domain ajax request is not allowed ,so I decide to use proxy on
> the server side
> but I don't know how to finish this, anyone point me some url?
>
> >
>

--~--~-~--~~~---~--~~
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: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Lee

You're close...

change your method in CHOICES to get_for_model( _model_ )

So it should be
CHOICES = (
(ContentType.objects.get_for_model(My_Model), "Model 1"),
(ContentType.objects.get_for_model(My_Other_Model), "Model
2"),
)

Obviously, make sure you import your model before you try to use it.

On Mar 23, 3:26 pm, Adam Stein  wrote:
> Trying to create a generic FK using ContentType.  In admin, the menu
> lists all the models.  Since I only ever need to select 1 of 2 different
> models, anyway to limit the choice?
>
> Setting the choices attribute as Django complains
>
>         must be a "ContentType" instance
>
> ContentType.objects.get() returns an instance of a particular model, not
> ContentType (as one would expect), so I'm not sure how to create an
> instance with the particulars I need to point to something specific in
> the choices list.  Here's what I have:
>
> from django.db import models
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.contenttypes import generic
>
> class GenericFKExample(models.Model):
>     CHOICES = (
>         (ContentType.objects.get(model="model1"), "Model 1"),
>         (ContentType.objects.get(model="model2"), "Model 2"),
>     )
>
>     content_type = models.ForeignKey(ContentType,
>         choices = CHOICES,
>         null = True,
>     )
>
>     object_id = models.PositiveIntegerField(
>         null = True,
>     )
>
>     content_object = generic.GenericForeignKey(
>         "content_type", "object_id"
>     )
>
> Obviously, if I don't use choices, it works but then I have a very long
> list of model choices.
>
> --
> Adam Stein @ Xerox Corporation       Email: a...@eng.mc.xerox.com
>
> Disclaimer: Any/All views expressed
> here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]

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



Re: how to django to request a page of the other domain

2009-04-01 Thread Dougal Matthews
It depends what data your fetching I suppose but you might just want to use
urllib?
JavaScript triggers a view that makes a request to the remote server and
outputs the result to your javascript.

Dougal


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



2009/4/1 Albert 

>
> cross domain ajax request is not allowed ,so I decide to use proxy on
> the server side
> but I don't know how to finish this, anyone point me some url?
>
> >
>

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



Re: Flatpages variables

2009-04-01 Thread Wiiboy

Sorry, should've pointed out: I'm not using Django's user system,
because I've got a PHP forum that I have to integrate with.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to django to request a page of the other domain

2009-04-01 Thread Albert

cross domain ajax request is not allowed ,so I decide to use proxy on
the server side
but I don't know how to finish this, anyone point me some url?

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



Re: how can I change(update) an existing avatar to a new one?

2009-04-01 Thread Karen Tracey
2009/4/1 TTear1943 <1943@gmail.com>

>
> I seems it doesnot work when update an ImageField.
>

Certainly ImageFields can be updated.

You've omitted from the code you posted what exactly is done by the function
user.handle_upload_user_avatar(), which is my first guess as to where the
problem is.  If you want help solving the problem, you will need to include
more of what your code is doing (dpaste.com is likely a better place for
than inline in email for any large block of code) , and also it would help
if you were very specific about the error messages, tracebacks, or whatever
you are encountering.

For example you say "the avatar cannot be uploaded to AVATAR_TEMP_DIR".  Why
not?  What exactly happens?

You also appear to be drawing conclusions from what you are seeing, when you
state things like: "It seems that, after create the user. the
AVATAR_TEMP_DIR set to upload_to is lost, so the program doesn't know where
to upload the file."  I don't believe this conclusion is valid, but I'm not
sure what you saw that made you come to that conclusion, so I'm having a
hard time guessing what might be the real problem.

Karen


>
> On 4月1日, 下午5时37分, TTear1943 <1943@gmail.com> wrote:
> > Hi, I encounter a problem.
> > In my user models there is an atrrbution: user.avatar = ImageField
> > ('avatar', upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
> > then i use a modelform as an create user form. And the avatar is
> > uploaded corrcet. Which upload to AVATAR_TEMP_DIR, then I move the
> > avatar into AVATAR_ORIGINAL_PATH and make user.avatar._name as
> > AVATAR_ORIGINAL_PATH % user.id
> > After this, then I try to change an avatar. So I user another
> > modelform to update. however, this time the avatar cannot be uploaded
> > to AVATAR_TEMP_DIR, so I also cannot move the avatar to
> > AVATAR_ORIGINAL_PATH.
> > It seems that, after create the user. the AVATAR_TEMP_DIR set to
> > upload_to is lost, so the program doesn't know where to upload the
> > file.
> > Can anyone help me to solve this problem? Thank you very much.
> >
> > class UserForm(forms.ModelForm):
> > class Meta:
> > model = User
> > fields = ('name', 'user_avatar', 'description')
> >
> > class UserAvatarForm(forms.ModelForm):
> > class Meta:
> > model = User
> > fields = ('user_avatar')
> >
> > @login_required
> > def user_create(request):
> > if request.method == 'POST':
> > form = UserForm(request.POST, request.FILES)
> > if form.is_valid():
> > user = form.save(commit=False)
> > user.save()
> > user.handle_upload_user_avatar() # move image from
> > AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
> > user.save()
> > return HttpResponseRedirect(user.url)
> >
> > else:
> > form = UserForm()
> >
> > return render_to_response('user/user_create.html', locals())
> >
> > @login_required
> > def settings_user_avatar(request, user_name):
> > user = get_object_or_404(User, name=user_name)
> > if request.method == 'POST':
> > form = UserAvatarForm(request.POST, request.FILES,
> > instance=user)
> > if form.is_valid():
> > user = form.save()
> > user.handle_upload_user_avatar() # move image from
> > AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
> > user.save()
> > return HttpResponseRedirect(user.url)
> > else:
> > form = UserAvatarForm(instance=user)
> >
> > return render_to_response('user/user_avatar.html', locals())
> >
>

--~--~-~--~~~---~--~~
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: set list_filter directly

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 7:40 AM, Sams  wrote:

>
> anyone knows?...
>

If someone knew, they likely would have answered.  You might be looking for
the solution in ticket #5833, but I'm not really sure.  The patch for that
ticket is lacking docs to describe the solution provided, and honestly I
don't quite follow what you are looking to do here.

Karen


>
> On 31 mar, 13:34, Sams  wrote:
> > Hi all,
> >
> > I would like to know if there is some way to pass to admin list_filter
> > the values I want to filter.
> >
> > for example, i have a field for author's book.
> > it's a string with more than one author.
> >
> > a few books could be have one or more author will be the same.
> >
> > I want to catch all the authors of the book, remove the duplicates
> > and pass that to list_filter.
> >
> > get the authors and remove the duplicates I know how to do it
> >
> > but I have no sucess to pass that to list_filter
> >
> > it's seems it doens't can link my values I want to pass as parameters
> > with the apropriate field...
> >
> > if anyone can help...
> >
>

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



Re: Sending SMS using python script

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 7:14 AM, gganesh  wrote:

>
> hi group,
> my application needs to send SMS occasionally to all the clients  .Is
> there any library in python that supports in sending SMS.
> [snip]
>

This question really has nothing to do with Django, so you'll likely get
better responses if you ask in a more appropriate place, like
comp.lang.python or some group devoted to SMS.  Django doesn't restrict what
Python libraries you can use, so whatever is available for Python in general
you can use in your Django app.

Karen

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



Re: Collapsed inline

2009-04-01 Thread Karen Tracey
2009/4/1 Filip Gruszczyński 

>
> I am creating my own admin for a model and I would to add a collapsed
> inline.
>
> [snip]
> But I have no idea how to achieve this with an inline. Is it possible
> in DJango (possibly in 1.0, because this is at the production server,
> but I can also live with 1.1)
>

No, currently collapsing inlines is not supported.  There is a ticket for
this:

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

that has a relatively recent patch you could try, but at this point this
will not make it into 1.1, as it is new function and not a bug fix.

Karen

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



Re: evaluation of checkboxes

2009-04-01 Thread Timothy

Hi Alex,

many thanks for your quick responce.
Now it works as I expect.

And I apologize for my questions but I'm learning by doing and I have
not much time to realize my project.

I know I have much to learn (reading the documentation) - sorry

Timothy
--~--~-~--~~~---~--~~
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: Changemanipulator takes 15 seconds to execute

2009-04-01 Thread Miguel
I don really understand the raw_id_admin issue. I have read the api but it
is still not clear.


You meant  I could improve the behaviour by adding this paramter?

forma_parte_de = models.ForeignKey('Plantilla_
>
> bloque',related_name='dentro_de',blank=True,null=True, raw_ide_admin=true)



And making the same method call to changemanipulator?


should I synchronize the database?







Miguel
Sent from Madrid, Spain

On Tue, Mar 31, 2009 at 5:36 PM, Karen Tracey  wrote:

> On Tue, Mar 31, 2009 at 11:17 AM, Miguel  wrote:
>
>>
>> where should I put "raw_id_admin=True" ?  in the foreing key declaration?
>>
>> forma_parte_de =
>> models.ForeignKey('Plantilla_bloque',related_name='dentro_de',blank=True,null=True)
>>
>> and what implications does it have?
>>
>
> Sorry, I meant to include a pointer to the doc:
>
> http://www.djangoproject.com/documentation/0.96/model-api/
>
> search on that page for raw_id_admin.  You can just put it after your
> null=True, though as it is a keyword argument anyplace after the one
> positional arg you have would be fine.  The implication will be when you
> edit an object of this type in admin (or assuming I'm correct that it
> affects the ChangeManipulator in general, anywhere you edit using a
> ChangeManipulator), instead of getting a select drop-down listing all the
> possible choices for a value, you will have a simple text input where you
> specify the related object's primary key.  In recent Django releases there's
> a magnifying-glass icon on the field to assist in finding the right  related
> object -- clicking that brings up a list to select from, but I can't say for
> sure if the magnifying glass existed in 0.96 (I'm assuming that's what you
> are running since you are still using ChangeManipulator).
>
> (Also -- I assume updating the app code to a 1.0 level is a possibility
> you've evaluated and decided not to do at least for now?  I can't say it
> would necessarily immediately improve your performance issue, but you'd have
> a much wider ranger of people who might answer questions.  My sense is
> knowledge of pre-1.0 APIs is getting a little scarce on this list.)
>
> Karen
>
> >
>

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



Re: evaluation of checkboxes

2009-04-01 Thread Alex Gaynor
On Wed, Apr 1, 2009 at 10:44 AM, Timothy <83...@gmx.de> wrote:

>
> Hi Folks,
>
> I have checkboxes in my Form - submitd with POST-method
>
> request.POST['stat'] delivers a list/a string(???)  [1, 2, 3 A, B] /
> "1, 2, 3, A, B"
>
> I try to evaluate this but get only the last value (here: "B")
>
> my code
>
> a)  if "stat" in request.POST:
>   st = request.POST['stat'] ->   st = "B"  not "123AB" as
> I expect
>
> b) if "stat" in request.POST:
>  st = ""
>  for x in request.POST['stat]':
>   st = st + x   -> same result
> "B" and not "123AB"
>
> How can I get the whole list/string to save it in my database?
>
> Thx
> Timothy
>
> >
>
Use request.POST.getlist('stat').  POST['var'] returns the first item while
getlist() return a list of them.

Alex

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

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



evaluation of checkboxes

2009-04-01 Thread Timothy

Hi Folks,

I have checkboxes in my Form - submitd with POST-method

request.POST['stat'] delivers a list/a string(???)  [1, 2, 3 A, B] /
"1, 2, 3, A, B"

I try to evaluate this but get only the last value (here: "B")

my code

a)  if "stat" in request.POST:
   st = request.POST['stat'] ->   st = "B"  not "123AB" as
I expect

b) if "stat" in request.POST:
  st = ""
  for x in request.POST['stat]':
   st = st + x   -> same result
"B" and not "123AB"

How can I get the whole list/string to save it in my database?

Thx
Timothy

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



Re: FileField cannot save file with chinese filenames.

2009-04-01 Thread Karen Tracey
On Wed, Apr 1, 2009 at 5:12 AM, 夏恺  wrote:

>
> Hi all!
>
> I wrote a model to hold files uploaded by users, it goes like this:
>
> [snip]
> and when I try to add an mp3 file with chinese filename through the
> admin interface, the files are not saved correctly, their names are
> changed to something like: '.mp3', '_.mp3', '__.mp3'.
>
> Has anyone any idea on how to solve this problem? Thanks!
>

This is ticket #10254: http://code.djangoproject.com/ticket/10254

It has a patch you can try.  I'm waiting on feedback as to whether there is
good reason to maintain the very restrictive set of allowed characters in
file names before checking that patch in.  I don't see the reason for it,
but it is code that has been in Django since forever so there may be some
reason for it that I don't understand.

Karen

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



Re: Modifu request.user

2009-04-01 Thread soniiic



On Apr 1, 3:16 pm, Митко Масарлиев  wrote:
> soniiic wrote:
>
> > On Mar 31, 10:31 pm, Mitko Masarliev  wrote:
>
> >> I have application with table name clients. Clients has one to one
> >> relation with django users and in all app logic I check clients id by
> >> request.user.id, In some cases user_id is not same as clients_id. This
> >> is the problem, so I am trying to change request.user.id to be equal to
> >> clients_id and this will halp me rewriting many classes and methods
>
> > if you got a one to one relationship why can't you just do this:
> > client = Clients.objects.filter(user=request.user)
>
> > ...where user is your relationship field in the Client model.
>
> Becouse I have other table with relation to clients I and these tables
> don't have relation with users
>
> --
>
> Regards,
> Mitko Masarliev
> Junior Php Developer
> m.masarl...@viscomp.bg 
> Mobile: +359 898 563 274
>
>         *Viscomp EOOD*
> 92V "Hristo Botev" Blvd
> 4000 Plovdiv
> Bulgaria        
> Tel: +359 32 655 175
> Fax: +359 32 655 176www.viscomp.bg

I'm new to django myself, but i don't think this can be done.  You got
to set up a relationship in your Clients model to user. i think the
common practise is to use a foreign key with "unique=True" so that
only one client is made per user.

like such:
user = models.ForeignKey(User, unique=True)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Modifying contrib.auth

2009-04-01 Thread jeremias.kangas

Hi,

I want to modify contrib.auth so that "username" validates as an email
field and can be longer than 30 characters. Is the only way to do this
to make my own version of contrib.auth (contrib.myauth) or is there
some handier way?

- Jeremias

--~--~-~--~~~---~--~~
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: weird name error

2009-04-01 Thread Adonis

To whom it may concern,
the problem was the order in which the classes are created.
In the above exampel, the order seems fine but in my model the
species_d comes first and then the layers. this makes it search for
sth that is not initiated yet!

cheers and sorry for the stupid error...



On Mar 31, 9:32 am, Adonis  wrote:
> well, this is the traceback,
>
> Traceback (most recent call last):
>   File "./manage.py", line 11, in 
>     execute_manager(settings)
>   File "/var/lib/python-support/python2.5/django/core/management/
> __init__.py", l                          ine 340, in execute_manager
>     utility.execute()
>   File "/var/lib/python-support/python2.5/django/core/management/
> __init__.py", l                          ine 295, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/var/lib/python-support/python2.5/django/core/management/
> base.py", line                           192, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/var/lib/python-support/python2.5/django/core/management/
> base.py", line                           218, in execute
>     self.validate()
>   File "/var/lib/python-support/python2.5/django/core/management/
> base.py", line                           246, in validate
>     num_errors = get_validation_errors(s, app)
>   File "/var/lib/python-support/python2.5/django/core/management/
> validation.py",                           line 28, in
> get_validation_errors
>     for (app_name,error) in get_app_errors().items():
>   File "/var/lib/python-support/python2.5/django/db/models/
> loading.py", line 128                          , in get_app_errors
>     self._populate()
>   File "/var/lib/python-support/python2.5/django/db/models/
> loading.py", line 57,                           in _populate
>     self.load_app(app_name, True)
>   File "/var/lib/python-support/python2.5/django/db/models/
> loading.py", line 72,                           in load_app
>     mod = __import__(app_name, {}, {}, ['models'])
>   File "/home/antonios/orchid_demo_dev/../orchid_demo_dev/appname/
> models.py", li                          ne 21, in 
>     class Species_d(models.Model):
>   File "/home/antonios/orchid_demo_dev/../orchid_demo_dev/appname/
> models.py", li                          ne 31, in Species_d
>     uLayer = models.ForeignKey(LayersOfUsers)
> NameError:name'LayersOfUsers' is not defined
>
> **
> and the model.py imports,
>
> from django.db import models
> from django.contrib.auth.models import User
>
> **
>
> Kind regards,
>
> On Mar 30, 7:16 pm, Briel  wrote:
>
> > Hi.
> > You really dont give much information, when this
> > happens traceback ect, but a wild guess would
> > be to check your imports.
>
> > ~Jakob
>
> > On Mar 30, 7:04 pm, Adonis  wrote:
>
> > > Hello,
> > > You will love this one,
>
> > > models.py
> > > *
> > > class LayersOfUsers(models.Model):
> > >    name= models.CharField(max_length=50)
> > >     desc = models.TextField(null=True)
> > >     geouser = models.ForeignKey(User)
>
> > >     def __unicode__(self):
> > >         return self.name
>
> > > class Species_d(models.Model):
> > >     speciesName = models.CharField(max_length=200, null=True)
> > >     speciesUser = models.ForeignKey(User)
> > >     lon = models.FloatField(4)
> > >     lat = models.FloatField(4)
> > >     uLayer = models.ForeignKey(LayersOfUsers)
>
> > >     def __unicode__(self):
> > >         return self.speciesName
> > > *
>
> > > i am getting anameerroron this occasion:
> > > * NameError:name'LayersOfUsers' is not defined *
> > > Anyone care to suggest sth? I will also add a hint, because the
> > > initially created project is now running under mod python, this
> > > happens to be a newly created project but with copied-paisted code
> > > from the previous one, so that i can continue developing.
> > > Kind regards,
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Modifu request.user

2009-04-01 Thread Митко Масарлиев




soniiic wrote:

  

On Mar 31, 10:31 pm, Mitko Masarliev  wrote:
  
  
I have application with table name clients. Clients has one to one
relation with django users and in all app logic I check clients id by
request.user.id, In some cases user_id is not same as clients_id. This
is the problem, so I am trying to change request.user.id to be equal to
clients_id and this will halp me rewriting many classes and methods

  
  
if you got a one to one relationship why can't you just do this:
client = Clients.objects.filter(user=request.user)

...where user is your relationship field in the Client model.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---


  

Becouse I have other table with relation to clients I and these tables
don't have relation with users

-- 


Regards,
Mitko Masarliev
Junior Php Developer
m.masarl...@viscomp.bg
Mobile: +359 898 563 274 


  

  
  
  Viscomp EOOD
92V "Hristo Botev" Blvd
4000 Plovdiv
Bulgaria
  
Tel: +359 32 655 175
Fax: +359 32 655 176
  www.viscomp.bg
  

  







Re: How to handle the Browser Close ?

2009-04-01 Thread Jeff FW

http://docs.djangoproject.com/en/dev/topics/http/sessions/#session-expire-at-browser-close

On Apr 1, 2:26 am, veeravendhan  wrote:
> Say a user is logged in to the system,  If he closes the browser how
> will I handle the Logout for that user ? Any idea ??
--~--~-~--~~~---~--~~
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: Modifu request.user

2009-04-01 Thread soniiic



On Mar 31, 10:31 pm, Mitko Masarliev  wrote:
> I have application with table name clients. Clients has one to one
> relation with django users and in all app logic I check clients id by
> request.user.id, In some cases user_id is not same as clients_id. This
> is the problem, so I am trying to change request.user.id to be equal to
> clients_id and this will halp me rewriting many classes and methods

if you got a one to one relationship why can't you just do this:
client = Clients.objects.filter(user=request.user)

...where user is your relationship field in the Client model.

--~--~-~--~~~---~--~~
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: Merging apps

2009-04-01 Thread Dids

You're correct, it's projects, not applications.
Each project has 1 application at the moment.

Not all of the project have user management but a couple have.



On Apr 1, 2:10 pm, Thomas Guettler  wrote:
> Dids schrieb:
>
> > Hi,
>
> > I have a handful of application running on the same apache server.
>
> > More are on the way and it's starting to get messy to manage.
>
> > I'd like to "merge" all the applications into one but I'm not sure how
> > to go about it.
> > [What I want is, a single entry in my apache.conf file, not one per
> > app as I have now]
>
> Please use django terms: One *project* contains one or many *applications*.
> Example: settings.py is part of the project. While most views and models.py
> are part of the applications.
>
> I think you should have one entry in apache.conf for every *project*.
>
>
>
> > I initially tried to write some sort of a portal that would link to
> > each app, but I can't get Django to switch to the different databases.
>
> > How would you guy go about it?
>
> Don't put code into projects, python logic should be in applications. A 
> project
> is quite small. It is just a container and configuration for several 
> applications.
>
> > Do I have to bite the bullet and merge the databases , views files,
> > settings etc etc?
>
> Does every project have its own user management?
>
> HTH,
>   Thomas
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how can I change(update) an existing avatar to a new one?

2009-04-01 Thread TTear1943

I seems it doesnot work when update an ImageField.

On 4月1日, 下午5时37分, TTear1943 <1943@gmail.com> wrote:
> Hi, I encounter a problem.
> In my user models there is an atrrbution: user.avatar = ImageField
> ('avatar', upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
> then i use a modelform as an create user form. And the avatar is
> uploaded corrcet. Which upload to AVATAR_TEMP_DIR, then I move the
> avatar into AVATAR_ORIGINAL_PATH and make user.avatar._name as
> AVATAR_ORIGINAL_PATH % user.id
> After this, then I try to change an avatar. So I user another
> modelform to update. however, this time the avatar cannot be uploaded
> to AVATAR_TEMP_DIR, so I also cannot move the avatar to
> AVATAR_ORIGINAL_PATH.
> It seems that, after create the user. the AVATAR_TEMP_DIR set to
> upload_to is lost, so the program doesn't know where to upload the
> file.
> Can anyone help me to solve this problem? Thank you very much.
>
> class UserForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ('name', 'user_avatar', 'description')
>
> class UserAvatarForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ('user_avatar')
>
> @login_required
> def user_create(request):
> if request.method == 'POST':
> form = UserForm(request.POST, request.FILES)
> if form.is_valid():
> user = form.save(commit=False)
> user.save()
> user.handle_upload_user_avatar() # move image from
> AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
> user.save()
> return HttpResponseRedirect(user.url)
>
> else:
> form = UserForm()
>
> return render_to_response('user/user_create.html', locals())
>
> @login_required
> def settings_user_avatar(request, user_name):
> user = get_object_or_404(User, name=user_name)
> if request.method == 'POST':
> form = UserAvatarForm(request.POST, request.FILES,
> instance=user)
> if form.is_valid():
> user = form.save()
> user.handle_upload_user_avatar() # move image from
> AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
> user.save()
> return HttpResponseRedirect(user.url)
> else:
> form = UserAvatarForm(instance=user)
>
> return render_to_response('user/user_avatar.html', locals())
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages variables

2009-04-01 Thread Rajesh D



On Apr 1, 2:30 am, Wiiboy  wrote:
> Hi,
> I've got a site where users must be logged in to view any pages.
> Logged in users may write articles for the newsletter, and upload
> them.  I then convert the article to HTML (manually), and make it
> available for other users.  I'd like make them available on flatpages,
> but I have to be able to check whether the user is logged in.
>
> Can I do that?

http://www.djangosnippets.org/snippets/136/

--~--~-~--~~~---~--~~
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: Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?

2009-04-01 Thread Mark Shewfelt

Thanks Karl - Actually, this morning I gave up and upgraded Ubuntu to
8.10, which uses a newer version of FreeTDS and unixODBC. It seems to
work OK, though there are some funky Unicode issues using Django's
TextField, but I can get around those for now.

Cheers,

Mark

On Mar 31, 8:41 pm, "Karl Gingerich"  wrote:
> Mark, I'll up to my eye balls in alligators right now, I'll get back to you 
> soon. - Karl
>
> -Original Message-
> From: Mark Shewfelt 
>
> Date: Tue, 31 Mar 2009 08:25:55
> To: Django users
> Subject: Re: Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?
>
> Hi Karl,
>
> I just came across your post and am having the same issue (Ubuntu 8.04
> Server). I managed to build the latest versions of unixODBC and
> FreeTDS and install them to /usr/local/lib. When I run python and try
> to import pyodbc I get the following error:
>
> administra...@maverick:~/pyodbc-2.1.4$ python -c "import pyodbc"
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: libodbc.so.1: cannot open shared object file: No such
> file or directory
> administra...@maverick:~/pyodbc-2.1.4$
>
> So obviously pyodbc cannot find the libs I just built - but I cannot
> figure out how to specify their location when building pyodbc. Did you
> have this issue? Any help is welcome!
>
> Thanks,
>
> Mark
>
> On Feb 25, 5:19 pm, kgingeri  wrote:
> > Ok, I figured this out myself...
>
> > I had to un-install all pre-installed odbc stuff - unixODBC (possibly
> > iODBC as well, except it didn't seem to actually uninstall completely)
> > andFreeTDS.
>
> > I then got source and did configure/make/make installs of unixODBC
> > first, thenFreeTDS.
> > This order is important so that the ./configure command can find all
> > the right stuff.
> > An important note is the params for theFreeTDS./configure command.
> > I used the following:
>
> > $ ./configure --with-unixodbc=/usr/local  --enable-msdblib --disable-
> > libiconv --with-tdsver=8.0
>
> > Anyway, it's working now without complaint!
>
> > :v)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inheriting attributes from a model

2009-04-01 Thread Rajesh D



On Apr 1, 6:43 am, Denis  wrote:
> I am developing a store using Satchmo, and I want the ability to save
> quotes; that's snapshots of the current cart, and I want to store the
> history of all the quotes in the database. My current models look like
> this:
>
> class QuoteItem(models.Model, Product):
> quantity = models.PositiveIntegerField(_('Quantity'))
> price_incl_vat = models.DecimalField(_("Price incl. VAT"),
> max_digits=10, decimal_places=2)
>
> class Quote(models.Model):
> items = models.ManyToManyField('QuoteItem')
>
> In Django my inherited Product class is represented as a foreign key
> in the QuoteItem table. The problem is that the product price is
> subject to change in the future, but the Quote shouldn't change.
> I want a copy of the product attributes in QuoteItem, instead of a
> foreign key.

Yes, that's the right way to approach this problem.

> Is there a clean way to do, or do I have to copy all the attributes
> here manually?

You could serialize your product instance into a TextField in
QuoteItem:

from django.core import serializers
serialized_product = serializers.serialize("json", [product_instance])

-Rajesh D

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



Re: Merging apps

2009-04-01 Thread Thomas Guettler



Dids schrieb:
> Hi,
> 
> I have a handful of application running on the same apache server.
> 
> More are on the way and it's starting to get messy to manage.
> 
> I'd like to "merge" all the applications into one but I'm not sure how
> to go about it.
> [What I want is, a single entry in my apache.conf file, not one per
> app as I have now]

Please use django terms: One *project* contains one or many *applications*.
Example: settings.py is part of the project. While most views and models.py
are part of the applications.

I think you should have one entry in apache.conf for every *project*.

> 
> I initially tried to write some sort of a portal that would link to
> each app, but I can't get Django to switch to the different databases.
> 
> How would you guy go about it?

Don't put code into projects, python logic should be in applications. A project
is quite small. It is just a container and configuration for several 
applications.

> Do I have to bite the bullet and merge the databases , views files,
> settings etc etc?

Does every project have its own user management?


HTH,
  Thomas

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

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

2009-04-01 Thread Sams

anyone knows?...

On 31 mar, 13:34, Sams  wrote:
> Hi all,
>
> I would like to know if there is some way to pass to admin list_filter
> the values I want to filter.
>
> for example, i have a field for author's book.
> it's a string with more than one author.
>
> a few books could be have one or more author will be the same.
>
> I want to catch all the authors of the book, remove the duplicates
> and pass that to list_filter.
>
> get the authors and remove the duplicates I know how to do it
>
> but I have no sucess to pass that to list_filter
>
> it's seems it doens't can link my values I want to pass as parameters
> with the apropriate field...
>
> if anyone can help...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Default values in inline admin widget

2009-04-01 Thread Filip Gruszczyński

I have inline admin widget, it's a tabular inline and I would like to
have a few of it's rows filled for the user. Can I achieve it somehow
quickly (DJango 1.0 or 1.1)? Should I put some JS somewhere or is it
possible from admin.py?

-- 
Filip Gruszczyński

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Sending SMS using python script

2009-04-01 Thread gganesh

hi group,
my application needs to send SMS occasionally to all the clients  .Is
there any library in python that supports in sending SMS.
I like to conform few information i gathered in this regard.

I can send SMS by two ways

1. Sending SMS using Email clients
2. Using sms gateway to send message(we can implement SMS Gateway API
's ,provided by vendor and ,send SMS -- we will be charged
accordingly )


In case of First approach
1. We can make use of libgamil library to send SMS using gmail ( I
ref : http://blog.datasingularity.com/?p=63 )
i suppose sending sms through gmail is not supported in India
 2. Can we use Skype4py library,

In case of second approach
1. Is there any way to send SMS for free inside India ,or ,Any free
SMS gateway providers in India
Any information regarding this is appreciable
  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
-~--~~~~--~~--~--~---



adding views to admin site

2009-04-01 Thread MarcoS

Hi, I've a problem adding views to my admin site using Django 1.1
beta.
I've defined inside my admin.py:

class SeasonAdmin(admin.ModelAdmin):

def get_urls(self):
urls = super(SeasonAdmin, self).get_urls()
my_urls = patterns('',
(r'check_calendar/$', 'myapp.admin_views.check_calendar',)
)
return my_urls + urls

(admin_views.py contains my customs views for admin)

In my project I defined urls.py:

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

but, when i call : http://localhost:8000/admin/myapp/check_calendar i
get a "page not found" that tell me "admin/myapp/check_calendar,
didn't match any of these"

where I'm wrong?

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



I can upload an avatar when creating, but how can I change an avatar when updating?

2009-04-01 Thread 林吓洪
Hi, I encounter a problem.
In my user models there is an atrrbution: user.avatar = ImageField('avatar',
upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
then i use a modelform as an create user form. And the avatar is uploaded
corrcet. Which upload to AVATAR_TEMP_DIR, then I move the avatar into
AVATAR_ORIGINAL_PATH and make user.avatar._name as AVATAR_ORIGINAL_PATH %
user.id
After this, then I try to change an avatar. So I user another modelform to
update. however, this time the avatar cannot be uploaded to AVATAR_TEMP_DIR,
so I also cannot move the avatar to AVATAR_ORIGINAL_PATH.
It seems that, after create the user. the AVATAR_TEMP_DIR set to upload_to
is lost, so the program doesn't know where to upload the file.
Can anyone help me to solve this problem?
Thank you very much.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Merging apps

2009-04-01 Thread Dids

Hi,

I have a handful of application running on the same apache server.

More are on the way and it's starting to get messy to manage.

I'd like to "merge" all the applications into one but I'm not sure how
to go about it.
[What I want is, a single entry in my apache.conf file, not one per
app as I have now]

I initially tried to write some sort of a portal that would link to
each app, but I can't get Django to switch to the different databases.

How would you guy go about it?

Do I have to bite the bullet and merge the databases , views files,
settings etc etc?

Or can I get my initial attempt working by having 1 front app that
would load the original apps as required?

Any input or comments welcome.

Regards,
Didier,

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



I can upload an avatar when creating, but how can I change an avatar when updating?

2009-04-01 Thread TTear1943

Hi, I encounter a problem.
In my user models there is an atrrbution: user.avatar = ImageField
('avatar', upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
then i use a modelform as an create user form. And the avatar is
uploaded corrcet. Which upload to AVATAR_TEMP_DIR, then I move the
avatar into AVATAR_ORIGINAL_PATH and make user.avatar._name as
AVATAR_ORIGINAL_PATH % user.id
After this, then I try to change an avatar. So I user another
modelform to update. however, this time the avatar cannot be uploaded
to AVATAR_TEMP_DIR, so I also cannot move the avatar to
AVATAR_ORIGINAL_PATH.
It seems that, after create the user. the AVATAR_TEMP_DIR set to
upload_to is lost, so the program doesn't know where to upload the
file.
Can anyone help me to solve this problem?
Thank you very much.

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



how can I change(update) an existing avatar to a new one?

2009-04-01 Thread TTear1943

Hi, I encounter a problem.
In my user models there is an atrrbution: user.avatar = ImageField
('avatar', upload_to=AVATAR_TEMP_DIR, blank=True, null=True)
then i use a modelform as an create user form. And the avatar is
uploaded corrcet. Which upload to AVATAR_TEMP_DIR, then I move the
avatar into AVATAR_ORIGINAL_PATH and make user.avatar._name as
AVATAR_ORIGINAL_PATH % user.id
After this, then I try to change an avatar. So I user another
modelform to update. however, this time the avatar cannot be uploaded
to AVATAR_TEMP_DIR, so I also cannot move the avatar to
AVATAR_ORIGINAL_PATH.
It seems that, after create the user. the AVATAR_TEMP_DIR set to
upload_to is lost, so the program doesn't know where to upload the
file.
Can anyone help me to solve this problem? Thank you very much.

class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ('name', 'user_avatar', 'description')

class UserAvatarForm(forms.ModelForm):
class Meta:
model = User
fields = ('user_avatar')

@login_required
def user_create(request):
if request.method == 'POST':
form = UserForm(request.POST, request.FILES)
if form.is_valid():
user = form.save(commit=False)
user.save()
user.handle_upload_user_avatar() # move image from
AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
user.save()
return HttpResponseRedirect(user.url)

else:
form = UserForm()

return render_to_response('user/user_create.html', locals())

@login_required
def settings_user_avatar(request, user_name):
user = get_object_or_404(User, name=user_name)
if request.method == 'POST':
form = UserAvatarForm(request.POST, request.FILES,
instance=user)
if form.is_valid():
user = form.save()
user.handle_upload_user_avatar() # move image from
AVATAR_TEMP_DIR to AVATAR_ORIGINAL_PATH
user.save()
return HttpResponseRedirect(user.url)
else:
form = UserAvatarForm(instance=user)

return render_to_response('user/user_avatar.html', locals())

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Inheriting attributes from a model

2009-04-01 Thread Denis

I am developing a store using Satchmo, and I want the ability to save
quotes; that's snapshots of the current cart, and I want to store the
history of all the quotes in the database. My current models look like
this:

class QuoteItem(models.Model, Product):
quantity = models.PositiveIntegerField(_('Quantity'))
price_incl_vat = models.DecimalField(_("Price incl. VAT"),
max_digits=10, decimal_places=2)

class Quote(models.Model):
items = models.ManyToManyField('QuoteItem')

In Django my inherited Product class is represented as a foreign key
in the QuoteItem table. The problem is that the product price is
subject to change in the future, but the Quote shouldn't change.
I want a copy of the product attributes in QuoteItem, instead of a
foreign key.
Is there a clean way to do, or do I have to copy all the attributes
here manually?

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



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

2009-04-01 Thread johan . uhle

Best way is to write your own authentication backend I think.

Check the docs:
http://docs.djangoproject.com/en/dev/topics/auth/?from=olddocs#writing-an-authentication-backend

This article might also give you a good idea:
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

The actual authenticate function might look something like this:

def authenticate(self, username=None, password=None):
# authenticate with email
try:
user = self.user_class.objects.get(email=username)
if user.check_password(password):
return user
except self.user_class.DoesNotExist:
# authentication with username
try:
user = self.user_class.objects.get(username=username)
if user.check_password(password):
return user
except self.user_class.DoesNotExist:
# neither nor succesfull, so no user exists
return None

Beware: During registration I have forbidden usernames that might look
like mail adresses (just unallow character @). Other than that there
might be the rare possibility that people can not login with their
username/password credentials if it username is the e-mail-adress used
by another account.

On Mar 31, 10:03 am, Rama Vadakattu  wrote:
> The authentication model provided along with django is based on
> username.
>
> What to do to change the authentication based on email instead of
> username?
>
> To be more specific
> ~~~
>      With username authentication , to login user  we do the following
>
>      user = authenticate(name,password)
>      ...
>      login(request,user)
>
>      what to write for the above statements if we are authenticating
> using email?
>
>  For form
>  ~
> iam planning to write my own form which shows the fields
> email,password and the validation.
> Is this the correct approach?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Collapsed inline

2009-04-01 Thread Filip Gruszczyński

I am creating my own admin for a model and I would to add a collapsed inline.

Right now it is:

inlines = [PriorityInline,]

but this was I have no idea how to specify it is collapsed. I can't
just put it into fieldsets. I tried adding classes=['collapse'] to the
inline, but it didn't help.

I would like to also be able to it put into fieldset, because I would
like to be described as 'Advanced', which would look like this

'Advanced', { 'fields': priority }

But I have no idea how to achieve this with an inline. Is it possible
in DJango (possibly in 1.0, because this is at the production server,
but I can also live with 1.1)

-- 
Filip Gruszczyński

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >