Re: Testing if a receiver is connected to a signal

2011-05-05 Thread Vinicius Mendes
Boa. Funciona para resolver esse problema.

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com



On Thu, May 5, 2011 at 1:33 PM, Bernardo Fontes <bernardo...@gmail.com>wrote:

> Hello everybody,
>
> I resolved this problem by looking at Djangos Signal's code and
> understanding its structure. The signal has an attribute called receivers
> which has stored references to its receivers function that were connect to
> it. When the send function is called, the signal just call this function
> which are in this receivers list. So, I created a setUpClass and a
> tearDownClass that does a monkey patch with my signal. It's like this:
>
>
> class YourTestClass(TestCase):
>
>
> @classmethod
> def setUpClass(cls):
> cls.signal_receivers = my_signal.receivers
> my_signal.receivers = []
>
>
> @classmethod
> def tearDownClass(cls):
> my_signal.receivers = cls.signal_receivers
>
> Hope I could help!
>
>
> --
> Bernardo Fontes
> http://www.bernardofontes.net
> bernardo...@gmail.com <falecom...@bernardofontes.net>
> Skype: bernardoxhc
> (21) 9629 1621
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: DjangoCon US 2011

2011-04-01 Thread Vinicius Mendes
Thanks for the information.

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com



On Fri, Apr 1, 2011 at 1:48 AM, Shawn Milochik <sh...@milochik.com> wrote:

> The event will definitely take place in Portland, Oregon in September.
>
> On Apr 1, 2011 12:15 AM, "Vinicius Mendes" <vbmen...@gmail.com> wrote:
> >
> > I work for a company that assist employees to go to events to learn about
> technologies they use. They always plan wich events their employees will
> attend in the begining of the year. I am trying to go to DjangoCon US with
> their help so I need to know if the event will take place or not.
> >
> > Atenciosamente,
> > Vinicius Mendes
> > Engenheiro de Computação
> > Globo.com
> >
> >
> >
> > On Thu, Mar 31, 2011 at 8:49 PM, Steve Holden <holden...@gmail.com>
> wrote:
> >>
> >> I have already started nagging people about this. It's only just over
> five months to go, and it's definitely time the CfP went out. Expect to see
> movement in the next two weeks.
> >>
> >> Regards
> >> Steve
> >>
> >> On Mar 31, 2011 6:19 PM, "Shawn Milochik" <sh...@milochik.com> wrote:
> >> > It's a bit early, in the year, but I'd expect something in the next
> >> > couple of months here:
> >> >
> >> > http://djangocon.us/
> >> >
> >> > Since it's not till September there's still plenty of time.
> >> >
> >> > That said, if @holdenweb is reading this -- any updates? ^_^
> >> >
> >> > Shawn
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >> >
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, 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: DjangoCon US 2011

2011-03-31 Thread Vinicius Mendes
I work for a company that assist employees to go to events to learn about
technologies they use. They always plan wich events their employees will
attend in the begining of the year. I am trying to go to DjangoCon US with
their help so I need to know if the event will take place or not.

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com



On Thu, Mar 31, 2011 at 8:49 PM, Steve Holden <holden...@gmail.com> wrote:

> I have already started nagging people about this. It's only just over five
> months to go, and it's definitely time the CfP went out. Expect to see
> movement in the next two weeks.
>
> Regards
> Steve
> On Mar 31, 2011 6:19 PM, "Shawn Milochik" <sh...@milochik.com> wrote:
> > It's a bit early, in the year, but I'd expect something in the next
> > couple of months here:
> >
> > http://djangocon.us/
> >
> > Since it's not till September there's still plenty of time.
> >
> > That said, if @holdenweb is reading this -- any updates? ^_^
> >
> > Shawn
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



DjangoCon US 2011

2011-03-31 Thread Vinicius Mendes
Hi, I am planing to go to DjangoCon US 2011 announced in this blog post:
http://www.djangoproject.com/weblog/2010/nov/22/djangocon-us-2011/ but it's
an old post and I haven't seen any other posts about it since this
announcement. Will this event take place? Or it will be only the DjangoCon
Europe?

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com

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



Testing if a receiver is connected to a signal

2011-02-21 Thread Vinicius Mendes
Hi,

I want to test if a receiver function is connected to a signal in django,
but I don't want other receivers from other apps to be called when my test
runs.

I thought of verifying if my callback function is in the receivers list of
the signal, but this list stores the receivers in a strange way.

Any ideas?

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com

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



Re: Saving File/Image in tmp. I'm in trouble ...

2010-07-13 Thread Vinicius Mendes
I never used Django with S3 but the upload_to is a folder inside the folder
referenced by the MEDIA_ROOT setting.

Atenciosamente,
Vinicius Mendes
Solucione Sistemas
vinic...@solucione.info


On Tue, Jul 13, 2010 at 8:06 AM, The Danny Bos <danny...@gmail.com> wrote:

> I can't get access to the servers own tmp path, only my own "/home/
> 72999/data/tmp" which the file isn't saving to.
>
> Madness.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Admin with only inlines, no fields

2010-06-29 Thread Vinicius Mendes
Try to debug this using PDB. You can insert some breakpoints where the form
is not validated and see what are the errors.

Atenciosamente,
Vinicius Mendes
Solucione Sistemas
vinic...@solucione.info


On Tue, Jun 29, 2010 at 12:14 PM, felix <crucialfe...@gmail.com> wrote:

>
> I need to present an admin form that has no fields from the model and
> only offers admin inlines.
>
>
> class AptTranslationForm(DefaultModelForm):
>
>class Meta:
>model = AptTranslation
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fields = []
>
>
> the empty fields list is ignored and the admin delivers all fields
> from the model
>
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fieldsets = []
>
>
> same thing, all fields are shown
>
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fieldsets = ( ("",{'fields':[]}), )
>
>
> this displays as wished (with a barely visible grouping at the top),
> but always returns an error on save:
>
> Please correct the errors below.
>
> but no errors are listed.
>
>
> class AptTranslationsAdmin(models.Admin):
>
>inlines = [AptTranslation_Inline,]
>
>fields = ['headline']
>readonly_fields = ['headline']
>
> same as above: Please correct the errors below,
> but no errors are shown
>
>
> I also tried using a dummy form class, but an empty field list is not
> respected there either
>
> thanks for any help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: hello django users, I have one doubt. I am doing one django project. It shows one SyntaxError in the line(if not created:) in views.py file.I attached the particular in that. I want the reason o

