Re: django help

2011-04-30 Thread Andres Lucena
El 30/04/11 14:56, Marcos Moyano escribió:
> Read the static-files docs
> 

Also read this document:

http://www.catb.org/~esr/faqs/smart-questions.html


> On Sat, Apr 30, 2011 at 4:14 AM, Sunil Chugh  > wrote:
> 
> how can i used static_root
> 
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 
> -- 
> Some people, when confronted with a problem, think “I know, I'll use
> regular expressions.” Now they have two problems.
> 
> Jamie Zawinski, in comp.emacs.xemacs
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: problem installing django 1.3 in virtualenv

2011-04-30 Thread Andres Lucena
El 30/04/11 18:06, shofty escribió:
> recreated the virtualenv from scratch totally, still got the same
> result. what am i doing wrong here? really cant work it out.

Exactly what is the output?

What is the content of $HOME/.pip/pip.log?

$ cat $HOME/.pip/pip.log


Also, I don't understand what you say later, about that you installed it
but not the right version. Pass the output of this command:

$ source envname/bin/activate
$ python -c 'import django ; print django.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.



Re: Apache2 with static file

2011-04-05 Thread Andres Lucena
On Tue, Apr 5, 2011 at 9:33 AM, yongzhen zhang <4...@live.cn> wrote:
> Hi,
> i have one problem with my apache2 work with static file.
> In apache2/sites-available file:
> 
>        ServerName www.imaboy.cn
>        ServerAlias shop.imaboy.cn
>       Alias /static /home/yongzhen/workspace/www/iStore/static
> 
> I want use apache to route to my static file. It works somehow, like
> if i type:imaboy.cn/static, i has the results .in my development
> server i opened 8000 port, like that:http://imaboy.cn:8000/  .The
> problem is that the static file is not shown, in the command window,
> it shows: "GET /static/images/ipad2_6.jpg HTTP/1.1" 200 5175. Anyone
> can help me? thanks a lot.
>

It seems like you're trying to mix up the development server (./manage
runserver) with Apache serving statics. I don't know why would you
want that.

If you want to serve statics from the development server, then you should read:
http://docs.djangoproject.com/en/dev/howto/static-files/


See you,
Andres

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

2011-03-16 Thread Andres Lucena
El lun, 14-03-2011 a las 11:45 -0500, Juan Gabriel Aldana Jaramillo
escribió:
> Thanks for your comprehensive reply. Now everything is clear to me.
> 

Also you should check django-rosetta, it permits translating through an
admin like interface, with google translate integration; very nice ;) 

http://code.google.com/p/django-rosetta/

Bye,
Andres



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



Re: jquery toggle in form from model

2011-03-09 Thread Andres Lucena
El mié, 09-03-2011 a las 12:17 -0500, Rich Wilson escribió:
> Hello all, I was wondering if I could get some guidance using jquery.
> 
> I have a form from model in which I would like to display certain form
> fields based on a check box being checked or unchecked.  Could also be
> done using a button.  I am already using Jquery datepicker and
> timepicker in the form which works fine.  Jquery toggle is here.
> I can get it work elsewhere, just not inside the form.
> 
> Here is a some template code where 'e' is the form from model being
> passed in, the datepicker code included as a quide for how toggle
> should work, and toggle code using a button to toggle highlighted.
> Thanks in advance.
> 
> ~ Rich
> 
/.../

Hey Rich, 

This is the Django mailing list, and this question is regarding JQuery.
Maybe JQuery have a list or you can try in StackOverflow...

Also, maybe what you're looking is this one:

http://api.jquery.com/checked-selector/

And: 

http://api.jquery.com/checkbox-selector/

See you,
Andres


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

2011-02-21 Thread Andres Lucena
El dom, 20-02-2011 a las 21:18 -0800, Ash escribió:
> Hi , I am new to Python and Django.
> 
> Can some please let me know -
> 

First of all, when you write a mail to a mailing list, you should put a
more descriptive subject (almost everyone who writes here is requiring
help).

