Re: Django Admin Page not working

2014-02-12 Thread Roberto López López


_Probably_ you will have to execute:

$ python manage.py collectstatic


On 12. feb. 2014 10:19, Puthi SUM wrote:

Hi Developers,

   I am new to Django App Development. My part-1 training is completed 
successfully. But when i go for part-2, my Admin page is not working 
properly. i.e., Admin page is loading with out CSS.



When i am open admin page it showing like above. I am running my 
django in Windows 8.


What Software, i am used is:

Python 3.3, Django 1.6.2 and I use PyCharm 3.0

and please find the attachment. i am attaching my project folder also. 
Please Help me Any one in this group.

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com.

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/860138ae-d915-493d-9643-2148842eb724%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52FB93A4.2090507%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django storage engine

2013-11-07 Thread Roberto López López

Which is the question?

On 07. nov. 2013 09:15, Harjot Mann wrote:

Is using the InnoDb storage engine as default as per my knowledge in
MySql MyISAM is the default storage engine.



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/527B6400.70705%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Defining new project as a service at nignx

2013-10-15 Thread Roberto López López

Hi Muhammed,

I agree with Javier: a django project is never run. In your case it is
deployed on gunicorn, which reads/interprets your source code. But it's
never started as a service. You can run nginx as a service, though.

Roberto







On 10/15/2013 11:12 AM, Muhammed TÜFEKYAPAN wrote:
> Hello everyone,
>
> Yes I know that but now my problem is our new project doesn't seen on
> services list and so I can't start it.
>
> I use gunicorn.
>
> How can I made it?
>
> On Monday, October 14, 2013 10:03:22 PM UTC+3, Javier Guerra wrote:
>
> On Mon, Oct 14, 2013 at 12:17 PM, Muhammed TÜFEKYAPAN
> > wrote:
> > I use digitalocean as a server. I upload my django project files
> on my
> > server and start to setup. Made postgresql settings etc but I
> can't define
> > my new project as a new service on nginx. How can I define my
> new projest as
> > a service and make possible to start it as "service blabla start".
> >
> > When I type "service --statıs-all" I can't see my new project now.
>
>
> i think you're mixing two things and missing a third.
>
> 1: AFAIK, nginx doesn't have "services", just serves requests via
> some
> methods, either static files, internal plugins or backend servers.
>
> 2: on most linux distros, the 'service' command manages startup
> scripts; with start/stop commands to run daemons.
>
> 3: nginx doesn't run python applications, you have to run them in an
> app server.  for Django, (and most python frameworks), the best
> option
> is a wsgi server.  One that runs really well with nginx is uWSGI.
> another option is to run gunicorn as an HTTP backend server behind
> nginx.
>
>
> so, which is your deployment strategy?
> (https://docs.djangoproject.com/en/1.6/howto/deployment/
> <https://docs.djangoproject.com/en/1.6/howto/deployment/>)
>
>
> -- 
> Javier
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ef9db670-7a3a-4b84-837a-c9e401840452%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/525D614A.1050702%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: New to Django

2013-10-15 Thread Roberto López López
>From your link:
https://docs.djangoproject.com/en/1.5/intro/tutorial01/#database-setup





On 10/15/2013 04:07 PM, Mahantesh U wrote:
> yeah ...
> https://docs.djangoproject.com/en/1.5/intro/tutorial01/
>
> And also wanted know how can I set-up mysql with django?
>
> On Tuesday, October 15, 2013 7:31:15 PM UTC+5:30, Lloyd Dube wrote:
>
> You're welcome, Mahantesh :) Did you find the tutorial I mentioned?
>
>
> On Tue, Oct 15, 2013 at 3:56 PM, Mahantesh U
> > wrote:
>
> Thanks a lot Lloyd Dube  :)
>
>
> On Tuesday, October 15, 2013 5:38:33 PM UTC+5:30, Lloyd Dube
> wrote:
>
> Hi,
>
> Do the tutorial on the official Django website - it will
> show you where else to look when you are done :)
>
>
> On Tue, Oct 15, 2013 at 7:55 AM, Mahantesh U
>  wrote:
>
> Hi All,
>
>   I am new to Django framework. I worked on Flask
> framework using python. Please share the sites to
> learn Django easily.
>
> Thanks
> Mahantesh
> -- 
> You received this message because you are subscribed
> to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving
> emails from it, send an email to
> django-users...@googlegroups.com.
> To post to this group, send email to
> django...@googlegroups.com.
>
> Visit this group at
> http://groups.google.com/group/django-users
> <http://groups.google.com/group/django-users>.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/78b41661-9ac0-4433-bb16-fd8ea7b8ccd2%40googlegroups.com
> 
> <https://groups.google.com/d/msgid/django-users/78b41661-9ac0-4433-bb16-fd8ea7b8ccd2%40googlegroups.com>.
> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
> -- 
> Regards,
> Sithu Lloyd Dube
>
> -- 
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to django-users...@googlegroups.com
> .
> To post to this group, send email to
> django...@googlegroups.com .
> Visit this group at
> http://groups.google.com/group/django-users
> <http://groups.google.com/group/django-users>.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/ceaab487-fd63-4fc0-bfb1-b37b765fa577%40googlegroups.com
> 
> <https://groups.google.com/d/msgid/django-users/ceaab487-fd63-4fc0-bfb1-b37b765fa577%40googlegroups.com>.
>
>
> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
> -- 
> Regards,
> Sithu Lloyd Dube
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fc21b86e-6a92-4c96-b376-0633d75b32e2%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/525D4CDE.3040600%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: readonly_fields depending on request

2013-10-15 Thread Roberto López López

Hi Timothy, thanks for your advice.

I'm sorry, I've been quite busy lately on other stuff so I had to leave
this apart. You are right, maybe I am overcomplicating things. I have
simplified my code to:

def get_readonly_fields(self, request, obj=None):
if not request.user.groups.filter(name__exact='administration'):
return ('is_featured', )
return ()

That should make the "featured" checkbox read only for those users not
in the administration group. But it doesn't, when the flow reaches the
line /return ('is_featured', )/, the user can check/uncheck the box in
the admin interface. Do you see any flaw here? Thanks again!

Roberto






On 10/10/2013 04:52 PM, Timothy W. Cook wrote:
> On Thu, Oct 10, 2013 at 10:04 AM, Roberto López López
> mailto:roberto.lo...@uni.no>> wrote:
>
> This is, for example, my code overriding get_readonly_fields():
>
> def get_readonly_fields(self, request, obj=None):
> readonly = super(NewsAdmin,
> self).get_readonly_fields(request, obj)
> if request.user.groups.filter(name__exact='administration') or
> request.user.is_superuser:
> return readonly
> else:
> import itertools
> return itertools.chain(readonly, ('is_featured',))
>
>
>
> I do not understand your logic as it compares to your description of
> the problem. 
>
> For your described problem:
> If the user is_superuser then you shouldn't set read_only at all.
>
> If a user is in a specific set of users then set read_only= ['field1',
> 'field2',] as appropriate. 
>
> It is a pretty simple problem it looks like you are making it far too
> complex. 
>
>
>
>
>  
>
>
>
>  
>
>
> On 10/10/2013 02:45 PM, Roberto López López wrote:
> > Hi,
> >
> > In my project I make use of django-admin. I need to have different
> > readonly_fields depending on the user is connected, thus
> administrators
> > will be able to modify all fields, and other users less fields.
> Which
> > method do I have to override? I have already tried
> > ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But
> no success.
> >
> > Any other suggestions?
> >
> > Thanks!
> >
> > Roberto
> >
> >
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing
> +47 55584091
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5256A5E2.9020505%40uni.no.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> -- 
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3U69QzDSbc0qyJ_zbgA3BYHCi5zK3%3DaAra-saAq%2Bvj3EA%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/525D4806.7090509%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: readonly_fields depending on request

2013-10-10 Thread Roberto López López
Hi,

It was something like that:

def get_form(self, request, obj=None, **kwargs):
if not request.user.groups.filter(name__exact='administration')
and not request.user.is_superuser:
import itertools
self.readonly_fields = itertools.chain(self.readonly_fields,
('is_featured', ))
return super(NewsAdmin, self).get_form(request, obj, **kwargs)

Now I see that this was slightly different than what I did with
get_readonly_fields...

On 10/10/2013 03:00 PM, Timothy W. Cook wrote:
> Can you post the code you tried with get_form()?  It should be the
> solution.
>
>
>
> On Thu, Oct 10, 2013 at 9:45 AM, Roberto López López
> mailto:roberto.lo...@uni.no>> wrote:
>
> Hi,
>
> In my project I make use of django-admin. I need to have different
> readonly_fields depending on the user is connected, thus
> administrators
> will be able to modify all fields, and other users less fields. Which
> method do I have to override? I have already tried
> ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no
> success.
>
> Any other suggestions?
>
> Thanks!
>
> Roberto
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5256A163.3000907%40uni.no.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> -- 
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3V6vOGGaG7_M9xmEPY232%3DpVXqMKSrxH-hMbCOwDo2Axg%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5256C126.5080909%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: readonly_fields depending on request

2013-10-10 Thread Roberto López López
This is, for example, my code overriding get_readonly_fields():