2010-06-04 Thread Vinicius Mendes
I guess it is because the 'I' is uppercase. Try all the line in lowercase.

Atenciosamente,
Vinicius Mendes
Solucione Sistemas
vinic...@solucione.info


On Fri, Jun 4, 2010 at 8:54 AM, kanniga sivasubramanian <
kskanniga...@gmail.com> wrote:

> def bookmark_save_page(request):
>  if request.method == 'POST':
>form = BookmarkSaveForm(request.POST)
>if form.is_valid():
>  # Create or get link.
>  link, dummy = Link.objects.get_or_create(
>   url=form.cleaned_data['url']
>  )
>  # Create or get bookmark.
>  bookmark, created = Bookmark.objects.get_or_create(
>user=request.user,
>link=link
>  )
>  # Update bookmark title.
>  bookmark.title = form.cleaned_data['title']
>  # If the bookmark is being updated, clear old tag list.
>  If not created:
>bookmark.tag_set.clear()
>  # Create new tag list.
>  tag_names = form.cleaned_data['tags'].split()
>  for tag_name in tag_names:
>tag, dummy = Tag.objects.get_or_create(name=tag_name)
>bookmark.tag_set.add(tag)
>  # Save bookmark to database.
>  bookmark.save()
>  return HttpResponseRedirect(
>'/user/%s/' % request.user.username
>  )
>  else:
> form = BookmarkSaveForm()
>  variables = RequestContext(request, {
>'form': form
>  })
>  return render_to_response('bookmark_save.html', variables)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Django 1.2.1 doesn't work with South but 1.2 works? How to find the previous version Django 1.2?

2010-06-01 Thread Vinicius Mendes
Why don't you try to fix this incompatibility? You can help South project by
doing this. It isn't recommended to use the 1.2 since 1.2.1 is the same with
bugfixes. But you can grab the 1.2 code using SVN. Just checkout this URL:
http://code.djangoproject.com/svn/django/tags/releases/1.2/

Atenciosamente,
Vinicius Mendes
Solucione Sistemas
vinic...@solucione.info


On Tue, Jun 1, 2010 at 10:29 PM, flyinglegs <flyingl...@gmail.com> wrote:

> I am having some trouble with South database migration using Fabric. I
> tried several machines, one works and the other 3 doesn't work. The
> only difference is that the machine that's working is using Django
> 1.2, and the others are using Django 1.2.1.
>
> Somehow I couldn't find the Django 1.2 tarball on the website, any
> idea why it was pulled? Does anybody else have trouble using Django
> 1.2.1 with South 0.7.1?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Four Hop, Two Criteria Query

2010-05-27 Thread Vinicius Mendes
Just be careful with the index errors. If you are sure that this query will
allway have at least one item, so this is fine. But if it returns an empty
queryset, so you will have trouble with IndexError.

Atenciosamente,
Vinicius Mendes
Solucione Sistemas
vinic...@solucione.info


On Thu, May 27, 2010 at 10:11 PM, Lee Hinde <leehi...@gmail.com> wrote:

> On Thu, May 27, 2010 at 5:44 PM, Lee Hinde <leehi...@gmail.com> wrote:
>
>> weather =
>> Weather.objects.filter(weather_date=self.target_date,zip_code=self.created_by.store.zip_code)
>>
>>
>
> so, the solution was
>
>   def get_weather(self):
> weather =
> Weather.objects.filter(weather_date=self.target_date,zip_code=self.created_by.store.zip_code)[0]
>
> return weather
>
> just return a single record
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Installing django

2010-04-15 Thread Vinicius Mendes
Follow the tutorial on http://docs.djangoproject.com

http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Thu, Apr 15, 2010 at 10:23 AM, Jagdeep Singh Malhi <
singh.malh...@gmail.com> wrote:

> #apt-get install python-django
> After this what can i do..
>
> On Apr 15, 12:17 am, Alexis Selves  wrote:
> > try to insall package python-django using apt-get install
> >
> > On 14 dub, 20:47, "Tom X. Tobin"  wrote:> On
> Wed, Apr 14, 2010 at 1:17 PM, Shawn Milochik  wrote:
> > > > The instructions on the site are incorrect. You only use
> django-admin.py to create the project. After that you use manage.py for
> everything else -- including syncdb.
> >
> > > You *can* use django-admin.py as long as you make sure
> > > DJANGO_SETTINGS_MODULE is defined in your environment to poing to your
> > > settings module (e.g., "some_project.settings") -- which is exactly
> > > what Jagdeep's traceback was complaining about.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How to concatenate a list of Q objects?

2010-04-07 Thread Vinicius Mendes
If you want to mix AND and OR, you will have to do this manually:

q = (q1 | q2) & q3

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Wed, Apr 7, 2010 at 3:56 PM, Daniel <unagimiy...@gmail.com> wrote:

> Thanks alot guys.  If I can be honest, I'm having a little trouble
> digesting just this one line:
>
> q = q | f if q else f
>
> That line of code only allows (q1 | q2 | q3), right?
>
> It will not allow mixing "AND" as well as "OR" (i.e., q1 & q2 | q3)?
>
> Thanks!
>
>
>
> On Apr 7, 1:26 pm, Vinicius Mendes <vbmen...@gmail.com> wrote:
> > On Wed, Apr 7, 2010 at 2:00 PM, Tom Evans <tevans...@googlemail.com>
> wrote:
> > > On Wed, Apr 7, 2010 at 5:39 PM, Daniel <unagimiy...@gmail.com> wrote:
> > > > Hi,
> >
> > > > Thank you for your help everyone.  I know that I need to learn python
> > > > better, and I did read those articles.  What is still a bit unclear
> to
> > > > me, though, is how could I add an "OR" or "AND" separator between Q
> > > > objects?
> >
> > > > So I have a list of qobjects like [qObj1, qObj2, qObj3].
> >
> > > > What I want is something like Sample.objects.filter((qObj1 | qObj2),
> > > > qObj3)
> >
> > > > I know that the default is for all Q objects to be "ANDed" together.
> > > > I think the join operation is not going to work here, nor is
> > > > concatenation, but is there something obvious that I'm missing?
> >
> > > > THANK YOU :>
> >
> > > Documentation on how to combine Q objects:
> >
> > >http://docs.djangoproject.com/en/1.1/topics/db/queries/#complex-looku.
> ..
> >
> > > So you want to loop through them, and 'or' them together..
> >
> > > filters = [ q1, q2, q3, q4, q5 ]
> > > q = None
> > > for f in filters:
> > >  q = q | f if q else f
> > > Foo.objects.filter(q)
> >
> > Refining a little:
> >
> > filters = [q1,q2,q3,q4,q5]
> > q = Q()
> > for f in filters:
> > q |= f
> > Foo.objects.filter(q)
> >
> > Q() is identity for & and |.
> >
> > > 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-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
> >
> > __
> > Vinícius Mendes
> > Solucione Sistemashttp://solucione.info/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: How to concatenate a list of Q objects?

2010-04-07 Thread Vinicius Mendes
On Wed, Apr 7, 2010 at 2:00 PM, Tom Evans  wrote:

> On Wed, Apr 7, 2010 at 5:39 PM, Daniel  wrote:
> > Hi,
> >
> > Thank you for your help everyone.  I know that I need to learn python
> > better, and I did read those articles.  What is still a bit unclear to
> > me, though, is how could I add an "OR" or "AND" separator between Q
> > objects?
> >
> > So I have a list of qobjects like [qObj1, qObj2, qObj3].
> >
> > What I want is something like Sample.objects.filter((qObj1 | qObj2),
> > qObj3)
> >
> > I know that the default is for all Q objects to be "ANDed" together.
> > I think the join operation is not going to work here, nor is
> > concatenation, but is there something obvious that I'm missing?
> >
> > THANK YOU :>
> >
> >
>
> Documentation on how to combine Q objects:
>
> http://docs.djangoproject.com/en/1.1/topics/db/queries/#complex-lookups-with-q-objects
>
> So you want to loop through them, and 'or' them together..
>
> filters = [ q1, q2, q3, q4, q5 ]
> q = None
> for f in filters:
>  q = q | f if q else f
> Foo.objects.filter(q)
>
>
Refining a little:

filters = [q1,q2,q3,q4,q5]
q = Q()
for f in filters:
q |= f
Foo.objects.filter(q)

Q() is identity for & and |.


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

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/

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



Re: queryset in clean method

2010-04-06 Thread Vinicius Mendes
You can pass the competition instance to the for in the initialization. In
the form you change the form a little bit adding the init method to receive
the competition parameter. Then you can save it in a form attribute and then
use it in clean method.

I made a simple gist to show you haw it could be:
http://gist.github.com/358245

I always recomend not to get values from cleaned_data directly
(self.cleaned_data['dob']) becouse 'dob' may be invalid before the clean is
called so it will raise an IndexError. I prefer to use
self.cleaned_data.get('bob') to avoid it.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Tue, Apr 6, 2010 at 6:32 PM, When ideas fail
wrote:

> hello, i have a clean method in my forms.py. I want this to check a
> person is old enough to enter a competiton
>
> The problem i have is that the minimum age changes and is a field in
> the competition model(it is entered by the user).
>
> My clean method is like this (pseudo code):
>
> class personform(forms.Form):
> ...
>
>def clean_recipients(self):
>dateOfBirth = self.cleaned_data['dob']
>if dateOfBirth > competition.min_age
>..
>return data
>
> The same form is used to enter any competition, and uses the url to
> get the competition id
>
> eg: mysite.com/enter_competition/my_competition
>
> since competition_slug will only become apparent from the url in views
> how can i find out the relevant min_age for my clean method in
> forms.py?
>
> I would be greatful for any help, sorry if i haven't explained this
> very well.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Problem with admin actions and i18n

2010-04-06 Thread Vinicius Mendes
Sorry, i am using Django 1.1.1 final

>>> import django
>>> django.VERSION
(1, 1, 1, 'final', 0)

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Tue, Apr 6, 2010 at 1:09 PM, Ramiro Morales <cra...@gmail.com> wrote:

> On Tue, Apr 6, 2010 at 12:48 PM, Vinicius Mendes <vbmen...@gmail.com>
> wrote:
> > Hi,
> > I have a ModelAdmin with two new actions and I added a
> > locale/pt_BR/LC_MESSAGES to my project folder to change the translation
> of
> > the "Delete selected" option. Locally it works but the translated message
> > user is the provided by Django. I get my change list with 3 actions, but
> > when I run it in production host it gives me an error.
> > The code is at http://gist.github.com/357740 . The ModelAdmin is at
> > admin.py, the messages are at django.po and the traceback at traceback.
> > I always have problems with such differences with i18n lazy objects when
> > dealing with production server. Can anyone help to understand this
> problem?
>
> You don't tell us what version/SVN revision of Django you are using.
>
> The locations shown in the traceback don't match the ones in SVN tip as of
> now.
>
> --
> Ramiro Morales  |  http://rmorales.net
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Problem with admin actions and i18n

2010-04-06 Thread Vinicius Mendes
Hi,

I have a ModelAdmin with two new actions and I added a
locale/pt_BR/LC_MESSAGES to my project folder to change the translation of
the "Delete selected" option. Locally it works but the translated message
user is the provided by Django. I get my change list with 3 actions, but
when I run it in production host it gives me an error.

