Re: Detail View Question

2014-05-07 Thread visionary800
I am not sure my first reply worked, but here it goes again.
Your template is using {{ post.NAME }} when I believe it should be using {{ 
customer.NAME }}.  The context name that is used in the template is 
obtained by default from the model and in your case, you are using model= 
Customer.  If you want to rename so that you can use {{ post.Name }}, you 
will have to use 'context_object_name = post'.  But I suggest you edit your 
template. 

url(r'^(?P\d+)$', DetailView.as_view(
model = Customer,
template_name="customer.html",

context_object_name='post')),# Do this only if you want 
to use {{ post.NAME }}


get_context_object_name(*obj*)

Return the context variable name that will be used to contain the data that 
this view is manipulating. If 
context_object_nameis
 
not set, the context name will be constructed from themodel_name of the 
model that the queryset is composed from. For example, the model Article would 
have context object named 'article'.
Ref: 
https://docs.djangoproject.com/en/1.6/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.get_context_object_name

hope that works.



On Tuesday, May 6, 2014 4:24:07 PM UTC-7, G Z wrote:
>
> repost easier to read
>
> So I'm using DetailView to associate a Customer ID with customer 
> information but due to my lack of knowledge im not entirely sure what the 
> issue is. It will go to the page but it won't load the unique customer 
> data. The data exist at domain/customers/ however when you click the link 
> which takes you to domain/customers/id it wont show the data its just a 
> blank page with a title.
>
> Here is my urls.py
>
> from django.conf.urls import patterns, include, url
> from django.views.generic.list import ListView
> from django.views.generic.detail import DetailView
> from vmware.models import Customer
>
> urlpatterns = patterns('',
> url(r'^$', ListView.as_view(
> queryset=Customer.objects.all().order_by("-id")[:100],
> template_name="vms.html")),
>
> url(r'^(?P\d+)$', DetailView.as_view(
> model = Customer,
> template_name="customer.html")),
>
> )
>
> Here is the html output for it
>
> {% extends "base.html" %}
> {% block content %}
>  {{ post.NAME }}  
> 
>  {{ post.id }}
> 
> 
>  {{ post.NAME }}
> 
> 
>  {{ post.WEBSITE }}
> 
> 
>  {{ post.PHONE }}
> 
> 
>  {{ post.EMAIL }}
> 
> 
>  {{ post.ADDRESS }}
> 
> 
>  {{ post.VMIDS }}
> 
> {% endblock %}
>
>

-- 
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/31ef4781-37b7-4d03-980c-3bc63aa4d382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: makemessages doesn't understand I'm reusing Django existing translation messages

2014-05-30 Thread visionary800
My recent experience with using django-admin.py makemessages is that this 
command only works when there is a subdirectory present named 'locale' that 
sits just below where you are executing this command.  Without a 'locale' 
subdirectory present, the command will raise an error.  I think by design 
it only makes translation files for the user created project/apps.  You can 
exclude parts of your project.

http://stackoverflow.com/questions/9973584/django-admin-makemessages-translate-all-django-package-with-mine

I am not sure if that helped.


