how we access language_code (current language) in cms_plugin.py in django_cms

95 views
Skip to first unread message

VRS Rajkot

unread,
May 30, 2016, 7:11:54 AM5/30/16
to django CMS developers

hi,

Enter code here...

my django_cms == 3.2.3
django == 1.8.10

my cms_plugins.py is


from .models import *
 
from cms.utils import get_language_from_request
 
from django.contrib import admin




 

class FaqPlugin(CMSPluginBase): name = _("Faq Plugin")
render_template
= "faq/faq_list.html"


def render(self, context, instance, placeholder):

faqs
= Faq.objects.language('fr').filter(status="published")
 lang
= context['request']

 context
.update({'instance' : instance, 'faqs' : faqs})

 return context

plugin_pool.register_plugin(FaqPlugin)

i want to get current language object instead of 'fr' how can i get that
plz help!!

Iacopo Spalletti

unread,
May 30, 2016, 7:32:08 AM5/30/16
to django-cms...@googlegroups.com
Il 30/05/2016 13:11, VRS Rajkot ha scritto:
> hi,
>
> |
> Entercode here...
> |
>
> my django_cms == 3.2.3
> django == 1.8.10
>
> my cms_plugins.py is
>
>
> |
> from.models import*
> fromcms.utils importget_language_from_request
> fromdjango.contrib importadmin
>
>
>
>
>
>
> classFaqPlugin(CMSPluginBase):name =_("Faq Plugin")
> render_template ="faq/faq_list.html"
>
>
> defrender(self,context,instance,placeholder):
>
> faqs =Faq.objects.language('fr').filter(status="published")
> lang =context['request']
>
> context.update({'instance':instance,'faqs':faqs})
>
> | returncontext|
>
> |
>
> |
> |
>
> plugin_pool.register_plugin(FaqPlugin)
>
> i want to get current language object instead of 'fr' how can i get that
> plz help!!

instance.language is the plugin language if you want the language of the
plugin, or get_language_from_request(request, check_path) (from
django.utils.translation) if you want the request language


>
> --
> Message URL:
> https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id
> Unsubscribe: send a message to
> django-cms-devel...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google
> Groups "django CMS developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-cms-devel...@googlegroups.com
> <mailto:django-cms-devel...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/django-cms-developers/c087a609-96a7-4995-a462-22cdd87091b2%40googlegroups.com
> <https://groups.google.com/d/msgid/django-cms-developers/c087a609-96a7-4995-a462-22cdd87091b2%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
Iacopo Spalletti

Nephila s.a.s. - Firenze
Telefono: +39 055 5357189
Assistenza Tecnica: +39 055 3985730
http://nephila.it

signature.asc
Reply all
Reply to author
Forward
0 new messages