Re: auth context processor setup

2008-06-22 Thread Vasiliy Gladkov

Maybe you forgot to use context_instance parameter in render() call?
If you want to use context processors, it must look like

return render_to_response('template.html', context,
context_instance=RequestContext(request))

context_instance parameter passes contexts from processors to your
templates

On 23 июн, 00:20, mcordes <[EMAIL PROTECTED]> wrote:
> I seem to already have the auth middleware enabled too. From what I'm
> seeing, generic views _do_ have the user object available in their
> templates. It's just my custom views that don't automatically have
> this. It's easy enough for me to pass in the request.user object from
> each of my templates, but I really thought I wouldn't need to do this.
>
> -Matt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: auth context processor setup

2008-06-22 Thread Vasiliy Gladkov

You have to enable auth middleware and application in settings.py -
http://djangobook.com/en/1.0/chapter12/
Then you can use user specific variables in your templates -
{{ user.username }}, {{ user.is_staff }} and so on

On 22 июн, 14:43, mcordes <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Is there anything I need to do to enable the auth context processor
> other than adding "django.core.context_processors.auth" to
> TEMPLATE_CONTEXT_PROCESSORS in my settings.py?
>
> I'd like to be able to access the 'auth user' object in my various
> templates, which from what I understand this processor is supposed to
> be injecting it, but it doesn't seem to be working.
>
> my settings.py file contains:
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>     "django.core.context_processors.auth",
> )
>
> and in my template I'm using:
>
> {{user}}
>
> Is there anything else I need to get this to work?  Any suggestions?
>
> -Matt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is it bad to use GET parameters for model entities management in my views?

2008-06-19 Thread Vasiliy Gladkov



On 19 июн, 17:42, Bradley Wright <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Jun 19, 4:31 am, Vasiliy Gladkov <[EMAIL PROTECTED]> wrote:
>
> > As i want to allow site editor to edit pages in convenient way without
> > built-in django admin, i use request.GET parameters like "http://
> > localhost:8000/somepage?action=edit"
>
> Like inline editing (Flickr-style), right?

Yes, that's exactly what im doing.

> > A lot of people from russian django group (http://groups.google.com/
> > group/django-russian/browse_thread/thread/678e725e12ccca46 - russian
> > language) told me that it's very bad decision as im losing some
> > important django advantages.
>
> I would guess the advantages are the robust and secure admin interface
> that comes packaged in django.contrib.admin, but as long as you're
> decorating your edit/delete/whatever views with logjn security I don't
> really see the problem either.

All of this actions permited for editors - company staff - only. For
persons who passed login procedure and who has turned on "is_staff"
flag in django.contrib.auth.

> Ryan Tomayko has done something similar (assuming we're talking about
> the same thing):
>
> http://tomayko.com/writings/administrative-debris

Thanks for link, it's interesting
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I display foriegn characters

2008-06-18 Thread Vasiliy Gladkov

Also you can try to change character set with MySql Workbench or any
other visual tool, if you prefer visual way. Im not sure about it as
im not using visual tools.

On 19 июн, 14:34, "Ramdas S" <[EMAIL PROTECTED]> wrote:
> Even I am facing the same problem. Any ideas how exactly do you set in MySQL
> or does migrating PostGres solve it?
>
> Ramdas S
> 2008/6/19 Vasiliy Gladkov <[EMAIL PROTECTED]>:
>
>
>
>
>
> > looks like you have to set character set in your database. as i
> > remember, i had similar problem with my mysql, wich has non-utf-8
> > character set
>
> > On 19 июн, 04:23, "Keith Mallory" <[EMAIL PROTECTED]> wrote:
> > > Hello,
>
> > > I am doing a small web site in django for my friend.
>
> > > The web site needs to have couple of dozen pages in chinese.
>
> > > What should I do in django to display these characters correctly?
>
> > > Most of them content needs to be updated. We have tools to create the
> > > chinese text in unicode. We want the same to cut and paste onto the
> > django
> > > admin interface, and it should render correctly.
>
> > > We also have some feedback form which is using newforms modelform. Again
> > if
> > > someone types in Chinese unicode characters (cut and paste from an
> > external
> > > editor, it should generate).
>
> > > While in the text box the text displays correctly, after saving all I see
> > is
>
> > > ???
>
> > > I changed my settings in the browser and I am able to view other pages
> > > correctly.
> > > I tried the i18n documentation. It is of little help, despite me trying
> > all
> > > combinations. All help appreciated
>
> > > Many Thanks
>
> > > Keith Mallory
>
> --
> Ramdas S
> +91 9342 583 065
> My Personal Blog:http://ramdas.diqtech.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I display foriegn characters