On Friday, May 30, 2014 9:57:40 AM UTC-7, Selenite Vingt-Neuf wrote:
>
> Hi,
>
> I'm writing authentication templates using authentication views provided 
> by Django, and for that purpose I am reusing translation messages present 
> in django.contrib.admin.
>
> That works very well at the execution time, Django understands that 
> translation messages already exist in django.contrib.admin and display them 
> in the requested language (French in my case).
>
> My concern is that "django-admin.py makemessages -a" command doesn't 
> understand just as well and it creates those translation messages again in 
> my auth app's locale files. But I don't need them, or at least commented as 
> #fuzzy. Is it the normal behavior of that command or am I doing wrong ?
>
> Below is the example with the message "Reset my password":
>
> In django.contrib.admin locale files:
>
> - 
> path/to/python2.7/sites-packages/django/contrib/admin/locale/en/LC_MESSAGES/django.py
>
> #: templates/registration/password_reset_form.html:21
> msgid "Reset my password"
> msgstr ""
>
>  
> - 
> path/to/python2.7/sites-packages/django/contrib/admin/locale/fr/LC_MESSAGES/django.py
>
> #: templates/registration/password_reset_form.html:21
> msgid "Reset my password"
> msgstr "RĂ©initialiser mon mot de passe"
>
>
> In my password_reset template of my auth app:
>
> - auth/templates/auth/password_reset.html:
>
> *{% load i18n %}*
>
> 
>
>
>
> In my auth app's locale files after typing "cd path/to/myproject; cd 
> auth; django-admin.py makemessages -a":
>
> - auth/locale/en/LC_MESSAGES/django.po:
>
> #: templates/auth/password_reset.html:36
> msgid "Reset my password"
> msgstr ""
>
>
> - auth/locale/en/LC_MESSAGES/django.po:
>
> #: templates/auth/password_reset.html:36
> msgid "Reset my password"
> msgstr ""
>
>
> Here my settings:
>
> - myproject/settings.py:
>
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.cache.UpdateCacheMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.locale.LocaleMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'django.middleware.cache.FetchFromCacheMiddleware',
> )
>
> LANGUAGE_CODE = 'en-us'
>
> LANGUAGES = (
> ('fr', _('French')),
> ('en', _('English')),
> )
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> Here my config:
>
> - Mac OS X 10.9.2
> - python 2.7.6
> - gettext 0.18.3 (installed via homebrew)
>
> Thanks for your help.
>
> Cheers,
>
> Selenite Vingt-Neuf
>
>

-- 
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/7ce57726-5f35-43cb-9c2e-3eb22592c862%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django ugettext translation glitch or as designed?

2014-05-30 Thread visionary800
I am running into a challenge.  For both examples below everything is good 
except when I move the ugettext() to a separate file.
Good: After running the django-admin.py makemessages -l es, both examples 
produce the appropriate .po file.
Good: I change ../locale/es/LC_MESSAGES/django.po
  #: nav/views.py: 
  msgid "name" 
 msgstr "nombre"
Good: django-admin.py compilemessages
Good: I get the appropriate file, ../locale/es/LC_MESSAGES/django.mo 

This is a simplified version of what is happening.

---
Good: 1 - This works: when ugettext is within the view.
*file : /project/app/views.py*

...other imports
from django.utils.translation import ugettext

class BaseView(ContextMixin, View):
template = 'base.html'

def get(self, request, *args, **kwargs):
context = self.get_context_data()
return render(request, self.template, context)

def get_context_data(self, **kwargs):
   
   context['translate_this']= ugettext('name')
   return context
-

Bad: 2 - This Fails: when ugettext is in another file
*file : /project/app/views.py   *

...other imports
from .mytext import FROM_ANOTHER_FILE

class BaseView(ContextMixin, View):
template = 'base.html'

def get(self, request, *args, **kwargs):
context = self.get_context_data()
return render(request, self.template, context)

def get_context_data(self, **kwargs):
   
   context['translate_this']= FROM_ANOTHER_FILE
   return context

*file: /project/app/text.py   *
from django.utils.translation import ugettext

FROM_ANOTHER_FILE = ugettext('name')

-

The primary difference between the two examples is that when I separate 
ugettext() to another file - it fails.  
The result is that 'name' never converts to 'nombre' when changing the 
language.  
It works fine in example 1, 'name' and 'nombre' change depending on 
language selected but not in example 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/2302f88c-2050-4265-bf22-6e4d34a2b486%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django ugettext translation glitch or as designed?

2014-05-30 Thread visionary800
Sorry for the large text... I forget to change it - I guess I am going 
blind :-)

