Re: Django version

2009-05-19 Thread VidrSan

O_o This function does not exist
>>>'module' object has no attribute 'get_version'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Error in basic template in admin

2009-05-19 Thread Diogo Baeder

Hi, guys,

I'm having an issue with the basic admin template at my project... 
basically, it says that it doesn't see an "urls" module, in a line that 
tries to include links to the admin documentation, but I've not 
activated the documentation! :-(

Can I post an image here with the traceback screen?

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: Recursive ManyToMany field question

2009-05-19 Thread Adam Olsen

On Tue, May 19, 2009 at 11:12 PM, Russell Keith-Magee
 wrote:
> You're looking for a non-symmetrical m2m relation:
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.symmetrical
>

Exactly what I was looking for, thanks!

-- 
Adam Olsen
http://www.vimtips.org

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

2009-05-19 Thread Russell Keith-Magee

On Wed, May 20, 2009 at 12:57 PM, Adam Olsen  wrote:
>
> I'm trying to make a tagging application.  I want to have tags that
> have related tags, ie, if they choose the tag 'car', it should also
> choose 'automobile'.  If they choose 'automobile', it should not
> automatically choose 'car'.  I'm using something like:
>
> class Tag(models.Model):
>   name = models.CharField(max_length=30)
>   related = models.ManyToManyField('self')
>
> If I do this:
>
 car = Tag(name='car')
 car.save()
 automobile = Tag(name='automobile')
 automobile.save()
 car.related.add(automobile)
 car.related.all()
> []
 automobile.related.all()
> []
>
> How do I make it so that if I add a relation of 'automobile' to 'car',
> it doesn't automatically add a reverse relation like that?

You're looking for a non-symmetrical m2m relation:

http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.symmetrical

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



Recursive ManyToMany field question

2009-05-19 Thread Adam Olsen

I'm trying to make a tagging application.  I want to have tags that
have related tags, ie, if they choose the tag 'car', it should also
choose 'automobile'.  If they choose 'automobile', it should not
automatically choose 'car'.  I'm using something like:

class Tag(models.Model):
   name = models.CharField(max_length=30)
   related = models.ManyToManyField('self')

If I do this:

>>> car = Tag(name='car')
>>> car.save()
>>> automobile = Tag(name='automobile')
>>> automobile.save()
>>> car.related.add(automobile)
>>> car.related.all()
[]
>>> automobile.related.all()
[]

How do I make it so that if I add a relation of 'automobile' to 'car',
it doesn't automatically add a reverse relation like that?

-- 
Adam Olsen
http://www.vimtips.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Rendering models using their own templates

2009-05-19 Thread Roberto Cea

HI Eric,

thanks for the reply.

I sort of found a solution, by poking through the contrib.syndication
app, I added this function to my model:

from django.template import loader

def render(self):
html_tmp = loader.get_template(self.html_template_name)
html = loader.render_to_string(html_tmp.name, {'obj': self})
return html

where self.html_template_name is the path + name of the template, and
it's passed the calling model instance as 'obj'.

Thanks!

Rodrigo

On May 19, 11:50 pm, Eric Abrahamsen  wrote:
> On May 20, 2009, at 10:53 AM, Roberto Cea wrote:
>
>
>
> > I have a large amount of optional components (with a model for each
> > one) that will be freely inserted by my users, and it would be
> > impractical to render each one in a single large template.
> > I want to give each component a ".render()" method, so I can just call
> > that from the template.
> > However, I don't want to have to put together each component's HTML in
> > its model definition. Ideally, each component would have a
> > corresponding template file, that would be added together with the
> > page's other components' output to generate the complete page's HTML.
> > Is there a way to specify, for each model, a small template-snippet
> > file that will be used to represent it? Hopefully using Django
> > standard template syntax?
>
> I'm not sure this will completely solve your problem, but in several  
> cases I've added python-only (non-database) attributes to models,  
> pointing at a template in my template dirs directory. That way you can  
> use generic code to render snippets for a variety of different models.  
> You could create a mixin class that provides the render() method,  
> using django's template rendering functions and a reference to  
> self.component_template, then have models subclass this mixin and  
> provide their own component_template attribute.
>
> Hope that's what you were looking for.
>
> Eric
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Generic subclass accessor for model inheritance?

2009-05-19 Thread Roberto Cea

I have a BaseModel and n models that subclass it.
Each instance of the BaseClass has a .name_of_subclass attribute that
returns the subclass instance associated with it.
Is there a generic way of accessing this instance without knowing
beforehand the name of the subclass, something like
base_class_instance.generic_subclass_instance?

Example:

class BaseModel(models.Model):
visible = models.BooleanField(default=True)

class OneSubModel(BaseModel):
   palatable = models.BooleanField(default=True)

class OtherRandomSubModel(BaseModel):
   palatable = models.BooleanField(default=True)

for base_class_instance in BaseModel.objects.filter(visible=True):
print base_class_instance.generic_subclass_instance.palatable()
--~--~-~--~~~---~--~~
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: Rendering models using their own templates

2009-05-19 Thread Eric Abrahamsen


On May 20, 2009, at 10:53 AM, Roberto Cea wrote:

>
> I have a large amount of optional components (with a model for each
> one) that will be freely inserted by my users, and it would be
> impractical to render each one in a single large template.
> I want to give each component a ".render()" method, so I can just call
> that from the template.
> However, I don't want to have to put together each component's HTML in
> its model definition. Ideally, each component would have a
> corresponding template file, that would be added together with the
> page's other components' output to generate the complete page's HTML.
> Is there a way to specify, for each model, a small template-snippet
> file that will be used to represent it? Hopefully using Django
> standard template syntax?

I'm not sure this will completely solve your problem, but in several  
cases I've added python-only (non-database) attributes to models,  
pointing at a template in my template dirs directory. That way you can  
use generic code to render snippets for a variety of different models.  
You could create a mixin class that provides the render() method,  
using django's template rendering functions and a reference to  
self.component_template, then have models subclass this mixin and  
provide their own component_template attribute.

Hope that's what you were looking for.

Eric

> >


--~--~-~--~~~---~--~~
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: if number <= othernumber

2009-05-19 Thread brawaga

Excuse me for my awful english ;)

On May 13, 7:33 pm, "richardcur...@googlemail.com"
 wrote:
> Can I do in Django 0.9 something like if number <= othernumber ?

Try to create your own filter that compares things (numbers as a case)

In that particular case when you want to check a length of a list, you
can use this:
{% if list|slice:"5:"|length_is:"0" %}
some HTML when the list is short
{% else %}
some HTML when the list is long
{% end if %}

This example tests if list is longer than 5 items or not. Use another
number if you need.

Bests!
--~--~-~--~~~---~--~~
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: Best Django host

2009-05-19 Thread Eugene Lazutkin

>From my experience with both hosts webfaction has a better uptime,
better setup, and less interferences from neighbors, which is important
on shared hosts.

Thanks,

Eugene Lazutkin
http://lazutkin.com/

On 05/19/2009 09:41 PM, LeonTheCleaner wrote:
> Thanks, I saw that link. But why webfaction is better. It has the same
> manual steps to install django, right? I can see a 1 click install
> would be good, but why these are better than say dreamhostÉ
> 
> 
> 
> Thanks.
> 
> On May 19, 8:06 pm, Zain Memon  wrote:
>> http://djangofriendly.com/
>>
>> On Tue, May 19, 2009 at 6:21 PM, LeonTheCleaner wrote:
>>
>>
>>
>>
>>
>>> Hi,
>>> I currently use dreamhost, but the installation process is very slow.
>>> Is it me or this process is overly complicated? All I want is to
>>> install an already written django project but to do that it's like I
>>> have to write the app myself.
>>> I read about dreamhost being not the best, but it's listed at #2 on
>>> django website. Should I use that for my site or buy one of the
>>> packages that features 1-click install, like:http://djangohosting.ch?
>>> I would appreciate if someone can help me out.
>>> 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: Best Django host

2009-05-19 Thread Roberto Cea

Webfaction has small-amount-of-clicks install for Django, and the
support staff is both knowledgeable (about Django and other topics)
and helpful.
It's very Django friendly.

On May 19, 10:41 pm, LeonTheCleaner  wrote:
> Thanks, I saw that link. But why webfaction is better. It has the same
> manual steps to install django, right? I can see a 1 click install
> would be good, but why these are better than say dreamhostÉ
>
> Thanks.
>
> On May 19, 8:06 pm, Zain Memon  wrote:
>
> >http://djangofriendly.com/
>
> > On Tue, May 19, 2009 at 6:21 PM, LeonTheCleaner wrote:
>
> > > Hi,
>
> > > I currently use dreamhost, but the installation process is very slow.
> > > Is it me or this process is overly complicated? All I want is to
> > > install an already written django project but to do that it's like I
> > > have to write the app myself.
>
> > > I read about dreamhost being not the best, but it's listed at #2 on
> > > django website. Should I use that for my site or buy one of the
> > > packages that features 1-click install, like:http://djangohosting.ch?
>
> > > I would appreciate if someone can help me out.
>
> > > 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
-~--~~~~--~~--~--~---



Rendering models using their own templates

2009-05-19 Thread Roberto Cea

I have a large amount of optional components (with a model for each
one) that will be freely inserted by my users, and it would be
impractical to render each one in a single large template.
I want to give each component a ".render()" method, so I can just call
that from the template.
However, I don't want to have to put together each component's HTML in
its model definition. Ideally, each component would have a
corresponding template file, that would be added together with the
page's other components' output to generate the complete page's HTML.
Is there a way to specify, for each model, a small template-snippet
file that will be used to represent it? Hopefully using Django
standard template syntax?
--~--~-~--~~~---~--~~
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: Best Django host

2009-05-19 Thread LeonTheCleaner

Thanks, I saw that link. But why webfaction is better. It has the same
manual steps to install django, right? I can see a 1 click install
would be good, but why these are better than say dreamhostÉ



Thanks.

On May 19, 8:06 pm, Zain Memon  wrote:
> http://djangofriendly.com/
>
> On Tue, May 19, 2009 at 6:21 PM, LeonTheCleaner wrote:
>
>
>
>
>
> > Hi,
>
> > I currently use dreamhost, but the installation process is very slow.
> > Is it me or this process is overly complicated? All I want is to
> > install an already written django project but to do that it's like I
> > have to write the app myself.
>
> > I read about dreamhost being not the best, but it's listed at #2 on
> > django website. Should I use that for my site or buy one of the
> > packages that features 1-click install, like:http://djangohosting.ch?
>
> > I would appreciate if someone can help me out.
>
> > 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: Best Django host

2009-05-19 Thread Zain Memon
http://djangofriendly.com/

On Tue, May 19, 2009 at 6:21 PM, LeonTheCleaner wrote:

>
> Hi,
>
> I currently use dreamhost, but the installation process is very slow.
> Is it me or this process is overly complicated? All I want is to
> install an already written django project but to do that it's like I
> have to write the app myself.
>
> I read about dreamhost being not the best, but it's listed at #2 on
> django website. Should I use that for my site or buy one of the
> packages that features 1-click install, like: http://djangohosting.ch?
>
> I would appreciate if someone can help me out.
>
>
>
>
> 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: Formwizard with inlines

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 8:53 PM, ringemup  wrote:

>
> This ticket indicates that formsets can't be used with FormWizards
> ( http://code.djangoproject.com/ticket/2 ).  Does that also mean
> that inlineformsets are also no go?
>
> Thanks!
> >
>
Yes, inline formsets are a subclass of formsets.

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



Formwizard with inlines

2009-05-19 Thread ringemup

This ticket indicates that formsets can't be used with FormWizards
( http://code.djangoproject.com/ticket/2 ).  Does that also mean
that inlineformsets are also no go?

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



Best Django host

2009-05-19 Thread LeonTheCleaner

Hi,

I currently use dreamhost, but the installation process is very slow.
Is it me or this process is overly complicated? All I want is to
install an already written django project but to do that it's like I
have to write the app myself.

I read about dreamhost being not the best, but it's listed at #2 on
django website. Should I use that for my site or buy one of the
packages that features 1-click install, like: http://djangohosting.ch?

I would appreciate if someone can help me out.




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: Installing django

2009-05-19 Thread LeonTheCleaner

Thanks for replying. I wanted to do that, but I canèt find the file. I
use win btw.

Also I am trying to install this on my host (dreamhost). Am I supposed
to do this operation on my machineÉ



Thanks.

On May 19, 4:27 pm, Aneesh  wrote:
> What operating system are you using?  If it's unix, Linux, or Mac OS
> X, there should be a file named ".bash_profile" in your home directory
> (if you're using bash).  You can run the export statements directly
> from a shell prompt on any of these OS-es.  You should also put the
> export statements in the .bash_profile (anywhere in that file is file)
>
> On May 19, 2:06 pm, LeonTheCleaner  wrote:
>
>
>
> > Hi,
>
> > I am trying to install django by using this:
>
> >http://wiki.dreamhost.com/Django
>
> > but there are a few things I don't understand.
>
> > 1. Where am I supposed to run stuff like these:
>
> > export PATH=$PATH:$HOME/django_src/django/bin
> > export PYTHONPATH=$PYTHONPATH:$HOME/django_src:$HOME/django_projects
>
> > 2. Also where is the .base_profile? Am I supposed to locate it
> > manually?
>
> > Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Raises Http404 from Middleware?

2009-05-19 Thread ringemup

Yikes.  Is there any workaround?  Say, calling process_exception() on
whatever middleware class usually handles this stuff?

On May 19, 8:56 pm, Alex Gaynor  wrote:
> On Tue, May 19, 2009 at 7:54 PM, ringemup  wrote:
>
> > When I raise a 404 exception from a middleware process_request method,
> > the traceback is posted to the browser instead of a proper debug error
> > page.  Is there something special one has to do in order to properly
> > return a 404 page from middleware?
>
> > Thanks!
>
> No, this is a known bug in Django:http://code.djangoproject.com/ticket/6094
>
> 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: Raises Http404 from Middleware?

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 7:54 PM, ringemup  wrote:

>
> When I raise a 404 exception from a middleware process_request method,
> the traceback is posted to the browser instead of a proper debug error
> page.  Is there something special one has to do in order to properly
> return a 404 page from middleware?
>
> Thanks!
> >
>
No, this is a known bug in Django: http://code.djangoproject.com/ticket/6094

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



Raises Http404 from Middleware?

2009-05-19 Thread ringemup

When I raise a 404 exception from a middleware process_request method,
the traceback is posted to the browser instead of a proper debug error
page.  Is there something special one has to do in order to properly
return a 404 page from middleware?

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: ForeignKeyRawId widget contains incorrect link when you click on search gif?

2009-05-19 Thread Margie

One more thing - when I first noticed the bug, I was using
admin.site.root in the urls reference.  But when pruning down the test
case I moved to including admin.site.urls - that seemed to make no
difference.

Margie

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

2009-05-19 Thread Karen Tracey
On Tue, May 19, 2009 at 7:36 PM, eric  wrote:

>
> Hi
>
> I know it is just an tutorial, but I would like to know how you handle
> this issue.
>
> this is the code in 4th tutorial:
> {{{
> def vote(request, poll_id):
>p = get_object_or_404(Poll, pk=poll_id)
>try:
>selected_choice = p.choice_set.get(pk=request.POST['choice'])
>except (KeyError, Choice.DoesNotExist):
>return render_to_response('polls/detail.html', {
>'poll': p,
>'error_message': "You didn't select a choice.",
>})
>else:
>selected_choice.votes += 1
>selected_choice.save()
>return HttpResponseRedirect(reverse
> ('mysite.polls.views.results', args=(p.id,)))
> }}}
>
> On except you render the same template as the "detail" function to
> show the error message, but at r'^(?P\d+)/vote/$' url. If you
> send the form from that url, it will post the form at r'^(?P\d
> +)/vote/vote/$'.
>
> How to solve that?
>
> I hope I was clear.


It's a test to see if you're paying attention -- you pass :-)

Actually there's a ticket open on this:

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

There you can see what it used to be and just use that instead.

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



Tutorial part 4 doubt

2009-05-19 Thread eric

Hi

I know it is just an tutorial, but I would like to know how you handle
this issue.

this is the code in 4th tutorial:
{{{
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
})
else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse
('mysite.polls.views.results', args=(p.id,)))
}}}

On except you render the same template as the "detail" function to
show the error message, but at r'^(?P\d+)/vote/$' url. If you
send the form from that url, it will post the form at r'^(?P\d
+)/vote/vote/$'.

How to solve that?

I hope I was clear.

thanks in advance

Eric

--~--~-~--~~~---~--~~
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't create django project

2009-05-19 Thread MFA

I'm a rook too and received the same error.

I re-read the installation instructions here:
http://docs.djangoproject.com/en/dev/topics/install/#installing-official-release

It turns out I had to run "python setup.py install".   I believe this
copies the django-admin.py to a location, or places a path variable,
so it is accessible.
Once i ran the command above, i was able to successfully use "django-
admin.py startproject X"

good luck.

On May 19, 1:02 pm, rookie  wrote:
> Hi,
>    I just install django and try to create django project following
> the instruction: django-admin.py startproject mysite
>   However, I got the message sais:  'django-admin.py' is not
> recognized as an internal or external command, operable program or
> batch file.  In pythonwin (Python 2.6 version), import django is no
> problem.   I also got (1, 0, 2, 'final', 0) from typing
> django.VERSION.  So it seems like django was installed successfully.
> Can anyone tell me how to fix the django-admin.py problem?  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: user object in login.html

2009-05-19 Thread Jon

Ah, and if you only want to display a message on the login page,
that's possible too. In that case you don't use the redirect in the
view, but use an if clause in your index.html template.

Something like this:

{% if logged_in %}
  You are logged in already.
{% endif %}

Jon.

On May 20, 2:18 am, Jon  wrote:
> Simply have an 'if logged in:' clause at the beginning of your login
> view definition that redirects to the /loggedin/ view if it matches.
>
> Of course this implies that you know some variable that will always
> match once someone is logged in.
>
> Most likely, django sets this already. If you cannot find one, you
> just set one yourself.
>
> I am new to django, only started learning it last week, so the
> solution may look a bit dirty in the eyes of seasoned django
> developers, but i am sure it will work.
>
> Have a look at the forms chapter, and read about the
> HttpResponseRedirect to see how to go about doing the redirect.
>
> HTH
>
> Jon.
>
> On May 19, 10:43 am, Rok  wrote:
>
> > But what if "user" specify login URL in the browser? He gets login
> > form regardless if he is logged in or not.
>
> > For example I have ( r'^login/$', login ) in urls.py and if I 
> > requesthttp://localhost:8000/login/Iget login form even though I am already
> > logged in; but I want to show some message that he/she is already
> > logged in.
>
> > On 19 maj, 00:41, jon michaels  wrote:
>
> > > From the documentation it seems that it is not only possible, but
> > > required too..
>
> > > login_required() does the following:
>
> > >     * If the user isn't logged in, redirect to settings.LOGIN_URL
> > > (/accounts/login/ by default), passing the current absolute URL in the
> > > query string as next or the value of redirect_field_name. For example:
> > > /accounts/login/?next=/polls/3/.
> > >     * If the user is logged in, execute the view normally. The view
> > > code is free to assume the user is logged in.
> > > [...]
> > > It's your responsibility to provide the login form in a template
> > > called registration/login.html by default. This template gets passed
> > > four template context variables:[...]
>
> > > Source:http://docs.djangoproject.com/en/dev/topics/auth/
>
> > > If this doesn't answer your question, please be more specific about
> > > the context.
>
> > > On Tue, May 19u, 2009 at 1:44 AM, Rok  wrote:
>
> > > > Hello.
>
> > > > Is it possible to use user object in login.html when @login_required
> > > > is used? I want to display login fields only when user is ianonymous.
>
> > > > Thank you.
>
> > > > Kind regards,
>
> > > > Rok
--~--~-~--~~~---~--~~
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: user object in login.html

2009-05-19 Thread Jon


Simply have an 'if logged in:' clause at the beginning of your login
view definition that redirects to the /loggedin/ view if it matches.

Of course this implies that you know some variable that will always
match once someone is logged in.

Most likely, django sets this already. If you cannot find one, you
just set one yourself.

I am new to django, only started learning it last week, so the
solution may look a bit dirty in the eyes of seasoned django
developers, but i am sure it will work.

Have a look at the forms chapter, and read about the
HttpResponseRedirect to see how to go about doing the redirect.

HTH

Jon.

On May 19, 10:43 am, Rok  wrote:
> But what if "user" specify login URL in the browser? He gets login
> form regardless if he is logged in or not.
>
> For example I have ( r'^login/$', login ) in urls.py and if I 
> requesthttp://localhost:8000/login/I get login form even though I am already
> logged in; but I want to show some message that he/she is already
> logged in.
>
> On 19 maj, 00:41, jon michaels  wrote:
>
> > From the documentation it seems that it is not only possible, but
> > required too..
>
> > login_required() does the following:
>
> >     * If the user isn't logged in, redirect to settings.LOGIN_URL
> > (/accounts/login/ by default), passing the current absolute URL in the
> > query string as next or the value of redirect_field_name. For example:
> > /accounts/login/?next=/polls/3/.
> >     * If the user is logged in, execute the view normally. The view
> > code is free to assume the user is logged in.
> > [...]
> > It's your responsibility to provide the login form in a template
> > called registration/login.html by default. This template gets passed
> > four template context variables:[...]
>
> > Source:http://docs.djangoproject.com/en/dev/topics/auth/
>
> > If this doesn't answer your question, please be more specific about
> > the context.
>
> > On Tue, May 19u, 2009 at 1:44 AM, Rok  wrote:
>
> > > Hello.
>
> > > Is it possible to use user object in login.html when @login_required
> > > is used? I want to display login fields only when user is ianonymous.
>
> > > Thank you.
>
> > > Kind regards,
>
> > > Rok
--~--~-~--~~~---~--~~
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: Conditionally redirecting admin requests?

2009-05-19 Thread ringemup


Answered my own question: yes.  root() just has to return an
HttpResponse.


On May 19, 4:48 pm, ringemup  wrote:
> I need users to have filled out out a form wizard to complete their
> profile before they can use the admin site -- basically to hijack the
> request and redirect it if the profile is incomplete.  Can this be
> accomplished by simply subclassing AdminSite and writing a custom root
> () method?
--~--~-~--~~~---~--~~
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: Creating a custom form from models, problems when ordering

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 2:53 PM, ccsakuweb  wrote:

>
> I have a form from a model. I add 3 new inputs. Then when I write in
> Meta :
> model = models.Table
> fields = ['attribute2', 'newInput1', 'newInput2', 'newInput3',
> 'attribute3']
> for example, the final order is not respect the new inputs. Only
> respect the attributes of the model in the fields array.
> The result in the form is:
> attribute2
> attribute3
> newInput1
> newInput2
> newInput3
>
> Is there any solution to order the new inputs too? Or the solution is
> only to create a form without inheritance from a model?
>
> I hope you understand me. Sorry because my simple english.
>
> >
>
What version of Django are you running?  Ordering fields is only supported
in the latest development version.

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



can't create django project

2009-05-19 Thread rookie

Hi,
   I just install django and try to create django project following
the instruction: django-admin.py startproject mysite
  However, I got the message sais:  'django-admin.py' is not
recognized as an internal or external command, operable program or
batch file.  In pythonwin (Python 2.6 version), import django is no
problem.   I also got (1, 0, 2, 'final', 0) from typing
django.VERSION.  So it seems like django was installed successfully.
Can anyone tell me how to fix the django-admin.py problem?  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
-~--~~~~--~~--~--~---



Creating a custom form from models, problems when ordering

2009-05-19 Thread ccsakuweb

I have a form from a model. I add 3 new inputs. Then when I write in
Meta :
model = models.Table
fields = ['attribute2', 'newInput1', 'newInput2', 'newInput3',
'attribute3']
for example, the final order is not respect the new inputs. Only
respect the attributes of the model in the fields array.
The result in the form is:
attribute2
attribute3
newInput1
newInput2
newInput3

Is there any solution to order the new inputs too? Or the solution is
only to create a form without inheritance from a model?

I hope you understand me. Sorry because my simple english.

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



Conditionally redirecting admin requests?

2009-05-19 Thread ringemup

I need users to have filled out out a form wizard to complete their
profile before they can use the admin site -- basically to hijack the
request and redirect it if the profile is incomplete.  Can this be
accomplished by simply subclassing AdminSite and writing a custom root
() method?
--~--~-~--~~~---~--~~
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: Installing django

2009-05-19 Thread Aneesh