def get_readonly_fields(self, request, obj=None):
readonly = super(NewsAdmin, self).get_readonly_fields(request, obj)
if request.user.groups.filter(name__exact='administration') or
request.user.is_superuser:
return readonly
else:
import itertools
return itertools.chain(readonly, ('is_featured',))



On 10/10/2013 02:45 PM, Roberto López López wrote:
> Hi,
>
> In my project I make use of django-admin. I need to have different
> readonly_fields depending on the user is connected, thus administrators
> will be able to modify all fields, and other users less fields. Which
> method do I have to override? I have already tried
> ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no success.
>
> Any other suggestions?
>
> Thanks!
>
> Roberto
>
>


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5256A5E2.9020505%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


readonly_fields depending on request

2013-10-10 Thread Roberto López López
Hi,

In my project I make use of django-admin. I need to have different
readonly_fields depending on the user is connected, thus administrators
will be able to modify all fields, and other users less fields. Which
method do I have to override? I have already tried
ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no success.

Any other suggestions?

Thanks!

Roberto


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5256A163.3000907%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: proper way to override text plugin widget

2013-10-07 Thread Roberto López López
wrong list, sorry :-(


On 10/07/2013 11:23 AM, Roberto López López wrote:
> Hi,
>
> The users of my project prefer ckeditor, so I am wondering how to use it
> for cms.plugins.text . I am already making use of django-ckeditor in
> other parts of the application. Can anyone enlighten me please?
>
> Thanks,
>
> Roberto
>
>


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52527E23.2080102%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


proper way to override text plugin widget

2013-10-07 Thread Roberto López López

Hi,

The users of my project prefer ckeditor, so I am wondering how to use it
for cms.plugins.text . I am already making use of django-ckeditor in
other parts of the application. Can anyone enlighten me please?

Thanks,

Roberto


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52527D84.7020301%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
On 10/03/2013 04:13 PM, Roberto López López wrote:
> *return HttpResponse(json.dumps([players]) ,
> content_type='application/json')*
better without the square brackets

*return HttpResponse(json.dumps(players) ,
content_type='application/json')*

-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7F41.7070003%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
Try this (I have not tried the code myself, but I think that it should
work):

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps([players]) ,
content_type='application/json')*



On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7B79.4090400%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
Better to say:

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps(players) ,
content_type='application/json')*


On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7BB6.1050502%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: model inheritance

2013-10-02 Thread Roberto López López

Is there maybe a way to set the cmsplugin_news.News.Meta.abstract option
to True? In order to prevent accessing the parent model to fetch the
inherited data.



On 10/02/2013 03:45 PM, Leonardo Giordani wrote:
> Are you sure your DB has been synced after putting the
> ForeignKey(News) in your Department model?
> Can you post somewhere the following models: News, OldNews, Department?
>
> Regards,
>
> Leo
>
> Leonardo Giordani
> Author of The Digital Cat <http://lgiordani.github.com>
> My profile on About.me <http://about.me/leonardo.giordani> - My GitHub
> page <https://github.com/lgiordani> - My Coderwall profile
> <https://coderwall.com/lgiordani>
>
>
> 2013/10/2 Roberto López López  <mailto:roberto.lo...@uni.no>>
>
> Hi,
>
> I am extending a 3rd party model in my application, using
> multi-table inheritance. I can create an instance and modify it,
> but when I try to list the created objects at
> http://localhost:8000/en/admin/news/news/ , I am getting a nice
> exception:
>
> Traceback:
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. result = block.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve

Re: model inheritance

2013-10-02 Thread Roberto López López

Hi Leonardo, thanks for your answer.

Yes, it has been synced.

The model itself is a little bit bigger, as you can notice from the code
https://dpaste.de/c3Rg I am using as well the News model from
https://github.com/wildfish/cmsplugin_news/blob/master/cmsplugin_news/models.py

Regards,

Roberto





On 10/02/2013 03:45 PM, Leonardo Giordani wrote:
> Are you sure your DB has been synced after putting the
> ForeignKey(News) in your Department model?
> Can you post somewhere the following models: News, OldNews, Department?
>
> Regards,
>
> Leo
>
> Leonardo Giordani
> Author of The Digital Cat <http://lgiordani.github.com>
> My profile on About.me <http://about.me/leonardo.giordani> - My GitHub
> page <https://github.com/lgiordani> - My Coderwall profile
> <https://coderwall.com/lgiordani>
>
>
> 2013/10/2 Roberto López López  <mailto:roberto.lo...@uni.no>>
>
> Hi,
>
> I am extending a 3rd party model in my application, using
> multi-table inheritance. I can create an instance and modify it,
> but when I try to list the created objects at
> http://localhost:8000/en/admin/news/news/ , I am getting a nice
> exception:
>
> Traceback:
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in 

model inheritance

2013-10-02 Thread Roberto López López
Hi,

I am extending a 3rd party model in my application, using multi-table
inheritance. I can create an instance and modify it, but when I try to
list the created objects at http://localhost:8000/en/admin/news/news/ ,
I am getting a nice exception:

Traceback:
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
  140. response = response.render()
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
in render
  105. self.content = self.rendered_content
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
in rendered_content
  82. content = template.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  140. return self._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  124. return compiled_parent._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  124. return compiled_parent._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  63. result = block.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  63. result = block.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  1185. _dict = func(*resolved_args,
**resolved_kwargs)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in result_list
  286. 'results': list(results(cl))}
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in results
  264. yield ResultList(None, items_for_result(cl, res,
None))
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in __init__
  256. super(ResultList, self).__init__(*items)

KeyError: Key 'slug' not found in Form

2013-09-28 Thread Roberto López López

Hi,

I am trying to translate my model using django-modeltranslation and the
SlugField is giving me a lot of trouble. I have successfully registered
the fields for translation, as you can see in the db table description:

| Table "public.news_news"
Column|   Type   |   Modifiers  
  
--+--+
 id   | integer  | not null default 
nextval('news_news_id_seq'::regclass)
 title| character varying(255)   | not null
 title_en | character varying(255)   | 
 title_nb | character varying(255)   | 
 slug | character varying(50)| not null
 slug_en  | character varying(50)| 
 slug_nb  | character varying(50)||

But when I try to add a new News item, I am getting the following error:

|Traceback: File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
 in get_response
  115. response = callback(request, *callback_args, 
**callback_kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
 in wrapper
  372. return self.admin_site.admin_view(view)(*args, **kwargs) 
File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in _wrapped_view
  91. response = view_func(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/views/decorators/cache.py"
 in _wrapped_view_func
  89. response = view_func(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/sites.py"
 in inner
  202. return view(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in _wrapper
  25. return bound_func(*args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in _wrapped_view
  91. response = view_func(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in bound_func
  21. return func(self, *args2, **kwargs2) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/db/transaction.py"
 in inner
  223. return func(*args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
 in add_view
  1036. model_admin=self) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/helpers.py"
 in __init__
  35. } for field_name, dependencies in prepopulated_fields.items()] 
File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/forms/forms.py"
 in __getitem__
  111. raise KeyError('Key %r not found in Form' % name)

Exception Type: KeyError at /en/admin/news/news/add/ Exception Value: u"Key 
'slug' not found in Form"|

My admin.py :

|from cmsplugin_news.admin import NewsAdmin as OldNewsAdmin

class NewsAdmin(OldNewsAdmin, TranslationAdmin,):
fields = ('title', 'slug')
form = NewNewsForm|

models.py:

|class News(models.Model):
title = models.CharField(_('Title'), max_length=255)
slug = models.SlugField(
_('Slug'), unique_for_date='pub_date',
)|

and forms.py:

|class NewNewsForm(forms.ModelForm):
class Meta:
model = News
fields = ('title', 'slug', )|

As well, this is my translation.py where I declare the fields that
should be translated by django-modeltranslation. I suppose anyhow that
the error is not here, as the fields are already translated in db:

|class NewsTranslationOptions(TranslationOptions):
fields = ('title', 'slug', 'excerpt', 'content')

translator.register(News, NewsTranslationOptions)|

Any help please? I am really stuck! Thanks!

Roberto

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


django admin: integrate django-modeltranslation + django-ckeditor into 3rd party module

2013-09-26 Thread Roberto López López

Hi,

I want to integrate django-modeltranslation into the cmsplugin_news
package. I mean, register some fields in the News class to have a
translation in the DB for each of the settings.LANGUAGES defined.


class NewNewsForm(forms.ModelForm):
class Meta:
model = News
fields = ('title', 'slug', 'excerpt', 'content',
'is_published', 'pub_date')
widgets = {
'content': CKEditorWidget(),
'excerpt': CKEditorWidget(),
}

class NewNewsAdmin(TranslationAdmin):
form = NewNewsForm

class Media:
js = (
   
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
   
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js',
'modeltranslation/js/tabbed_translation_fields.js',
)
css = {
'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}

admin.site.register(News, NewsAdmin)


This works ok, if we just take into account django-modeltranslation. But
the django-ckeditor widget is not loading. Using firebug I have seen
that some static files are not loaded, so I tried loading them manually
by modifying the Media class. Anyhow the editor continues not working:

class Media:
js = (
   
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
   
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js',
'modeltranslation/js/tabbed_translation_fields.js',
'ckeditor/ckeditor/ckeditor.js',
'ckeditor/ckeditor/config.js?t=D26D',
'ckeditor/ckeditor/styles.js?t=D26D',
)
css = {
'all': [cms_static_url(path) for path in (
'css/rte.css',
'css/pages.css',
'css/change_form.css',
'css/jquery.dialog.css',
'css/plugin_editor.css',
)],
'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}

Does anyone have any idea about how to make the editor work? Thank you
very much!

Regards,

Roberto

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Roberto López López

Check virtualenvwrapper

http://virtualenvwrapper.readthedocs.org/en/latest/



On 09/25/2013 08:06 PM, Jorge Arevalo wrote:
> Fine. I don't think my boss is going to pay for PyCharm license, so
> I'll probably go for Eclipse now (I don't really like it too much, but
> if works, it's ok for me)
>
> About virtualenv, is there any method to provide something like a
> script to create a virtualenv, install the needed software and have a
> working environment in a few commands? Something like "vagrantfile for
> virtualenv" http://docs.vagrantup.com/v2/vagrantfile/index.html
>
> Again, many thanks for your useful insights
>
> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>
> Answering the other half of your question:  The choice of IDE is
> not nearly as important as its ease of integration with your
> dvcs.  If you are already familiar with a good one, don't change.
>
> On my present project, my boss and I are both using PyCharm, and
> my other co-worker is using Eclipse, since he is more comfortable
> (and therefore, more productive) with it. Both IDE's have good
> integration with git (my least favourite dvcs, but the boss's
> choice) and our sharing is done using a group private repository
> on github.  This is on Ubuntu Linux, it all works well.   In the
> evening hours, I use PyCharm on Windows 7 to contribute to an open
> source project hosted on bitbucket using mercurial. Both projects
> end up being tested on the same Linode.
>
> Yes, use virtualenv.  I also made the mistake of thinking of it as
> a virtual computer.  It is not.  It is only a method of separating
> Python library directories so that you can experiment with
> different configurations easily.  It does not slow anything down,
> and actually makes installation of packages easier.  Use
> virtualenvwrapper to make switching environments easy.  PyCharm
> also supports virtual environments as well as django projects. It
> is commercial, and suffers from a few Java idiosyncrasies, but the
> boss paid for the license ;-) so I don't mind.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: m2m_changed signal not caught

2013-09-17 Thread Roberto López López

Thanks for your advice, but that dint't solve the issue :-/

@receiver(m2m_changed, sender=News.department.through)



On 09/17/2013 05:02 PM, John DeRosa wrote:
> From memory, I _think_ this catches the signal from the Department
> model, not the News model. To catch it when you edit the relationship
> from a *News* model form, you need to hook it up
> ("sender=News.department.through"). 
>
> On Sep 17, 2013, at 3:59 AM, Roberto López López  <mailto:roberto.lo...@uni.no>> wrote:
>
>>
>> Hi,
>>
>> I need to use the m2m_changed signal to assign permissions over an
>> object. But somehow, I cannot make it work.
>>
>> To summarise, my models.py is as follows:
>>
>> from cmsplugin_news.models import News
>> from django.contrib.auth.models import Group
>> from django.db import models
>> from guardian.shortcuts import assign_perm, remove_perm
>>
>>
>> class Department(models.Model):
>> news = models.ManyToManyField(
>> News, blank=True, related_name='departments'
>> )
>> write_group = models.ForeignKey(Group, blank=True)
>>
>>
>> @receiver(m2m_changed, sender=Department.news.through)
>> def _m2m_changed_news_departments(sender, instance, action,
>> reverse, model, pk_set, **kwargs):
>> if action == "pre_add":
>> for pk in pk_set:
>> d = Department.objects.get(pk__exact=pk)
>> assign_perm('cmsplugin_news.change_news',
>> d.write_group, instance)
>> assign_perm('cmsplugin_news.delete_news',
>> d.write_group, instance)
>> elif action == "pre_remove":
>> for pk in pk_set:
>> d = Department.objects.get(pk__exact=pk)
>> remove_perm('cmsplugin_news.change_news',
>> d.write_group, instance)
>> remove_perm('cmsplugin_news.delete_news',
>> d.write_group, instance)
>>
>>
>> The point is that the signal is never caught. I am editing the m2m
>> relation from the admin interface (as an inline in cmsplugin_news).
>> When I add/delete a department from the formset, the signal is never
>> caught by my method.
>>
>> Any help here? Thank you very much.
>>
>> Roberto
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


m2m_changed signal not caught

2013-09-17 Thread Roberto López López

Hi,

I need to use the m2m_changed signal to assign permissions over an
object. But somehow, I cannot make it work.

To summarise, my models.py is as follows:

from cmsplugin_news.models import News
from django.contrib.auth.models import Group
from django.db import models
from guardian.shortcuts import assign_perm, remove_perm


class Department(models.Model):
news = models.ManyToManyField(
News, blank=True, related_name='departments'
)
write_group = models.ForeignKey(Group, blank=True)


@receiver(m2m_changed, sender=Department.news.through)
def _m2m_changed_news_departments(sender, instance, action, reverse,
model, pk_set, **kwargs):
if action == "pre_add":
for pk in pk_set:
d = Department.objects.get(pk__exact=pk)
assign_perm('cmsplugin_news.change_news', d.write_group,
instance)
assign_perm('cmsplugin_news.delete_news', d.write_group,
instance)
elif action == "pre_remove":
for pk in pk_set:
d = Department.objects.get(pk__exact=pk)
remove_perm('cmsplugin_news.change_news', d.write_group,
instance)
remove_perm('cmsplugin_news.delete_news', d.write_group,
instance)


The point is that the signal is never caught. I am editing the m2m
relation from the admin interface (as an inline in cmsplugin_news). When
I add/delete a department from the formset, the signal is never caught
by my method.

Any help here? Thank you very much.

Roberto


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: New field in django

2013-09-08 Thread Roberto López López
You have to fake the migration.


On 09/08/2013 09:12 PM, Harjot Mann wrote:
> I am trying to add a new field to model class in django using south
> but when I am running ./manage.py migrate app, I am getting this error
> http://202.164.53.122/~harjotmann/southerror
>


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re:

2013-08-21 Thread Roberto López López
I got it as well.



On 08/21/2013 07:50 PM, Mike Doroshenko II wrote:
> How/Why am I getting this? Has anyone else received this?
>
> To: django-users+unsubscr...@googlegroups.com
> On 08/21/2013 02:44 AM, Shahmi Junoh wrote:
>> Hi,
>>
>> I would like to unsubscribe from getting the updates.
>>
>> Thanks in advance.
>>
>> Regards,
>> Shahmi
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> Mike Doroshenko, Junior Sys Admin
> TecKnoQuest Inc.
> mi...@tecknoquest.com
> www.tecknoquest.com
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: working with images in django

2013-07-28 Thread Roberto López López

I use https://pypi.python.org/pypi/django-ckeditor/4.0.2 and I'm quite
happy. There's not too much else to code than what's explained there.




On 07/28/2013 04:21 PM, Robert Brown wrote:
> Hello, can anyone suggest where I might find some of example of
> working with images in django.  I want to store them and pull them
> into text documents, about one every couple of paragraphs.  I am
> finding a lot of posts on this site about the img class but most of
> them seem to address very specific problems.  I am looking more for a
> beginners how to do it discussion or tutorial.
>
> Thanks,
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: flatpages-tinymce

2013-07-28 Thread Roberto López López

Your message is quite confusing and difficult to understand, I have to
say. What are you asking for? To show tinymce within your change_form or
within the admin app? What do you mean by "flat pages"? Which error are
you getting?



On 07/28/2013 08:35 AM, Karl Arunachal wrote:
> Hello,
> I am trying to use tinymce in the flat pages. But i just can't show it
> up in my admin. Please help me out where am going wrong.
>
> The javascript file is in:
>
> C:\Users\Kakar\web\cms\static\js\tinymce\tinymce.min.js
>
> urls.py:
>
> |(r'^tiny_mce/(?P.*)$','django.views.static.serve',{'document_root':'C:/Users/Kakar/web/cms/static/js/tinymce'}),
>
> |In my templates dir i have another admin folder, which have the
> change_form.html, and right after {{ media }}:
>
> |
> 
> tinyMCE.init({
> mode: "textareas",
> theme: "simple"
> });
> |
> Please help me out. Thank you.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: flatpages-tinymce

2013-07-28 Thread Roberto López López
On 07/28/2013 08:35 AM, Karl Arunachal wrote:
> ||


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error.

2013-07-27 Thread Roberto López López
Well, I suppose you are running that locally or have access to the
server. So show the logs.



On 07/27/2013 01:40 PM, Nigel Legg wrote:
>
> I have provided all the information I have. That's all there is on the
> screen in the browser. There is no trace.
>
> On 27 Jul 2013 12:26, "Roberto López López"  <mailto:roberto.lo...@uni.no>> wrote:
>
>
> Could be. But if you don't provide more information (i.e. detailed
> information about how you get that error, error stacktrace, logs), you
> won't get an answer.
>
>
> On 07/27/2013 01:21 PM, Nigel Legg wrote:
> > I've just set up a new view / url etc, which has quite a bit of
> > processing behind it.  When I click on the link for it, I get the
> > "Connecting" message for a few minutes, and then just "A server
> error
> > has occurred. Please contact the administrator." appears.  Is this a
> > time out message?
> > Regards,
> > Nigel Legg
> > 07914 740972 
> > http://www.trevanianlegg.co.uk
> > http://twitter.com/nigellegg
> > http://uk.linkedin.com/in/nigellegg
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from
> it, send
> > an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> > To post to this group, send email to
> django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing
> +47 55584091 
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error.

2013-07-27 Thread Roberto López López

Could be. But if you don't provide more information (i.e. detailed
information about how you get that error, error stacktrace, logs), you
won't get an answer.


On 07/27/2013 01:21 PM, Nigel Legg wrote:
> I've just set up a new view / url etc, which has quite a bit of
> processing behind it.  When I click on the link for it, I get the
> "Connecting" message for a few minutes, and then just "A server error
> has occurred. Please contact the administrator." appears.  Is this a
> time out message?
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What is the best practice to learn Django 1.5?

2013-06-28 Thread Roberto López López
Two scoops of django is also a good book https://django.2scoops.org/


On 06/28/2013 03:45 PM, Gabriel wrote:
>
> Hey, you could also try Getting Started With Djangorest, that's a
> series of classes in everything you might need to become a Django dev.
>
> -Gabe
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

Changing the m2m_changed signal on Project.departments.through to
post_save on ProjectDepartmentMembership did the trick.

m2m_changed signal seems to work as long as you don't explicitly define
the "through" model.



On 06/28/2013 02:06 PM, Roberto López López wrote:
>
> I am doing tests and the m2m_changed signal seems to work perfectly as
> long as I have not defined a "through" model. Is there any trick here?
>
> Thanks!
>
>
>
>
> On 06/28/2013 12:14 PM, Roberto López López wrote:
>>
>> I have tried as well using the post_save signal and overriding the
>> save() method. But in none of those cases Project.departments is
>> populated yet when reaching my code :-/
>>
>>
>>
>> On 06/28/2013 11:50 AM, Roberto López López wrote:
>>>
>>> Hi,
>>>
>>> I am trying to listen to the m2m_changed signal on my models, but I
>>> can't make it work. Even the execution flow does not reach the
>>> linked method!
>>>
>>> class Project(models.Model):
>>> departments =
>>> models.ManyToManyField('department.Department',
>>> related_name='projects',
>>> 
>>> through='project.ProjectDepartmentMembership')
>>>
>>> @receiver(m2m_changed, sender=Project.departments.through)
>>> def _on_change_m2m(sender, instance, action, reverse, model,
>>> pk_set, using, **kwargs):
>>> pass
>>>
>>> As interface I am using the django admin, and departments appears as
>>> an inline of Project
>>>
>>> Any help please? Thanks.
>>>
>>> Cheers,
>>>
>>> Roberto
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>
>>
>> -- 
>> Kind regards,
>>
>> Roberto López López
>>
>>
>> System Developer
>> Parallab, Uni Computing
>> Høyteknologisenteret, Thormøhlensgate 55
>> N-5008 Bergen, Norway
>> Tel:(+47) 555 84091
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>
>
> -- 
> Kind regards,
>
> Roberto López López
>
>
> System Developer
> Parallab, Uni Computing
> Høyteknologisenteret, Thormøhlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

I am doing tests and the m2m_changed signal seems to work perfectly as
long as I have not defined a "through" model. Is there any trick here?

Thanks!




On 06/28/2013 12:14 PM, Roberto López López wrote:
>
> I have tried as well using the post_save signal and overriding the
> save() method. But in none of those cases Project.departments is
> populated yet when reaching my code :-/
>
>
>
> On 06/28/2013 11:50 AM, Roberto López López wrote:
>>
>> Hi,
>>
>> I am trying to listen to the m2m_changed signal on my models, but I
>> can't make it work. Even the execution flow does not reach the linked
>> method!
>>
>> class Project(models.Model):
>> departments = models.ManyToManyField('department.Department',
>> related_name='projects',
>> 
>> through='project.ProjectDepartmentMembership')
>>
>> @receiver(m2m_changed, sender=Project.departments.through)
>> def _on_change_m2m(sender, instance, action, reverse, model,
>> pk_set, using, **kwargs):
>> pass
>>
>> As interface I am using the django admin, and departments appears as
>> an inline of Project
>>
>> Any help please? Thanks.
>>
>> Cheers,
>>
>> Roberto
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>
>
> -- 
> Kind regards,
>
> Roberto López López
>
>
> System Developer
> Parallab, Uni Computing
> Høyteknologisenteret, Thormøhlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help in finding how to learn Django

2013-06-28 Thread Roberto López López
https://docs.djangoproject.com/en/1.5/intro/




On 06/28/2013 09:49 AM, subsn...@gmail.com wrote:
> Hi all,
>
> What is the best way to learn Django 1.5 thouroughly? I have been a
> .NET developer and have a really good understanding of OOP, HTML5, CSS
> and JavaScript. I also have an entry-level knowledge of Python. I am
> completely new to MVC (or MVT, in this case).
>
> I have a need to build apps with Django that provide users with
> features such as finding each other based on geographical distance,
> upload pictures and edit them online, natural language search, etc...
> (just to highlight that I need to know more than how to build a poll
> app or a simple blog).
>
> My understanding is that the entry point to learn Django is by
> completing the tutorial at the Django project site. Then, what? What
> path would you recommend? I have seen that lots of learning resources
> on the web target versions lower than 1.5 and I couldn't really find
> books on 1.5. When reading reviews on learning material on 1.4, I
> often see they are outdated and not really applying to 1.5.
>
> Also, I briefly looked at what it takes to deploy a Django app.
> Virtualenv, git, pip, etc... are all things unknown to me and it looks
> a bit scary for a guy used to deploy apps by uploading the compiled
> binaries through FTP.
>
> Help in defining a clear path to learn how to bend Django to my will
> would be invaluable!
>
> Thank you for your time.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django-admin-tools unicode problem

2013-06-28 Thread Roberto López López
   send an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>      
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

I have tried as well using the post_save signal and overriding the
save() method. But in none of those cases Project.departments is
populated yet when reaching my code :-/



On 06/28/2013 11:50 AM, Roberto López López wrote:
>
> Hi,
>
> I am trying to listen to the m2m_changed signal on my models, but I
> can't make it work. Even the execution flow does not reach the linked
> method!
>
> class Project(models.Model):
> departments = models.ManyToManyField('department.Department',
> related_name='projects',
> 
> through='project.ProjectDepartmentMembership')
>
> @receiver(m2m_changed, sender=Project.departments.through)
> def _on_change_m2m(sender, instance, action, reverse, model,
> pk_set, using, **kwargs):
> pass
>
> As interface I am using the django admin, and departments appears as
> an inline of Project
>
> Any help please? Thanks.
>
> Cheers,
>
> Roberto
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

Hi,

I am trying to listen to the m2m_changed signal on my models, but I
can't make it work. Even the execution flow does not reach the linked
method!

class Project(models.Model):
departments = models.ManyToManyField('department.Department',
related_name='projects',

through='project.ProjectDepartmentMembership')

@receiver(m2m_changed, sender=Project.departments.through)
def _on_change_m2m(sender, instance, action, reverse, model, pk_set,
using, **kwargs):
pass

As interface I am using the django admin, and departments appears as an
inline of Project

Any help please? Thanks.

Cheers,

Roberto


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: redirection problem

2013-06-26 Thread Roberto López López

Update: if I disable 'django.middleware.locale.LocaleMiddleware', it's
not redirecting anymore. But I need to have i18n support in my website!

Any idea?



On 06/26/2013 05:09 PM, Roberto López López wrote:
> Hi,
>
> After creating an object from the admin interface I'm redirected to a
> "localized" version of the url. For example, if the original url is
> http://127.0.0.1:8000/admin/project/project/2/ , I'm redirected to
> http://127.0.0.1:8000/en/admin/project/project/2/ .
>
> I suppose this has to do with the middleware in my settings file:
>
> MIDDLEWARE_CLASSES = (
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.locale.LocaleMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> # Uncomment the next line for simple clickjacking protection:
> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'cms.middleware.page.CurrentPageMiddleware',
> 'cms.middleware.user.CurrentUserMiddleware',
> 'cms.middleware.toolbar.ToolbarMiddleware',
> 'cms.middleware.language.LanguageCookieMiddleware',
> )
>
> Any suggestion please? Thanks!
>
> Roberto
>
>


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




redirection problem

2013-06-26 Thread Roberto López López

Hi,

After creating an object from the admin interface I'm redirected to a
"localized" version of the url. For example, if the original url is
http://127.0.0.1:8000/admin/project/project/2/ , I'm redirected to
http://127.0.0.1:8000/en/admin/project/project/2/ .

I suppose this has to do with the middleware in my settings file:

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.doc.XViewMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
)

Any suggestion please? Thanks!

Roberto


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: countries phone prefixes

2013-06-20 Thread Roberto López López

Ok, answering my own question: django-country-dialcode



On 06/20/2013 11:35 AM, Roberto López López wrote:
> Hi,
>
> I need a sort of prepopulated foreign key with countries and their phone
> prefixes, to add to my models. Does anyone know any 3rd party package or
> service providing this? Thanks.
>
> Cheers,
>
> Roberto
>


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




countries phone prefixes

2013-06-20 Thread Roberto López López
Hi,

I need a sort of prepopulated foreign key with countries and their phone
prefixes, to add to my models. Does anyone know any 3rd party package or
service providing this? Thanks.

Cheers,

Roberto

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: m2m_changed signal registration

2013-06-18 Thread Roberto López López

Btw I have opened a stackoverflow thread:
http://stackoverflow.com/questions/17149305/post-save-signal-and-relations

At the beginning I was thinking of using a post_save signal, but an user
there suggested me to better use the m2m_changed.




On 06/18/2013 04:12 PM, Roberto López López wrote:
>
> Hi,
>
> I am having trouble registering a function to the m2m_changed signal.
> My code is as follows:
>
>  1. from django.db.models.signals import m2m_changed
>  2. from django.db import models
>  3. from django.dispatch.dispatcher import receiver
> 4.
>  5. class Project(models.Model):
>  6. employees = models.ManyToManyField('staff.Person',
> through='project.PersonProjectMembership',
>  7. related_name='projects')
> 8.
>  9. class PersonProjectMembership(models.Model):
> 10. project = models.ForeignKey('project.Project',
> related_name="person_memberships")
> 11. person = models.ForeignKey('staff.Person',
> related_name="project_memberships")
> 12. lead = models.BooleanField(default=False)
> 13. position = models.CharField(max_length=50)
> 14. project_manager = models.BooleanField(
> 15. default=False
> 16. )
>17.
> 18. class Meta:
> 19. permissions = (
> 20. ('view_personprojectmembership', _('View person project membership')),
> 21. )
>22.
> 23. @receiver(m2m_changed, sender=Project.employees.through)
> 24. def _on_save_project_assign_privileges(sender, instance, action,
> reverse, model, pk_set, using, **kwargs):
> 25. # [...]
>
> Somehow it doesn't seem to work, the execution point never reaches the
> _on_save_project_assign_privileges function when I modify the m2m
> relation (I am using the admin interface for that). On the other side,
> I have another method registered to the post_save signal for the same
> object and it works correctly.
>
> I have read the signals documentation -concretely the m2m_changed-,
> re-read my code, googled for it, asked in other sites... but I have
> not been able to find a solution. Any help please? Thanks!
>
> Roberto
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




m2m_changed signal registration

2013-06-18 Thread Roberto López López

Hi,

I am having trouble registering a function to the m2m_changed signal. My
code is as follows:

 1. from django.db.models.signals import m2m_changed
 2. from django.db import models
 3. from django.dispatch.dispatcher import receiver
 4.
 5. class Project(models.Model):
 6. employees = models.ManyToManyField('staff.Person',
through='project.PersonProjectMembership',
 7. related_name='projects')
 8.
 9. class PersonProjectMembership(models.Model):
10. project = models.ForeignKey('project.Project',
related_name="person_memberships")
11. person = models.ForeignKey('staff.Person',
related_name="project_memberships")
12. lead = models.BooleanField(default=False)
13. position = models.CharField(max_length=50)
14. project_manager = models.BooleanField(
15. default=False
16. )
17.
18. class Meta:
19. permissions = (
20. ('view_personprojectmembership', _('View person project membership')),
21. )
22.
23. @receiver(m2m_changed, sender=Project.employees.through)
24. def _on_save_project_assign_privileges(sender, instance, action,
reverse, model, pk_set, using, **kwargs):
25. # [...]


Somehow it doesn't seem to work, the execution point never reaches the
_on_save_project_assign_privileges function when I modify the m2m
relation (I am using the admin interface for that). On the other side, I
have another method registered to the post_save signal for the same
object and it works correctly.

I have read the signals documentation -concretely the m2m_changed-,
re-read my code, googled for it, asked in other sites... but I have not
been able to find a solution. Any help please? Thanks!

Roberto


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Pls help me

2013-05-15 Thread Roberto López López
group, send email to
> django...@googlegroups.com .
> Visit this group at
> http://groups.google.com/group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>  
>  
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: form validation

2013-05-11 Thread Roberto López López

Problem solved with BaseInlineFormSet.clean() :-)




On 05/11/2013 06:56 PM, Roberto López López wrote:
>
> Hi everyone,
>
> I need to do some validation in my model. So far, I have been able to
> validate normal forms, but I want to validate forms with an inline, to
> ensure that at least one of those inlines match the requirement.
>
> My code:
>
> class PDMAdminForm(ModelForm):
> class Meta:
> model = PersonDepartmentMembership
>
> def clean(self):
> previous_leaders = []
> if self.instance:  # the instance is already on the db
> previous_leaders =
> self.instance.department.employee_memberships.filter(lead__exact=True)
> lead = self.cleaned_data['lead'] # access fields from the
> form itself
> # do some validations and eventually throw
> ValidationErrrors [...]
> return self.cleaned_data
>
> This works great for a single inline. But if I have several
> PersonDepartmentMembership instances to be created, I don't know how
> to check the value of those other (I just want to ensure that at least
> one fo them has lead==True).
>
> Does anyone know how to do this cross validation? Thank you very much
> for your suggestions.
>
> Regards,
>
> Roberto
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




form validation

2013-05-11 Thread Roberto López López

Hi everyone,

I need to do some validation in my model. So far, I have been able to
validate normal forms, but I want to validate forms with an inline, to
ensure that at least one of those inlines match the requirement.

My code:

class PDMAdminForm(ModelForm):
class Meta:
model = PersonDepartmentMembership

def clean(self):
previous_leaders = []
if self.instance:  # the instance is already on the db
previous_leaders =
self.instance.department.employee_memberships.filter(lead__exact=True)
lead = self.cleaned_data['lead'] # access fields from the
form itself
# do some validations and eventually throw ValidationErrrors
[...]
return self.cleaned_data

This works great for a single inline. But if I have several
PersonDepartmentMembership instances to be created, I don't know how to
check the value of those other (I just want to ensure that at least one
fo them has lead==True).

Does anyone know how to do this cross validation? Thank you very much
for your suggestions.

Regards,

Roberto


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




django-guardian VS django admin

2013-04-28 Thread Roberto López López
Hi,

I have problems setting up django-guardian to work properly in my web
application. Object permissions seem to be correct after testing with
the django shell, but somehow admin doesn't seem to react to the
permission system.

I have a Department model:

class Department(models.Model):
name = models.CharField(_('department name'), max_length=50,
default=_('Department name'))
description = models.TextField(_('department description'))
# etc.


I'm catching the post_save signal to assign user rights:

@receiver(post_save, sender=Department)
def _on_save_department(sender, instance, created, **kwargs):
# users to give privileges
superusers = User.objects.filter(is_superuser__exact=True)
try:
department_leader_user = instance.leader_user()

# assign privileges
assign_perm('change_department', department_leader_user,
instance)
except ObjectDoesNotExist:
pass

for u in User.objects.all():
remove_perm('view_department', u, instance)
remove_perm('change_department', u, instance)
remove_perm('delete_department', u, instance)
for u in filter(lambda x: x is not None, superusers):
assign_perm('view_department', u, instance)
assign_perm('change_department', u, instance)
assign_perm('delete_department', u, instance)

The signal receiver seem to work, as I said I have checked the user
rights on the django shell.

I have as well a DepartmentAdmin:

class PersonDepartmentMembershipInline(admin.StackedInline):
model = PersonDepartmentMembership
extra = 2


class GroupDepartmentMembershipInline(admin.StackedInline):
model = GroupDepartmentMembership
extra = 1


class DepartmentAdmin(GuardedModelAdmin):
inlines = (PersonDepartmentMembershipInline,
GroupDepartmentMembershipInline,)

admin.site.register(Department, DepartmentAdmin)

According to the documentation this should be enough to integrate
django-guardian into the admin interface. Even though, when I log in
with a user from different department, he's able to modify the other
department. Any help please? Thanks in advance.

Regards,

Roberto




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




Re: WSGIPythonPath and

2013-04-12 Thread Roberto López López

Thank you very much Joey and Nik, I will talk about your proposed
solutions with our sysadmin.

Best,

Roberto



On 04/12/2013 01:11 AM, Nikolas Stevenson-Molnar wrote:
> Another direction might be to run a separate WSGI HTTP server (like
> gunicorn) and proxy to it from Apache. Saves the hassle of messing
> around with mod_wsgi.
> 
> _Nik
> 
> On 4/11/2013 3:20 PM, Joey Espinosa wrote:
>>
>> I had basically the same issue as you.
>>
>> With only one Django app deployed, it's easy to just stick your
>> WSGIPythonPath directive in /etc/apache2/apache.conf.
>>
>> But with multiple different virtualenvs, you need to do something like
>> this:
>>
>> http://stackoverflow.com/questions/4614121/running-python-from-a-virtualenv-with-apache-mod-wsgi-on-windows
>>
>> Hope that helps. I've implemented this solution myself.
>>
>> --
>> Joey Espinosa
>> Python Developer
>> http://about.me/joelinux
>>
>> On Apr 11, 2013 5:20 PM, "Roberto López López" > <mailto:roberto.lo...@uni.no>> wrote:
>>
>>
>> Hi Joey,
>>
>> All of them are in different virtualenvs.
>>
>>
>>
>> On 04/11/2013 11:02 PM, Joey Espinosa wrote:
>>>
>>> I meant Python libs/binary.
>>>
>>> --
>>> Joey "JoeLinux" Espinosa
>>> Python Developer
>>> http://about.me/joelinux
>>>
>>> On Apr 11, 2013 5:00 PM, "Joey Espinosa"
>>> mailto:jlouis.espin...@gmail.com>> wrote:
>>>
>>> Do all your sites share the same Python, or are they in
>>> different virtualenvs?
>>>
>>> --
>>> Joey "JoeLinux" Espinosa
>>> Python Developer
>>> http://about.me/joelinux
>>>
>>> On Apr 11, 2013 3:39 PM, "Roberto López López"
>>> mailto:roberto.lo...@uni.no>> wrote:
>>>
>>>
>>> Hi everyone,
>>>
>>> We are trying to deploy a django application on our
>>> apache server
>>> (mod_wsgi) following
>>> 
>>> https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
>>> We
>>> have different virtualhosts defined as well in httpd.conf.
>>>
>>> We are now stuck, apache is throwing the following error:
>>>
>>> WSGIPythonPath cannot occur within  section
>>>
>>> Can anyone give us any hint? Thank you very much!
>>>
>>> Roberto
>>>
>>>
>>> --
>>> You received this message because you are subscribed to
>>> the Google Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails
>>> from it, send an email to
>>> django-users+unsubscr...@googlegroups.com
>>> <mailto:django-users%2bunsubscr...@googlegroups.com>.
>>> To post to this group, send email to
>>> django-users@googlegroups.com
>>> <mailto:django-users@googlegroups.com>.
>>> Visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit
>>> https://groups.google.com/groups/opt_out.
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to django-users+unsubscr...@googlegroups.com
>>> <mailto:django-users+unsubscr...@googlegroups.com>.
>>> To post to this group, send email to
>>> django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
>>> Visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com
>> <ma

Re: WSGIPythonPath and

2013-04-11 Thread Roberto López López

Hi Joey,

All of them are in different virtualenvs.



On 04/11/2013 11:02 PM, Joey Espinosa wrote:
>
> I meant Python libs/binary.
>
> --
> Joey "JoeLinux" Espinosa
> Python Developer
> http://about.me/joelinux
>
> On Apr 11, 2013 5:00 PM, "Joey Espinosa"  <mailto:jlouis.espin...@gmail.com>> wrote:
>
> Do all your sites share the same Python, or are they in different
> virtualenvs?
>
> --
> Joey "JoeLinux" Espinosa
> Python Developer
> http://about.me/joelinux
>
> On Apr 11, 2013 3:39 PM, "Roberto López López"
> mailto:roberto.lo...@uni.no>> wrote:
>
>
> Hi everyone,
>
> We are trying to deploy a django application on our apache server
> (mod_wsgi) following
> https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
> We
> have different virtualhosts defined as well in httpd.conf.
>
> We are now stuck, apache is throwing the following error:
>
> WSGIPythonPath cannot occur within  section
>
> Can anyone give us any hint? Thank you very much!
>
> Roberto
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to
> django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at
> http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




WSGIPythonPath and

2013-04-11 Thread Roberto López López

Hi everyone,

We are trying to deploy a django application on our apache server
(mod_wsgi) following
https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/ We
have different virtualhosts defined as well in httpd.conf.

We are now stuck, apache is throwing the following error:

WSGIPythonPath cannot occur within  section

Can anyone give us any hint? Thank you very much!

Roberto


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




Re: field lookups problem

2013-03-22 Thread Roberto López López

Hi Anssi, thanks for your answer.

I already thought about that, but checking the code from
django.db.models.base.Model#__eq__() is not telling me the same:

def __eq__(self, other):
return isinstance(other, self.__class__) and self._get_pk_val()
== other._get_pk_val()



On 03/22/2013 05:02 PM, akaariai wrote:
> On 22 maalis, 15:44, Roberto López López  wrote:
>> Hi,
>>
>> I have a problem with my data model while doing field lookups. This is
>> my models.py:
>>
>> from django.db import models, IntegrityError
>>
>> # Create your models here.
>>
>> class Model1(models.Model):
>> title = models.CharField(max_length=15)
>> models2 = models.ManyToManyField('Model2', through='ThroughModel')
>>
>> def __unicode__(self):
>> return self.title
>>
>> class Model2(models.Model):
>> title = models.CharField(max_length=15)
>>
>> def __unicode__(self):
>> return self.title
>>
>> class ThroughModel(models.Model):
>> model1 = models.ForeignKey(Model1)
>> model2 = models.ForeignKey(Model2)
>> lead = models.BooleanField(default=False)
>>
>> def __unicode__(self):
>> return u'{0} - {1} - {2}'.format(self.model1, self.model2,
>> self.lead)
>>
>> Testing it on the django shell:
>>
>>>>> m1 = Model1.objects.create(title='blabla')
>>>>> m2 = Model2.objects.create(title='blabla2')
>>>>> m1.__eq__(m2)
>> False # OBVIOUSLY>>> t = 
>> ThroughModel.objects.create(model1=m1, model2=m2)
>>>>> ThroughModel.objects.filter(model1__exact=m1)
>> []# OK>>> 
>> ThroughModel.objects.filter(model1__exact=m2)
>>
>> []# NOT OK!!!
>>
>> Am I missing anything? Can anyone spot the problem?
>>
>> Thanks for your advice.
>>
>> Regards,
>>
>> Roberto
> The problem here is that Django doesn't do any verification that the
> given model values for lookups are of correct type.  My bet is that
> m1.pk == m2.pk. So, Django will create a query using m2.pk in
> model1__exact=m2, and this is the reason you get the results you get.
>
>  - Anssi
>

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




field lookups problem

2013-03-22 Thread Roberto López López


Hi,

I have a problem with my data model while doing field lookups. This is
my models.py:

from django.db import models, IntegrityError

# Create your models here.

class Model1(models.Model):
title = models.CharField(max_length=15)
models2 = models.ManyToManyField('Model2', through='ThroughModel')

def __unicode__(self):
return self.title

class Model2(models.Model):
title = models.CharField(max_length=15)

def __unicode__(self):
return self.title

class ThroughModel(models.Model):
model1 = models.ForeignKey(Model1)
model2 = models.ForeignKey(Model2)
lead = models.BooleanField(default=False)

def __unicode__(self):
return u'{0} - {1} - {2}'.format(self.model1, self.model2,
self.lead)




Testing it on the django shell:

>>> m1 = Model1.objects.create(title='blabla')
>>> m2 = Model2.objects.create(title='blabla2')
>>> m1.__eq__(m2)
False # OBVIOUSLY
>>> t = ThroughModel.objects.create(model1=m1, model2=m2)
>>> ThroughModel.objects.filter(model1__exact=m1)
[]# OK
>>> ThroughModel.objects.filter(model1__exact=m2)
[]# NOT OK!!!



Am I missing anything? Can anyone spot the problem?

Thanks for your advice.

Regards,

Roberto


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




Re: django templates - iterate over several lists

2013-03-08 Thread Roberto López López

Thank you very much!


On 03/08/2013 03:12 PM, Javier Guerra Giraldez wrote:
> On Fri, Mar 8, 2013 at 5:07 AM, Roberto López López
>  wrote:
>> I'd like to avoid having to concatenate them in the view and pass that
>> as another parameter.
> 
> 
> two ideas come to mind:
> 
> - itertools.chain() on the view.  it's equivalent to concatenating,
> but done lazily, so there's _very_ little overhead.
> 
> - add them in the template.  the 'add' filter is supposed to work with
> lists too.
> 
> needless to say, i'd far prefer the first option.  view functions are
> supposed to gather and organize all the info and templates should have
> as little behaviour as possible.
> 
> 

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




django templates - iterate over several lists

2013-03-08 Thread Roberto López López

Hi,

How can I iterate over several list objects available in my template?
I'd like to avoid having to concatenate them in the view and pass that
as another parameter.

I mean something like this:

{% for x in list1, list2, list3... listN %}
{% if not forloop.first %}, {% endif %}write some stuff
{% endfor %}

Thanks for your input!

Roberto


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




Re: I screwed up my django site using touch

2013-03-07 Thread Roberto López López

If you are using pycharm, you just need to use the local history to
check which indents you have changed.

(right click over the file you want to check - local history - show
history - ...)


On 03/07/2013 03:58 PM, frocco wrote:
> The problem with the stack trace, is that I could not tell what views.py
> it was talking about.
> I use PyCharm, but at work I think I used notepad++ to make a quick change.
> 
> I understand now that is is a python problem, but what bothers me is
> that I could not resolve it via the trace.
> I may have been reading it wrong, but nothing it said pointed me to the
> views.py that was in error.
> I wish I had the full trace again so I could post it.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  



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




Re: I screwed up my django site using touch

2013-03-07 Thread Roberto López López


In python indentation really matters. Two consecutive lines, with
different indentation, do not belong to the same execution block. So:

def function(self):
   this_code_belong_to_the_function()
   this_code_also()
   if(True):
   this_as_well()
this_doesnt()

And code indented using tabs is not the same as code indented with
spaces. For sake of simplicity, people tend to use just 4 spaces instead
of tabs (somebody mentioned that some days ago on the mailing list if I
remember well). You can configure that in your editor/ide.





On 03/07/2013 03:06 PM, frocco wrote:
> I do not understand what the error indentation means.
> I am new to django, coming from PHP.
> I was using touch, because unlike PHP, I wanted changes to show without
> kicking users off.
> now I am afraid to use touch.
> 
> 
> On Thursday, March 7, 2013 8:54:15 AM UTC-5, Roberto López López wrote:
> 
> 
> Check the history of the files you've touched, and rollback all
> indentation changes.
> 
> 
> 
> On 03/07/2013 02:49 PM, frocco wrote:
> > Hello,
> >
> > I am not sure what happened, I did a touch wsgi and then a touch
> wsgi.py
> > I got an error afterwards and could not recover from it. I could not
> > find the views.py it was complaining about.
> > I tried to reload the site from a backup and still had errors. I
> ended
> > up recreating the site on webfaction and uploading each app until
> it was
> > working.
> >
> >
> >   IndentationError at /
> >
> > unindent does not match any outer indentation level (views.py,
> line 29)
> >
> > Django Version:1.5
> > Exception Type:IndentationError
> > Exception Value:
> >
> > unindent does not match any outer indentation level (views.py,
> line 29)
> >
> > Exception Location:
> > /home/frocco/webapps/ntw/lib/python2.7/django/utils/importlib.py in
> > import_module, line 35
> > Python Executable:/usr/local/bin/python
> > Python Version:2.7.3
> > Python Path:
> >
> > ['/home/frocco/webapps/ntw',
> >  '/home/frocco/webapps/ntw/myproject',
> >  '/home/frocco/webapps/ntw/lib/python2.7',
> >  '/home/frocco/lib/python2.7/pip-1.2.1-py2.7.egg',
> >  '/home/frocco/lib/python2.7',
> >  '/usr/local/lib/python27.zip',
> >  '/usr/local/lib/python2.7',
> >  '/usr/local/lib/python2.7/plat-linux2',
> >  '/usr/local/lib/python2.7/lib-tk',
> >  '/usr/local/lib/python2.7/lib-old',
> >  '/usr/local/lib/python2.7/lib-dynload',
> >  '/usr/local/lib/python2.7/site-packages',
> >  '/usr/local/lib/python2.7/site-packages/PIL']
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to django-users...@googlegroups.com .
> > To post to this group, send email to django...@googlegroups.com
> .
> > Visit this group at
> http://groups.google.com/group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> >  
> >  
> 
> 
> -- 
> Kind regards,
> 
> Roberto L�pez L�pez
> 
> 
> System Developer
> Parallab, Uni Computing
> H�yteknologisenteret, Thorm�hlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: models i18n

2013-03-07 Thread Roberto López López

Yes, I meant that. It works great, and fits perfectly my needs. I give
it an AAA+

Thanks again.




On 03/07/2013 02:58 PM, Johan ter Beest wrote:
> 
> On Mar 6, 2013, at 4:20 PM, Roberto López López  wrote:
> 
>>
>> Thanks for your suggestion Johan.
>>
>> Just another question, which I've not seen answered in the
>> documentation: is there any custom filter/tag to access those translated
>> fields from a template? Thanks
> 
> If you do {% load i18n %} somewhere in your template then you can use the {{ 
> employee.position }} tag for the translated one based on the user's language 
> setting or you could specifically use {{ employee.position_en }} to target 
> the English translation if you so desire. 
> 
> Is this what you meant?
> 
> Johan
> 
>>
>> Best,
>>
>> Roberto
>>
>> On 03/05/2013 10:39 PM, Johan ter Beest wrote:
>>>
>>> On Mar 5, 2013, at 10:31 PM, Roberto López López >> <mailto:roberto.lo...@uni.no>> wrote:
>>>
>>>> Hi guys,
>>>>
>>>> I am developing a django application and between my requirements there
>>>> is being able to set the model fields into different languages.
>>>>
>>>> For example:
>>>>
>>>> class Employee(models.Model):
>>>>   position = models.CharField()
>>>>   # etc.
>>>>
>>>> The employee position won't be the same in English and Spanish. Ideally,
>>>> when an user fills in the data for an employee using the admin, there
>>>> will be one tab for each language defined in the settings file.
>>>>
>>>> Do you have any suggestion about how to deal with this issue?
>>>
>>> Django-modeltranslation: https://github.com/deschler/django-modeltranslation
>>>
>>> Very nice and easy, I use it all the time, works like a charm. You can
>>> do the tabs with some custom CSS and JS in the Admin through a Media
>>> class like this:
>>>
>>> class Media:
>>>js = (
>>>'modeltranslation/js/force_jquery.js',
>>>
>>> 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js',
>>>'modeltranslation/js/tabbed_translation_fields.js',
>>>)
>>>css = {
>>>'screen':
>>> ('modeltranslation/css/tabbed_translation_fields.css',),
>>>}
>>>
>>> Johan
>>>
>>>>
>>>> Thanks!
>>>>
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com
>>>> <mailto:django-users+unsubscr...@googlegroups.com>.
>>>> To post to this group, send email to django-users@googlegroups.com
>>>> <mailto:django-users@googlegroups.com>.
>>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
> 


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: I screwed up my django site using touch

2013-03-07 Thread Roberto López López

Check the history of the files you've touched, and rollback all
indentation changes.



On 03/07/2013 02:49 PM, frocco wrote:
> Hello,
> 
> I am not sure what happened, I did a touch wsgi and then a touch wsgi.py
> I got an error afterwards and could not recover from it. I could not
> find the views.py it was complaining about.
> I tried to reload the site from a backup and still had errors. I ended
> up recreating the site on webfaction and uploading each app until it was
> working.
> 
> 
>   IndentationError at /
> 
> unindent does not match any outer indentation level (views.py, line 29)
> 
> Django Version:   1.5
> Exception Type:   IndentationError
> Exception Value:  
> 
> unindent does not match any outer indentation level (views.py, line 29)
> 
> Exception Location:
> /home/frocco/webapps/ntw/lib/python2.7/django/utils/importlib.py in
> import_module, line 35
> Python Executable:/usr/local/bin/python
> Python Version:   2.7.3
> Python Path:  
> 
> ['/home/frocco/webapps/ntw',
>  '/home/frocco/webapps/ntw/myproject',
>  '/home/frocco/webapps/ntw/lib/python2.7',
>  '/home/frocco/lib/python2.7/pip-1.2.1-py2.7.egg',
>  '/home/frocco/lib/python2.7',
>  '/usr/local/lib/python27.zip',
>  '/usr/local/lib/python2.7',
>  '/usr/local/lib/python2.7/plat-linux2',
>  '/usr/local/lib/python2.7/lib-tk',
>  '/usr/local/lib/python2.7/lib-old',
>  '/usr/local/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/site-packages',
>  '/usr/local/lib/python2.7/site-packages/PIL']
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: models i18n

2013-03-06 Thread Roberto López López

Thanks for your suggestion Johan.

Just another question, which I've not seen answered in the
documentation: is there any custom filter/tag to access those translated
fields from a template? Thanks

Best,

Roberto

On 03/05/2013 10:39 PM, Johan ter Beest wrote:
> 
> On Mar 5, 2013, at 10:31 PM, Roberto López López  <mailto:roberto.lo...@uni.no>> wrote:
> 
>> Hi guys,
>>
>> I am developing a django application and between my requirements there
>> is being able to set the model fields into different languages.
>>
>> For example:
>>
>> class Employee(models.Model):
>>position = models.CharField()
>># etc.
>>
>> The employee position won't be the same in English and Spanish. Ideally,
>> when an user fills in the data for an employee using the admin, there
>> will be one tab for each language defined in the settings file.
>>
>> Do you have any suggestion about how to deal with this issue?
> 
> Django-modeltranslation: https://github.com/deschler/django-modeltranslation
> 
> Very nice and easy, I use it all the time, works like a charm. You can
> do the tabs with some custom CSS and JS in the Admin through a Media
> class like this:
> 
> class Media:
> js = (
> 'modeltranslation/js/force_jquery.js',
>
> 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js',
> 'modeltranslation/js/tabbed_translation_fields.js',
> )
> css = {
> 'screen':
> ('modeltranslation/css/tabbed_translation_fields.css',),
> }
> 
> Johan
> 
>>
>> Thanks!
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
>> an email to django-users+unsubscr...@googlegroups.com
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




i18n

2013-03-06 Thread Roberto López López

Hi,

I am setting up i18n in my django app. I have added the following to my
settings.py:

PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))