> 1) can I use Django framework for my existing Python application.

You didn't say what your application is about. 

> 2) or do I need to write the whole application again,

I would recommend you, giving that you're new to Django and Python, to
start all over... 

> 3) If I can use , can someone tell me how to proceed?
> 

Probably if your application is well coded you could import it and use
it in Django... But again, we don't know what your application is
about

Greetings,
Andres


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



Re: Ordering/sort_by from a custom method

2011-02-17 Thread Andres Lucena
El jue, 10-02-2011 a las 07:44 -0800, Alex Robbins escribió:
> Wow, you are right. This is a tricky lookup. The generic relation
> makes it pretty tough. I'd just use the python sort unless you see a
> real performance problem.
> 
> class LinkGetTopScores(models.Manager):
> def get_top_score(self):
> return sorted(self.all(), key=lambda n: n.get_score)
> 
> Maybe you need to make it n.get_score(), instead of n.get_score in the
> lambda.
> 

Sorry for no answering this before. 

Nop, this didn't work either :(

The solution I'll try then is with SQL, something similar to this and
the get_top method: 
http://stackoverflow.com/questions/544597/problem-ordering-by-votes-with-django-voting

Thank you for your help Alex. 

Bye,
Andres

> 
> Alex
> 
> On Feb 10, 8:54 am, Andres Lucena <andresluc...@gmail.com> wrote:
> > On Thu, Feb 10, 2011 at 2:52 PM, Alex Robbins
> >
> > <alexander.j.robb...@gmail.com> wrote:
> > > Do you want the episode with the highest individual score, or the
> > > highest average score?
> >
> > I want the links (within that episode) sorted by highest score.
> >
> > (Sorry for no making it clear before)
> >
> > Thank you,
> > Andres
> >
> >
> >
> >
> >
> >
> >
> > > Alex
> >
> > > On Thu, Feb 10, 2011 at 7:41 AM, Andres Lucena <andresluc...@gmail.com> 
> > > wrote:
> > >> On Thu, Feb 10, 2011 at 2:29 PM, Alex Robbins
> > >> <alexander.j.robb...@gmail.com> wrote:
> > >>> Yeah, you'll definitely want to find some aggregate to do the sorting.
> >
> > >> Ok, didn't know it. I'll take a look at it...
> >
> > >>> The only way to sort by a custom method is doing an in-python sort,
> > >>> which is going to be much slower than having the db sort for you.
> >
> > >> Yeah, I tought so but it seems (to me) the only way of doing this...
> >
> > >>>  If you post the score models, we could probably help more.
> >
> > >> The score models are from django-voting:
> >
> > >>http://django-voting.googlecode.com/svn/trunk/voting/models.py
> > >>http://django-voting.googlecode.com/svn/trunk/voting/managers.py
> >
> > >> Thanks for the help!
> >
> > >> Andres
> >
> > >>> Alex
> >
> > >>> On Feb 9, 8:49 am, "Casey S. Greene" <csgre...@princeton.edu> wrote:
> > >>>> I haven't used django-voting but it sounds to me like you want 
> > >>>> something
> > >>>> like:
> > >>>> Link.objects.aggregate(Avg(score = 'vote__score')).order_by('score')
> >
> > >>>> If I recall correctly you can chain aggregate and order_by.
> >
> > >>>> Anyway, that example and this link should get you started at 
> > >>>> least:http://docs.djangoproject.com/en/dev/topics/db/aggregation/
> >
> > >>>> Hope this helps!
> > >>>> Casey
> >
> > >>>> On Wed, 2011-02-09 at 10:08 +0100, Andres Lucena wrote:
> > >>>> > On Tue, Feb 8, 2011 at 6:00 PM, Andres Lucena 
> > >>>> > <andresluc...@gmail.com> wrote:
> > >>>> > > Dear Gurus,
> >
> > >>>> > > I've made a custom method for getting the score (from 
> > >>>> > > django-voting)
> > >>>> > > for a giving Model:
> >
> > >>>> > > class Link(models.Model):
> > >>>> > >episode = models.ForeignKey("Episode", related_name="links")
> > >>>> > >url = models.CharField(max_length=255, unique=True, 
> > >>>> > > db_index=True)
> >
> > >>>> > >def __unicode__(self):
> > >>>> > >return self.url
> >
> > >>>> > >def get_score(self):
> > >>>> > >return Vote.objects.get_score(self)['score']
> >
> > >>>> > > Now I want to make a custom manager to getting the top-scored links
> > >>>> > > for the given episode. AFAIK, you can't sort by a custom method, so
> > >>>> > > I'm trying to apply the ordering through sorted(), like this links
> > >>>> > > says:
> >
> > >>>> > >http://stackoverflow.com/questions/981375/using-a-django-custom-model...
> > >>>> > >http://stack