What operating system are you using?  If it's unix, Linux, or Mac OS
X, there should be a file named ".bash_profile" in your home directory
(if you're using bash).  You can run the export statements directly
from a shell prompt on any of these OS-es.  You should also put the
export statements in the .bash_profile (anywhere in that file is file)

On May 19, 2:06 pm, LeonTheCleaner  wrote:
> Hi,
>
> I am trying to install django by using this:
>
> http://wiki.dreamhost.com/Django
>
> but there are a few things I don't understand.
>
> 1. Where am I supposed to run stuff like these:
>
> export PATH=$PATH:$HOME/django_src/django/bin
> export PYTHONPATH=$PYTHONPATH:$HOME/django_src:$HOME/django_projects
>
> 2. Also where is the .base_profile? Am I supposed to locate it
> manually?
>
> Thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ForeignKeyRawId widget contains incorrect link when you click on search gif?

2009-05-19 Thread Margie

When I do that I just get '1.1 beta 1' (no svn revision info).
However, I can see that I am in my newly installed library by putting
pdb.set_trace() into the code.


I checked it out like this:
  svn co http://code.djangoproject.com/svn/django/trunk/
django_trunk_05_18

At the end it printed:
  Checked out revision 10821.

I installed it with this command:

python setup.py install --prefix /home/mlevine/django/django_libs/
django_trunk_05_18

Then in settings.py and manage.py I insert "/home/mlevine/django/
django_libs/django_trunk_05_18/lib/python2.5/site-packages" at the
front of sys.path.

Does the installation make it so that it doesn't print the svn
revision info?

Margie



On May 19, 1:00 pm, Alex Gaynor  wrote:
> On Tue, May 19, 2009 at 2:21 PM, Margie  wrote:
>
> > I tried it on trunk (checked out yesterday) and I see the problem
> > there as well.  Note, this is in the change list view.  The problem
> > doesn't appear in the edit forf view.  Here's my testcase:
>
> > ### urls.py 
>
> > from django.conf.urls.defaults import *
> > from django.conf import settings
>
> > from django.contrib import admin
> > admin.autodiscover()
>
> > import os
>
> > urlpatterns = patterns('',
> >                       (r'^admin/', include(admin.site.urls)),
> > )
>
> > if settings.SERVE_MEDIA:
> >    urlpatterns += patterns('',
> >        (r'^site_media/(?P.*)$', 'django.views.static.serve',
> >            {'document_root': os.path.join(os.path.dirname(__file__),
> > "site_media")}),
> >    )
>
> > ### models.py 
> > from django.db import models
>
> > class Task(models.Model):
> >    name=models.CharField(max_length=50, blank=True, null=True)
> >    owner = models.ForeignKey('auth.User', blank=True, null=True,
> > related_name="tasks")
>
> > ### admin.py #
> > from django.contrib import admin
> > from taskmanager.models import *
>
> > class TaskAdmin(admin.ModelAdmin):
>
> >    list_display = ('id', 'name', 'owner')
> >    ordering = ('name',)
> >    list_editable = ('owner',)
> >    raw_id_fields = ('owner',)
>
> > admin.site.register(Task ,TaskAdmin)
>
> > How do I identify the version of the code I am running on?
>
> > Margie
>
> > On May 19, 6:16 am, Karen Tracey  wrote:
> > > On Tue, May 19, 2009 at 12:15 AM, Margie 
> > wrote:
>
> > > > I tried using raw_id_fields in admin for the first time (using the
> > > > Django 1.1 beta).  When I click search gif I find that it tries to
> > > > redirect me to:
>
> > > >http://mysite.com/auth/user/?t=id
>
> > > > Seems to me it should be redirecting me to this instead (note addition
> > > > of admin):
>
> > > >http://myste.com/admin/auth/user/?t=id
>
> > > > Isn't this a bug?  If so, I can post it, just wanted to get input
> > > > first in case I am missing something.
>
> > > I can't recreate this with either the alpha or current trunk level (don't
> > > have beta set up to test easily at the moment).  I tried both the 1.0
> > style
> > > of urlpattern (referencing admin.site.root) for admin and 1.1 (including
> > > admin.site.urls).  Which are you using?  Perhaps more details on the
> > > specifics of your admin configuration would shed some light.
>
> > > Karen
>
> import django
> django.get_version()
>
> should print the current version (including the svn revision if you're using
> SVN)
>
> 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: User attribute access from within profile model

2009-05-19 Thread Sam Chuparkoff

On Tue, 2009-05-19 at 12:12 -0700, neridaj wrote:
> There are attributes for first_name and last_name, why wouldn't
> user.first_name work?

I'd expect an AttributeError is you are accessing an attribute that
doesn't exist. Thus my assumption.

sdc



--~--~-~--~~~---~--~~
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: ForeignKeyRawId widget contains incorrect link when you click on search gif?

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 2:21 PM, Margie  wrote:

>
> I tried it on trunk (checked out yesterday) and I see the problem
> there as well.  Note, this is in the change list view.  The problem
> doesn't appear in the edit forf view.  Here's my testcase:
>
> ### urls.py 
>
> from django.conf.urls.defaults import *
> from django.conf import settings
>
> from django.contrib import admin
> admin.autodiscover()
>
> import os
>
> urlpatterns = patterns('',
>   (r'^admin/', include(admin.site.urls)),
> )
>
>
> if settings.SERVE_MEDIA:
>urlpatterns += patterns('',
>(r'^site_media/(?P.*)$', 'django.views.static.serve',
>{'document_root': os.path.join(os.path.dirname(__file__),
> "site_media")}),
>)
>
> ### models.py 
> from django.db import models
>
> class Task(models.Model):
>name=models.CharField(max_length=50, blank=True, null=True)
>owner = models.ForeignKey('auth.User', blank=True, null=True,
> related_name="tasks")
>
> ### admin.py #
> from django.contrib import admin
> from taskmanager.models import *
>
> class TaskAdmin(admin.ModelAdmin):
>
>list_display = ('id', 'name', 'owner')
>ordering = ('name',)
>list_editable = ('owner',)
>raw_id_fields = ('owner',)
>
>
> admin.site.register(Task ,TaskAdmin)
>
> How do I identify the version of the code I am running on?
>
> Margie
>
>
>
> On May 19, 6:16 am, Karen Tracey  wrote:
> > On Tue, May 19, 2009 at 12:15 AM, Margie 
> wrote:
> >
> > > I tried using raw_id_fields in admin for the first time (using the
> > > Django 1.1 beta).  When I click search gif I find that it tries to
> > > redirect me to:
> >
> > >http://mysite.com/auth/user/?t=id
> >
> > > Seems to me it should be redirecting me to this instead (note addition
> > > of admin):
> >
> > >http://myste.com/admin/auth/user/?t=id
> >
> > > Isn't this a bug?  If so, I can post it, just wanted to get input
> > > first in case I am missing something.
> >
> > I can't recreate this with either the alpha or current trunk level (don't
> > have beta set up to test easily at the moment).  I tried both the 1.0
> style
> > of urlpattern (referencing admin.site.root) for admin and 1.1 (including
> > admin.site.urls).  Which are you using?  Perhaps more details on the
> > specifics of your admin configuration would shed some light.
> >
> > Karen
> >
>
import django
django.get_version()

should print the current version (including the svn revision if you're using
SVN)

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: ForeignKeyRawId widget contains incorrect link when you click on search gif?

2009-05-19 Thread Margie

I tried it on trunk (checked out yesterday) and I see the problem
there as well.  Note, this is in the change list view.  The problem
doesn't appear in the edit forf view.  Here's my testcase:

### urls.py 

from django.conf.urls.defaults import *
from django.conf import settings

from django.contrib import admin
admin.autodiscover()

import os

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


if settings.SERVE_MEDIA:
urlpatterns += patterns('',
(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': os.path.join(os.path.dirname(__file__),
"site_media")}),
)

### models.py 
from django.db import models

class Task(models.Model):
name=models.CharField(max_length=50, blank=True, null=True)
owner = models.ForeignKey('auth.User', blank=True, null=True,
related_name="tasks")

### admin.py #
from django.contrib import admin
from taskmanager.models import *

class TaskAdmin(admin.ModelAdmin):

list_display = ('id', 'name', 'owner')
ordering = ('name',)
list_editable = ('owner',)
raw_id_fields = ('owner',)


admin.site.register(Task ,TaskAdmin)

How do I identify the version of the code I am running on?

Margie



On May 19, 6:16 am, Karen Tracey  wrote:
> On Tue, May 19, 2009 at 12:15 AM, Margie  wrote:
>
> > I tried using raw_id_fields in admin for the first time (using the
> > Django 1.1 beta).  When I click search gif I find that it tries to
> > redirect me to:
>
> >http://mysite.com/auth/user/?t=id
>
> > Seems to me it should be redirecting me to this instead (note addition
> > of admin):
>
> >http://myste.com/admin/auth/user/?t=id
>
> > Isn't this a bug?  If so, I can post it, just wanted to get input
> > first in case I am missing something.
>
> I can't recreate this with either the alpha or current trunk level (don't
> have beta set up to test easily at the moment).  I tried both the 1.0 style
> of urlpattern (referencing admin.site.root) for admin and 1.1 (including
> admin.site.urls).  Which are you using?  Perhaps more details on the
> specifics of your admin configuration would shed some light.
>
> 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: User attribute access from within profile model

2009-05-19 Thread neridaj

There are attributes for first_name and last_name, why wouldn't
user.first_name work?

On May 19, 1:15 am, Ayaz Ahmed Khan  wrote:
> On 19-May-09, at 5:12 AM, neri...@gmail.com wrote:
>
> > class Employee(models.Model):
> >  user= models.ForeignKey(User, unique=True)
> >   phone = PhoneNumberField()
> >   ssn = models.CharField(max_length=11)
> >   address = models.CharField(max_length=50)
> >   city = models.CharField(max_length=30)
> >   state = USStateField(default='WA')
> >   zip_code = models.CharField(max_length=10)
>
> >   def __unicode__(self):
> >       return self.user.full_name
>
> Is there anattributeor property that goes by the name `full_name`
> defined on theUsermodel? As far as I can tell, no. You can, however,
> get to the full name associated with aUserinstance by calling 
> theUser.get_full_name() method.
>
> --
> Ayaz Ahmed Khan
>
> If I'd known computer science was going to be like this, I'd never
> have given up being a rock 'n' roll star.
>          -- G. Hirst
--~--~-~--~~~---~--~~
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: MultiValueField with required=True problem

2009-05-19 Thread Sam Chuparkoff

On Mon, 2009-05-18 at 10:13 -0700, [CPR]-AL.exe wrote:
> I've created a field+widget set that i use to render a number of
> checkboxes and a TextInput with comma-separated values.
> 
> The problem is, when i set required = True, I get a ValidationError if
> only checkboxes are selected (but i don't get it if TextInput is
> filled)

At least in 1.0.x, MultiValueField.clean will throw a validation error
if self.required is True and one of that values in the value array is
empty. I'm looking at django/forms/fields.py:800 :

if self.required and field_value in EMPTY_VALUES:
raise ValidationError(self.error_messages['required'])

I don't understand why this should be the case, but if I'm reading
correctly then you are reporting correctly as well :). Hope that
helps.

sdc



--~--~-~--~~~---~--~~
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: Separate User namespace

2009-05-19 Thread Timboy

Initially we will have in the ballpark of 10,000 Private users. Anyone
have an idea on an additional user namespace?



On May 19, 8:42 am, Aneesh  wrote:
> How many private users do you have?  If it's just a small number,
> consider using the same model for all Users, and making some profiles
> public/private.  A couple usernames will be taken, but that shouldn't
> be a big deal.
>
> If you actually want a second namespace, I'm not sure of the best way
> to proceed.
>
> On May 18, 9:28 pm, Timboy  wrote:
>
> > I have a normal User model for our private users of our project we
> > also have a UserProfile for those users.
>
> > We need to have a public portion of our site as well with a separate
> > user namespace.
>
> > Please advise the best way to achieve our goal.
>
> > TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HTML works directly in browser, but not in DJango... Why???

2009-05-19 Thread Colin Bean

On Tue, May 19, 2009 at 11:44 AM, Alex Gaynor  wrote:
>
>
> On Tue, May 19, 2009 at 1:42 PM, Social Network in DJango
>  wrote:
>>
>> I put the below code to embed an mp3 file in an html page in an html
>> file and pointed my browser to it.  It works.
>>
>> I then try
>>     url(r'^$','django.views.generic.simple.direct_to_template',
>> {"template": "wimpybutton.html"}, name="home"),
>>
>> Then, http://127.0.0.1:8080/
>>
>> I do not see the button. I view page source.  The page source is
>> identical to the below.
>>
>> Please let me know how I can see the button and hear the music from
>> DJango if I already can do so in html.
>>
>> Thank you in advance,
>>
>> Jonathan
>>
>>
>>
>>
>> 
>> > codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/
>> swflash.cab#version=8,0,0,0" width="35" height="35"
>> id="wimpybutton288">
>> 
>> 
>> 
>> 
>> 
>> 
>> > bgcolor="#FF" loop="false" menu="false" quality="high"
>> name="wimpybutton288" align="middle" allowScriptAccess="sameDomain"
>> type="application/x-shockwave-flash" pluginspage="http://
>> www.macromedia.com/go/getflashplayer" />
>> 
>> 
>>
>
> The browser probably isn't rendering it because there are no starting 
> tag, or  tag, which are required by the spec AFAIK.
>
> 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
>
> >
>

Also, your embed code is trying load several things (flash file, MP3
file) from a "file:///" url.  Your browser might have a problem with
this (cross domain restrictions).  I'd try serving all of your static
resources through django (of course you'll want to use something else
for static media when if you put this into production).

Colin

--~--~-~--~~~---~--~~
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 work with web service in django

2009-05-19 Thread LiLi
hey nick!

 tnx for advice.. I will try those things :)





From: Nick Lo 
To: django-users@googlegroups.com
Sent: Tuesday, May 19, 2009 1:36:35 AM
Subject: Re: how to work with web service in django


Hello,

> I'm trying to make application in wich you will search some product  
> and  for response my application will list you products from other  
> pages(for example amazon or some e-shop).. I want to do it with web  
> service and I have no idea where to start..does someone know how to  
> do it? Or give me some link where I can see how to work with web  
> services in django?! What do you think that will be best choice for  
> this problem?


You're talking about being a client of web services rather than a  
server so it's often as simple as just querying the relevant web  
service from your views.py file. Using Amazon as an example:

http://code.djangoproject.com/wiki/WebServices

http://pyaws.sourceforge.net/

The quick start in that second link shows how simple it could be. Just  
use that example in views.py and pass the info to your template. Then  
since you're going to be making queries to a service that, depending  
on your network, may or may be available or may be slow, take a look  
at caching that information.

Nick



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



Re: HTML works directly in browser, but not in DJango... Why???

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 1:42 PM, Social Network in DJango <
readb...@gmail.com> wrote:

>
> I put the below code to embed an mp3 file in an html page in an html
> file and pointed my browser to it.  It works.
>
> I then try
> url(r'^$','django.views.generic.simple.direct_to_template',
> {"template": "wimpybutton.html"}, name="home"),
>
> Then, http://127.0.0.1:8080/
>
> I do not see the button. I view page source.  The page source is
> identical to the below.
>
> Please let me know how I can see the button and hear the music from
> DJango if I already can do so in html.
>
> Thank you in advance,
>
> Jonathan
>
>
>
>
> 
>  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/
> swflash.cab#version=8,0,0,0"
> width="35" height="35"
> id="wimpybutton288">
> 
> 
> 
> 
> 
> 
>  bgcolor="#FF" loop="false" menu="false" quality="high"
> name="wimpybutton288" align="middle" allowScriptAccess="sameDomain"
> type="application/x-shockwave-flash" pluginspage="http://
> www.macromedia.com/go/getflashplayer" />
> 
> 
> >
>
The browser probably isn't rendering it because there are no starting 
tag, or  tag, which are required by the spec AFAIK.

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



HTML works directly in browser, but not in DJango... Why???

2009-05-19 Thread Social Network in DJango

I put the below code to embed an mp3 file in an html page in an html
file and pointed my browser to it.  It works.

I then try
 url(r'^$','django.views.generic.simple.direct_to_template',
{"template": "wimpybutton.html"}, name="home"),

Then, http://127.0.0.1:8080/

I do not see the button. I view page source.  The page source is
identical to the below.

Please let me know how I can see the button and hear the music from
DJango if I already can do so in html.

Thank you in advance,

Jonathan





http://download.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=8,0,0,0" width="35" height="35"
id="wimpybutton288">









--~--~-~--~~~---~--~~
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: http://127.0.0.1:8000/admin/admin/logout/ (duplicate admin)

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 1:20 PM, Jesse  wrote:

>
> Thanks!  I'm in the middle of reloading everything again, because I
> thought it was something I had done.  Good to know that wasn't the
> case and glad they are working on it.
> Thanks, again!
>
> On May 19, 11:11 am, Reiner  wrote:
> > I stumbled across this bug too some days ago, it is already known and
> > being worked on, it is one of the tickets that need to be fixed in
> > order to ship django 1.1.
> >
> > http://code.djangoproject.com/ticket/10061
> >
> > If you need a quick fix, have a look at the comment by carljm:
> http://code.djangoproject.com/ticket/10061#comment:23
> >
> > On May 19, 7:57 pm, Jesse  wrote:
> >
> > > I'm setting up a new server with Apache/mod_python on windows.  I can
> > > see my data on the admin page, but when I log out it is logging out
> > > with two admin/admin and I get an error page not found.  I cannot
> > > figure out why this is happening?
> > > Thx
> >
> >
> >
>
Yep, the patch on there should *just work* after you apply it, and if there
are any issues with it please note them on the ticket.

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



Installing django

2009-05-19 Thread LeonTheCleaner

Hi,

I am trying to install django by using this:

http://wiki.dreamhost.com/Django

but there are a few things I don't understand.

1. Where am I supposed to run stuff like these:

export PATH=$PATH:$HOME/django_src/django/bin
export PYTHONPATH=$PYTHONPATH:$HOME/django_src:$HOME/django_projects

2. Also where is the .base_profile? Am I supposed to locate it
manually?




Thanks in advance.

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



Form Help

2009-05-19 Thread eric.frederich

I need a view to edit Enrollment objects for a particular Offering.

An Offering has a foreign key to a Room and a Course.  All three of
these (Offering, Room, and Course) have a maximum capacity field which
can be null (for unlimited).  Offering has a method called
get_max_capacity() which returns the minimum of all 3 maximums or None
if none have them defined.

An Enrollment has a foreign key to User and Offering.

I need a per-offering view of enrollments.  Where the number of forms
is the maximum capacity of the Offering or 3 extra if not defined.  I
would like to edit all fields (except for the foreign key to Offering
since this view is offering specific).

I am having the following problems trying to make the view Offering
specific.

1) Trying to use exclude=('offering',) since all Enrollments in this
view should be for the given offering.

2) Trying to make the view offering specific by using
queryset=offering.enrollment_set.all().

Without 1) or 2) I am able to edit existing Enrollments.  I am able to
create new Enrollments using the empty forms.

When I have exclude=('offering',) I cannot make use of the extra forms
because it will complain about no offering_id being set.

When I use queryset=offering.enrollment_set.all() and I submit, it
complains about all the empty forms not having information in them.

What am I doing wrong?

Here is my template and view code


{% extends "train/base_admin.html" %}
{% block content %}
Enrollments for {{ offering }}

{{ formset.management_form }}
{% for form in formset.forms %}

{{ form }}


{% endfor %}


{% endblock %}


@login_required
def offering_admin(request, location_slug, offering_id):

offering = get_object_or_404(Offering, id=offering_id)

location = get_object_or_404(Location, slug=location_slug)