LOCALE_PATHS = (
os.path.join(PROJECT_PATH, 'locale'),
)

LANGUAGES = [
('en', _('English')),
('nb', _('Norwegian')),
]

And created a locale/ directory into my project root.

Then I've run the command:

django-admin.py makemessages --all

...without any error, but it doesn't generate anything into locale/. I
know I've created locale/ in the correct location, as I got some errors
running the command until I created it there.

myprojectroot$ find . -iname '*.po'
myprojectroot$  ### NONE!!!

Any suggestions please? Thanks :-)

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




Re: reverse foreign key relationship usage

2013-03-06 Thread Roberto López López

Hi Fatih,

This is extremely useful in case you have two different relations
between the same model. As a rough example, consider the two following
models:

class Person(models.Model):
name = models.CharField(max_length=30)

class Car(models.Model):
model = models.CharField(max_length=20)
owner = models.OneToOne(Person, related_name='owned_car')
users = models.ForeignKey(Person, related_name='used_car')

In case of not having a different related_name for each of those two
relations, you wouldn't be able to get the person's car or the car this
person uses. (This person may own a car but use his company car, or a
friend's, a rental one...)





On 03/06/2013 08:30 AM, Fatih Tiryakioglu wrote:
> Hello all,
> 
> In Appendix B:Database API, it says "related_name (keyword) is
> particularly useful if a model has two foreign keys to the same second
> model." which is about 'related_name' keyword used reverse foreign key
> relationships. 
> e.g. blog = ForeignKey(Blog, related_name='entries').
> 
> What does it mean? Where should I use related_name instead of simply
> reversing by "x_set" keyword.
> 
> Thanks.
> 
> 
> --
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




models i18n

2013-03-05 Thread Roberto López López
Hi guys,

I am developing a django application and between my requirements there
is being able to set the model fields into different languages.

For example:

class Employee(models.Model):
position = models.CharField()
# etc.

The employee position won't be the same in English and Spanish. Ideally,
when an user fills in the data for an employee using the admin, there
will be one tab for each language defined in the settings file.

Do you have any suggestion about how to deal with this issue?

Thanks!


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




Re: Use variable in my template?

2013-02-28 Thread Roberto López López

of course, your model should be something like this:

class Marke(models.Model):
marke = models.ImageField(upload_to="images/")

or wherever you prefer to put your images into the media folder




On 02/28/2013 12:06 PM, Maria wrote:
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to
> insert an image:
>  
> 
> {% load staticfiles %}
> 
> 
> 
>  type="text/css" media="screen" />
> 
> 
> 
>   alt="Picture" />
>  
> 
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
> 
> from choice import*
> 
> global marke
> marke = read_m()
> 
> The value of marke is *marke3 *and I have an image marke3.jpg. I
> successfully used another variable to insert an image (poll.id) but this
> time it wont work.
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Use variable in my template?

2013-02-28 Thread Roberto López López

I don't understand exactly what do you mean, but if those images are
uploaded by the user (for example, using the admin app), they should be
"{{ MEDIA_URL }}{{ marke.marke }}" instead of "{{ STATIC_URL }}images/{{
marke.marke }}.jpg"