The code is at http://gist.github.com/357740 . The ModelAdmin is at
admin.py, the messages are at django.po and the traceback at traceback.

I always have problems with such differences with i18n lazy objects when
dealing with production server. Can anyone help to understand this problem?

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/

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



Re: How to concatenate a list of Q objects?

2010-04-06 Thread Vinicius Mendes
I recommend you to read more documentation about python. It's a basic python
feature. You can read more about it here:

http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/

Try this:

Sample.objects.filter(*qObjects)

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Tue, Apr 6, 2010 at 2:54 AM, Aaron  wrote:

> Sample.objects.filter(*qObjects)
>
> On Apr 6, 1:10 am, Daniel  wrote:
> > Hi, I think that this must be super easy, but I'm kind of stumped.
> >
> > I have a list qObjects = [qObject1, qObject2, qObject3]
> > What I'd like is to form this query:  Sample.objects.filter(qObject1,
> > qObject2, qObject3)
> >
> > How would I accomplish what I need?  Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Dashboard plugin/widget development - create new post

2010-04-05 Thread Vinicius Mendes
This list is about Django, not PHP.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Mon, Apr 5, 2010 at 1:23 PM, Jim N  wrote:

> Hi List,
>
> I thought this would be easy at first.  Maybe it is.
>
> I am developing a dashboard widget that creates a post.  Trying to
> emulate what QuickPress does, only the title is from a select box,
> instead of text input.
>
> Here is the form.  It points at wp-admin/post.php.  I get redirected
> to edit.php, but no post shows up.  No error message
> ether.
>
>
>function draw_form($instance) {
>   global $qotd_user_id, $qotd_base_url, $local_url;
>
>   $json = $this->get_questions($qotd_user_id);
>   ?>
>   
>   Question label>
>   
>  foreach($json as &$q) {
>   ?>
>$q{'fields'}{'text'} ?>
>  }
>   ?>
>   
>   Answer label>
>   
>class="mceEditor"
> rows="3" cols="15" tabindex="2">
>   
>   
>name="conversation_post_ID" value="0" /
> >
>name="_wpnonce" value=" php echo wp_create_nonce( "conversate_$qotd_user_id" ) ?>" />
>id="save-post"
> class="button" tabindex="4" value="Save Draft" />
>>
>id="publish"
> accesskey="p" tabindex="5"
>   class="button-primary"
> value="Publish" />
>class="clear" />
>   
>   
>
>  }
> ?>
>
> Thanks in advance for any help or suggestions!
>
> -JIM
>
> P.S.
> Apologies if this question already posted.  I seem to be having
> posting issues.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: URL data in templatetags

2010-04-05 Thread Vinicius Mendes
You can try this:

context['request'].GET

It will work only if you are using RequestContext[1] or add the request to
the template manually. It can be achieved either using generic views [2] or
passing the context_instance parameter to the render_to_response [3]. I
usually prefer to use direct_to_template [4] instead of render_to_response
when I will need to use the Template Context Processors.

[1] http://docs.djangoproject.com/en/dev/ref/templates/api/#id1
[2] http://docs.djangoproject.com/en/dev/ref/generic-views/
[3]
http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response
[4]
http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-direct-to-template

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Mon, Apr 5, 2010 at 8:07 AM, Anders Eide  wrote:

> Hello!
>
> How can i get information from request.GET in a inclusion tag?
>
> http://docs.djangoproject.com/en/1.1/howto/custom-template-tags/#inclusion-tags
>
> - Anders
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Select previous and next from a table

2010-03-31 Thread Vinicius Mendes
I know how to do this with 3 queries:

object = Model.objects.filter(pk=pk)
previous =
Model.objects.filter(votes__lt=object.votes).order_by('-votes')[:1][0]
next = Model.objects.filter(votes__gt=object.votes).order_by('votes')[:1][0]

My only problem with this is if there is any object with the same value for
votes.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Wed, Mar 31, 2010 at 7:45 PM, x13  wrote:

> Hello,
>
> I'm trying to figure out a simple way to get a known record from a
> database but also get the "previous" and "next" records too. My model
> is a Photo table with user's votes :
>
> ID  Votes
>
> 1 24
> 2 5
> 3 102
> 4 21
> 5 10
>
>
> So, if I query for the photo with ID=4 (21 votes) I'd like to get the
> next photo in the votes rank (ID=1 with 24 votes) and the previous
> photo in the rank (ID=5 with 10 votes). Can I do this with only one
> query to the database? Ideas?
>
> Thanks in advance.
> Cheers!
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Getting strange email from "dreamhost"

2010-03-31 Thread Vinicius Mendes
I getting those too.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Wed, Mar 31, 2010 at 12:14 PM, Brandon Taylor wrote:

> I'm getting those from this forum as well.
>
> On Mar 31, 10:13 am, Wiiboy  wrote:
> > Hi guys,
> > I've gotten two emails from "Mail Delivery Subsystem
> > " with the subject "Your message was NOT
> > received by django-us...@googlegroups.com!".
> > The body is below.  Anyone know why I'm getting these?  Is anyone else
> > getting them?  I have no affiliation with Dreamhost or at all, so this
> > is...strange.
> >
> > We're sorry.. your email was unable to be processed by our automatic
> > support system, and so is being returned to you.
> >
> > We could not find your email address in our customer database and so
> > couldn't accept your email. Due to the HUGE volume of spam we receive
> > at this address, we've been forced to implement this new policy.
> >
> > Therefore, please just re-submit your message at:
> >
> >  http://www.dreamhost.com/contact.cgi
> >
> > All messages submitted through that form are guaranteed to be
> > received,
> > even if you aren't currently a customer!
> >
> > Our apologies for the inconvenience,
> > --
> > The Happy DreamHost Support Team!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: modelform validation

2010-03-31 Thread Vinicius Mendes
Test if self.instance.user is not None, if so, change the queryset to
exclude the self.instance.user:

http://gist.github.com/350440

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Wed, Mar 31, 2010 at 11:24 AM, Emanuel  wrote:

> Hi all!
>
> I have a modelform and I want to customize validation.
>
> I'm overriding the method clean_().
>
> When I'm saving the form I want to see if a specific user has been already
> assigned to a project. The only way he can ben assigned again is if he's an
> inactive user, so:
>
> models.py
> Class User(models.Model):
>name = models.CharField(...)
>active = models.BooleanField()
>...
>
> Class Project(models.Model):
>user = models.ForeignKey(User)
>
> **
>
> forms.py
> Class ProjectForm(ModelForm)
>
>def clean_name(self):
>user = self.cleaned_data['user']
>if User.objecs.filter(user.id, active=True):
>raise forms.ValidationError(_("This man has been
> already assign
> to a partner"))
>return user
>
>
> When I'm creating a new project it works fine (I believe, haven't been
> tested
> yet), but when editing it throws an error because the user already exists,
> and
> that's obvious. So, I want to be able to verify if it is a new instance or
> if
> it is an instance being edited.
>
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: content type printed as first line in mails

2010-03-29 Thread Vinicius Mendes
Django algo has a shortcut called django.template.loader.render_to_string.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Mon, Mar 29, 2010 at 8:15 AM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On 29 mar, 10:47, "het.oosten"  wrote:
> > When I send mails with my Django app the first line of every mail is:
> > Content-Type: text/html; charset=utf-8
> >
> > When i watch the message source i noticed that charset=utf-8 is
> > changed into charset=3Dutf-8
> >
> > I also saw that in the message header the mail is marked as:
> > Content-Type: text/plain; charset="utf-8"
> >
> > Why is the contect type printed in the first line of the mail?
> >
> > This is my view:
> > from django.core.mail import send_mail
> > subject = "subject"
> > message = render_to_response('mymail',
>
> Look no further. render_to_response() - as the name implies - returns
> an HTTPResponse object - which doesn't make sense here. You just want
> to render the template:
>
>  t = loader.get_template('mymail')
>  c = Context({
>'Mailaddress': Mailaddress,
>'Mailhash': Mailhash,
>})
>  message = t.render(c)
>
>
> > mymail is a text file in my template directory.
>
> html files, django template files, python source files etc are all
> "text files", you know ?-)
>
>
> HTH
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: tag generates another tags

2010-03-29 Thread Vinicius Mendes
You can include a template with area 1 and inside this template, you add the
other tags.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Sun, Mar 28, 2010 at 6:26 PM, Sławek Tuleja wrote:

> Hi all!
> my question is: can 'tag' generate another tag/s? if yes, what is the
> best practice?
>
> In template e.g. `base.html` i want to have tag: {% area 1 %}, this
> tag communicates with database table called `components` and searching
> for a components (apps) which are established with area 1,
>
> let's say post app and rss app are established with area 1, so {% area
> 1 %} tag generates:
> {% get_posts %} {% get_rss_links %}
> and user gets latests posts and rss links.
>
> that's it
>
> any help is appreciated
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Why must {% extends '' %} be first value in template? Inconvenient for ajax versions.

2010-03-28 Thread Vinicius Mendes
I implemented two solutions for this problem. The first one is the solution
already said here: create a template context processor that inserts a
variable in context with the name of the base template ("base.html" for
normal requests and "base_ajax.html" for ajax requests).

The second one is a bit more complicated. I created a new template tag based
in the {% extends %} that ships with django. The template tag receives the
name of the base template and substitutes ".html" with ".xhr" if the request
is an ajax request. For example: if the template name is "base.html" and the
request is normal, then it will extend the "base.html". But if the request
is ajax, then it will extend the "base.xhr".

I'm thinkin about creating a post in my blog talking about this template
tag. What do you think?

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/
http://meiocodigo.com/


On Sun, Mar 28, 2010 at 9:10 PM, pjrhar...@gmail.com wrote:

>  Ideally, I want to do:
> >
> > {% if not ajax %}
> > {% extends 'base.html' %}
> > {% endif %}
> > {% block content %}Content Here.{% endblock %}
>
> Extends can't be optional. Consider the following:
>
> base_template.html:
> Foo
> {% block foo %}{% endblock %}
> Bar
> {% block bar %}{% endblock %}
>
> other_template.html:
> {% extends "base_template.html" %}
> {% block foo %}Foo{% endblock %}
> {% block bar %}Bar{% endblock %}
>
> Now where do "Foo" and "Bar" appear if you don't have the extends?
>
> Either use an includes, or pass the name of your base template as a
> variable so you can extend "base_template.html" or
> "ajax_base_template.html" which would leave out all the extras.
>
> Peter
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Making email unique

2010-03-28 Thread Vinicius Mendes
email = models.EmailField(unique=True)

If it's using django.contrib.auth you can use something like this in the
init of your project:

from django.contrib.auth.models import User
User._meta.get_field('email').unique = True

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/


On Sun, Mar 28, 2010 at 12:44 PM, Wiiboy  wrote:

> Hi guys,
> I've got a Python website that has to integrate with a forum (i.e.
> when a user registers on mysite.com, they also have to be registered
> automatically on forum.mysite.com).  That forum forces email addresses
> to be unique.  How can I force that on Django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Negate querysets

2010-03-24 Thread Vinicius Mendes | meiocodigo.com
Ok. I thought it was more simple. I don't know the ORM in deep and
forgot about the extra() method. Thanks for the explanation.