# We use location in this view just so that urls look similar
# we could get location from offering's room.  Still... make sure
# the url is okay.
if offering.room.location != location:
return showmessage(request, 'Bad url.  Offering / Location
missmatch')

if not request.user.profile.gid in settings.TRAIN_ADMINS
[location.name]:
return showmessage(request, 'You are not an admin for location
%s' % location.long_name)

try:
extra = int(request.REQUEST.get('extra'))
except:
if offering.get_max_capacity():
extra = offering.get_max_capacity() -
offering.enrollment_set.count()
else:
extra = 3

EnrollmentFormSet = modelformset_factory(Enrollment, extra=extra,
exclude=('offering',))

if request.method == 'POST':
formset = EnrollmentFormSet(request.POST, request.FILES)
if formset.is_valid():
print 'VALID!!!'
# do something with the formset.cleaned_data
formset.save()
# calling save may have populated variables (like cost
center when left blank)
# so get it again from the database rather than the
request
#formset = EnrollmentFormSet
(queryset=offering.enrollment_set.all())
else:
#formset = EnrollmentFormSet
(queryset=offering.enrollment_set.all())
formset = EnrollmentFormSet()

return render_to_response(
'train/offering_admin_form.html',
{'offering': offering,
 'formset' : formset,},
context_instance=RequestContext(request)
)

--~--~-~--~~~---~--~~
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: http://127.0.0.1:8000/admin/admin/logout/ (duplicate admin)

2009-05-19 Thread Jesse

Thanks!  I'm in the middle of reloading everything again, because I
thought it was something I had done.  Good to know that wasn't the
case and glad they are working on it.
Thanks, again!

On May 19, 11:11 am, Reiner  wrote:
> I stumbled across this bug too some days ago, it is already known and
> being worked on, it is one of the tickets that need to be fixed in
> order to ship django 1.1.
>
> http://code.djangoproject.com/ticket/10061
>
> If you need a quick fix, have a look at the comment by 
> carljm:http://code.djangoproject.com/ticket/10061#comment:23
>
> On May 19, 7:57 pm, Jesse  wrote:
>
> > I'm setting up a new server with Apache/mod_python on windows.  I can
> > see my data on the admin page, but when I log out it is logging out
> > with two admin/admin and I get an error page not found.  I cannot
> > figure out why this is happening?
> > Thx
>
>
--~--~-~--~~~---~--~~
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: Question: What's the best way to denormalize M2M data?

2009-05-19 Thread Ben Welsh
I'm imagining some pretty simple that would capture the M2M
relationship, like this slightly modified one from the Django docs

models:
http://www.djangoproject.com/documentation/models/many_to_many/

picklefield:
http://www.djangosnippets.org/snippets/513/

from django.db import models
from utils.fields import PickleField

class Publication(models.Model):
title = models.CharField(max_length=30)

def __unicode__(self):
return self.title

class Meta:
ordering = ('title',)

class Article(models.Model):
headline = models.CharField(max_length=100)
publications = models.ManyToManyField(Publication)
publications_denorm = PickleField(null=True, editable=False)

def __unicode__(self):
return self.headline

class Meta:
ordering = ('headline',)

def save(self):
  print "Before", self.publications.all()
  super(Article, self).save()
  print "after", self.publications.all()


But my efforts to pull things like this off have been frustrated by being
unable to be a signals to do the necessary filling in of the _denorm field.
As described here:
http://groups.google.com/group/django-users/browse_thread/thread/99680b69d2d4799c/07093d3695163269

But, to reiterate my first post, this is just one hacky concept that I've
stumbled with. I suspect there might be better concepts back at the drawing
board and wouldn't want to push it as a best practice.


On Tue, May 19, 2009 at 10:12 AM, George Song  wrote:

>
> On 5/19/2009 9:47 AM, Ben Welsh wrote:
> > On Tue, May 19, 2009 at 12:18 AM, George Song  > > wrote:
> >
> >
> > You can always explicitly define the m2m model, then you can override
> > the save() on that model if you like, or use signals like any other
> > model.
> >
> >
> > Perhaps I've fumbled my way past the obvious, but the problem I'm
> > running into with that method is the one described in the link above. It
> > seems the M2M data connections are not inserted into the relational
> > database until a PK has been created and all the signals have already
> > fired.
>
> Can you be more explicit about describing what it is you want to do?
>
> --
> George
>
> >
>

--~--~-~--~~~---~--~~
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: Dynamic ForeignKey using or how ?

2009-05-19 Thread Will Matos

You can use model inheritance

class SomeCommonNameHere(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()

class Casts(SomeCommonNameHere):
somecastfield = models

class Articles(SomeCommonNameHere):
somearticlefield = models...

class Faves(models.Model):
post = models.ForeignKey(SomeCommonNameHere)
user = models.ForeignKey(User,unique=True)

you can then access the subclass' specific fields by referencing:
#where fave is an instance of Faves...  
fave.post.articles.somearticlefield...
 or
fave.post.casts.somecastfield...



You may also want to look at proxy classes.

Checkout
http://docs.djangoproject.com/en/dev/topics/db/models/#multiple-inherita
nce


Will
-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Anakin
Sent: Tuesday, May 19, 2009 5:29 AM
To: Django users
Subject: Dynamic ForeignKey using or how ?


i want to use 2 model in one foreignkey, i think its dynamic
foreignkey

it means;

i have 2 model named screencasts and articles. and i have a fave
model, for favouriting this model entrys. can i use model dynamicly ?

class Articles(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()

class Casts(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()

class Faves(models.Model):
post = models.ForeignKey(CASTS-OR-ARTICLES)
user = models.ForeignKey(User,unique=True)

is it possible ?

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: Django version

2009-05-19 Thread Zain Memon
import djangodjango.get_version()

On Tue, May 19, 2009 at 10:47 AM, VidrSan  wrote:

>
> How can I see django version on my web-server? Just python's code,
> beaucause I can't find any information on hosting
>
> >
>

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



http://127.0.0.1:8000/admin/admin/logout/ (duplicate admin)

2009-05-19 Thread Jesse

I'm setting up a new server with Apache/mod_python on windows.  I can
see my data on the admin page, but when I log out it is logging out
with two admin/admin and I get an error page not found.  I cannot
figure out why this is happening?
Thx
--~--~-~--~~~---~--~~
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 version

2009-05-19 Thread VidrSan

How can I see django version on my web-server? Just python's code,
beaucause I can't find any information on hosting

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



Admin formating for inline, fieldsets don't work?

2009-05-19 Thread Keith Pettit
In the admin pages I'm using a parent that can have multiple child objects.
For display I'm using inlines in my admin.py.   The parent displays fine and
the child displays fine using inlines but I can't seem to find out a way to
control the formating of the inline child objects.

This is a example of the admin.py I have.  Ticket being the parent, and load
being the child.

from ticket.models import Load, Ticket

class LoadsInline(admin.TabularInline):
  model = Load

class TicketAdmin(admin.ModelAdmin):
  inlines = [LoadsInline,]
  list_display = ('id', 'type', 'unload_date', 'transporter', 'shipper',
'receiver')

admin.site.register(Ticket, TicketAdmin)
admin.site.register(Load)


I've tried various fieldset options but for the child inline "Load" it
dosen't seem to matter if I but the fieldsets under Ticket or Load, the
admin site dosen't pay attention to the formating I set.

So long story short, how can do something simlar to the fieldsets option
with inlines?

Thanks


-- 
Keith Pettit

--~--~-~--~~~---~--~~
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: MultiValueField with required=True problem

2009-05-19 Thread [CPR]-AL.exe

It is required

On 19 май, 08:05, Thierry  wrote:
> Isn't required the default behaviour of Field:
>
> http://docs.djangoproject.com/en/dev/ref/forms/fields/
>
> From the above code, TextInput is required:
>
> forms.TextInput(),
>
> On May 18, 1:15 pm, "[CPR]-AL.exe"  wrote:
>
> > class CheckboxSelectWithTextInputWidget(forms.MultiWidget):
>
> >     def __init__(self,choices, attrs=None):
>
> >         widgets = (
> >             forms.CheckboxSelectMultiple(choices = choices),
> >             forms.TextInput(),
> >         )
> >         super(CheckboxSelectWithTextInputWidget,self).__init__
> > (widgets,attrs)
>
> >     def decompress(self,value):
> >         print "widget value in decompress for checkbox-with-textinput:
> > %s" % str(value)
> >         if value:
> >             return value.split(',')
> >         return [None,None]
>
> >     def format_output(self, rendered_widgets):
>
> >         rendered_widgets[0] = u"выберите: " + rendered_widgets[0]
> >         rendered_widgets[1] = u"и (или) впишите свои значения через
> > запятую: " + rendered_widgets[1]
>
> >         return u''.join(rendered_widgets)
>
> > class CheckboxSelectWithTextInput(forms.MultiValueField):
>
> >     widget = CheckboxSelectWithTextInputWidget
>
> >     def __init__(self, choices, *args, **kwargs):
> >         print 'CheckboxSelectWithTextInput initialised'
> >         self.choices = choices
>
> >         widgets = CheckboxSelectWithTextInputWidget(choices)
> >         fields=(forms.MultipleChoiceField(choices = self.choices,
> > label = u"выберите", required = False), forms.CharField(label =
> > u"впишите свои значения", required = False))
> >         super(CheckboxSelectWithTextInput, self).__init__(fields,
> > widget=widgets, *args, **kwargs)
>
> >     def compress(self, data_list):
> >         print "data list for from-to-range: %s" % data_list
> >         try:
> >             result = data_list[0]       #добавим в вывод значения из
> > чекбоксов
>
> >             #заберем из поля ввода и разделим запятыми введенные
> > дополнительные варианты:
> >             additional_result = data_list[1].split(",")
>
> >             #порежем лишние пробелы и пустые значения и добавим к
> > результирующему массиву элементы из текстового поля:
> >             for word in additional_result:
> >                 if word.strip():
> >                     result.append(word.strip())
>
> >         except IndexError:
> >             result = u""
>
> >         return result
>
>
--~--~-~--~~~---~--~~
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: Question: What's the best way to denormalize M2M data?

2009-05-19 Thread George Song

On 5/19/2009 9:47 AM, Ben Welsh wrote:
> On Tue, May 19, 2009 at 12:18 AM, George Song  > wrote:
> 
> 
> You can always explicitly define the m2m model, then you can override
> the save() on that model if you like, or use signals like any other
> model.
> 
> 
> Perhaps I've fumbled my way past the obvious, but the problem I'm 
> running into with that method is the one described in the link above. It 
> seems the M2M data connections are not inserted into the relational 
> database until a PK has been created and all the signals have already 
> fired.

Can you be more explicit about describing what it is you want to do?

-- 
George

--~--~-~--~~~---~--~~
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: Question: What's the best way to denormalize M2M data?

2009-05-19 Thread Ben Welsh
On Tue, May 19, 2009 at 12:18 AM, George Song  wrote:

>
> You can always explicitly define the m2m model, then you can override
> the save() on that model if you like, or use signals like any other model.
>
>
Perhaps I've fumbled my way past the obvious, but the problem I'm running
into with that method is the one described in the link above. It seems the
M2M data connections are not inserted into the relational database until a
PK has been created and all the signals have already fired.

--~--~-~--~~~---~--~~
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: upload_to usage

2009-05-19 Thread Alex Rades

On Tue, May 12, 2009 at 1:02 PM, Alex Gaynor  wrote:

> The reason the model isn't saved at thie point is because Django stores the
> path to the file in the DB.  This means it has to know the path to the file
> in order to save it.  However, you want it to save it in order to construct
> the path to the file.  I'd solve this by using a post_save handler to move
> the file and resave the object with the new location.
>
Yeah, went that way. Not very clean imho, but I don't see cleaner ways.

--~--~-~--~~~---~--~~
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: additional data on ManyToManyField and symmetrical

2009-05-19 Thread Alex Rades

On Mon, May 18, 2009 at 2:13 AM, Russell Keith-Magee
 wrote:

> When you have a symmetrical m2m relation to self, Django needs to
> store 2 rows in the m2m table to fully represent the relation - that
> is, when you store a 'friendship' between Alice and Bob, Django stores
> the relationship (alice, bob) and the relationship (bob, alice).
>
> This poses a problem when you are using an intermediate m2m table:
> what happens to the other data in the m2m table? Do you duplicate the
> intermediate data? How do you guarantee consistency? If I modify the
> m2m relation in one direction, what updates the row in the other
> direction?
>
> If anyone comes up with a creative way to address this issue, I'm
> certainly willing to entertain those ideas. However, in the interim,
> Django takes the conservative path, preventing behaviour that is
> predictably problematic.
>

Hi Russ,
never thought of this...

But...
If we have a relation between Alice and Bob, we could save just one
relationship with the intermediate data, and when we access the
symmetrical m2m field, we could use an UNION to retrieve relations
from both Alice and Bob.

For example in this situation:

class Person(models.Model):
   friends = models.ManyToManyField("self", through="Friendship")

class Friendship(models.Model):
  person_a = models.ForeignKey(Person)
  person_b = models.ForeignKey(Person, related_name="_unused_")

and  p is a  Person with some friends, accessing p.friends could
result in something like:

SELECT DISTINCT person_a as friend_id FROM friendship WHERE person_b = p.pk
UNION
SELECT DISTINCT person_b as friend_Id FROM friendship WHERE person_a = p.pk

Probably this could be done without the UNION using an OR, but I'm no
sql guru :(

I think this is crucial to represent the typical "friendship" model,
infact Pinax is currently using some workarounds to overcome this
limitation.

What  do you think?

--~--~-~--~~~---~--~~
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: Oracle and Primary Keys

2009-05-19 Thread Tim Sawyer

On Tuesday 19 May 2009 16:20:58 Karen Tracey wrote:
> On Tue, May 19, 2009 at 10:51 AM, Tim Sawyer wrote:
> > It hasn't created a sequence/trigger for the primary key.  Why is this? 
> > It does work for tables that have an implicit primary key (ie not
> > specified in the
> > model.)
>
> I'd guess because you made it a simple IntegerField rather than an
> AutoField.  If you want it to be automatically assigned and incremented you
> need to make it an AutoField:
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#autofield

Excellent, thanks

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: Separate User namespace

2009-05-19 Thread Aneesh

How many private users do you have?  If it's just a small number,
consider using the same model for all Users, and making some profiles
public/private.  A couple usernames will be taken, but that shouldn't
be a big deal.

If you actually want a second namespace, I'm not sure of the best way
to proceed.

On May 18, 9:28 pm, Timboy  wrote:
> I have a normal User model for our private users of our project we
> also have a UserProfile for those users.
>
> We need to have a public portion of our site as well with a separate
> user namespace.
>
> Please advise the best way to achieve our goal.
>
> TIA
--~--~-~--~~~---~--~~
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: Oracle and Primary Keys

2009-05-19 Thread Karen Tracey
On Tue, May 19, 2009 at 10:51 AM, Tim Sawyer wrote:

>
> Hi,
>
> I have a django model that looks like this:
>
> class Lender(models.Model):
>id = models.IntegerField(primary_key=True, db_column='lse_serial')
>version = models.IntegerField(db_column='lse_version')
>name = models.CharField(max_length=50, db_column='lse_lender')
>uri = models.TextField(db_column='lse_lender_uri')
>
>def __unicode__(self):
>return self.name
>
>class Meta:
>ordering = ['name']
>db_table = 'lender_service_endpoints'
>
> I'm connecting to an Oracle database.  If I do a
>
> python manage.py sqlall home
>
> I get the following SQL:
>
> CREATE TABLE "LENDER_SERVICE_ENDPOINTS" (
>"LSE_SERIAL" NUMBER(11) NOT NULL PRIMARY KEY,
>"LSE_VERSION" NUMBER(11) NOT NULL,
>"LSE_LENDER" NVARCHAR2(50) NULL,
>"LSE_LENDER_URI" NCLOB NULL
> )
> ;
> COMMIT;
>
> It hasn't created a sequence/trigger for the primary key.  Why is this?  It
> does work for tables that have an implicit primary key (ie not specified in
> the
> model.)
>

I'd guess because you made it a simple IntegerField rather than an
AutoField.  If you want it to be automatically assigned and incremented you
need to make it an AutoField:

http://docs.djangoproject.com/en/dev/ref/models/fields/#autofield

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: Parsing the arguments in HTTP GET

2009-05-19 Thread Andrew Ingram

I've used the forms framework with GET (I'm using it for a search form
and a 'q' parameter), but it never occurred to me to use it to
validate non-form parameters.

Thanks!

- Andrew Ingram

2009/5/19 Russell Keith-Magee :
>
> On Tue, May 19, 2009 at 10:38 PM, Andrew Ingram  wrote:
>>
>> This is the only real way to do this with Django, though I do wish
>> there was a core Django way to validate GET params, ie which ones are
>> allowed and what format they should be.
>
> You mean, something like the Forms framework? :-)
>
> Ordinarily, the Forms framework is used to handle inputs submitted
> using HTML  elements via a HTTP POST, but the Forms framework
> will work just as well with request.GET. Your Form definition can
> declare the get arguments that will be accepted, perform validation on
> them if required, specify default values, specify required arguments,
> and cross validate between optional arguments (i.e., if you specify x,
> you must specify y, but you can't specify z as well).
>
> The fact that you will never use the rendering portion of the Form
> doesn't matter at all - you just use the validation part that you
> require.
>
> 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
-~--~~~~--~~--~--~---



Oracle and Primary Keys

2009-05-19 Thread Tim Sawyer

Hi,

I have a django model that looks like this:

class Lender(models.Model):
id = models.IntegerField(primary_key=True, db_column='lse_serial')
version = models.IntegerField(db_column='lse_version')
name = models.CharField(max_length=50, db_column='lse_lender')
uri = models.TextField(db_column='lse_lender_uri')

def __unicode__(self):
return self.name

class Meta:
ordering = ['name']
db_table = 'lender_service_endpoints'

I'm connecting to an Oracle database.  If I do a 

python manage.py sqlall home

I get the following SQL:

CREATE TABLE "LENDER_SERVICE_ENDPOINTS" (
"LSE_SERIAL" NUMBER(11) NOT NULL PRIMARY KEY,
"LSE_VERSION" NUMBER(11) NOT NULL,
"LSE_LENDER" NVARCHAR2(50) NULL,
"LSE_LENDER_URI" NCLOB NULL
)
;
COMMIT;

It hasn't created a sequence/trigger for the primary key.  Why is this?  It 
does work for tables that have an implicit primary key (ie not specified in the 
model.)

I'm using django 1.0.2.

Cheers,

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: Parsing the arguments in HTTP GET

2009-05-19 Thread Russell Keith-Magee

On Tue, May 19, 2009 at 10:38 PM, Andrew Ingram  wrote:
>
> This is the only real way to do this with Django, though I do wish
> there was a core Django way to validate GET params, ie which ones are
> allowed and what format they should be.

You mean, something like the Forms framework? :-)

Ordinarily, the Forms framework is used to handle inputs submitted
using HTML  elements via a HTTP POST, but the Forms framework
will work just as well with request.GET. Your Form definition can
declare the get arguments that will be accepted, perform validation on
them if required, specify default values, specify required arguments,
and cross validate between optional arguments (i.e., if you specify x,
you must specify y, but you can't specify z as well).

The fact that you will never use the rendering portion of the Form
doesn't matter at all - you just use the validation part that you
require.

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: Restricting fields to certain users in admin

2009-05-19 Thread Matias Surdi

Matias Surdi escribió:
> I need to hide a couple fields from a model depending on the logged in 
> user in the admin interface.
> 
> How would you do this?
> 
> 
> > 
> 


Replying to myself, here is the solution:



class LimitedCustomUserAdmin(UserAdmin):
 inlines = [ProfileAdmin]
 form = forms.CustomUserChangeForm
 fieldsets = (
 (None, {'fields': ('username', 'password')}),
 ('Personal info', {'fields': ('first_name', 'last_name', 
'email')}),
 ('Permissions', {'fields': ('is_staff', 'is_active', 
'is_superuser')}),
 ('Important dates', {'fields': ('last_login', 'date_joined')}),
 ('Groups', {'fields': ('groups',)}),
 )



class CustomUserAdmin(LimitedCustomUserAdmin):
 fieldsets = (
 (None, {'fields': ('username', 'password')}),
 ('Personal info', {'fields': ('first_name', 'last_name', 
'email')}),
 ('Permissions', {'fields': ('is_staff', 'is_active', 
'is_superuser', 'user_permissions')}),
 ('Important dates', {'fields': ('last_login', 'date_joined')}),
 ('Groups', {'fields': ('groups',)}),
 )
 def __init__(self,*args,**kwargs):
 CustomUserAdmin.limited_user_admin = 
LimitedCustomUserAdmin(*args,**kwargs)
 return super(CustomUserAdmin,self).__init__(*args,**kwargs)

 def __call__(self, *args, **kwargs):
 if get_current_user().is_superuser:
 return super(CustomUserAdmin, self).__call__(*args, **kwargs)
 else:
 return CustomUserAdmin.limited_user_admin(*args,**kwargs)



This way, super_users can view/edit the fields defined in 
CustomUserAdmin and non super_users can view/edit the fields on 
LimitedCustomUserAdmin.


Note: You've to register only CustomUserAdmin with the User 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: MultiValueField with required=True problem

2009-05-19 Thread [CPR]-AL.exe
And so? I don't get you. How can i requere that the user will select a
checkbox OR input some text in TextInput?

2009/5/19 Thierry 

> Isn't required the default behaviour of Field:
>
> http://docs.djangoproject.com/en/dev/ref/forms/fields/
>
> From the above code, TextInput is required:
>
> forms.TextInput(),
>
>
> On May 18, 1:15 pm, "[CPR]-AL.exe"  wrote:
> > class CheckboxSelectWithTextInputWidget(forms.MultiWidget):
> >
> > def __init__(self,choices, attrs=None):
> >
> > widgets = (
> > forms.CheckboxSelectMultiple(choices = choices),
> > forms.TextInput(),
> > )
> > super(CheckboxSelectWithTextInputWidget,self).__init__
> > (widgets,attrs)
> >
> > def decompress(self,value):
> > print "widget value in decompress for checkbox-with-textinput:
> > %s" % str(value)
> > if value:
> > return value.split(',')
> > return [None,None]
> >
> > def format_output(self, rendered_widgets):
> >
> > rendered_widgets[0] = u"выберите: " + rendered_widgets[0]
> > rendered_widgets[1] = u"и (или) впишите свои значения через
> > запятую: " + rendered_widgets[1]
> >
> > return u''.join(rendered_widgets)
> >
> > class CheckboxSelectWithTextInput(forms.MultiValueField):
> >
> > widget = CheckboxSelectWithTextInputWidget
> >
> > def __init__(self, choices, *args, **kwargs):
> > print 'CheckboxSelectWithTextInput initialised'
> > self.choices = choices
> >
> > widgets = CheckboxSelectWithTextInputWidget(choices)
> > fields=(forms.MultipleChoiceField(choices = self.choices,
> > label = u"выберите", required = False), forms.CharField(label =
> > u"впишите свои значения", required = False))
> > super(CheckboxSelectWithTextInput, self).__init__(fields,
> > widget=widgets, *args, **kwargs)
> >
> > def compress(self, data_list):
> > print "data list for from-to-range: %s" % data_list
> > try:
> > result = data_list[0]   #добавим в вывод значения из
> > чекбоксов
> >
> > #заберем из поля ввода и разделим запятыми введенные
> > дополнительные варианты:
> > additional_result = data_list[1].split(",")
> >
> > #порежем лишние пробелы и пустые значения и добавим к
> > результирующему массиву элементы из текстового поля:
> > for word in additional_result:
> > if word.strip():
> > result.append(word.strip())
> >
> > except IndexError:
> > result = u""
> >
> > return result
> >
>


-- 
Sincerely yours, Alexey.

--~--~-~--~~~---~--~~
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: Parsing the arguments in HTTP GET

2009-05-19 Thread Andrew Ingram

This is the only real way to do this with Django, though I do wish
there was a core Django way to validate GET params, ie which ones are
allowed and what format they should be.

- Andrew Ingram

2009/5/19 Will Matos :
>
> You wouldn't match this using a url pattern.  The rest of the query
> string will be in the request.GET list.  So you can do the following:
>
> ui=request.GET['ui']
> shva=request.GET['shva']
> name=request.GET['name']
>
> you'll probably want to check that it exists first by doing:
>  if 'ui' in request.GET:
>    ui=request.GET['ui']
>
> or you can default it by doing:
>  ui=request.GET.get('ui','defaultvalue')
>
>
> W
>
> -Original Message-
> From: django-users@googlegroups.com
> [mailto:django-us...@googlegroups.com] On Behalf Of MohanParthasarathy
> Sent: Friday, May 15, 2009 5:56 PM
> To: Django users
> Subject: Parsing the arguments in HTTP GET
>
>
> Hi,
>
> I am very new to django. I am following along the tutorial. But I want
> to be able to parse the URL which has the following form:
>
> http://example.com/data/?ui=2=1#label=/fetch
>
> From what I can tell, i can't match the whole thing using the url
> pattern. I can parse up till "http://example.com/data; and the rest in
> the code. Where can i find examples/tutorials for the above format ?
>
>
> thanks
> mohan
>
>
>
>
>
> >
>

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



RE: Need help for nested list in template

2009-05-19 Thread Will Matos

In this case a dictionary would not be necessary if he is indeed adding
the model object itself:

>  user_status_list = UserStatus.objects.filter(id =20,time__gte
> = somelist[val], time__lte = somelist[val+1))
>   for item in user_status_list:
>testing_list.append(item)
>

It appears he is appending the UserStatus instance. 

W
-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of Tom Evans
Sent: Tuesday, May 19, 2009 10:33 AM
To: django-users@googlegroups.com
Subject: Re: Need help for nested list in template


On Tue, 2009-05-19 at 06:46 -0700, laspal wrote:
> Hi,
> My model is :
>id  val msg
>20 1234 text
>20 1245text
>20 1275  text
>20 1356  text
> 
> so I have to display record in calendar format.
> I am doing it in this way:
> final_list =[]
> somelist = [1200, 1250, 1300, 1350, 1400]
> val = 0
> i = iter(range(5))
> testing_list =[]
> for item in i:
> user_status_list = UserStatus.objects.filter(id =20,time__gte
> = somelist[val], time__lte = somelist[val+1))
>   for item in user_status_list:
>testing_list.append(item)
> 
> final_list.append(testing_list)
> 
> so my final list should look like:
> 
> [ [  [20, 1234, sdfs], [20, 1245, sdffd]  ],  [ 20,1275, dfdfgf], [ ],
> [20, 1356, dsfdf] ]
> 
> wanted to know How can I use this list in my template.
> for item in final_list:
>  for val in item:
> print val.id, val.val, val.msg
> 
> which is wrong.
> how can I fix this.
> 
> thanks...
> 

Build a dict instead, where you wish to refer to specific elements.

Eg:

foo = [ { 'id': 20, 'name': sdfs, }, { . } ]

and 

{% for item in foo %}
{{ item.name }}
{% endfor %}

Cheers

Tom




--~--~-~--~~~---~--~~
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: Parsing the arguments in HTTP GET

2009-05-19 Thread Will Matos

You wouldn't match this using a url pattern.  The rest of the query
string will be in the request.GET list.  So you can do the following:

ui=request.GET['ui']
shva=request.GET['shva']
name=request.GET['name']

you'll probably want to check that it exists first by doing:
  if 'ui' in request.GET:
ui=request.GET['ui']

or you can default it by doing:
  ui=request.GET.get('ui','defaultvalue')


W

-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of MohanParthasarathy
Sent: Friday, May 15, 2009 5:56 PM
To: Django users
Subject: Parsing the arguments in HTTP GET


Hi,

I am very new to django. I am following along the tutorial. But I want
to be able to parse the URL which has the following form:

http://example.com/data/?ui=2=1#label=/fetch

>From what I can tell, i can't match the whole thing using the url
pattern. I can parse up till "http://example.com/data; and the rest in
the code. Where can i find examples/tutorials for the above format ?


thanks
mohan





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



Re: Need help for nested list in template

2009-05-19 Thread Tom Evans

On Tue, 2009-05-19 at 06:46 -0700, laspal wrote:
> Hi,
> My model is :
>id  val msg
>20 1234 text
>20 1245text
>20 1275  text
>20 1356  text
> 
> so I have to display record in calendar format.
> I am doing it in this way:
> final_list =[]
> somelist = [1200, 1250, 1300, 1350, 1400]
> val = 0
> i = iter(range(5))
> testing_list =[]
> for item in i:
> user_status_list = UserStatus.objects.filter(id =20,time__gte
> = somelist[val], time__lte = somelist[val+1))
>   for item in user_status_list:
>testing_list.append(item)
> 
> final_list.append(testing_list)
> 
> so my final list should look like:
> 
> [ [  [20, 1234, sdfs], [20, 1245, sdffd]  ],  [ 20,1275, dfdfgf], [ ],
> [20, 1356, dsfdf] ]
> 
> wanted to know How can I use this list in my template.
> for item in final_list:
>  for val in item:
> print val.id, val.val, val.msg
> 
> which is wrong.
> how can I fix this.
> 
> thanks...
> 

Build a dict instead, where you wish to refer to specific elements.

Eg:

foo = [ { 'id': 20, 'name': sdfs, }, { . } ]

and 

{% for item in foo %}
{{ item.name }}
{% endfor %}

Cheers

Tom


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



RE: Need help for nested list in template

2009-05-19 Thread Will Matos


{%for item in final_list%}
 {%for val in item%}
{{val.id}}, {{val.val}}, {{val.msg}}
{%endfor%}
{%endfor%}



-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of laspal
Sent: Tuesday, May 19, 2009 9:47 AM
To: Django users
Subject: Need help for nested list in template


Hi,
My model is :
   id  val msg
   20 1234 text
   20 1245text
   20 1275  text
   20 1356  text

so I have to display record in calendar format.
I am doing it in this way:
final_list =[]
somelist = [1200, 1250, 1300, 1350, 1400]
val = 0
i = iter(range(5))
testing_list =[]
for item in i:
user_status_list = UserStatus.objects.filter(id =20,time__gte
= somelist[val], time__lte = somelist[val+1))
  for item in user_status_list:
   testing_list.append(item)

final_list.append(testing_list)

so my final list should look like:

[ [  [20, 1234, sdfs], [20, 1245, sdffd]  ],  [ 20,1275, dfdfgf], [ ],
[20, 1356, dsfdf] ]

wanted to know How can I use this list in my template.
for item in final_list:
 for val in item:
print val.id, val.val, val.msg

which is wrong.
how can I fix this.

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: Many-to-one relations on the "one" side admin form

2009-05-19 Thread diogobaeder

Thanks a lot, Alex! That's exactly what I needed! :-)

Diogo



On May 19, 12:13 am, Alex Gaynor  wrote:
> On Mon, May 18, 2009 at 10:12 PM, Diogo Baeder wrote:
>
> > Hi, guys,
>
> > Is there any way to put a repeatable field (say, many phones) in an admin
> > form (say, a person)? This way a Person could be related to many Phones, but
> > these phones could be inserted right in the Person form... is it possible?
>
> > Thanks!
>
> > __
> > Diogo Baeder
> >http://www.diogobaeder.com.br
>
> Take a look at inlines in the 
> admin:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodelad...
>
> 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: Form Wizard and Saving to Database

2009-05-19 Thread geraldcor

So that's how that works. Brilliant. Thank you. It worked perfectly.

On May 19, 1:43 am, George Song  wrote:
> On 5/18/2009 4:01 PM, geraldcor wrote:
>
> > Hello all,
>
> > I am working on my second Django app and it involves a very long form.
> > I successfully used modelForms in my last app to successfully save
> > form data to a database.
>
> > With this long form, I have split it up into smaller forms (forms.Form
> > not ModelForms) and used the FormWizard to tie it all together. All is
> > well so far. However, now I have no idea how to save the form data
> > from form_list into my database. It is only one table so I don't have
> > any foreign key stuff going on. I just need to save the form data and
> > move on with my life :)
>
> > I have searched the Django site and web extensively and haven't found
> > anything useful about saving data from regular forms or FormWizards.
>
> Just instantiate a new Model object with the form attributes assigned to
> the proper model attributes, and save the object. If you happen to name
> your form fields the same as your model fields, then you can just use
> cleaned_data directly:
>
> {{{
> form_data = {}
> for form in form_list:
>      form_data.update(form.cleaned_data)
> m = Model.objects.create(**form_data)
>
> }}}
>
> --
> George
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Need help for nested list in template

2009-05-19 Thread laspal

Hi,
My model is :
   id  val msg
   20 1234 text
   20 1245text
   20 1275  text
   20 1356  text

so I have to display record in calendar format.
I am doing it in this way:
final_list =[]
somelist = [1200, 1250, 1300, 1350, 1400]
val = 0
i = iter(range(5))
testing_list =[]
for item in i:
user_status_list = UserStatus.objects.filter(id =20,time__gte
= somelist[val], time__lte = somelist[val+1))
  for item in user_status_list:
   testing_list.append(item)

final_list.append(testing_list)

so my final list should look like:

[ [  [20, 1234, sdfs], [20, 1245, sdffd]  ],  [ 20,1275, dfdfgf], [ ],
[20, 1356, dsfdf] ]

wanted to know How can I use this list in my template.
for item in final_list:
 for val in item:
print val.id, val.val, val.msg

which is wrong.
how can I fix this.

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: help on outlook integration

2009-05-19 Thread Karen Tracey
On Tue, May 19, 2009 at 8:54 AM, Chris Withers wrote:

>
> kam wrote:
> > We have to integrate of web outlook using HTTP protocol.  We are
> > trying to connect outlook with form based authentication to connect
> > using HTTP protocol. We are able to connect outlook using HTTPS and
> > COM object but this is not work on Linux & using COM object we are
> > able to access only outlook’s data. We are expecting header cookie and
> > response data from inbox page of outlook.
>
> I don't really understand how posting the same vague requirements once
> every 10-15 minutes is supposed to help other than by annoying everyone
> on this list...
>

It was likely posted 3 times because it was being held for moderation (new
members posts are moderated so as to limit spam on the list), so it seemed
to the poster that  the post didn't go through.  When I see absolutely
identical posts I generally remove all but one, but if there are differences
I let them all through since I don't want to try to sort out which one
contains the most information.   As there were slight differences here I
sent them all through.  So, partly my fault.

We could make the new poster moderation fact more obvious by noting it in
the welcome message but from my experience in using that message on
django-developers to guide people to the right list it will have limited
effect.  People don't read it.  So, best to just try to ignore what look
like repeated questions by newcomers.  It's better than having the list
overrun with spam.

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: model form validation always failing

2009-05-19 Thread Karen Tracey
On Tue, May 19, 2009 at 5:23 AM, watad  wrote:

> i have a model Career
>
> class Career(models.Model):
>  full_name = models.CharField(max_length=200)
>  email = models.EmailField()
>  nationality = CountryField()
>  resume = models.FileField(upload_to='resumes')
>  def __unicode__(self):
>return self.full_name
>
>
> and i have the model form:
> class CareerForm(ModelForm):
>class Meta:
>model = Career
>
> inside my template im using :
>
> {{ form.as_p }} to display the form
>
> i can see the fileds but when i try to submit , the rusume validation
> is always failing (This field is required.)
> although i upload the file, and i was able to add data usign the admin
> interface without any problems
>
> any ideas about this issue


The template (or at least the part that includes the form definition) you
use for the form would have been helpful to post, as  that would have shown
whether you had the enctype="multipart/form-data" mentioned by Thomas.

The other part you haven't shown is how you create the form from the post
data in the view.  My guess would be you are not passing request.FILES in
when you instantiate the form.  See:

http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

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: ForeignKeyRawId widget contains incorrect link when you click on search gif?

2009-05-19 Thread Alex Gaynor
On Tue, May 19, 2009 at 8:16 AM, Karen Tracey  wrote:

> On Tue, May 19, 2009 at 12:15 AM, Margie  wrote:
>
>>
>> I tried using raw_id_fields in admin for the first time (using the
>> Django 1.1 beta).  When I click search gif I find that it tries to
>> redirect me to:
>>
>> http://mysite.com/auth/user/?t=id
>>
>> Seems to me it should be redirecting me to this instead (note addition
>> of admin):
>>
>> http://myste.com/admin/auth/user/?t=id
>>
>> Isn't this a bug?  If so, I can post it, just wanted to get input
>> first in case I am missing something.
>>
>
> I can't recreate this with either the alpha or current trunk level (don't
> have beta set up to test easily at the moment).  I tried both the 1.0 style
> of urlpattern (referencing admin.site.root) for admin and 1.1 (including
> admin.site.urls).  Which are you using?  Perhaps more details on the
> specifics of your admin configuration would shed some light.
>
> Karen
>
> >
>
There was a bug similar to this when using raw_id from the change_list view
with list_editable, however this was resolved (after the beta though I
think).

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: ForeignKeyRawId widget contains incorrect link when you click on search gif?

2009-05-19 Thread Karen Tracey
On Tue, May 19, 2009 at 12:15 AM, Margie  wrote:

>
> I tried using raw_id_fields in admin for the first time (using the
> Django 1.1 beta).  When I click search gif I find that it tries to
> redirect me to:
>
> http://mysite.com/auth/user/?t=id
>
> Seems to me it should be redirecting me to this instead (note addition
> of admin):
>
> http://myste.com/admin/auth/user/?t=id
>
> Isn't this a bug?  If so, I can post it, just wanted to get input
> first in case I am missing something.
>

I can't recreate this with either the alpha or current trunk level (don't
have beta set up to test easily at the moment).  I tried both the 1.0 style
of urlpattern (referencing admin.site.root) for admin and 1.1 (including
admin.site.urls).  Which are you using?  Perhaps more details on the
specifics of your admin configuration would shed some light.

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: help on outlook integration

2009-05-19 Thread Chris Withers

kam wrote:
> We have to integrate of web outlook using HTTP protocol.  We are
> trying to connect outlook with form based authentication to connect
> using HTTP protocol. We are able to connect outlook using HTTPS and
> COM object but this is not work on Linux & using COM object we are
> able to access only outlook’s data. We are expecting header cookie and
> response data from inbox page of outlook.

I don't really understand how posting the same vague requirements once 
every 10-15 minutes is supposed to help other than by annoying everyone 
on this list...

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk

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



help on outlook integration

2009-05-19 Thread kamlesh . ldce

Hi All,

We have to integrate of web outlook using HTTP protocol.  We are
trying to connect outlook with form based authentication to connect
using HTTP protocol. We are able to connect outlook using HTTPS and
COM object but this is not work on Linux . We are expecting header
cookie and response data from inbox page of outlook.

We are getting HTTP 200 response and login page as response data.


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



help on outlook integration

2009-05-19 Thread kam

Hi All,



We have to integrate of web outlook using HTTP protocol.  We are
trying to connect outlook with form based authentication to connect
using HTTP protocol. We are able to connect outlook using HTTPS and
COM object but this is not work on Linux & using COM object we are
able to access only outlook’s data. We are expecting header cookie and
response data from inbox page of outlook.

We are getting HTTP 200 response and login page as response data.


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



help on outlook integration

2009-05-19 Thread kamlesh . ldce

Hi All,


We have to integrate web outlook using HTTP protocol.  We are trying
to connect outlook with form based authentication to connect using
HTTP protocol. We are able to connect outlook using HTTPS and COM
object but this is not work on Linux & using COM object. We are
expecting header cookie and response data from inbox page of outlook.

We are getting HTTP 200 response and login page as response data.

We are using weboutlook to connect outlook for form based
authentication.

Thanks in advance.

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



Re: Passing a dynamic ChoiceField response to a ForeignKey instance

2009-05-19 Thread Simon Greenwood



On May 18, 3:32 pm, Simon Greenwood  wrote:
> On May 18, 12:02 pm, Simon Greenwood  wrote:
>
>
>
> > On May 15, 5:58 pm, simong  wrote:
>
> > > There's probably a very simple answer to this but I can't see it at
> > > the moment:
>
> > > This model:
>
> > > class Product(models.Model):
> > >         user = models.ForeignKey(User, related_name="product_list",
> > > editable=False)
> > >         productid = models.CharField(max_length=40, blank=True)
> > >         prodname = models.CharField(max_length=255, verbose_name='Product
> > > name')
> > >         proddesc = models.TextField(blank=True, 
> > > verbose_name='Description')
> > >         prodtopcat = models.ForeignKey(ProductTopCategory,
> > > verbose_name='Product Main Category')
> > >         prodsubcat = models.ForeignKey(ProductSubCategory,
> > > verbose_name='Product Sub Category')
> > >         unit = models.ForeignKey(Units, verbose_name='Unit')
> > >         video = models.ManyToManyField('Video', blank=True,
> > > verbose_name='Video')
> > >         costperunit = models.DecimalField(max_digits=6, decimal_places=2,
> > > verbose_name='Cost per unit')
> > >         costperlot = models.DecimalField(max_digits=6, decimal_places=2,
> > > verbose_name='Cost per lot')
> > >         available = models.BooleanField(default=True)
> > >         featured = models.BooleanField(blank=True, null=True)
>
> > > is used to generate a ModelForm with two modified fields that enable
> > > the field 'prodsubcat' to be dynamically populated based on the
> > > selection of 'prodtopcat'.
>
> > > class DynamicChoiceField(forms.ChoiceField):
> > >         def clean(self, value):
> > >                 return value
>
> > > class ProductForm(ModelForm):
> > >         prodsubcat = DynamicChoiceField(widget=forms.Select(attrs=
> > > {'disabled': 'true'}), choices =(('-1', 'Select Top Category'),))
>
> > > I took this from an item I found on the web. I think setting the
> > > 'disabled' attribute is all I actually need.
>
> > > The dynamic lookup is performed using jQuery.getJSON with this view:
>
> > > def feeds_subcat(request, cat_id):
> > >         from django.core import serializers
> > >         json_subcat = serializers.serialize("json",
> > > ProductSubCategory.objects.filter(prodcat = cat_id), fields=('id',
> > > 'shortname', 'longname'))
> > >         return HttpResponse(json_subcat, 
> > > mimetype="application/javascript")
>
> > > and the SELECT HTML is generated like this:
>
> > > options += '' + j[i].fields
> > > ['longname'] + '';
>
> > > This all works, but on submitting the form, I get the error 'Cannot
> > > assign "u'17'": "Product.prodsubcat" must be a "ProductSubCategory"
> > > instance' where "u'17'" is the option value of id_prodsubcat
>
> > > What type of variable should I be passing (I assume int) and where
> > > should I be converting it? In validation, in the pre-save signal, in
> > > the save signal? Or should I be trying to convert it on the form
> > > itself? Where is the ForeignKey instance save process documented?
>
> > To bump this and to add more detail: now, when I attempt to save the
> > form, I am getting the error 'Cannot assign "u'266'":
> > "Product.prodsubcat" must be a "ProductSubCategory" instance.' where
> > 266 is the primary key of the ProductSubCategory object selected from
> > a list that is looked up by the selection of a ProductTopCategory
> > option as shown in the Product model above. How can I return a
> > ProductSubCategory instance from the variable at form save time?
>
> To answer myself, this 
> post:http://monogroncho.com/2008/10/django-gotchas-part-1/
> is exactly what I was looking for, although the code as given seems
> rather inelegant and gives me the AttributeError 'list' object has no
> attribute 'widget'. My feeling is that I don't have to be returning a
> list of ProductSubCategory objects, just the one that my choice
> represents. Does anyone have a view on this? I can't be the only
> person combining django and Ajax in this way.
>

This is a sort of solution: A ChoiceField is populated at render time
by data either called from the ModelForm relationship or from a
ModelChoiceField lookup, and populates the HTML select field on the
form. It is this instance that is validated. Populating the choices
dictionary therefore deletes the data from the lookup:

class ProductForm(ModelForm):
  prodsubcat = forms.ModelChoiceField(ProductSubCategory.objects,
widget=forms.Select(attrs={'disabled': 'true'}), choices =(('-1',
'Select Top Category'),))

and breaks the validation.

If the field is rendered without the choices dictionary, but with the
'disabled' attribute, it will display as a disabled select field.
Selecting an option from the prodtopcat select field calls the Ajax
lookup, which populates the prodsubcat field with filtered data in the
browser, but not in the field object. Selecting a category from the
prodsubcat field returns an option 

Re: Help on query

2009-05-19 Thread Daniel Roseman

On May 19, 12:11 pm, Lokesh  wrote:
> class Users(models.Model):
>     userId = models.IntegerField(max_length=2, primary_key=True)
>     userName = models.CharField(max_length=10, null=False,
> blank=False)
>
>     def __unicode__(self):
>         return self.userName
>
> class MotherTongue(models.Model):
>     MT_id = models.IntegerField(max_length=2, null=False, blank=False,
> unique=True)
>     MT_value = models.CharField(max_length=15, null=False,
> blank=False)
>
>     def __unicode__(self):
>         return self.MT_value
>
> class Sr_Pr_MotherTongue(models.Model):
>     Sr_Pr_userId = models.ForeignKey(Users, to_field='userId')
>     Sr_Pr_MT_id = models.ForeignKey(MotherTongue, to_field='MT_id')
>     Sr_Pr_type = models.CharField(max_length=7, null=False,
> blank=False)
>
>     def __unicode__(self):
>         return self.Sr_Pr_type
>
> mysql> select * from polls_users;
> ++--+
> | userId | userName |
> ++--+
> |      1 | django3  |
> |      2 | django2  |
> |      3 | django1  |
> ++--+
> mysql> select * from polls_mothertongue;
> ++---+--+
> | id | MT_id | MT_value |
> ++---+--+
> |  1 |     1 | Telugu   |
> |  2 |     2 | English  |
> |  3 |     3 | Hindi    |
> |  4 |     4 | Sindi    |
> ++---+--+
> mysql> select * from polls_sr_pr_mothertongue;
> ++-+++
> | id | Sr_Pr_userId_id | Sr_Pr_MT_id_id | Sr_Pr_type |
> ++-+++
> |  2 |               1 |              1 | search     |
> |  3 |               2 |              2 | pref       |
> |  4 |               3 |              4 | search     |
> ++-+++
>
> mysql>select a.mt_value, b.Sr_Pr_type, c.userName from
> polls_mothertongue a, polls_sr_pr_mothertongue b, polls_users c where
> a.mt_id = b.sr_pr_mt_id_id and c.userId=1 and
> c.userId=b.Sr_Pr_userId_id;
> Django -> ??
> step1 - p = Users.objects.get(pk=1) => get the user id object
> step2 - not able to proceed further
> +--++--+
> | mt_value | Sr_Pr_type | userName |
> +--++--+
> | Telugu   | search     | django3  |
> +--++--+
>
> Could some one please guide me how I can achieve the above mysql
> result from django query
>
> Regards,
> Lokesh

Posting a bunch of badly-formatted SQL is not at all helpful. What do
you actually want to achieve? If you can spell it out in plain
language - ie 'I want all the users where...' - then it might be more
obvious how to do it in Django.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model form validation always failing

2009-05-19 Thread watad

thanks for the reply thomas
if tried that but it is still giving the validation message

On May 19, 1:18 pm, Thomas Guettler  wrote:
> Maybe you form misses this: enctype="multipart/form-data"
>
> watad schrieb:
>
> > dear all
> ...
> > i can see the fileds but when i try to submit , the rusume validation
> > is always failing (This field is required.)
> > although i upload the file, and i was able to add data usign the admin
> > interface without any problems
>
> --
> 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: Dynamic ForeignKey using or how ?

2009-05-19 Thread Michael Radziej

On Tue, May 19, Anakin wrote:

> class Faves(models.Model):
> post = models.ForeignKey(CASTS-OR-ARTICLES)
> user = models.ForeignKey(User,unique=True)
> 
> is it possible ?

You might want to use "generic relations" for this. They are described in
the contenttypes framework.

Hope this helps a bit,

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689

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



Restricting fields to certain users in admin

2009-05-19 Thread Matias Surdi

I need to hide a couple fields from a model depending on the logged in 
user in the admin interface.

How would you do this?


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



Help on query

2009-05-19 Thread Lokesh

class Users(models.Model):
userId = models.IntegerField(max_length=2, primary_key=True)
userName = models.CharField(max_length=10, null=False,
blank=False)

def __unicode__(self):
return self.userName

class MotherTongue(models.Model):
MT_id = models.IntegerField(max_length=2, null=False, blank=False,
unique=True)
MT_value = models.CharField(max_length=15, null=False,
blank=False)

def __unicode__(self):
return self.MT_value

class Sr_Pr_MotherTongue(models.Model):
Sr_Pr_userId = models.ForeignKey(Users, to_field='userId')
Sr_Pr_MT_id = models.ForeignKey(MotherTongue, to_field='MT_id')
Sr_Pr_type = models.CharField(max_length=7, null=False,
blank=False)

def __unicode__(self):
return self.Sr_Pr_type

mysql> select * from polls_users;
++--+
| userId | userName |
++--+
|  1 | django3  |
|  2 | django2  |
|  3 | django1  |
++--+
mysql> select * from polls_mothertongue;
++---+--+
| id | MT_id | MT_value |
++---+--+
|  1 | 1 | Telugu   |
|  2 | 2 | English  |
|  3 | 3 | Hindi|
|  4 | 4 | Sindi|
++---+--+
mysql> select * from polls_sr_pr_mothertongue;
++-+++
| id | Sr_Pr_userId_id | Sr_Pr_MT_id_id | Sr_Pr_type |
++-+++
|  2 |   1 |  1 | search |
|  3 |   2 |  2 | pref   |
|  4 |   3 |  4 | search |
++-+++

mysql>select a.mt_value, b.Sr_Pr_type, c.userName from
polls_mothertongue a, polls_sr_pr_mothertongue b, polls_users c where
a.mt_id = b.sr_pr_mt_id_id and c.userId=1 and
c.userId=b.Sr_Pr_userId_id;
Django -> ??
step1 - p = Users.objects.get(pk=1) => get the user id object
step2 - not able to proceed further
+--++--+
| mt_value | Sr_Pr_type | userName |
+--++--+
| Telugu   | search | django3  |
+--++--+

Could some one please guide me how I can achieve the above mysql
result from django query

Regards,
Lokesh
--~--~-~--~~~---~--~~
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: model form validation always failing

2009-05-19 Thread Thomas Guettler

Maybe you form misses this: enctype="multipart/form-data"


watad schrieb:
> dear all
...
> i can see the fileds but when i try to submit , the rusume validation
> is always failing (This field is required.)
> although i upload the file, and i was able to add data usign the admin
> interface without any problems


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



model form validation always failing

2009-05-19 Thread watad

dear all

i have a model Career

class Career(models.Model):
  full_name = models.CharField(max_length=200)
  email = models.EmailField()
  nationality = CountryField()
  resume = models.FileField(upload_to='resumes')
  def __unicode__(self):
return self.full_name


and i have the model form:
class CareerForm(ModelForm):
class Meta:
model = Career

inside my template im using :

{{ form.as_p }} to display the form

i can see the fileds but when i try to submit , the rusume validation
is always failing (This field is required.)
although i upload the file, and i was able to add data usign the admin
interface without any problems

any ideas about this issue
thanks in advance

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



preferred/correct way to modify imagefields

2009-05-19 Thread ozgurisil

Hello all,

I have spent considerable time going through the documentation but
have been unable to find clear information about how to save an image
after uploading it via a form. I think I have somehow missed it. After
trial and error, I have done it in this way:

content = request.FILES['image']
foo.img.save(filepath, content=content,save=False)

here foo is an instance of the Foo model, which has an ImageField
named img

Is this the recommended way to upload an image (for forms that are not
modelform)?

And I update an imagefield (ie, set it to point another file) by
setting it to its relative path against the path defined in the
MEDIA_ROOT constant. I wonder if this is also correct.

A third question is that when I use the default option for the
ImageField, the field is set to an absolute path (MEDIA_ROOT +
mypath), and this stems problems such as foo.img.url() giving a path
instead of a url. How can I prevent that?

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



Dynamic ForeignKey using or how ?

2009-05-19 Thread Anakin

i want to use 2 model in one foreignkey, i think its dynamic
foreignkey

it means;

i have 2 model named screencasts and articles. and i have a fave
model, for favouriting this model entrys. can i use model dynamicly ?

class Articles(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()

class Casts(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()

class Faves(models.Model):
post = models.ForeignKey(CASTS-OR-ARTICLES)
user = models.ForeignKey(User,unique=True)

is it possible ?

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: crossdomain.xml

2009-05-19 Thread Matt Davies
I got it
Thanks for your help James



2009/5/19 Matt Davies 

> Thanks James
> I'm serving the sites with nginx, but in my django urls file I'm using this
> line for a simple pages app we've built.
>
> urlpatterns += patterns('fact.pages.views',
> (r'^(?P.*)$', 'page'),
> )
>
> What happens is that whatever you put into the URL the pages app will try
> and serve it.
>
> So what you are saying is that I should be able to tell nginx to serve up
> the file prior to handing off the request to django, is that about it?
>
> It should be easy, nes't pas?
>
>
>
>
>
> 2009/5/19 James Bennett 
>
>
>> On Tue, May 19, 2009 at 2:47 AM, Matt Davies  wrote:
>> > I've been asked to server up a crossdomain.xml file at the root of our
>> web
>> > sites so that another team of developers can access our data via Flash.
>> > How do I set that up in the urls.py file?  I use one urls.py file for
>> many
>> > web sites so it would be far easier to put it in here.
>> > I've got to this bit but can't think how I can tell the app to serve the
>> doc
>> > from the root folder
>> > urlpatterns = patterns('',
>> > (r'^crossdomain.xml', What goes in here?)
>> > )
>>
>> You can set up some sort of override to tell your web server -- not
>> Django -- to just serve up the file. Examples are available here:
>>
>> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1
>>
>> Or... I wrote an application recently that generates and serves
>> cross-domain policy files for Flash. With the exception of the
>> unit-test suite (which relies on a new-in-1.1 feature), it'll probably
>> actually work on the version of Django you're using. You can grab the
>> package to install here:
>>
>> http://pypi.python.org/pypi/django-flashpolicies/
>>
>> Or read the documentation (and source code) here:
>>
>> http://bitbucket.org/ubernostrum/django-flashpolicies/src/
>>
>>
>> --
>> "Bureaucrat Conrad, you are technically correct -- the best kind of
>> correct."
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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: crossdomain.xml

2009-05-19 Thread Matt Davies
Thanks James
I'm serving the sites with nginx, but in my django urls file I'm using this
line for a simple pages app we've built.

urlpatterns += patterns('fact.pages.views',
(r'^(?P.*)$', 'page'),
)

What happens is that whatever you put into the URL the pages app will try
and serve it.

So what you are saying is that I should be able to tell nginx to serve up
the file prior to handing off the request to django, is that about it?

It should be easy, nes't pas?





2009/5/19 James Bennett 

>
> On Tue, May 19, 2009 at 2:47 AM, Matt Davies  wrote:
> > I've been asked to server up a crossdomain.xml file at the root of our
> web
> > sites so that another team of developers can access our data via Flash.
> > How do I set that up in the urls.py file?  I use one urls.py file for
> many
> > web sites so it would be far easier to put it in here.
> > I've got to this bit but can't think how I can tell the app to serve the
> doc
> > from the root folder
> > urlpatterns = patterns('',
> > (r'^crossdomain.xml', What goes in here?)
> > )
>
> You can set up some sort of override to tell your web server -- not
> Django -- to just serve up the file. Examples are available here:
>
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1
>
> Or... I wrote an application recently that generates and serves
> cross-domain policy files for Flash. With the exception of the
> unit-test suite (which relies on a new-in-1.1 feature), it'll probably
> actually work on the version of Django you're using. You can grab the
> package to install here:
>
> http://pypi.python.org/pypi/django-flashpolicies/
>
> Or read the documentation (and source code) here:
>
> http://bitbucket.org/ubernostrum/django-flashpolicies/src/
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>

--~--~-~--~~~---~--~~
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: crossdomain.xml

2009-05-19 Thread James Bennett

On Tue, May 19, 2009 at 2:47 AM, Matt Davies  wrote:
> I've been asked to server up a crossdomain.xml file at the root of our web
> sites so that another team of developers can access our data via Flash.
> How do I set that up in the urls.py file?  I use one urls.py file for many
> web sites so it would be far easier to put it in here.
> I've got to this bit but can't think how I can tell the app to serve the doc
> from the root folder
> urlpatterns = patterns('',
> (r'^crossdomain.xml', What goes in here?)
> )

You can set up some sort of override to tell your web server -- not
Django -- to just serve up the file. Examples are available here:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1

Or... I wrote an application recently that generates and serves
cross-domain policy files for Flash. With the exception of the
unit-test suite (which relies on a new-in-1.1 feature), it'll probably
actually work on the version of Django you're using. You can grab the
package to install here:

http://pypi.python.org/pypi/django-flashpolicies/

Or read the documentation (and source code) here:

http://bitbucket.org/ubernostrum/django-flashpolicies/src/


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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: models unique_for_date

2009-05-19 Thread Reiner

Hey,

most of the options on a ModelAdmin control the display of your model,
and how you interact with it, in the admin site. What fields you want
to show in the table (list_display), how many objects per page
(list_per_page) and so on:

ModelAdmin options: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options

Whereas fields options in your Model let you further define your
model's specification. You already define what fields your model
consists of, and with unique_for_date you add another constraint to
your model field. It may be enforced on the admin form level, but I
think the only reason for this is, that enforcing it on the database
level is actually not possible, or not reasonable - and maybe it will
be enforced on the database level some day.

Field options on models: 
http://docs.djangoproject.com/en/dev/ref/models/fields/#field-options

So think of the ModelAdmin options as a mean to control (mostly)
display and interaction with the model, and field options as further
constraints to your model. You want your model specification to be in
only one place, and that would be in the model itself.

Regards,
Reiner

On May 19, 2:19 am, Mohan Parthasarathy  wrote:
> Hi,
>
> I can see that Models don't use the inner class to define the options, so I
> used
>
> class EntryAdmin(admin.ModelAdmin):
>         prepopulated_fields = {'slug' : ('title',)}
>
> How do I use unique_for_date here ? Is there a place where all the options
> are listed for this new style interface ?
>
> I can see that unique_for_date works when added to the field directly which
> confuses me as I thought anything to do with admin interfaces
> (unique_for_date is controlled at the admin level and not at database level
> ?) is specified separately. What am i missing ?
>
> -mohan
--~--~-~--~~~---~--~~
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: Import Error: couldn't locate module Http.Isapi

2009-05-19 Thread George Song

On 5/18/2009 6:53 AM, BuckRogers wrote:
> Hi,
> 
> I am using IIS6/Python2.5/mssql 2000 on windows server 2003
> 
> I followed the instructions available here:
> http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer
> 
> PyISAPIe doesn't seem to work, I am getting Import Error: couldn't
> locate module Http.Isapi
> 
> Any idea?

Your PYTHONPATH is probably not set correctly. You'll have to make sure 
the environment variable is set properly for the IIS user. There are 
couple special users if I remember correctly.

I'm not sure if you can set an ISAPI filter to run as a specific user, 
if so, that could be another route.

-- 
George

--~--~-~--~~~---~--~~
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: ModelForm question

2009-05-19 Thread George Song

On 5/18/2009 12:55 PM, Rusty Greer wrote:
> 
> i have the following:
> 
> a model:
> class MyClass(models.Model):
> otherClass = models.ForeignKey('otherClass')
> someData = models.CharField(max_length=20)
> 
> 
> class MyClassForm(forms.ModelForm):
> 
> class Meta:
> model = MyClass
> fields = ('someData')
> 
> 
> When the user edits or adds a MyClass object with the MyClassForm, the 
> otherClass will always be known.  I don't want the user to ever change 
> the otherClass.  What I want it to be in the MyClassForm is a hidden 
> field.  I know I can do this with a Form instead of a ModelForm, but I 
> like the convenience of the ModelForm.  Is there a way to pass hidden 
> inputs through a ModelForm and still get the convenience of the ModelForm?
> 
> Any help would be appreciated.

Just override otherClass's widget.
See: 


-- 
George

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



crossdomain.xml

2009-05-19 Thread Matt Davies
Morning everyone
Stupid question number 243

I've been asked to server up a crossdomain.xml file at the root of our web
sites so that another team of developers can access our data via Flash.

How do I set that up in the urls.py file?  I use one urls.py file for many
web sites so it would be far easier to put it in here.

I've got to this bit but can't think how I can tell the app to serve the doc
from the root folder

urlpatterns = patterns('',
(r'^crossdomain.xml', What goes in here?)
)

We're using a really old version of django for these sites, I think it's
revision 5643, foof, old as.

Any help, greatly appreciated.

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