On 02/28/2013 12:06 PM, Maria wrote:
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to
> insert an image:
>  
> 
> {% load staticfiles %}
> 
> 
> 
>  type="text/css" media="screen" />
> 
> 
> 
>   alt="Picture" />
>  
> 
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
> 
> from choice import*
> 
> global marke
> marke = read_m()
> 
> The value of marke is *marke3 *and I have an image marke3.jpg. I
> successfully used another variable to insert an image (poll.id) but this
> time it wont work.
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: problem in displaying data on html

2013-02-28 Thread Roberto López López

If you just output a m2m field that's normal. If you rather prefer to
iterate over it and show all the related objects, use a for loop...


On 02/28/2013 02:43 PM, Avnesh Shakya wrote:
> hi i have one problem, i want to display data from database on html page
> all data is displaying but one attribute(university name) which i
> defined as models.ManyToManyField(University) is not being displyed,
> it's not generating error but it showing msz on html page-
> 
> instead of showing university name
> 
> plz help me...
> thanks
>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Redirect and execute after 2 seconds?

2013-02-27 Thread Roberto López López

Hi again Maria,

Try to combine the solutions proposed in those two pages:

http://stackoverflow.com/questions/2133166/loop-timer-in-javascript#2133217
http://stackoverflow.com/questions/948227/should-i-use-window-navigate-or-document-location-in-javascript#948242