On Mar 23, 5:15 pm, James Bennett <ubernost...@gmail.com> wrote:
> On Tue, Mar 23, 2010 at 10:21 AM, Vinicius Mendes | meiocodigo.com
>
> <vbmen...@gmail.com> wrote:
> > integrated to the framework. I think the queryset should keep track of
> > it self. It knows what is the filter, so why can't it negate this
> > filter?
>
> Given an already-existing QuerySet which has already had all the
> filters applied, there's really no way to do this. The reason is that
> there's so much more that can be done to a QuerySet than just calls to
> filter(); for example, calls to extra() may have added additional raw
> SQL in the SELECT or WHERE clauses, and the ORM doesn't have any way
> to work out how to negate arbitrary user-supplied SQL.
>
> The WHERE clause itself is represented on the Query object by an
> instance of django.db.models.sql.where.WhereNode, which is actually a
> tree structure with each node representing part of the WHERE clause.
> Each node in that tree does know whether it's negated or not (and
> hence whether to use a NOT on the constraint each node expresses), but
> walking that tree and figuring out which nodes you'd want to negate
> would be difficult to say the least, and still wouldn't work on a
> QuerySet which had been affected by something like extra().
>
> So about the only way to do this is to collect the filter arguments in
> advance *without* applying them to the QuerySet, and then use either
> exclude() or negated Q objects to ensure you get a "negated" query.
>
> --
> "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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Negate querysets

2010-03-23 Thread Vinicius Mendes | meiocodigo.com
Matt,

I know I can do this, but if I want to write a generic view that
receives a queryset and deletes everything that isn't in this
queryset? I'm not having this problem right now. I just thought that
this was a feature that would be interesting to have in the ORM. And I
am asking if it already exists to think of suggesting it to be
integrated to the framework. I think the queryset should keep track of
it self. It knows what is the filter, so why can't it negate this
filter?

On Mar 23, 10:40 am, Paulo Almeida <igcbioinformat...@gmail.com>
wrote:
> Is there some way you can keep track of the queryset? I understand it's
> dynamic, and maybe complex, for you to be looking for this kind of solution,
> but if it were possible to have a variable or dictionary keeping track of
> what you add to the queryset, it might be possible to use it to build the
> inverse.
>
> - Paulo
>
> On Tue, Mar 23, 2010 at 1:23 PM, Vinicius Mendes | meiocodigo.com <
>
>
>
> vbmen...@gmail.com> wrote:
> > Ok. The code proposed by Tim Shaffer works and gives only one query.
> > But it makes use of subselects, what is heavy for the database. Take a
> > look at the generated SQL:
>
> > 'SELECT `auth_user`.`id`, `auth_user`.`username`,
> > `auth_user`.`first_name`, `auth_user`.`last_name`,
> > `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
> > `auth_user`.`is_active`, `auth_user`.`is_superuser`,
> > `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
> > WHERE NOT (`auth_user`.`id` IN (SELECT U0.`id` FROM `auth_user` U0
> > WHERE U0.`first_name` = vinicius )) LIMIT 21'
>
> > I was thinking of something like:
>
> > 'SELECT `auth_user`.`id`, `auth_user`.`username`,
> > `auth_user`.`first_name`, `auth_user`.`last_name`,
> > `auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
> > `auth_user`.`is_active`, `auth_user`.`is_superuser`,
> > `auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
> > WHERE NOT `auth_user`.`first_name` = vinicius  LIMIT 21'
>
> > Why hit the database if I can do this with boolean login? Why not
> > negate the filter condition instead of doing a subselect?
>
> > On Mar 22, 7:15 pm, Tim Shaffer <timster...@gmail.com> wrote:
> > > It depends. This will only run one query, when negated_queryset is
> > > used.
>
> > > queryset = User.objects.filter(first_name='vinicius')
> > > negated_queryset = User.objects.exclude(id__in=queryset.values("id"))
>
> > > Since the first queryset is not evaluated until it's used in the
> > > negated_queryset (as a subquery).
>
> > > On Mar 22, 5:55 pm, Matt Schinckel <m...@schinckel.net> wrote:
>
> > > > On Mar 23, 6:17 am, Phlip <phlip2...@gmail.com> wrote:
>
> > > > > > Just create another queryset that excludes everything in your first
> > > > > > queryset:
>
> > > > > > negated_queryset =
> > User.objects.exclude(id__in=queryset.values("id"))
>
> > > > > QuerySets are already so easy to plug-n-play... Ain't there a way to
> > > > > do it without whacking the database twice?
>
> > > > Are you sure it hits the db twice? I seem to recall a similar case
> > > > where I thought I was, but since the queryset evaluation is lazy, the
> > > > ORM potentially has the ability to make this into a single query.
>
> > > > (I can't recall if when I did this sort of thing I was using
> > > > SQLAlchemy, but I _think_ it was pure django).
>
> > > > Matt.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google 
> > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Negate querysets

2010-03-23 Thread Vinicius Mendes | meiocodigo.com
Ok. The code proposed by Tim Shaffer works and gives only one query.
But it makes use of subselects, what is heavy for the database. Take a
look at the generated SQL:

'SELECT `auth_user`.`id`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`,
`auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
`auth_user`.`is_active`, `auth_user`.`is_superuser`,
`auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
WHERE NOT (`auth_user`.`id` IN (SELECT U0.`id` FROM `auth_user` U0
WHERE U0.`first_name` = vinicius )) LIMIT 21'

I was thinking of something like:

'SELECT `auth_user`.`id`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`,
`auth_user`.`email`, `auth_user`.`password`, `auth_user`.`is_staff`,
`auth_user`.`is_active`, `auth_user`.`is_superuser`,
`auth_user`.`last_login`, `auth_user`.`date_joined` FROM `auth_user`
WHERE NOT `auth_user`.`first_name` = vinicius  LIMIT 21'

Why hit the database if I can do this with boolean login? Why not
negate the filter condition instead of doing a subselect?

On Mar 22, 7:15 pm, Tim Shaffer  wrote:
> It depends. This will only run one query, when negated_queryset is
> used.
>
> queryset = User.objects.filter(first_name='vinicius')
> negated_queryset = User.objects.exclude(id__in=queryset.values("id"))
>
> Since the first queryset is not evaluated until it's used in the
> negated_queryset (as a subquery).
>
> On Mar 22, 5:55 pm, Matt Schinckel  wrote:
>
>
>
> > On Mar 23, 6:17 am, Phlip  wrote:
>
> > > > Just create another queryset that excludes everything in your first
> > > > queryset:
>
> > > > negated_queryset = User.objects.exclude(id__in=queryset.values("id"))
>
> > > QuerySets are already so easy to plug-n-play... Ain't there a way to
> > > do it without whacking the database twice?
>
> > Are you sure it hits the db twice? I seem to recall a similar case
> > where I thought I was, but since the queryset evaluation is lazy, the
> > ORM potentially has the ability to make this into a single query.
>
> > (I can't recall if when I did this sort of thing I was using
> > SQLAlchemy, but I _think_ it was pure django).
>
> > Matt.

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