Re: Customize flatpage

2011-02-13 Thread Andres Lucena
El dom, 13-02-2011 a las 04:02 -0800, galago escribió:
> Should I alternate original flatpage midddleware?
> If I won't do that, my new fields can be unseen?

No, you don't have to change the middleware. 

AFAIK the middleware [0] the only thing it does is capture the 404 and
try to get the flatpage. 

Also check this stack overflow question [1], I think is what you're
trying to do. 


[0]
http://code.djangoproject.com/browser/django/trunk/django/contrib/flatpages/middleware.py

[1]
http://stackoverflow.com/questions/1021487/add-functionality-to-django-flatpages-without-changing-the-original-django-app

Good luck, 
Andres

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



Re: Login, Password Recovery, etc

2011-02-13 Thread Andres Lucena
El vie, 11-02-2011 a las 21:06 -0500, Mike Seidle escribió:
> Quick question - is there an application or examples of completely 
> implemented 
> user authentication templates?  It's getting old trying to devine how to set 
> up templates for password recovery and registration. Seems to me that this 
> should (and probably is) included with the rest of the batteries.
> 

Sure, here: 

https://github.com/yourcelf/django-registration-defaults

Also this one: 

https://github.com/banterability/django-registration-templates

(don't remember what was the one I used, but the two seems to be fine)

Hope this is what you're looking for. 

See you, 
Andres



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



Re: Customize flatpage

2011-02-13 Thread Andres Lucena
El vie, 11-02-2011 a las 12:35 -0800, galago escribió:
> I found that
> link: http://linfiniti.com/2011/01/bending-django-flatpages-to-your-will. I 
> want to make some customization in flatpage. Where should I put this extra 
> module and form?
> I want to add 2 fields to custom flatpage.
> 

You can put it everywhere in your project, I think the best would be
putting it in app_name/models.py (or creating another app just for the
flatpage); then you have to referenciate it in the app_name/admin.py, in
the line:

from models import ExtendedFlatPage

Would be

from app_name.models import ExtendedFlatPage 

Good luck,
Andres

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



Re: Ordering/sort_by from a custom method

2011-02-10 Thread Andres Lucena
On Thu, Feb 10, 2011 at 2:52 PM, Alex Robbins
<alexander.j.robb...@gmail.com> wrote:
> Do you want the episode with the highest individual score, or the
> highest average score?
>

I want the links (within that episode) sorted by highest score.

(Sorry for no making it clear before)

Thank you,
Andres


> Alex
>
> On Thu, Feb 10, 2011 at 7:41 AM, Andres Lucena <andresluc...@gmail.com> wrote:
>> On Thu, Feb 10, 2011 at 2:29 PM, Alex Robbins
>> <alexander.j.robb...@gmail.com> wrote:
>>> Yeah, you'll definitely want to find some aggregate to do the sorting.
>>
>> Ok, didn't know it. I'll take a look at it...
>>
>>> The only way to sort by a custom method is doing an in-python sort,
>>> which is going to be much slower than having the db sort for you.
>>
>> Yeah, I tought so but it seems (to me) the only way of doing this...
>>
>>>  If you post the score models, we could probably help more.
>>
>> The score models are from django-voting:
>>
>> http://django-voting.googlecode.com/svn/trunk/voting/models.py
>> http://django-voting.googlecode.com/svn/trunk/voting/managers.py
>>
>> Thanks for the help!
>>
>> Andres
>>
>>
>>>
>>> Alex
>>>
>>> On Feb 9, 8:49 am, "Casey S. Greene" <csgre...@princeton.edu> wrote:
>>>> I haven't used django-voting but it sounds to me like you want something
>>>> like:
>>>> Link.objects.aggregate(Avg(score = 'vote__score')).order_by('score')
>>>>
>>>> If I recall correctly you can chain aggregate and order_by.
>>>>
>>>> Anyway, that example and this link should get you started at 
>>>> least:http://docs.djangoproject.com/en/dev/topics/db/aggregation/
>>>>
>>>> Hope this helps!
>>>> Casey
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, 2011-02-09 at 10:08 +0100, Andres Lucena wrote:
>>>> > On Tue, Feb 8, 2011 at 6:00 PM, Andres Lucena <andresluc...@gmail.com> 
>>>> > wrote:
>>>> > > Dear Gurus,
>>>>
>>>> > > I've made a custom method for getting the score (from django-voting)
>>>> > > for a giving Model:
>>>>
>>>> > > class Link(models.Model):
>>>> > >    episode = models.ForeignKey("Episode", related_name="links")
>>>> > >    url = models.CharField(max_length=255, unique=True, db_index=True)
>>>>
>>>> > >    def __unicode__(self):
>>>> > >        return self.url
>>>>
>>>> > >    def get_score(self):
>>>> > >        return Vote.objects.get_score(self)['score']
>>>>
>>>> > > Now I want to make a custom manager to getting the top-scored links
>>>> > > for the given episode. AFAIK, you can't sort by a custom method, so
>>>> > > I'm trying to apply the ordering through sorted(), like this links
>>>> > > says:
>>>>
>>>> > >http://stackoverflow.com/questions/981375/using-a-django-custom-model...
>>>> > >http://stackoverflow.com/questions/883575/custom-ordering-in-django
>>>>
>>>> > > So, what I have now is this:
>>>>
>>>> > > class LinkGetTopScores(models.Manager):
>>>> > >    def get_top_score(self):
>>>> > >        return sorted(self.filter(episode=self.episode), key=lambda n:
>>>> > > n.get_score)
>>>>
>>>> > > class Link(models.Model):
>>>> > >    episode = models.ForeignKey("Episode", related_name="links")
>>>> > >    url = models.CharField(max_length=255, unique=True, db_index=True)
>>>> > >    get_top_score = LinkGetTopScores()
>>>> > > 
>>>>
>>>> > > So of course this isn't working because of the self.episode stuff...
>>>> > > But I've to filter somehow by episode (the ForeignKey), and I don't
>>>> > > know how. Is there anyway of doing this?? What I'm doing is right or
>>>> > > there would be an easier way of doing this?
>>>>
>>>> > I noticed that the .filter isn't necesary, so now I have this:
>>>>
>>>> > class LinkGetTopScores(models.Manager):
>>>> >     def get_top_score(self):
>>>> >         return sorted(s

Re: Ordering/sort_by from a custom method

2011-02-10 Thread Andres Lucena
On Thu, Feb 10, 2011 at 2:29 PM, Alex Robbins
<alexander.j.robb...@gmail.com> wrote:
> Yeah, you'll definitely want to find some aggregate to do the sorting.

Ok, didn't know it. I'll take a look at it...

> The only way to sort by a custom method is doing an in-python sort,
> which is going to be much slower than having the db sort for you.

Yeah, I tought so but it seems (to me) the only way of doing this...

>  If you post the score models, we could probably help more.

The score models are from django-voting:

http://django-voting.googlecode.com/svn/trunk/voting/models.py
http://django-voting.googlecode.com/svn/trunk/voting/managers.py

Thanks for the help!

Andres


>
> Alex
>
> On Feb 9, 8:49 am, "Casey S. Greene" <csgre...@princeton.edu> wrote:
>> I haven't used django-voting but it sounds to me like you want something
>> like:
>> Link.objects.aggregate(Avg(score = 'vote__score')).order_by('score')
>>
>> If I recall correctly you can chain aggregate and order_by.
>>
>> Anyway, that example and this link should get you started at 
>> least:http://docs.djangoproject.com/en/dev/topics/db/aggregation/
>>
>> Hope this helps!
>> Casey
>>
>>
>>
>>
>>
>>
>>
>> On Wed, 2011-02-09 at 10:08 +0100, Andres Lucena wrote:
>> > On Tue, Feb 8, 2011 at 6:00 PM, Andres Lucena <andresluc...@gmail.com> 
>> > wrote:
>> > > Dear Gurus,
>>
>> > > I've made a custom method for getting the score (from django-voting)
>> > > for a giving Model:
>>
>> > > class Link(models.Model):
>> > >    episode = models.ForeignKey("Episode", related_name="links")
>> > >    url = models.CharField(max_length=255, unique=True, db_index=True)
>>
>> > >    def __unicode__(self):
>> > >        return self.url
>>
>> > >    def get_score(self):
>> > >        return Vote.objects.get_score(self)['score']
>>
>> > > Now I want to make a custom manager to getting the top-scored links
>> > > for the given episode. AFAIK, you can't sort by a custom method, so
>> > > I'm trying to apply the ordering through sorted(), like this links
>> > > says:
>>
>> > >http://stackoverflow.com/questions/981375/using-a-django-custom-model...
>> > >http://stackoverflow.com/questions/883575/custom-ordering-in-django
>>
>> > > So, what I have now is this:
>>
>> > > class LinkGetTopScores(models.Manager):
>> > >    def get_top_score(self):
>> > >        return sorted(self.filter(episode=self.episode), key=lambda n:
>> > > n.get_score)
>>
>> > > class Link(models.Model):
>> > >    episode = models.ForeignKey("Episode", related_name="links")
>> > >    url = models.CharField(max_length=255, unique=True, db_index=True)
>> > >    get_top_score = LinkGetTopScores()
>> > > 
>>
>> > > So of course this isn't working because of the self.episode stuff...
>> > > But I've to filter somehow by episode (the ForeignKey), and I don't
>> > > know how. Is there anyway of doing this?? What I'm doing is right or
>> > > there would be an easier way of doing this?
>>
>> > I noticed that the .filter isn't necesary, so now I have this:
>>
>> > class LinkGetTopScores(models.Manager):
>> >     def get_top_score(self):
>> >         return sorted(self.all(), key=lambda n: n.get_score)
>>
>> > But it don't sort by score, and I don't know what I'm doing wrong :S
>>
>> > Any idea?
>>
>> > Thanks,
>> > Andres
>>
>> > > Thank you,
>> > > Andres
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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: Ordering/sort_by from a custom method

2011-02-09 Thread Andres Lucena
On Tue, Feb 8, 2011 at 6:00 PM, Andres Lucena <andresluc...@gmail.com> wrote:
> Dear Gurus,
>
> I've made a custom method for getting the score (from django-voting)
> for a giving Model:
>
> class Link(models.Model):
>    episode = models.ForeignKey("Episode", related_name="links")
>    url = models.CharField(max_length=255, unique=True, db_index=True)
>
>    def __unicode__(self):
>        return self.url
>
>    def get_score(self):
>        return Vote.objects.get_score(self)['score']
>
> Now I want to make a custom manager to getting the top-scored links
> for the given episode. AFAIK, you can't sort by a custom method, so
> I'm trying to apply the ordering through sorted(), like this links
> says:
>
> http://stackoverflow.com/questions/981375/using-a-django-custom-model-method-property-in-order-by
> http://stackoverflow.com/questions/883575/custom-ordering-in-django
>
> So, what I have now is this:
>
> class LinkGetTopScores(models.Manager):
>    def get_top_score(self):
>        return sorted(self.filter(episode=self.episode), key=lambda n:
> n.get_score)
>
> class Link(models.Model):
>    episode = models.ForeignKey("Episode", related_name="links")
>    url = models.CharField(max_length=255, unique=True, db_index=True)
>    get_top_score = LinkGetTopScores()
> 
>
> So of course this isn't working because of the self.episode stuff...
> But I've to filter somehow by episode (the ForeignKey), and I don't
> know how. Is there anyway of doing this?? What I'm doing is right or
> there would be an easier way of doing this?
>

I noticed that the .filter isn't necesary, so now I have this:

class LinkGetTopScores(models.Manager):
def get_top_score(self):
return sorted(self.all(), key=lambda n: n.get_score)

But it don't sort by score, and I don't know what I'm doing wrong :S

Any idea?

Thanks,
Andres


> Thank you,
> Andres
>

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



Re: Calling out for Help!

2011-02-08 Thread Andres Lucena
On Tue, Feb 8, 2011 at 6:11 PM, Tom Evans  wrote:
> On Tue, Feb 8, 2011 at 5:01 PM, Dev@CB  wrote:
>> Tom, why are you discouraging me?
>>
>
> My intention was not to discourage you; it was to encourage you to ask
> a sensible question in a legible manner. If you take slight at that,
> then I have no problem with not corresponding with you further.
>

I think that is always helpful this text:

http://www.catb.org/~esr/faqs/smart-questions.html

Specially the part:

1. Try to find an answer by searching the archives of the forum you
plan to post to.
2. Try to find an answer by searching the Web.
3. Try to find an answer by reading the manual.
4. Try to find an answer by reading a FAQ.
5. Try to find an answer by inspection or experimentation.
6. Try to find an answer by asking a skilled friend.
7. If you're a programmer, try to find an answer by reading the source code.

And the return key is your friend ;)

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



Ordering/sort_by from a custom method

2011-02-08 Thread Andres Lucena
Dear Gurus,

I've made a custom method for getting the score (from django-voting)
for a giving Model:

class Link(models.Model):
episode = models.ForeignKey("Episode", related_name="links")
url = models.CharField(max_length=255, unique=True, db_index=True)

def __unicode__(self):
return self.url

def get_score(self):
return Vote.objects.get_score(self)['score']

Now I want to make a custom manager to getting the top-scored links
for the given episode. AFAIK, you can't sort by a custom method, so
I'm trying to apply the ordering through sorted(), like this links
says:

http://stackoverflow.com/questions/981375/using-a-django-custom-model-method-property-in-order-by
http://stackoverflow.com/questions/883575/custom-ordering-in-django

So, what I have now is this:

class LinkGetTopScores(models.Manager):
def get_top_score(self):
return sorted(self.filter(episode=self.episode), key=lambda n:
n.get_score)

class Link(models.Model):
episode = models.ForeignKey("Episode", related_name="links")
url = models.CharField(max_length=255, unique=True, db_index=True)
get_top_score = LinkGetTopScores()


So of course this isn't working because of the self.episode stuff...
But I've to filter somehow by episode (the ForeignKey), and I don't
know how. Is there anyway of doing this?? What I'm doing is right or
there would be an easier way of doing this?

Thank you,
Andres

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



Re: Calling out for Help!

2011-02-08 Thread Andres Lucena
On Tue, Feb 8, 2011 at 5:26 PM, Dev@CB  wrote:
> Hello. I hope someone is maybe having a slow day and can spend a
> little time with me. Here's the whole story: Several months ago, our
> company started a django project. This project was headed by one man.
> Well, as of early January, he is no longer with the company. Now, we,
> the survivors, have the task of completing the project. Oh, little
> more background: Everything was set up on an Amazon cloud server. I
> think originally the project seemed simple enough to be run on a
> “small cloud”. So, here is where we are at now:  This one report
> actually turned out to be a monster and took several hours to run.
> That’s not good; that report needs to run in a few minutes with more
> data being processed. So, I created a “large cloud” (with AutoScaling,
> a feature not available to small clouds), installed Apache, PHP,
> MySQL, Python, and Django. I used SCP to copy the data from one server
> to another. Now, I need to align the configuration files to make it
> all work on the new server. This is where I need help. The small
> server was a Ubuntu distro and the large is a SUSE Enterprise 64-bit
> version, and some default paths and different things are not the same.
> I mentioned I did all the setup myself to give you the idea that I’m
> linux-savvy, but in truth, that was all a learning experience. I’m
> learning fast, but my supervisor wants all this done last week. Can
> anyone help me? At least give me a good push in the right directions,
> so that I can take off on my own again. Please?
>

Well, the first thing to see when deploying a django project is the
settings.py file. Here you'll see the database information.

Then the second step will be testing it (with the command python
manage.py runserver, it should start the development server, NOT for
using in production).

The last thing will see the Apache configuration, and it'll depend if
you're using wsgi or fcgi... More information here:
http://docs.djangoproject.com/en/dev/howto/deployment/
http://www.djangobook.com/en/beta/chapter21/

Hope it isn't that difficult, you can see the configs from the old
server, right?

Good luck!
Andres

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

2011-02-08 Thread Andres Lucena
On Tue, Feb 8, 2011 at 5:00 PM, jean polo  wrote:
> hi
>
> I created some User Profile in my app.
> Each user can add some posts and now I'd like one user to be able to
> view/modify only his/her posts in the admin, and not the posts from
> other users.
> I have no idea about how to do this.
>
> Any hint or link to a tutorial/doc would be very helpful, so far I can
> only list all posts for all users (in the admin of course).
>

Found this:

http://www.alextreme.org/drupal/?q=node/600

Hope it'll help.

See you,
Andres

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

2011-02-04 Thread Andres Lucena
On Fri, Feb 4, 2011 at 11:07 AM, Tom Evans <tevans...@googlemail.com> wrote:
> On Fri, Feb 4, 2011 at 9:53 AM, Andres Lucena <andresluc...@gmail.com> wrote:
>> Hi,
>>
>> In my base.html I'm trying to do this:
>>
>>        {% block title %}{{title|default:"{{SITE_NAME}}"}}{%
>> endblock %}
>>
>> But I'm getting this:
>>
>> TemplateSyntaxError at /
>> default requires 1 arguments, 0 provided
>>
>> So, SITE_NAME is not passed to the filter.
>>
>> As a workaround I did this:
>>
>>        {% block title %}{% if not title %}{{SITE_NAME}}{% else
>> %}{{title}}{% endif %}{% endblock %}
>>
>> But it's pretty ugly... Is there anyway to passing a variable to a
>> template filter??
>>
>> Thanks,
>> Andres
>>
>
> Yes, and you will kick yourself:
>
> {{ title|default:SITE_NAME }}
>

Yes, you're right, I'm kicking myself xD

> It is a template variable. Inside tags, template variables are
> unquoted and "values are quoted".
>

Oh. Didn't know that. 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: Redirecting to personal pages.

2011-02-04 Thread Andres Lucena
On Fri, Feb 4, 2011 at 10:59 AM, balu  wrote:
> Hi all :)
>
> I'm trying to create a website application using django's built in
> authenticaiton app. I had customized the login, logout, signup...
> template. But how to customize personal page which will be redirected
> after login confirmation. Which will be just how we redirected to our
> inbox after autheticated in gmail.
>