On Friday, May 30, 2014 6:51:35 PM UTC-7, visionary800 wrote:
>
> I am running into a challenge.  For both examples below everything is good 
> except when I move the ugettext() to a separate file.
> Good: After running the django-admin.py makemessages -l es, both examples 
> produce the appropriate .po file.
> Good: I change ../locale/es/LC_MESSAGES/django.po
>   #: nav/views.py: 
>   msgid "name" 
>  msgstr "nombre"
> Good: django-admin.py compilemessages
> Good: I get the appropriate file, ../locale/es/LC_MESSAGES/django.mo 
>
> This is a simplified version of what is happening.
>
>
> ---
> Good: 1 - This works: when ugettext is within the view.
> *file : /project/app/views.py*
>
> ...other imports
> from django.utils.translation import ugettext
>
> class BaseView(ContextMixin, View):
> template = 'base.html'
>
> def get(self, request, *args, **kwargs):
> context = self.get_context_data()
> return render(request, self.template, context)
>
> def get_context_data(self, **kwargs):
>
>context['translate_this']= ugettext('name')
>return context
>
> -
>
> Bad: 2 - This Fails: when ugettext is in another file
> *file : /project/app/views.py   *
>
> ...other imports
> from .mytext import FROM_ANOTHER_FILE
>
> class BaseView(ContextMixin, View):
> template = 'base.html'
>
> def get(self, request, *args, **kwargs):
> context = self.get_context_data()
> return render(request, self.template, context)
>
> def get_context_data(self, **kwargs):
>
>context['translate_this']= FROM_ANOTHER_FILE
>return context
>
> *file: /project/app/text.py   *
> from django.utils.translation import ugettext
>
> FROM_ANOTHER_FILE = ugettext('name')
>
> -
>
> The primary difference between the two examples is that when I separate 
> ugettext() to another file - it fails.  
> The result is that 'name' never converts to 'nombre' when changing the 
> language.  
> It works fine in example 1, 'name' and 'nombre' change depending on 
> language selected but not in example 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/ad352064-6e11-4f0c-89a6-a0fab2d091c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django ugettext translation glitch or as designed?

2014-05-30 Thread visionary800
Thank you Ramiro!  That was it - I changed to ugettext_lazy() and it worked!

I want to separate the text from the templates - this is why I want to 
place the text in a separate file.  Placing the text within the template is 
a d

What approach should I take to just separate the text from from the 
templates and views?  I want the text easy to edit without worrying about 
tags around the text.  Any 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2bad743d-d190-4ed1-affb-932e5c1e9236%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Internationalize: Get two things to happen when you select a language: set the language and redirected to a different part of the site

2014-06-19 Thread visionary800
I am stumped.  I am not sure how to approach this.  I think its best if I 
describe what I would like to happen then I would greatly appreciate some 
recommendations.

*Imagine this...*
You go to www.mysite.com and you are presented solely with two buttons(and 
nothing else): [Enter in English] | [Enter in Spanish].  You can press 
either button and what happens next is you enter the site to a different 
page that says "Welcome" or "hola" (which ever you chose) and language is 
session is set.  I am trying to get two things to happen with one button: 
1. set the language and 2. go to a new page(all in one process).

*Background: *
Internationalization works excellent on my site once you are in the site 
and you change to another language.  I have no problems with my site when 
you are in and you change the language setting - all is good there. 
 Internationalization works but I can't combine it with an other step.

*This is a general idea of what I thought might work - Any suggestions?*
urlpatterns = patterns('',
url(
regex=r'^english/',
view = UserEnterInEnglish.asView(),
name = 'enter_english'
),
url(
regex=r'^spanish/',
view = UserEnterInSpanish.asView(),
name = 'enter_spanish'
),...

class UserEnterInEnglish(TemplateView):
'''User selects english''
'
get(self, request, *args, **kwargs):
#Step 1. Set the language
#Post to language which I do not know how to do
#Post to' name="language" value="es" action="/i18n/setlang/"
   #Step 2 Go Enter the Site
return HttpResponseRedirect('/about')

class UserEnterInSpanish(TemplateView):
'''User selects spanish''
'
get(self, request, *args, **kwargs):
#Step 1. Set the language
#Post to language which I do not know how to do
#Post to' name="language" value="es" action="/i18n/setlang/"
   #Step 2 Go Enter the Site
return HttpResponseRedirect('/about')

-- 
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/6d24dbe5-ea73-4024-9b9d-f63f63b62f7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Internationalize: Get two things to happen when you select a language: set the language and redirected to a different part of the site

2014-06-19 Thread visionary800

>
> Resolved.  The solution was staring right at me (0^0) the whole time n the 
> template language.  I figured it out upon reading further down on the 
> documents.
>

https://docs.djangoproject.com/en/1.6/topics/i18n/translation/#miscellaneous
 

-- 
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/38a740dc-eaf6-4265-8323-4500ba1fb97e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.