That should be more than enough.

Roberto



On 02/27/2013 04:19 PM, Maria wrote:
> Hello Alan,
>  
> I'd love to learn something new but unfortunately I dont have the time
> since my project is due very soon. Is there no easy or short way to get
> this time variable into my code? Also, how do I "look for everything
> that happens on the client-side"? I am sorry for my incompetence.. :D
>  
> 
> Am Mittwoch, 27. Februar 2013 16:06:05 UTC+1 schrieb Alan Plum:
> 
> Hi Maria,
> 
> as Bill explained, you should be looking at JavaScript for
> everything that happens on the client-side (i.e. after the page has
> left the server).
> 
> However you should consider shifting more of the logic to the
> client-side in this case. For time-based actions with such a short
> duration the additional overhead involved in sending and receiving a
> web page could affect the results quite dramatically, especially
> when the user is on a dodgy connection (think mobile or dial-up).
> 
> You may want to look into learning AJAX to communicate between the
> client and server without requiring a full page reload and into a
> front-end library like jQuery for adding the necessary client-side
> logic to hide and reveal elements on the page (i.e. client-side) or
> provide dynamic updates after the page has been sent by the server
> (Django).
> 
> There are some good live coding exercises and screencasts available
> online if you want to learn more about jQuery or other front-end
> libraries or just JavaScript in general.
> 
> 
> Yours,
> 
> Alan
> 
> On 27.02.2013 15:01, Maria wrote:
>> Hi everyone! :)
>>  
>> I am working on a project for my studies, it is a web poll where
>> you can only answer yes or no by clicking on buttons.
>>  
>> If the user clicked on one button, the result will be saved in a
>> text-file and the user will be redirected to another page with a
>> random id:
>>  
>>
>> return HttpResponseRedirect ('/polls/'+str(sid))
>>
>>  
>> *If the user doesnt click on any button quickly enough, I want the
>> page to redirect them after 3 seconds to another page with a
>> random id AND i want to save the id of the question that wasnt
>> answered.*  How can I do it? I searched the web but only found the
>> time.sleep function. As far as I understood, I cant use the sleep
>> function because the site has to do other stuff while the 3
>> seconds pass.
>>  
>> I would be very thankful for any help on this!
>>  
>> Kind regards,
>>  
>> Maria
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at
>> http://groups.google.com/group/django-users?hl=en
>> <http://groups.google.com/group/django-users?hl=en>.
>> For more options, visit https://groups.google.com/groups/opt_out
>> <https://groups.google.com/groups/opt_out>.
>>  
>>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Redirect and execute after 2 seconds?