Jeje, just talking about that in another thread ;)

You should look the "next" parameter in the login form:

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

Or if it will always be the same page, maybe what you're looking for
is the LOGIN_REDIRECT_URL setting parameter:

http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_REDIRECT_URL

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



Re: user full name in template

2011-02-04 Thread Andres Lucena
On Fri, Feb 4, 2011 at 10:23 AM, Ivo Brodien  wrote:
>
>> Don't forget the login_required decorator, because if an anonymous
>> user try to get that page he will get an exception (I think, didn't
>> try that)
>
> No, they will be redirected to login and after login they come back to the 
> original page, if the form considers the ’next’ field. How nice is that!?
>

Yeah, I know, the 'next' magic, with GET or POST, it's vry nice ;)

The thing that I was saying is that he should validate that the user
is logged in, (login_required decorator, or
request.user.is_authenticated), because if he doesn't then he will
have an anonymous user instance, and I think that isn't what he
wants...

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



Passing variables to template filters

2011-02-04 Thread Andres Lucena
Hi,

In my base.html I'm trying to do this:

{% block title %}{{title|default:"{{SITE_NAME}}"}}{%
endblock %}

But I'm getting this:

TemplateSyntaxError at /
default requires 1 arguments, 0 provided

So, SITE_NAME is not passed to the filter.