Negate querysets

2010-03-22 Thread Vinicius Mendes
Is there any way to negate a queryset? Let's supose i have this queryset:

User.objects.filter(first_name='vinicius')

and I want to have the queryset with the objects that is not in first
queryset. I know I can do this:

User.objects.exclude(first_name='vinicius')

But we have cases where we don't know what is the queryset, we only knows
that we want to get the elements that isn't in it, like this:

queryset.negate()

It's good to keep the chainable property of querysets.

__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/

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



Re: Model design

2009-10-26 Thread Vinicius Mendes | meiocodigo.com

def __unicode__(self):
return unicode(self.place)+' - '+self.nome

On Oct 25, 8:47 pm, Caisys <amamd...@gmail.com> wrote:
> Thanks but I am not very familiar with forms yet I barely managed to
> override the default form.
> However, I thought that its ok for the time being since places and
> subplaces are not changed frequently so i can live with it for the
> time being and move to more important parts until I am more familiar
> with the forms.
>
> I just need to know how to call the a related field in __unicode__
> (self)
>
> On Oct 25, 2:30 pm, "Vinicius Mendes | meiocodigo.com"
>
> <vbmen...@gmail.com> wrote:
> > On Oct 25, 4:53 am, Caisys <amamd...@gmail.com> wrote:
>
> > > > Just override the form in the inlne admin. All you have to do is set a
> > > > default in the field you want.
>
> > > I managed to do that but now all the extra fields have the default
> > > text not just one.
>
> > What about overriding the formset? You override the __init__ of the
> > formset and before calling super, you add an initial data to the
> > formset adding the default value for the first form.
>
> > > > In this case i prefer the approach of creating a "fake" field called
> > > > places, populated with the places, and when the user select the place,
> > > > you do an ajax request and populate the subplace select with the
> > > > subplaces from the selected place. You will have to override the form
> > > > in the ModelAdmin and add this behaviour to the form. Also you will
> > > > have to create a view to retrieve the subplaces based in the selected
> > > > place.
>
> > > I am not so sure how to do that yet. However, i would like to know how
> > > i could not return the related object name in __unicode__ . Where did
> > > I go wrong?
>
> > > Thanks
>
> > > On Oct 24, 1:38 pm, "Vinicius Mendes | meiocodigo.com"
>
> > > <vbmen...@gmail.com> wrote:
> > > > On Oct 24, 7:14 am, Caisys <amamd...@gmail.com> wrote:
>
> > > > > Thanks !!! I also felt the second sounds more "right" which leads to
> > > > > two requirements, the first is for convenience but the second is a
> > > > > must:
>
> > > > > 1) On the admin page for add Place I will put 2 or 3 slots for adding
> > > > > Subplace to a place ... is there a way where the first one would be
> > > > > filled with "default" by default? so that each created place would
> > > > > have a default subplace?
>
> > > > Just override the form in the inlne admin. All you have to do is set a
> > > > default in the field you want.
>
> > > > > 2) On the admin page for add event there will be a drop down list for
> > > > > the subplace most of the subplaces will be called "default" is
> > > > > there a way to change the label on drop down list to "place -
> > > > > subplace". i tried to change the __unicode__ of subplace to "return
> > > > > u"% - %" % (self.place, self.name)" but it generated and error that
> > > > > subplace object has no attribute 'place'.
>
> > > > In this case i prefer the approach of creating a "fake" field called
> > > > places, populated with the places, and when the user select the place,
> > > > you do an ajax request and populate the subplace select with the
> > > > subplaces from the selected place. You will have to override the form
> > > > in the ModelAdmin and add this behaviour to the form. Also you will
> > > > have to create a view to retrieve the subplaces based in the selected
> > > > place.
>
> > > > > thanks
>
> > > > > On Oct 24, 2:27 am, Léon Dignòn <leon.dig...@gmail.com> wrote:
>
> > > > > > The second sounds more logically.
>
> > > > > > On 23 Okt., 15:41, chefsmart <moran.cors...@gmail.com> wrote:
>
> > > > > > > I would go with your second solution.
>
> > > > > > > On Oct 23, 5:17 pm, Caisys <amamd...@gmail.com> wrote:
>
> > > > > > > > Hi,
> > > > > > > > I have classes for Event, Place and Subplace. Some of the 
> > > > > > > > Places are
> > > > > > > > divided into different Halls (Subplace) and some have only one. 
> > > > > > > > I
> > > > > > > > would like to know how design the relations between the classes.
>
> > > > > > > > 1) Should I put two columns in the Event one FK to Place and 
> > > > > > > > another
> > > > > > > > FK to Hall?
> > > > > > > > 2) Should I create one FK only to Hall and create a record in 
> > > > > > > > Hall for
> > > > > > > > every Place even if the Place has no Halls?
>
> > > > > > > > Thanks- Zitierten Text ausblenden -
>
> > > > > > > - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 design

2009-10-25 Thread Vinicius Mendes | meiocodigo.com

On Oct 25, 4:53 am, Caisys <amamd...@gmail.com> wrote:
> > Just override the form in the inlne admin. All you have to do is set a
> > default in the field you want.
>
> I managed to do that but now all the extra fields have the default
> text not just one.
>

What about overriding the formset? You override the __init__ of the
formset and before calling super, you add an initial data to the
formset adding the default value for the first form.