2013-02-27 Thread Roberto López López

Maria, that code (your "after three seconds") has to be run on the
client, so django has nothing to do with it. As Bill suggests, you
should try some javascript here.



On 02/27/2013 04:10 PM, Maria wrote:
> _like this:_
> if user clicks button
>   save answer
>   return HttpResponseRedirect ('/polls/'+str(sid))
> else *after 3 seconds*
>   save this page for later
>   return HttpResponseRedirect ('/polls/'+str(sid))
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Begginer

2013-02-27 Thread Roberto López López


Try https://docs.djangoproject.com/en/1.5/intro/



On 02/27/2013 09:29 AM, Akshay Ramesh wrote:
> Hi I am new to Djnago and would like to have some help from you. Where
> should I start from ?
> 

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




Re: m2m relation just working in one direction

2013-02-24 Thread Roberto López López

Mike,

Cool, you are right! Changing the related_name to something different
than groups seems to solve the problem. Thank you very much :-)

Roberto



On 02/24/2013 11:30 PM, Mike Dewhirst wrote:
> Roberto
>
> I'm not entirely sure but it is possible that your group is getting
> mixed up with the contrib.auth group. I would try changing the name of
> my group temporarily to something else just to eliminate that.
>
> Mike
>
> On 25/02/2013 8:58am, Roberto López López wrote:
>> Hi,
>>
>> I have a problem involving a relation between two entities, Person and
>> Group.
>>
>>  from django.contrib.auth.models import User
>>  from django.db import models
>>
>>  class Group(models.Model):
>>  employees = models.ManyToManyField('staff.Person',
>> related_name='groups')
>>  leader = models.OneToOneField('staff.Person',
>> related_name='led_group')
>>
>>  class Person(User):
>>  pass
>>
>>
>> $ python manage.py shell
>>
>>  In [1]: from group.models import Group
>>
>>  In [2]: from staff.models import Person
>>
>>  In [3]: p = Person.objects.create(username='person1',
>> first_name='person 1')
>>
>>  In [5]: g = Group.objects.create(group_name='group 1', leader=p)
>>
>>  In [9]: g.employees.all()
>>  Out[9]: []
>>
>>  In [10]: g.employees.add(p)
>>
>>  In [11]: g.employees.all()
>>  Out[11]: []
>>
>>  In [16]: p.groups.all()
>>  Out[16]: []
>>
>>
>> As you can see, when I add a person through the group, it's not added to
>> group.employees but to person.groups. Can you see any mistake in my
>> code? Thanks in advance for your suggestions :-)
>>
>

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




m2m relation just working in one direction

2013-02-24 Thread Roberto López López
Hi,

I have a problem involving a relation between two entities, Person and
Group.

from django.contrib.auth.models import User
from django.db import models

class Group(models.Model):
employees = models.ManyToManyField('staff.Person',
related_name='groups')
leader = models.OneToOneField('staff.Person',
related_name='led_group')

class Person(User):
pass


$ python manage.py shell

In [1]: from group.models import Group

In [2]: from staff.models import Person

In [3]: p = Person.objects.create(username='person1',
first_name='person 1')

In [5]: g = Group.objects.create(group_name='group 1', leader=p)

In [9]: g.employees.all()
Out[9]: []

In [10]: g.employees.add(p)

In [11]: g.employees.all()
Out[11]: []

In [16]: p.groups.all()
Out[16]: []


As you can see, when I add a person through the group, it's not added to
group.employees but to person.groups. Can you see any mistake in my
code? Thanks in advance for your suggestions :-)

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