As a workaround I did this:

{% block title %}{% if not title %}{{SITE_NAME}}{% else
%}{{title}}{% endif %}{% endblock %}

But it's pretty ugly... Is there anyway to passing a variable to a
template filter??

Thanks,
Andres

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

2011-02-04 Thread Andres Lucena
On Fri, Feb 4, 2011 at 6:24 AM, Bobby Roberts  wrote:
> here's what i'm trying
>
> from django.contrib.auth import authenticate, login, logout
> #import django user modules
> from django.contrib.auth.models import User
>
> def ShowMainMenu (request):
>        fullname=User.first_name + ' ' + User.last_name
>        return render_to_response('scanning/menu.html',
> {'fullname':fullname}, context_instance=RequestContext(request))
>
> I'm getting this err:
>
> type object 'User' has no attribute 'first_name'
>
>

I think the problem is that you're trying to get from the class and
not from the instance of the class. So insted of doing that, you
should do something like this:

user = User.objects.get(first_name=bar, last_name=foo)
user.first_name

Of course for doing that you should first get bar and foo (through the
URL, or request.POST, or request.GET)

But I think that what you're looking instead of all that crap is
request.user, so you should do this:

   fullname=request.user.first_name + ' ' + request.user.last_name

Or even better:

   fullname=request.user.get_full_name