> > In this case i prefer the approach of creating a "fake" field called
> > places, populated with the places, and when the user select the place,
> > you do an ajax request and populate the subplace select with the
> > subplaces from the selected place. You will have to override the form
> > in the ModelAdmin and add this behaviour to the form. Also you will
> > have to create a view to retrieve the subplaces based in the selected
> > place.
>
> I am not so sure how to do that yet. However, i would like to know how
> i could not return the related object name in __unicode__ . Where did
> I go wrong?
>
> Thanks
>
> On Oct 24, 1:38 pm, "Vinicius Mendes | meiocodigo.com"
>
> <vbmen...@gmail.com> wrote:
> > On Oct 24, 7:14 am, Caisys <amamd...@gmail.com> wrote:
>
> > > Thanks !!! I also felt the second sounds more "right" which leads to
> > > two requirements, the first is for convenience but the second is a
> > > must:
>
> > > 1) On the admin page for add Place I will put 2 or 3 slots for adding
> > > Subplace to a place ... is there a way where the first one would be
> > > filled with "default" by default? so that each created place would
> > > have a default subplace?
>
> > Just override the form in the inlne admin. All you have to do is set a
> > default in the field you want.
>
> > > 2) On the admin page for add event there will be a drop down list for
> > > the subplace most of the subplaces will be called "default" is
> > > there a way to change the label on drop down list to "place -
> > > subplace". i tried to change the __unicode__ of subplace to "return
> > > u"% - %" % (self.place, self.name)" but it generated and error that
> > > subplace object has no attribute 'place'.
>
> > In this case i prefer the approach of creating a "fake" field called
> > places, populated with the places, and when the user select the place,
> > you do an ajax request and populate the subplace select with the
> > subplaces from the selected place. You will have to override the form
> > in the ModelAdmin and add this behaviour to the form. Also you will
> > have to create a view to retrieve the subplaces based in the selected
> > place.
>
> > > thanks
>
> > > On Oct 24, 2:27 am, Léon Dignòn <leon.dig...@gmail.com> wrote:
>
> > > > The second sounds more logically.
>
> > > > On 23 Okt., 15:41, chefsmart <moran.cors...@gmail.com> wrote:
>
> > > > > I would go with your second solution.
>
> > > > > On Oct 23, 5:17 pm, Caisys <amamd...@gmail.com> wrote:
>
> > > > > > Hi,
> > > > > > I have classes for Event, Place and Subplace. Some of the Places are
> > > > > > divided into different Halls (Subplace) and some have only one. I
> > > > > > would like to know how design the relations between the classes.
>
> > > > > > 1) Should I put two columns in the Event one FK to Place and another
> > > > > > FK to Hall?
> > > > > > 2) Should I create one FK only to Hall and create a record in Hall 
> > > > > > for
> > > > > > every Place even if the Place has no Halls?
>
> > > > > > Thanks- Zitierten Text ausblenden -
>
> > > > > - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 design

2009-10-24 Thread Vinicius Mendes | meiocodigo.com



On Oct 24, 7:14 am, Caisys  wrote:
> Thanks !!! I also felt the second sounds more "right" which leads to
> two requirements, the first is for convenience but the second is a
> must:
>
> 1) On the admin page for add Place I will put 2 or 3 slots for adding
> Subplace to a place ... is there a way where the first one would be
> filled with "default" by default? so that each created place would
> have a default subplace?
>

Just override the form in the inlne admin. All you have to do is set a
default in the field you want.

> 2) On the admin page for add event there will be a drop down list for
> the subplace most of the subplaces will be called "default" is
> there a way to change the label on drop down list to "place -
> subplace". i tried to change the __unicode__ of subplace to "return
> u"% - %" % (self.place, self.name)" but it generated and error that
> subplace object has no attribute 'place'.
>

In this case i prefer the approach of creating a "fake" field called
places, populated with the places, and when the user select the place,
you do an ajax request and populate the subplace select with the
subplaces from the selected place. You will have to override the form
in the ModelAdmin and add this behaviour to the form. Also you will
have to create a view to retrieve the subplaces based in the selected
place.

> thanks
>
> On Oct 24, 2:27 am, Léon Dignòn  wrote:
>
> > The second sounds more logically.
>
> > On 23 Okt., 15:41, chefsmart  wrote:
>
> > > I would go with your second solution.
>
> > > On Oct 23, 5:17 pm, Caisys  wrote:
>
> > > > Hi,
> > > > I have classes for Event, Place and Subplace. Some of the Places are
> > > > divided into different Halls (Subplace) and some have only one. I
> > > > would like to know how design the relations between the classes.
>
> > > > 1) Should I put two columns in the Event one FK to Place and another
> > > > FK to Hall?
> > > > 2) Should I create one FK only to Hall and create a record in Hall for
> > > > every Place even if the Place has no Halls?
>
> > > > Thanks- Zitierten Text ausblenden -
>
> > > - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Trac + Sphinx

2009-03-31 Thread Vinicius Mendes
Hi all,

Does anyone here integrate trac and sphinx? How do you take advantages from
this?



Vinícius Mendes
Engenheiro de Computação
Meio Código - A peça que faltava para o seu código!
URL http://www.meiocodigo.com

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



POST sub dictionaries

2009-01-19 Thread Vinicius Mendes
Is there in django something like the PHP POST subarrays?

For example, if i do this in my form:




and submit it, i will have the following data structure in my PHP POST:

$_POST = array(
'test' => array(
0 => 0,
1 => 1
)
)

In django, i think it can turn into:

request.POST = {
'test': (0,1)
}

What means it is a dictionary with a tuple as the value of the 'test' key.

Another case is this:



Whet gives this in PHP:

$_POST = array(
'test' => array(
'key' => 1
)
)

What means the following in python:

request.POST = {
'test': {
'key': 1
}
}

Is there anything like this in django? I think it can make formsets much
more easier to use, and eliminates the needing of the management_form.



Vinícius Mendes
Engenheiro de Computação
Meio Código - A peça que faltava para o seu código!
URL http://www.meiocodigo.com

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