2008-06-18 Thread Vasiliy Gladkov

In MySql console client:

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf-8;
or
ALTER TABLE t MODIFY latin1_text_col TEXT CHARACTER SET utf8;

for each table. or something like it. look to the manual -
http://dev.mysql.com/doc/refman/5.0/en/alter-table.html
http://dev.mysql.com/doc/refman/5.0/en/alter-database.html - this is
usefull too, you can set default character table for whole db and new
table will have proper character set

my old solution was to kill whole dababase, modify my.sql  string to
"default-character-set=utf8" and recreate db, followed by "manage.py
syncdb" :)

On 19 июн, 14:34, "Ramdas S" <[EMAIL PROTECTED]> wrote:
> Even I am facing the same problem. Any ideas how exactly do you set in MySQL
> or does migrating PostGres solve it?
>
> Ramdas S
> 2008/6/19 Vasiliy Gladkov <[EMAIL PROTECTED]>:
>
>
>
>
>
> > looks like you have to set character set in your database. as i
> > remember, i had similar problem with my mysql, wich has non-utf-8
> > character set
>
> > On 19 июн, 04:23, "Keith Mallory" <[EMAIL PROTECTED]> wrote:
> > > Hello,
>
> > > I am doing a small web site in django for my friend.
>
> > > The web site needs to have couple of dozen pages in chinese.
>
> > > What should I do in django to display these characters correctly?
>
> > > Most of them content needs to be updated. We have tools to create the
> > > chinese text in unicode. We want the same to cut and paste onto the
> > django
> > > admin interface, and it should render correctly.
>
> > > We also have some feedback form which is using newforms modelform. Again
> > if
> > > someone types in Chinese unicode characters (cut and paste from an
> > external
> > > editor, it should generate).
>
> > > While in the text box the text displays correctly, after saving all I see
> > is
>
> > > ???
>
> > > I changed my settings in the browser and I am able to view other pages
> > > correctly.
> > > I tried the i18n documentation. It is of little help, despite me trying
> > all
> > > combinations. All help appreciated
>
> > > Many Thanks
>
> > > Keith Mallory
>
> --
> Ramdas S
> +91 9342 583 065
> My Personal Blog:http://ramdas.diqtech.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I display foriegn characters

2008-06-18 Thread Vasiliy Gladkov

looks like you have to set character set in your database. as i
remember, i had similar problem with my mysql, wich has non-utf-8
character set

On 19 июн, 04:23, "Keith Mallory" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am doing a small web site in django for my friend.
>
> The web site needs to have couple of dozen pages in chinese.
>
> What should I do in django to display these characters correctly?
>
> Most of them content needs to be updated. We have tools to create the
> chinese text in unicode. We want the same to cut and paste onto the django
> admin interface, and it should render correctly.
>
> We also have some feedback form which is using newforms modelform. Again if
> someone types in Chinese unicode characters (cut and paste from an external
> editor, it should generate).
>
> While in the text box the text displays correctly, after saving all I see is
>
> ???
>
> I changed my settings in the browser and I am able to view other pages
> correctly.
> I tried the i18n documentation. It is of little help, despite me trying all
> combinations. All help appreciated
>
> Many Thanks
>
> Keith Mallory
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is it bad to use GET parameters for model entities management in my views?

2008-06-18 Thread Vasiliy Gladkov

urls.py for my application looks like this:

urlpatterns = patterns('ms.masterstroy.views',
(r'^(?P[^/]+)$', 'page'),
...
)

As i want to allow site editor to edit pages in convenient way without
built-in django admin, i use request.GET parameters like "http://
localhost:8000/somepage?action=edit" and than process it in my
views.py like this:

def page(request, title):
  page = Page.objects.get(url_name=title)
  ...
  if 'action' in request.GET:
action = request.GET['action']
if action == 'delete':
  target_name = request.GET.get('target', '')
  target_page = get_object_or_404(Page, url_name=target_name)
  target_page.delete()
  return http.HttpResponseRedirect('/')
if action == 'edit':
   and so on...

A lot of people from russian django group (http://groups.google.com/
group/django-russian/browse_thread/thread/678e725e12ccca46 - russian
language) told me that it's very bad decision as im losing some
important django advantages.

What they talking about? I have no idea. I have clear and simple urls
and my urls is much closer to REST princeiples then django admin site
with all this "http://localhost:8000/admin/my_cms/page/4/delete/"; wich
is not REST at all. Btw, REST is kind of religion so you can follow it
or you can not. I just dont want to have large trees of url-patterns
in my urls.py and move all actions with my model in one view with a
couple of "if action == ...: elseif action ==..."

And i still can use url reversing in my templates like "{% url page
'pagename' %}?action=edit"

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