You can skip that step and do this:

def ShowMainMenu (request):
   return render_to_response('scanning/menu.html',
{'fullname': request.user.get_full_name,},
context_instance=RequestContext(request))

Or skip the fullname stuff and getting the atribute directly in the
template: {{request.user.get_full_name }}

Don't forget the login_required decorator, because if an anonymous
user try to get that page he will get an exception (I think, didn't
try that)

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



Re: Debugging Why CSS File Will Not Load

2011-02-03 Thread Andres Lucena
On Wed, Feb 2, 2011 at 7:55 PM, octopusgrabbus
 wrote:
> I am trying to load static content (one css file) from the same apache
> server, using a different virtual host. I have no errors, but the css
> file appears not to load. How can I debug this further?
>
> The load shows up in /var/log/apache2/other_vhosts_access.log:
>
> Here are settings from httpd.conf.
>
> Listen 12345
> 
>
> DocumentRoot /usr/local/www/documents/static
>
> 
>
> I am loading the PageStyle.css file from a template. The css file  is
> in the static directory:
>
> Here is base.html that loads PageStyle.css
>
>  
>        {% block title %}Town of Arlington Water Department AMR
> System{% endblock %} 
>        
>
>   
>
> and the appropriate lines from settings.py
>
>
> # URL that handles the media served from MEDIA_ROOT
> MEDIA_URL = 'http://steamboy:8082'
>


First, I'd check if the apache is working, if you go to

http://steamboy:8082/PageStyle.css

Do you see the CSS?

Also, what you see when you see the HTML source code? Is that URL?

See you,
Andres


>
> PageStyle.css is set to display Windows Gray 0x808080.
>
>
>
>
> other_vhosts_access.log
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, 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.