Re: Pyjamas in Django

2011-11-07 Thread Kevin
Hi,

  I've created a few small "test" projects using it with Django.
However, I felt that it makes the entire site feel more like an
application, rather than a website.  For a usability point, when a
user visits a website, they would normally expect an experience like
the last site they visited.  If your goal is to create a web
application for a internal corporate website, then it will do a fine
job.  For a end-user facing website, such as a blog, online shop, or
online forums.  It would be much easier to use the Django template
system.  If say, you plan on making a public facing chat application,
or an application that requires more of a desktop application feel,
then Pyjamas would be a nice fit.

  Basically, it comes down to what your project requirements are, and
which solution would be best suited for that project.  Keep in mind
that you can embed a Pyjamas application inside a single DIV tag.
This is great for mini apps on a larger site, such as a chat box, or
perhaps rendering a shopping cart.  Pyjamas has some really nice
widgets, which can come in handy.

  Lately, I've been using Django with JQueryUI and Dajax.  I really
like the widgets in JQueryUI, and it still allows me to use some
really nice HTML5/CSS3 styling to the website.  I found that the
default themes with Pyjamas aren't very pretty, and Pyjamas is just
gaining support for more HTML5/CSS3.  Pyjamas still uses tables, the
next version is suppose to change this.

- Kevin

On Nov 5, 11:48 am, Chandrakant Kumar  wrote:
> Hello all,
>
> Has anyone around here used Pyjamas(pyjs.org) with django.
>
> I went through the tutorial and it feels right, using a single
> language(python) for development.
>
> Is it production ready? I want to use it in my current project.

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



Re: CSRF failures for users that block all cookies. Is my planned solution stupid?

2011-11-07 Thread Kevin
Yes, this will open your site up to attack, as most bots never send
cookies.  Take a look at how the shell programs curl and wget
function, both of them never send a cookie, unless the user
specifically adds them.

These ~5% of your userbase is most likely like myself, where I block
all cookies and add specific sites to an exception list.  I do this
mainly because if I don't, my browser will have an unmanageable amount
of cookies from many sites, which I may visit just once in my entire
life time.

You can use csrf_exempt on select forms which you believe you can
secure yourself, or simply advise users to add your site to their
exempt list if they so do choose to use these forms on your website.
An idea that does normally work for contact forms, is to add a honey
pot field, a field which is hidden through a DIV tag, and if it is
filled in with anything to reject the form entirely.  Since modern
browsers know how to use "display: none;" style tag, regular users
will not see this honeypot field, but bots will always try and fill in
every form field with something before submission.

All in all, there are other options out there besides the CSRF
included with Django.  CSRF in Django is great for authenticated
users, and for sites where the user is expected to have Cookies
enabled.

Another idea is to fetch the form via AJAX and render it using
Javascript onto the page.  If you minify your javascript which does
the fetching and rendering, you can for the most part csrf_exempt the
submission view, as it will be hidden from a bots prying eyes.  You
can also do the submission using javascript and place some sort of
hash in the submission to verify the data being submitted is valid.
Dajax has an example on submitting forms via AJAX to Django.

- Kevin

On Nov 7, 3:53 am, Benjamin  Wohlwend  wrote:
> Hi,
>
> I have recently updated a fairly high-traffic website from Django 1.0 to
> 1.3. I added the csrf token to every form on the website, but nevertheless
> we regularly hear back from users that get the dreaded 403 error on form
> submits. I added some logging to the csrf error view (thanks Sentry to make
> this so easy), and what I found out is that the failing requests have no
> cookies at all. After observing this for a couple of days, it seems that
> ~5% of our users have blocked cookies completely. This amounts to dozens of
> CSRF failures a day that are not attacks, but normal users trying to submit
> a contact form or some such.
>
> After thinking about this for a while, I came up with the following idea:
> CSRF attacks make use of the session cookie to make malicious requests in
> the name of the user. But in the case of the user blocking cookies, there
> is no session cookie to abuse. So what if I modified (through inheritance)
> the behavior of the CsrfViewMiddleware in such a way that it accepts
> requests that have no cookies at all? Would that open any attack vectors?
>
> Kind regards,
> Benjamin

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



Re: Serving up CSS files in development

2011-11-07 Thread Xavier Ordoquy
Hi,

Where did you put your static files ?
I noticed that your STATICFILES_DIRS is empty which means you don't have any 
static files on the project level.
What the docs say about this:

Your project will probably also have static assets that aren’t tied to a 
particular app. The STATICFILES_DIRS setting is a tuple of filesystem 
directories to check when loading static files. It’s a search path that is by 
default empty. See the STATICFILES_DIRSdocs how to extend this list of 
additional paths.

Regards,
Xavier.

Le 8 nov. 2011 à 04:55, M. Herold a écrit :

> This is driving me insane. I've done it what feels like 6 different
> ways and for whatever reason, none of them appear to work. The worst
> part is it's something so simple: I want to link to a css file on my
> system. Why does this have to be so ridiculous before I get the
> project into production? Here are the two tutorials that seem the most
> relevant:
> 
> https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
> 
> http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates
> 
> And here's what I have:
> 
> settings.py
> STATIC_ROOT = '/Users/digitallimit/DjangoProjects/mherodev/'
> STATIC_URL = '/static/'
> ADMIN_MEDIA_PREFIX = '/static/admin'
> STATICFILES_DIRS = (
> )
> STATICFILES_FINDERS = (
>'django.contrib.staticfiles.finders.FileSystemFinder',
>'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
> 
> urls.py
> if settings.DEBUG:
>urlpatterns += patterns('',
>(r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.STATIC_ROOT}),
>)
> 
> Worst cast, I'll just embed the CSS directly, but this is silly. It
> should be the easiest thing in the world.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: bar charts

2011-11-07 Thread skysb...@gmail.com

On 2011?11?07? 21:26, Andre Terra wrote:

Pass serialized json as a template variable?
yes of course, pupulate data from django is not special, it's a normal 
process just like other language. we can output json to the chart


That's what I'm doing atm. But JKM has built an app to help reduce the 
need to write javascript [1]. I haven't used it myself, but it looks 
interesting and promising.



Cheers,
AT

[1] https://github.com/jacobian/django-googlecharts


On Mon, Nov 7, 2011 at 8:16 AM, kenneth gonsalves 
mailto:law...@thenilgiris.com>> wrote:


On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:
> Here's the Quick Start page: http://goo.gl/g5I7X

that is easy - how does one populate with data from django?
--
regards
Kenneth Gonsalves

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


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


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



Re: Serving up CSS files in development

2011-11-07 Thread Mike Dewhirst
Forgive top posting - I can't debug your code but I can show you what I 
do (an excerpt from my settings.py) to debug my own using print 
statements. I use PROJECT as the project name and PROJECT_ROOT to 
contain SRC_ROOT which contains settings.py


...

MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'htdocs/media/').replace('\\','/')
if DEBUG: print('MEDIA_ROOT = %s %s' % (MEDIA_ROOT, '(images etc)'))

MEDIA_URL = '/media/'
if DEBUG: print('MEDIA_URL  = %s (serve images)' % 
MEDIA_URL)


ADMIN_MEDIA_PREFIX = '/static/admin/'

STATICFILES_DIRS = (
os.path.join(SRC_ROOT, 'static/').replace('\\','/'),
os.path.join(SRC_ROOT, 'company/static/').replace('\\','/'),
)
if DEBUG:
i = 0
for item in STATICFILES_DIRS:
i += 1
print('STATICFILES_DIRS#%s = %s' % (i, item ))


STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

if DEBUG:
STATIC_ROOT = os.path.join(PROJECT_ROOT, 
'htdocs/static/').replace('\\','/')

print('STATIC_ROOT= %s %s' % (STATIC_ROOT, '(collectstatic)'))
else:
STATIC_ROOT = '/srv/www/%s/htdocs/static/' % PROJECT

STATIC_URL = '/static/'
if DEBUG:
print('STATIC_URL = %s (to serve css etc)' % 
STATIC_URL)


...

I must say I had difficulty figuring things out as well until I could 
see exactly what was happening


Good luck

Mike


On 8/11/2011 2:57pm, M. Herold wrote:

By the way, I'm trying to get this URI to work: 
http://mysite/static/css/style.css

On Nov 7, 9:55 pm, "M. Herold"  wrote:

This is driving me insane. I've done it what feels like 6 different
ways and for whatever reason, none of them appear to work. The worst
part is it's something so simple: I want to link to a css file on my
system. Why does this have to be so ridiculous before I get the
project into production? Here are the two tutorials that seem the most
relevant:

https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:se...

http://stackoverflow.com/questions/446026/django-how-do-you-serve-med...

And here's what I have:

settings.py
STATIC_ROOT = '/Users/digitallimit/DjangoProjects/mherodev/'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
 'django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

urls.py
if settings.DEBUG:
 urlpatterns += patterns('',
 (r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),
 )

Worst cast, I'll just embed the CSS directly, but this is silly. It
should be the easiest thing in the world.




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



Re: Serving up CSS files in development

2011-11-07 Thread M. Herold
By the way, I'm trying to get this URI to work: 
http://mysite/static/css/style.css

On Nov 7, 9:55 pm, "M. Herold"  wrote:
> This is driving me insane. I've done it what feels like 6 different
> ways and for whatever reason, none of them appear to work. The worst
> part is it's something so simple: I want to link to a css file on my
> system. Why does this have to be so ridiculous before I get the
> project into production? Here are the two tutorials that seem the most
> relevant:
>
> https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:se...
>
> http://stackoverflow.com/questions/446026/django-how-do-you-serve-med...
>
> And here's what I have:
>
> settings.py
> STATIC_ROOT = '/Users/digitallimit/DjangoProjects/mherodev/'
> STATIC_URL = '/static/'
> ADMIN_MEDIA_PREFIX = '/static/admin'
> STATICFILES_DIRS = (
> )
> STATICFILES_FINDERS = (
>     'django.contrib.staticfiles.finders.FileSystemFinder',
>     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
>
> urls.py
> if settings.DEBUG:
>     urlpatterns += patterns('',
>         (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.STATIC_ROOT}),
>     )
>
> Worst cast, I'll just embed the CSS directly, but this is silly. It
> should be the easiest thing in the world.

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



Serving up CSS files in development

2011-11-07 Thread M. Herold
This is driving me insane. I've done it what feels like 6 different
ways and for whatever reason, none of them appear to work. The worst
part is it's something so simple: I want to link to a css file on my
system. Why does this have to be so ridiculous before I get the
project into production? Here are the two tutorials that seem the most
relevant:

https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS

http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates

And here's what I have:

settings.py
STATIC_ROOT = '/Users/digitallimit/DjangoProjects/mherodev/'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

urls.py
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),
)

Worst cast, I'll just embed the CSS directly, but this is silly. It
should be the easiest thing in the world.

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



Re: Is there a standard way to implement the top level of my site?

2011-11-07 Thread M. Herold
Awesome, that was exactly what I wanted. What confuses me is that I'm
not on an old version on Django, but this is the method which works...
if I check the version number, it's 1.3.1 if my memory serves.

Thanks baxter!

On Nov 7, 5:28 pm, "bax...@gretschpages.com" 
wrote:
> On Nov 7, 4:51 pm, "M. Herold"  wrote:
>
> > That last, simple implementation is probably what I'm really looking
> > for at this point. My only problem is I'm not sure where that line of
> > code should live or where that template is expected (the template
> > directory set in my settings.py, I imagine). I tried implementing it
> > in urls.py, but it has some sort of syntax error:
>
> > urlpatterns = patterns('',
> >     (r'^polls/', include('polls.urls')),
> >     (r'^admin/', include(admin.site.urls)),
> >     (r'^$', TemplateView.as_view(template_name = '404.html'),
> > )
>
> If you're on Django prior to 1.3, you probably want the simple
> direct_to_template generic view (which does still work in 
> 1.3):https://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs...
>
> If you ARE on 1.3, make sure you're importing TemplateView before you
> try to use it.
> from django.views.generic import TemplateView
>
> Also, if you are going to do it all with template tags, watch your
> queries. I think it's easier for them to spiral out of control with
> template tags.

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



Re: How to

2011-11-07 Thread Songhun Kim
Hi.

Oh. Okay. Thanks you!!!
I'll check again setting of MySQL and AWS.
Maybe It's a problem of setting of MySQL. Because update is worked well, 
just insert has a problem.

Thanks.
Songhun

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



Re: How to

2011-11-07 Thread Russell Keith-Magee
On Tue, Nov 8, 2011 at 10:02 AM, Songhun Kim  wrote:
> Hi. every one.
> I'm a beginner in django.
> I wrote a code for insert to mysql.
> ex)
> model_for_test = ModelTest(column01=postvalue1, column02=postvalue2...)
> model_for_test.save()
> This code made a query have no quotes like "insert ... values ( aaa, bbb ...
> );".
> So a mysql returns error.
> Interested thing, It is worked well in mysql on my computer(mac), but not
> worked in mysql on AWS.
>
> BTW, I want to fix a code make a having quotes query all the time.
> Have you any idea for this?

Django *does* include the quotes on every query. However, the debug
assistance provided can be a little misleading.

If you ask a query to output its SQL, what is displayed is not exactly
equivalent to what is passed to the underlying query engine. Django
uses a standard Python database API to access the database. That
database API specifies the way that arguments are passed in to queries
(which handles the quoting automatically), but doesn't provide a way
to (easily and quickly) extract the *literal* SQL that was ultimately
executed. For debugging purposes, the query generates a quick
approximation of the SQL corresponding to a query, but that SQL isn't
100% exactly the same as that seen by the database.

If your query is working on a Mac, but not on AWS, the problem isn't
likely to be quoting -- it's more likely to be:

 1) A connection/permissions problem accessing the AWS database instance

 2) Some difference between the database installed on your Mac, and
the database installed on AWS.

In the case of (2) It isn't enough to just say "They're both MySQL" --
MySQL (and, for that matter, any other database) have *thousands* of
configuration options, all of which can affect the way that queries
are executed.

However, without any details about the errors you're seeing, we can't
provide any more help. All I can tell you is that it's almost
certainly *not* quoting that is the source of your problem.

Yours,
Russ Magee %-)

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



models.FileField versus forms.FileField

2011-11-07 Thread Eli_West
Hello,

When creating a working with the models and views to upload files what
is the difference between models.FileField and forms.FileField? Just a
practical usage explanation would be good at this point.

i can't find any comparison of the two but django directions and
examples use one or the other. I've gotten forms that use
models.FileField calls to work but the forms.FileField seems to act
up. For example this general django directions use the
form.fileField:

from django import forms

class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file  = forms.FileField()

def upload_file(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
handle_uploaded_file(request.FILES['file'])
return HttpResponseRedirect('/success/url/')
else:
form = UploadFileForm()
return render_to_response('upload.html', {'form': form})

def handle_uploaded_file(f):
destination = open('some/file/name.txt', 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()

All the chunks() calls and others seem helpful but the
models.FileField ( upload to = /somedir)   gets things done in a snap.

Any recommendations?

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



How to

2011-11-07 Thread Songhun Kim
Hi. every one.
I'm a beginner in django.

I wrote a code for insert to mysql.
ex)
model_for_test = ModelTest(column01=postvalue1, column02=postvalue2...)
model_for_test.save()

This code made a query have no quotes like "insert ... values ( aaa, bbb 
... );".
So a mysql returns error.
Interested thing, It is worked well in mysql on my computer(mac), but not 
worked in mysql on AWS.

BTW, I want to fix a code make a having quotes query all the time.
Have you any idea for this?

Thanks.
Songhun.

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



Re: bar charts

2011-11-07 Thread kenneth gonsalves
On Mon, 2011-11-07 at 11:26 -0200, Andre Terra wrote:
> Pass serialized json as a template variable?
> 
> 

got it to work. I had passed the json, but had to turn autoescape off to
get it to work.
-- 
regards
Kenneth Gonsalves

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



ZeroMQ / Mongrel2

2011-11-07 Thread Markus Gattol
Maybe sombody has given http://code.google.com/p/django-dmq and Mongrel2 a 
spin already and can report how it went? The reason I am interested is 
because it would allow me to get rid of WSGI altogether and have this stack 
(ZeroMQ being directly Mongrel2 for example):



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



Re: Disable debugging for all, but allow debug toolbar for one host

2011-11-07 Thread Gelonida N
On 11/07/2011 12:49 PM, Tom Evans wrote:
> On Sun, Nov 6, 2011 at 12:30 AM, Gelonida N  wrote:
>> Hi,
>>
>> If I understood well, then the Django debug toolbar is only working if
>> debugging is enabled.
>>
>> What I wanted to do is is to disable the explicit django error messages
>> for all but one specific IP address and to disable the django debug
>> toolbar for this one address.
>>
> 
> You've not understood well. Whether the toolbar is displayed depends
> upon a number of things, as explained in the docs:
> 
> https://github.com/django-debug-toolbar/django-debug-toolbar
> 
> See in particular INTERNAL_IPS and SHOW_TOOLBAR_CALLBACK.
> 
> Cheers
> 
> Tom
> 
Thanks Tom, Thanks for putting me straight.

In fact it seems I misread the documentation quite a bit.

I knew about INTERNAL_IPS, but misunderstood it. I thought, that the IP
must be in INTERNAL_IPs AND that DEBUG must be true.

So probably I just have some other hickup in settings.py,

I wasn't aware of SHOW_TOOLBAR_CALLBACK

I should be able to setup the debug toolbasr is I intended to
SHOW_TOOLBAR_CALLBACK should give me even finer granularity and control.

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



Re: Is there a standard way to implement the top level of my site?

2011-11-07 Thread bax...@gretschpages.com


On Nov 7, 4:51 pm, "M. Herold"  wrote:
> That last, simple implementation is probably what I'm really looking
> for at this point. My only problem is I'm not sure where that line of
> code should live or where that template is expected (the template
> directory set in my settings.py, I imagine). I tried implementing it
> in urls.py, but it has some sort of syntax error:
>
> urlpatterns = patterns('',
>     (r'^polls/', include('polls.urls')),
>     (r'^admin/', include(admin.site.urls)),
>     (r'^$', TemplateView.as_view(template_name = '404.html'),
> )
>

If you're on Django prior to 1.3, you probably want the simple
direct_to_template generic view (which does still work in 1.3):
https://docs.djangoproject.com/en/dev/ref/generic-views/?from=olddocs#django-views-generic-simple-direct-to-template

If you ARE on 1.3, make sure you're importing TemplateView before you
try to use it.
from django.views.generic import TemplateView

Also, if you are going to do it all with template tags, watch your
queries. I think it's easier for them to spiral out of control with
template tags.

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



Re: Is there a standard way to implement the top level of my site?

2011-11-07 Thread M. Herold
That last, simple implementation is probably what I'm really looking
for at this point. My only problem is I'm not sure where that line of
code should live or where that template is expected (the template
directory set in my settings.py, I imagine). I tried implementing it
in urls.py, but it has some sort of syntax error:

urlpatterns = patterns('',
(r'^polls/', include('polls.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^$', TemplateView.as_view(template_name = '404.html'),
)

With that, I'm trying to link a static style.css file for development,
but it's not working worth a damn:

if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': 'static/'}),
)

The css file exists within mysite/static/css and I'm trying to
navigate to it by http://mysite/static/css/style.css

I'll make a separate post for the second issue if it doesn't get any
attention here. Following this FAQ, by the way:
https://docs.djangoproject.com/en/1.0/howto/static-files/

On Nov 7, 1:19 pm, Kurtis Mullins  wrote:
> I'm not exactly clear on the question, but I'll share with you what I've
> done on my site.
>
> For pages like the "Home Page", I've created an application called "core".
> Then I just call my .core.views.HomePageView.as_view() from the
> "urls.py" file under my main project directory. The regular expression I
> use, which is also an example in the default urls.py, is simply u'^$' (I
> think -- I'd have to double check).
>
> Hopefully that helps a little bit, sorry if I was completely off. I do kind
> of get the feeling that you want a views.py right in your project root. I
> believe it's possible (I've seen examples of it somewhere in the docs) but
> I personally don't go that route and have never tried it.
>
> Also, if your home page is just a simple template and there's no need for a
> lot of functionality behind it, you can do this:
>
> url(u'^$', TemplateView.as_view(template_name = 'home_page.html')),
>
>
>
>
>
>
>
> On Mon, Nov 7, 2011 at 2:12 PM, M. Herold  wrote:
> > I've developed a number of apps and stuck them into my django
> > framework, but in looking to create a hub at the index of my site
> > (among other standard pages; e.g. about, network, etc.), I've sort of
> > gotten stuck. Do I really want to create another app and just redirect
> > from my index, having a sort of "index" app? Is there a clever way to
> > have a "top level" app?
>
> > Thanks in advance
> > Michael
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Haystack and date facets, anyone knows how it works?

2011-11-07 Thread Andre Lopes
Hi,

I'm trying to do a date facet with Haystack using Solr. The thing is
that I have no clue on how to use the results that I get from Haystack
and how to put this results in a Django template.

I have made a post in stackoverflow, but until now I have no clues on
how to achieve this. Can you guys give me a clue on this?

http://stackoverflow.com/questions/8041459/django-haystack-how-can-i-display-a-date-facet-in-a-template

Best Regards,

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



Re: admindocs app - almost, but not, working

2011-11-07 Thread Kurtis Mullins
Hmm, I just tried it and it seems to work fine for me. I'm not sure on the
directions -- as I just uncommented the stuff in my code and installed
docutils. Maybe the dev docs are not in sync with the version of django you
are running?

On Mon, Nov 7, 2011 at 5:31 PM, Brett Epps  wrote:

> If this is a bug in Django, you should file a Trac ticket for it here:
>
> https://code.djangoproject.com/newticket
>
> Brett
>
>
> On 11/7/11 3:40 PM, "lorin"  wrote:
>
> >In case anybody else cares, there seems to be a mismatch between the
> >template and the urls for the admindocs module. I solved this problem
> >by editing the file django/contrib/admindocs/templates/admin_doc/
> >index.html
> >and changing each of the links. Models should go to docmodels, Views
> >to docviews, etc.
> >
> >Hope this helps somebody else.
> >
> >On Nov 4, 3:45 pm, lorin  wrote:
> >> I followed the instructions to activate the admindocs (https://
> >> docs.djangoproject.com/en/dev/ref/contrib/admin/admindocs/#overview)
> >> and now I see a link Documentation, next to Welcome, myname in the
> >> admin, and that goes to a nice page at admin/doc. But none of the
> >> hyperlinks go to working pages (Tags, Filters, Models, Views,
> >> Bookmarklets). E.g. Models goes to admin/models/ and results in a Page
> >> not found (404) with a very short message "The requested admin page
> >> does not exist."
> >>
> >> Using the development server.
> >>
> >> Any ideas?
> >
> >--
> >You received this message because you are subscribed to the Google Groups
> >"Django users" group.
> >To post to this group, send email to django-users@googlegroups.com.
> >To unsubscribe from this group, send email to
> >django-users+unsubscr...@googlegroups.com.
> >For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: admindocs app - almost, but not, working

2011-11-07 Thread Brett Epps
If this is a bug in Django, you should file a Trac ticket for it here:

https://code.djangoproject.com/newticket

Brett


On 11/7/11 3:40 PM, "lorin"  wrote:

>In case anybody else cares, there seems to be a mismatch between the
>template and the urls for the admindocs module. I solved this problem
>by editing the file django/contrib/admindocs/templates/admin_doc/
>index.html
>and changing each of the links. Models should go to docmodels, Views
>to docviews, etc.
>
>Hope this helps somebody else.
>
>On Nov 4, 3:45 pm, lorin  wrote:
>> I followed the instructions to activate the admindocs (https://
>> docs.djangoproject.com/en/dev/ref/contrib/admin/admindocs/#overview)
>> and now I see a link Documentation, next to Welcome, myname in the
>> admin, and that goes to a nice page at admin/doc. But none of the
>> hyperlinks go to working pages (Tags, Filters, Models, Views,
>> Bookmarklets). E.g. Models goes to admin/models/ and results in a Page
>> not found (404) with a very short message "The requested admin page
>> does not exist."
>>
>> Using the development server.
>>
>> Any ideas?
>
>-- 
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To post to this group, send email to django-users@googlegroups.com.
>To unsubscribe from this group, send email to
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

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



Re: firstof as

2011-11-07 Thread Brett Epps
Instead of adding a template tag, you could handle this in the class for
obj.  Just have get_votes() cache its result and use the cached value
after the first time get_votes() is called.  In the template, always call
get_votes().

Brett


On 11/7/11 4:12 PM, "Nikolas Stevenson-Molnar" 
wrote:

>Ah, ok; I see what you want to do. I'm not aware of any way to do this,
>other than as you mentioned a custom template tag.
>
>On 11/7/2011 2:04 PM, bax...@gretschpages.com wrote:
>>
>> On Nov 7, 3:50 pm, Nikolas Stevenson-Molnar 
>> wrote:
>>> Assuming obj is iterable, you can do: {% with
>>> obj.0.thingobj.get_something as thing %}
>>>
>>> ...is that what you mean?
>> Not exactly, no. In my particular case, it's more of a check to see if
>> it's available, and if not, do a bit more work to get something that
>> will fill the current need. Or, in other words, maybe I'm storing it
>> locally, or maybe I'm not.
>>
>> Another example:
>>
>> {% with firstof obj.votes obj.get_votes as votes %}
>> Which would then let me do something with votes: "There have been
>> {{ votes }} vote{{ votes|pluralize }}.
>>
>
>-- 
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To post to this group, send email to django-users@googlegroups.com.
>To unsubscribe from this group, send email to
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

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



Re: firstof as

2011-11-07 Thread Nikolas Stevenson-Molnar
Ah, ok; I see what you want to do. I'm not aware of any way to do this,
other than as you mentioned a custom template tag.

On 11/7/2011 2:04 PM, bax...@gretschpages.com wrote:
>
> On Nov 7, 3:50 pm, Nikolas Stevenson-Molnar 
> wrote:
>> Assuming obj is iterable, you can do: {% with
>> obj.0.thingobj.get_something as thing %}
>>
>> ...is that what you mean?
> Not exactly, no. In my particular case, it's more of a check to see if
> it's available, and if not, do a bit more work to get something that
> will fill the current need. Or, in other words, maybe I'm storing it
> locally, or maybe I'm not.
>
> Another example:
>
> {% with firstof obj.votes obj.get_votes as votes %}
> Which would then let me do something with votes: "There have been
> {{ votes }} vote{{ votes|pluralize }}.
>

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



Re: firstof as

2011-11-07 Thread bax...@gretschpages.com


On Nov 7, 3:50 pm, Nikolas Stevenson-Molnar 
wrote:
> Assuming obj is iterable, you can do: {% with
> obj.0.thingobj.get_something as thing %}
>
> ...is that what you mean?

Not exactly, no. In my particular case, it's more of a check to see if
it's available, and if not, do a bit more work to get something that
will fill the current need. Or, in other words, maybe I'm storing it
locally, or maybe I'm not.

Another example:

{% with firstof obj.votes obj.get_votes as votes %}
Which would then let me do something with votes: "There have been
{{ votes }} vote{{ votes|pluralize }}.

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



Re: firstof as

2011-11-07 Thread Nikolas Stevenson-Molnar
Assuming obj is iterable, you can do: {% with
obj.0.thingobj.get_something as thing %}

...is that what you mean?

_Nik

On 11/7/2011 11:57 AM, bax...@gretschpages.com wrote:
> What I'm after is something like {% with firstof obj.thing
> obj.get_something as thing %}
>
> Is there any way to do this short of writing my own template tag and
> figuring out which exists first? Seems like it would be a fairly
> common need.
>

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



Re: admindocs app - almost, but not, working

2011-11-07 Thread lorin
In case anybody else cares, there seems to be a mismatch between the
template and the urls for the admindocs module. I solved this problem
by editing the file django/contrib/admindocs/templates/admin_doc/
index.html
and changing each of the links. Models should go to docmodels, Views
to docviews, etc.

Hope this helps somebody else.

On Nov 4, 3:45 pm, lorin  wrote:
> I followed the instructions to activate the admindocs (https://
> docs.djangoproject.com/en/dev/ref/contrib/admin/admindocs/#overview)
> and now I see a link Documentation, next to Welcome, myname in the
> admin, and that goes to a nice page at admin/doc. But none of the
> hyperlinks go to working pages (Tags, Filters, Models, Views,
> Bookmarklets). E.g. Models goes to admin/models/ and results in a Page
> not found (404) with a very short message "The requested admin page
> does not exist."
>
> Using the development server.
>
> Any ideas?

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



Postgres paginator fixing slow count(*)

2011-11-07 Thread Alec
I've seen many posts about how slow PostgreSQL is when doing count(*)
and how this gets called in the admin all the time, so I thought I'd
share a simple paginator class override to use the RELTUPLES statistic
when the query is not filtered.  This should speed up the loading of
the default admin page for a large table!

http://djangosnippets.org/snippets/2593/

Alec

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



Re: bar charts

2011-11-07 Thread bax...@gretschpages.com
Most times I just use css and percentwidth for simple bar charts.

On Nov 7, 10:23 am, Leotis buchanan 
wrote:
> You could also try processing.js
>
>

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



Re: Is there a standard way to implement the top level of my site?

2011-11-07 Thread bax...@gretschpages.com
I've had per-project views (in the project root), I've had apps
feeding indexes, and I've gone direct to template using template tags
to fill in snippets needed. Most times -- but not always -- the last
approach seems the most flexible and easiest.


On Nov 7, 1:19 pm, Kurtis Mullins  wrote:
> I'm not exactly clear on the question, but I'll share with you what I've
> done on my site.
>
> For pages like the "Home Page", I've created an application called "core".
> Then I just call my .core.views.HomePageView.as_view() from the
> "urls.py" file under my main project directory. The regular expression I
> use, which is also an example in the default urls.py, is simply u'^$' (I
> think -- I'd have to double check).
>
> Hopefully that helps a little bit, sorry if I was completely off. I do kind
> of get the feeling that you want a views.py right in your project root. I
> believe it's possible (I've seen examples of it somewhere in the docs) but
> I personally don't go that route and have never tried it.
>
> Also, if your home page is just a simple template and there's no need for a
> lot of functionality behind it, you can do this:
>
> url(u'^$', TemplateView.as_view(template_name = 'home_page.html')),
>
>
>
>
>
>
>
> On Mon, Nov 7, 2011 at 2:12 PM, M. Herold  wrote:
> > I've developed a number of apps and stuck them into my django
> > framework, but in looking to create a hub at the index of my site
> > (among other standard pages; e.g. about, network, etc.), I've sort of
> > gotten stuck. Do I really want to create another app and just redirect
> > from my index, having a sort of "index" app? Is there a clever way to
> > have a "top level" app?
>
> > Thanks in advance
> > Michael
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



firstof as

2011-11-07 Thread bax...@gretschpages.com
What I'm after is something like {% with firstof obj.thing
obj.get_something as thing %}

Is there any way to do this short of writing my own template tag and
figuring out which exists first? Seems like it would be a fairly
common need.

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



Re: Pyjamas in Django

2011-11-07 Thread Juergen Schackmann
hi,
i have played around with it, and it seemed ok for me. 
but actually never put anything into production, since my project did not 
move forward.
regards

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



Re: Is there a standard way to implement the top level of my site?

2011-11-07 Thread Kurtis Mullins
I'm not exactly clear on the question, but I'll share with you what I've
done on my site.

For pages like the "Home Page", I've created an application called "core".
Then I just call my .core.views.HomePageView.as_view() from the
"urls.py" file under my main project directory. The regular expression I
use, which is also an example in the default urls.py, is simply u'^$' (I
think -- I'd have to double check).

Hopefully that helps a little bit, sorry if I was completely off. I do kind
of get the feeling that you want a views.py right in your project root. I
believe it's possible (I've seen examples of it somewhere in the docs) but
I personally don't go that route and have never tried it.

Also, if your home page is just a simple template and there's no need for a
lot of functionality behind it, you can do this:

url(u'^$', TemplateView.as_view(template_name = 'home_page.html')),


On Mon, Nov 7, 2011 at 2:12 PM, M. Herold  wrote:

> I've developed a number of apps and stuck them into my django
> framework, but in looking to create a hub at the index of my site
> (among other standard pages; e.g. about, network, etc.), I've sort of
> gotten stuck. Do I really want to create another app and just redirect
> from my index, having a sort of "index" app? Is there a clever way to
> have a "top level" app?
>
> Thanks in advance
> Michael
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Is there a standard way to implement the top level of my site?

2011-11-07 Thread M. Herold
I've developed a number of apps and stuck them into my django
framework, but in looking to create a hub at the index of my site
(among other standard pages; e.g. about, network, etc.), I've sort of
gotten stuck. Do I really want to create another app and just redirect
from my index, having a sort of "index" app? Is there a clever way to
have a "top level" app?

Thanks in advance
Michael

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



Re: FAQ app 2011

2011-11-07 Thread Mike
Thanks for your help.  My requirements are simple, but I'd like
something well done without headaches.  I'll try the fack fork.  ;)

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



Re: render_to_response pointing to multiple templates

2011-11-07 Thread Joey Espinosa
Jay,

How are you making the choice for a template? User interaction, specific
runtime circumstance, random, etc?
--
Joey "JoeLinux" Espinosa*
*





On Mon, Nov 7, 2011 at 12:04 PM, Tom Evans  wrote:

> On Mon, Nov 7, 2011 at 3:59 PM, jay K. 
> wrote:
> > hi, Tom
> >
> > thanks for the reply
> >
> > what I actually want to do is to
> > list several templates in the render_to_response
> > function and be able to choose which one to use
> >
> > can I choose which template to use?
> >
> > thanks again, and let me know if my question is clear enough
> >
>
> Of course you can; use logic in your view to decide which template to
> render, and call render_to_response with that template name… I must be
> missing something?
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Multiple sessions per user?

2011-11-07 Thread Nan

OK, right now I'm looking at replacing SessionMiddleware with a
subclass that will take a dict with multiple session cookie names and
timeout values, and set both the traditional request.session from the
default values from settings (so as not to mess up third-party apps
that depend on it) and a custom request.sessions list with all
sessions.

Does anyone see any major pitfalls to this approach?

Thanks,
-Nan



On Nov 4, 2:32 pm, Nan  wrote:
> OK, the subject doesn't *quite* describe what I need to do, but
> almost.  Basically, I'd like to have
>
> 1) one "session" that expires after logout or browser close, and
> applies to logged-in sessions (like the default Django session
> framework using the "SESSION_EXPIRE_AT_BROWSER_CLOSE" setting)
>
> 2) one "session" that's persistent indefinitely and applies to both
> anonymous and logged-in users.
>
> The data in (2) could probably be stored directly in a cookie, but
> it's pretty handy how the session framework protects one from users
> editing cookies, abstracts away database storage, etc. -- and I'd
> rather not have to duplicate this functionality.
>
> Any suggestions?

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



Re: render_to_response pointing to multiple templates

2011-11-07 Thread Tom Evans
On Mon, Nov 7, 2011 at 3:59 PM, jay K.  wrote:
> hi, Tom
>
> thanks for the reply
>
> what I actually want to do is to
> list several templates in the render_to_response
> function and be able to choose which one to use
>
> can I choose which template to use?
>
> thanks again, and let me know if my question is clear enough
>

Of course you can; use logic in your view to decide which template to
render, and call render_to_response with that template name… I must be
missing something?

Cheers

Tom

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



Re: Relation not found error while dealing with foreign keys and forms

2011-11-07 Thread Furbee
I guess the form object is not holding the nics_group object, in this case,
you could send the group information (all groups in one array or other
object, and the selected group in another variable) back to the template as
a separate object. However, the suggested paradigm is using Database
Routers. With the database routers, you can force the instances of the
NICSGroupType and Staff to use the gold database. More details here:
https://docs.djangoproject.com/en/1.3/topics/db/multi-db/#automatic-database-routing.
I submitted a bug ticket over the weekend (
https://code.djangoproject.com/ticket/17167), but it was closed by a
contributor who seemed to misunderstand the situation. The issue is
somewhere in the ModelForm class, since everything works UNTIL you use the
staff object as an instance to the ModelForm StaffForm object. The
ModelForm class is looking to the default database for referential objects.
There are not arguments I can find to forcefully tell ModelForm to use a
non-default database. So, it may be that Database Routers are the only way
you can get ModelForm to look for NICSGroupType in the database 'gold.'

Furbee

On Sun, Nov 6, 2011 at 3:04 PM, Tabitha Samuel wrote:

> Hey thanks a bunch for the workaround. Maybe I am doing something
> wrong, but this is what I'm getting when I implement it and it really
> seems weird..
>
> in my view I have:
>staff_person =
> Staff.objects.using('gold').get(username=current_staff)
>form = StaffForm(instance = staff_person)
>group
>
> =NICSGroupType.objects.using('gold').get(n_group_number=staff_person.nics_group.n_group_number)
>form.nics_group = group
>print form.nics_group
>print form
>
> The first print gives me "3" which is correct. The print form on the
> other hand gives me the same:
> Exception Type: DatabaseError at /staff/staffinfo
> Exception Value: relation "n_nics_groups" does not exist
>
> If I comment out that print and render the template, I get pretty much
> the same error:
> Exception Type: TemplateSyntaxError at /staff/staffinfo
> Exception Value: Caught DatabaseError while rendering: relation
> "n_nics_groups" does not exist
> and the problem line in the template is: NICS Group:  td>{{form.nics_group}}
>
> So the question is how can it print the group number when I do a print
> form.group_number but exception out when I do a print form?
>
> Tabitha
>
> On Nov 5, 11:26 am, Furbee  wrote:
> > As a workaround to this bug, you could get the group separately, and
> attach
> > all of the group fields to the staff form manually until a fix is
> > implemented. Something like (hasn't been tested, you may need to assign
> > each NICSGroupType field to a form field):
> >
> > staff = Staff.objects.using('gold').get(username=current_staff)
> > form = StaffForm(instance = staff)
> > group =
> >
> NICSGroupType.objects.using('gold').get(n_group_number=staff.nics_group.n_group_number)
> >
> > form.nics_group = group # this may attach all fields, but most likely
> > you'll have to attach them manually, since they would just be a goup, not
> > FormFields.
> >
> > Hopefully that will get you through this jam, until a fix is created. I
> > haven't written any patches before, but I will see if I can figure it
> out,
> > time permitting.
> >
> > Thanks,
> >
> > Furbee
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Nov 4, 2011 at 3:36 PM, Furbee  wrote:
> > > No worries. Wow, I've got some interesting results. I am pretty sure
> the
> > > ModelForm class has a bug in it that it is not looking at the secondary
> > > database with the using() method. It is a bug in the foreign reference
> > > fields only, though.
> >
> > > I set up tables in my default database, and in an extra database named
> > > staff, which is set up in settings.py.
> >
> > > In default DB:
> > > n_test_staff
> > > username;nics_group
> > > "tsamuel";1
> >
> > > n_nics_groups
> > > n_group_number;n_group_name
> > > 1;"Group1"
> > > 2;"Group2"
> >
> > > In staff DB:
> > > n_test_staff
> > > username;nics_group
> > > "tsamuel";2 (Notice tsamuel in group 2 in this DB)
> >
> > > n_nics_groups
> > > n_group_number;n_group_name
> > > 1;"Staff1"
> > > 2;"Staff2"
> >
> > > In the models, wrote __unicode__(self): method to show the groups.
> >
> > > Here's something strange:
> > > >>> from models import Staff, NICSGroupType
> > > >>> from django.forms import ModelForm
> > > >>> class StaffForm(ModelForm):
> > > ... class Meta:
> > > ... model = Staff
> > > ...
> > > >>> staff = Staff.objects.using('staff').get(username='tsamuel')
> > > >>> print staff
> > > tsamuel 
> > > >>> form = StaffForm(instance=staff)
> > > >>> print form
> > > Username: > > id="id_username" type="text" name="username" value="tsamuel"
> maxlength="50"
> > > />
> > > Nics group: > > name="nics_group" id="id_nics_group">
> > > -
> > > 2: Group2
> > > 1: Group1
> > > 
> >
> > > Notice this ModelForm is getting the Staff data from the 'staff'
> database,
> > > but is getting the reference n_nics

Re: bar charts

2011-11-07 Thread Leotis buchanan
You could also try processing.js


Regards
Leotis Buchanan
Co-Founder
Exterbox




On Mon, Nov 7, 2011 at 9:22 AM, Yok Keen Hui  wrote:

> You could try out cairoplot, it works for me in Django, just have to print
> the render as a picture to a url and reference it from there(looks nice
> too!)
>
>
> On Tue, Nov 8, 2011 at 12:26 AM, Andre Terra  wrote:
>
>> Pass serialized json as a template variable?
>>
>> That's what I'm doing atm. But JKM has built an app to help reduce the
>> need to write javascript [1]. I haven't used it myself, but it looks
>> interesting and promising.
>>
>>
>> Cheers,
>> AT
>>
>> [1] https://github.com/jacobian/django-googlecharts
>>
>>
>>
>> On Mon, Nov 7, 2011 at 8:16 AM, kenneth gonsalves > > wrote:
>>
>>> On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:
>>> > Here's the Quick Start page: http://goo.gl/g5I7X
>>>
>>> that is easy - how does one populate with data from django?
>>> --
>>> regards
>>> Kenneth Gonsalves
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Project general design question - "From scratch" or use of admin interface

2011-11-07 Thread Andre Terra
django-registration [1], quite possibly with a custom backend.


Cheers,
AT

[1] https://github.com/nathanborror/django-registration

On Mon, Nov 7, 2011 at 11:50 AM, youpsla  wrote:

> Ok,
> thanks for the answer,then I'll start this way.
>
> Just another question. I'll use a registration package I think for
> Shops owners, do you know wich one could be the best for jsut a simple
> registration workflow ?
>
>
> Agian, thnaks for your time
>
> Regards
>
> Alain
>
> On 7 nov, 13:32, Russell Keith-Magee  wrote:
> > On Mon, Nov 7, 2011 at 8:06 PM, youpsla  wrote:
> > > Hi,
> > > before getting more in depth in writing my project I ask you a general
> > > design question. My Django knowledge is not BIG enough for me to be
> > > able to have a clear answer (with for and cons) on my question.
> >
> > > Here are the main guidelines of my project :
> > > - I've two kind of users : Shop owners and consumers (I've already don
> > > the part for consumers wich is quite simple)
> > > - Shop owners have to register (Simple workflow : Email send with a
> > > link for confirmation and activation)
> > > - I like shops owners to be able to:
> > >- Create one ore more shops with some informations (Adress, openg/
> > > closing time etc )
> > >- For each shop, they can add events
> > >- Of course each shops owner can only access to shops and events
> > > he has created himself
> >
> > > My question, is:
> > > Do you thing it's better to use and customize the admin interface or
> > > it's better to write all "from scratch".
> >
> > Generally speaking, you're going to want to do it "from scratch".
> >
> > The admin interface isn't intended to be a framework for building your
> > site. It's exactly what it says on the box -- an administration
> > interface. It presents a very low-level view of your database, which
> > is handy for tweaking data at a low level, but it isn't really suited
> > to public facing sites.
> >
> > If you have requirements that involve customized workflows, or you're
> > expecting to customize views or structure, you're going to be better
> > served by building the site from scratch.
> >
> > That said, Django doesn't leave you completely to your own devices.
> > Most websites have, at their core, lots of fairly common functionality
> > -- show me a list of all available X objects; show me the details for
> > widget 3; allow me to edit the details for widget 3, and so on.
> >
> > This is where Django's generic views come in. The generic views are
> > pre-canned views for displaying and editing objects in common ways. If
> > you're looking to bang out a proof of concept, you'd be much better
> > suited to spending your time working out how to use generic views,
> > rather than trying to work out how to bend the admin to your will.
> >
> > Yours,
> > Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: render_to_response pointing to multiple templates

2011-11-07 Thread jay K.
hi, Tom

thanks for the reply

what I actually want to do is to
list several templates in the render_to_response
function and be able to choose which one to use

can I choose which template to use?

thanks again, and let me know if my question is clear enough

On Mon, Nov 7, 2011 at 12:18 PM, Tom Evans  wrote:

> On Mon, Nov 7, 2011 at 3:09 PM, jay K. 
> wrote:
> >
> > Hello
> >
> > I have a view with the following render_to_template function
> >
> > ...
> >
> > return render_to_response( 'template/template.html', {var'': var},
> > context_instance=RequestContext(request))
> > ...
> >
> > I want the render_to_response to point to more than 1 template. So far
> > I've tried adding a dictionary of templates but it gives me an error,
> > maybe I'm
> > not doing it properly
> >
> > If anyone can teach me how to do it I'd really appreciate it
> >
> > thanks
> >
>
> What do you want to happen with your list of templates? Do you want to
> find the first one that exists and render that one? If so, you can
> pass an iterable to render_to_response instead of a single template
> name, and it will render the first available one, see the docs:
>
> https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#id1
>
> Otherwise, you will have to explain what you are trying to do, as it
> is non-obvious.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: "Key 'Content-Type' not found in Form"

2011-11-07 Thread bentzy
Thanks Tom,
Solved.
The issue was not at view code, but at urls.py
The urlpattern pointed to the model instead to the view.
That's learning django the hard way...

Cheers

--bentzy


On Nov 7, 2:53 pm, Tom Evans  wrote:
> On Mon, Nov 7, 2011 at 11:07 AM, bentzy  wrote:
> > Hello,
>
> > I have a page displaying a list of "Data" objects and I placed at the
> > same page a "submit" button opening a form that updates the "Data"
> > table at DB. Pretty simple.
>
> > class Thing(models.Model):
> >    thing_id = models.BigIntegerField(primary_key=True)
> >    etc...
>
> > class Data(models.Model):
> >    data_id = models.AutoField(primary_key=True)
> >    thing = models.ForeignKey(Thing)
> >    key = models.CharField(max_length=200, blank=False)
> >    value = models.CharField(max_length=200, blank=False)
> >    def __unicode__(self):
> >        return unicode(self.thing)
>
> > I've created then a form:
>
> > class DataForm(ModelForm):
> >    class Meta:
> >        model = Data
>
> > At my template I've added:
>
> > {% csrf_token %}
> > {{ form.as_p }}
> > 
> > 
>
> > The issue,
> > I get the following after clicking "Submit":
>
> > Traceback (most recent call last):
> >  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
> > line 280, in run
> >    self.result = application(self.environ, self.start_response)
> >  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
> > line 674, in __call__
> >    return self.application(environ, start_response)
> >  File "/usr/lib/pymodules/python2.7/django/core/handlers/wsgi.py",
> > line 252, in __call__
> >    response = middleware_method(request, response)
> >  File "/usr/lib/pymodules/python2.7/django/middleware/csrf.py", line
> > 221, in process_response
> >    if response['Content-Type'].split(';')[0] in _HTML_TYPES:
> >  File "/usr/lib/pymodules/python2.7/django/forms/forms.py", line 106,
> > in __getitem__
> >    raise KeyError('Key %r not found in Form' % name)
> > KeyError: "Key 'Content-Type' not found in Form"
>
> > I've already added at settings.py:
> >    'django.middleware.csrf.CsrfViewMiddleware',
> >    'django.middleware.csrf.CsrfResponseMiddleware',
>
> > p.s.
> > I've also tried to change my models using use the contenttypes
> > framework - but it didn't help. I got the same error.
>
> > Any help will be really appreciated!
>
> > Thanks in advance.
>
> The only bit of code you've not shown is the bit that is actually
> relevant - your view code. What looks like is happening is that you
> are returning a Form object from your view, rather than a
> HttpResponse.
>
> Cheers
>
> Tom

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



Re: FAQ app 2011

2011-11-07 Thread Peter Herndon
Hi Mike,

revsys/django-fack is a reasonably recent fork of howiworkdaily/django-faq, 
with some subsequent divergence between the two code bases on both sides. Both 
projects' primary developers are well-respected members of the Django 
community. In fact, the primary developer of revsys/django-fack is Jacob 
Kaplan-Moss, co-BDFL of Django itself. At the same time, he respected Kevin 
Fricovsky's work enough to both submit fixes *and* then fork it, rather than 
write from scratch.

I have used Kevin's app in a site, and it does what it says on the tin. I'm 
guessing about this, but since Jacob released django-fack under his company's 
github account (RevSys), chances are the cleanup work was done for a client, 
which means that django-fack is very likely in production somewhere.  Either 
fork will serve well enough, though you don't mention any specific requirements 
that could be addressed. Were I to need an app for FAQs in a new project, I'd 
probably use django-fack at this point, as the code base is a little cleaner.

Hope that helps,

---Peter Herndon
On Nov 5, 2011, at 12:37 PM, Mike wrote:

> I've been searching for a FAQ app for Django and found several but no
> commentary as to which is best and still maintained, etc.
> 
> This group looks to have mentioned the subject last in 2006 and refers
> to this:
> 
> http://simon.net.nz/articles/simple-faq-application-for-django/&usg=AFQjCNFwcCQGBUOKI_lMzqUc3gVR56Oesg
> 
> In my googling I've found these:
> 
> https://github.com/revsys/django-fack
> https://github.com/howiworkdaily/django-faq
> https://github.com/benspaulding/django-faq
> http://code.google.com/p/django-generic-faq/
> 
> Can anyone provide some recommendations?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: render_to_response pointing to multiple templates

2011-11-07 Thread Tom Evans
On Mon, Nov 7, 2011 at 3:09 PM, jay K.  wrote:
>
> Hello
>
> I have a view with the following render_to_template function
>
> ...
>
> return render_to_response( 'template/template.html', {var'': var},
> context_instance=RequestContext(request))
> ...
>
> I want the render_to_response to point to more than 1 template. So far
> I've tried adding a dictionary of templates but it gives me an error,
> maybe I'm
> not doing it properly
>
> If anyone can teach me how to do it I'd really appreciate it
>
> thanks
>

What do you want to happen with your list of templates? Do you want to
find the first one that exists and render that one? If so, you can
pass an iterable to render_to_response instead of a single template
name, and it will render the first available one, see the docs:

https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#id1

Otherwise, you will have to explain what you are trying to do, as it
is non-obvious.

Cheers

Tom

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



Re: bar charts

2011-11-07 Thread Brad Montgomery
+1 for Google Charts.


For small stuff (1 chart), I just render JavaScript in the  of my 
html templates. For more complex stuff, you could write a view that *just* 
renders JavaScript and include it via a script tag. Just make sure to serve 
it with MIME type "application/javascript"


Here's more info on generating Non-HTML content:
http://djangobook.com/en/2.0/chapter13/

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



render_to_response pointing to multiple templates

2011-11-07 Thread jay K.

Hello

I have a view with the following render_to_template function

...

return render_to_response( 'template/template.html', {var'': var},
context_instance=RequestContext(request))
...

I want the render_to_response to point to more than 1 template. So far
I've tried adding a dictionary of templates but it gives me an error,
maybe I'm
not doing it properly

If anyone can teach me how to do it I'd really appreciate it

thanks

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



one view for multiple templates

2011-11-07 Thread jay K.

Hello,

I have a page with a form on it

the form is handled by a view

I want to create another page and embed the same form on it

how can I use the same view on another template?
do I have to modify the 'render_to_response' so it points to the other
template (besides the current template)?

thanks

jay k

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



Re: bar charts

2011-11-07 Thread Yok Keen Hui
You could try out cairoplot, it works for me in Django, just have to print
the render as a picture to a url and reference it from there(looks nice
too!)

On Tue, Nov 8, 2011 at 12:26 AM, Andre Terra  wrote:

> Pass serialized json as a template variable?
>
> That's what I'm doing atm. But JKM has built an app to help reduce the
> need to write javascript [1]. I haven't used it myself, but it looks
> interesting and promising.
>
>
> Cheers,
> AT
>
> [1] https://github.com/jacobian/django-googlecharts
>
>
>
> On Mon, Nov 7, 2011 at 8:16 AM, kenneth gonsalves 
> wrote:
>
>> On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:
>> > Here's the Quick Start page: http://goo.gl/g5I7X
>>
>> that is easy - how does one populate with data from django?
>> --
>> regards
>> Kenneth Gonsalves
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Project general design question - "From scratch" or use of admin interface

2011-11-07 Thread youpsla
Ok,
thanks for the answer,then I'll start this way.

Just another question. I'll use a registration package I think for
Shops owners, do you know wich one could be the best for jsut a simple
registration workflow ?


Agian, thnaks for your time

Regards

Alain

On 7 nov, 13:32, Russell Keith-Magee  wrote:
> On Mon, Nov 7, 2011 at 8:06 PM, youpsla  wrote:
> > Hi,
> > before getting more in depth in writing my project I ask you a general
> > design question. My Django knowledge is not BIG enough for me to be
> > able to have a clear answer (with for and cons) on my question.
>
> > Here are the main guidelines of my project :
> > - I've two kind of users : Shop owners and consumers (I've already don
> > the part for consumers wich is quite simple)
> > - Shop owners have to register (Simple workflow : Email send with a
> > link for confirmation and activation)
> > - I like shops owners to be able to:
> >    - Create one ore more shops with some informations (Adress, openg/
> > closing time etc )
> >    - For each shop, they can add events
> >    - Of course each shops owner can only access to shops and events
> > he has created himself
>
> > My question, is:
> > Do you thing it's better to use and customize the admin interface or
> > it's better to write all "from scratch".
>
> Generally speaking, you're going to want to do it "from scratch".
>
> The admin interface isn't intended to be a framework for building your
> site. It's exactly what it says on the box -- an administration
> interface. It presents a very low-level view of your database, which
> is handy for tweaking data at a low level, but it isn't really suited
> to public facing sites.
>
> If you have requirements that involve customized workflows, or you're
> expecting to customize views or structure, you're going to be better
> served by building the site from scratch.
>
> That said, Django doesn't leave you completely to your own devices.
> Most websites have, at their core, lots of fairly common functionality
> -- show me a list of all available X objects; show me the details for
> widget 3; allow me to edit the details for widget 3, and so on.
>
> This is where Django's generic views come in. The generic views are
> pre-canned views for displaying and editing objects in common ways. If
> you're looking to bang out a proof of concept, you'd be much better
> suited to spending your time working out how to use generic views,
> rather than trying to work out how to bend the admin to your will.
>
> Yours,
> Russ Magee %-)

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



Re: bar charts

2011-11-07 Thread Andre Terra
Pass serialized json as a template variable?

That's what I'm doing atm. But JKM has built an app to help reduce the need
to write javascript [1]. I haven't used it myself, but it looks interesting
and promising.


Cheers,
AT

[1] https://github.com/jacobian/django-googlecharts


On Mon, Nov 7, 2011 at 8:16 AM, kenneth gonsalves wrote:

> On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:
> > Here's the Quick Start page: http://goo.gl/g5I7X
>
> that is easy - how does one populate with data from django?
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: "Key 'Content-Type' not found in Form"

2011-11-07 Thread Tom Evans
On Mon, Nov 7, 2011 at 11:07 AM, bentzy  wrote:
> Hello,
>
> I have a page displaying a list of "Data" objects and I placed at the
> same page a "submit" button opening a form that updates the "Data"
> table at DB. Pretty simple.
>
> class Thing(models.Model):
>    thing_id = models.BigIntegerField(primary_key=True)
>    etc...
>
> class Data(models.Model):
>    data_id = models.AutoField(primary_key=True)
>    thing = models.ForeignKey(Thing)
>    key = models.CharField(max_length=200, blank=False)
>    value = models.CharField(max_length=200, blank=False)
>    def __unicode__(self):
>        return unicode(self.thing)
>
> I've created then a form:
>
> class DataForm(ModelForm):
>    class Meta:
>        model = Data
>
>
> At my template I've added:
>
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
>
> The issue,
> I get the following after clicking "Submit":
>
> Traceback (most recent call last):
>  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
> line 280, in run
>    self.result = application(self.environ, self.start_response)
>  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
> line 674, in __call__
>    return self.application(environ, start_response)
>  File "/usr/lib/pymodules/python2.7/django/core/handlers/wsgi.py",
> line 252, in __call__
>    response = middleware_method(request, response)
>  File "/usr/lib/pymodules/python2.7/django/middleware/csrf.py", line
> 221, in process_response
>    if response['Content-Type'].split(';')[0] in _HTML_TYPES:
>  File "/usr/lib/pymodules/python2.7/django/forms/forms.py", line 106,
> in __getitem__
>    raise KeyError('Key %r not found in Form' % name)
> KeyError: "Key 'Content-Type' not found in Form"
>
>
> I've already added at settings.py:
>    'django.middleware.csrf.CsrfViewMiddleware',
>    'django.middleware.csrf.CsrfResponseMiddleware',
>
> p.s.
> I've also tried to change my models using use the contenttypes
> framework - but it didn't help. I got the same error.
>
> Any help will be really appreciated!
>
> Thanks in advance.
>
>

The only bit of code you've not shown is the bit that is actually
relevant - your view code. What looks like is happening is that you
are returning a Form object from your view, rather than a
HttpResponse.

Cheers

Tom

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



Re: Project general design question - "From scratch" or use of admin interface

2011-11-07 Thread Russell Keith-Magee
On Mon, Nov 7, 2011 at 8:06 PM, youpsla  wrote:
> Hi,
> before getting more in depth in writing my project I ask you a general
> design question. My Django knowledge is not BIG enough for me to be
> able to have a clear answer (with for and cons) on my question.
>
> Here are the main guidelines of my project :
> - I've two kind of users : Shop owners and consumers (I've already don
> the part for consumers wich is quite simple)
> - Shop owners have to register (Simple workflow : Email send with a
> link for confirmation and activation)
> - I like shops owners to be able to:
>    - Create one ore more shops with some informations (Adress, openg/
> closing time etc )
>    - For each shop, they can add events
>    - Of course each shops owner can only access to shops and events
> he has created himself
>
> My question, is:
> Do you thing it's better to use and customize the admin interface or
> it's better to write all "from scratch".

Generally speaking, you're going to want to do it "from scratch".

The admin interface isn't intended to be a framework for building your
site. It's exactly what it says on the box -- an administration
interface. It presents a very low-level view of your database, which
is handy for tweaking data at a low level, but it isn't really suited
to public facing sites.

If you have requirements that involve customized workflows, or you're
expecting to customize views or structure, you're going to be better
served by building the site from scratch.

That said, Django doesn't leave you completely to your own devices.
Most websites have, at their core, lots of fairly common functionality
-- show me a list of all available X objects; show me the details for
widget 3; allow me to edit the details for widget 3, and so on.

This is where Django's generic views come in. The generic views are
pre-canned views for displaying and editing objects in common ways. If
you're looking to bang out a proof of concept, you'd be much better
suited to spending your time working out how to use generic views,
rather than trying to work out how to bend the admin to your will.

Yours,
Russ Magee %-)

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



Re: bar charts

2011-11-07 Thread Tim Sawyer
Flot.

http://code.google.com/p/flot/

My docs about what I did:
http://drumcoder.co.uk/tags/flot/

Example (including zooming by slider):
http://brassbandresults.co.uk/bands/rothwell-temperance-band/

Enjoy,

Tim.

> hi,
>
> what do people use to display bar charts in their sites?
> --
> regards
> Kenneth Gonsalves
>
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


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



Project general design question - "From scratch" or use of admin interface

2011-11-07 Thread youpsla
Hi,
before getting more in depth in writing my project I ask you a general
design question. My Django knowledge is not BIG enough for me to be
able to have a clear answer (with for and cons) on my question.

Here are the main guidelines of my project :
- I've two kind of users : Shop owners and consumers (I've already don
the part for consumers wich is quite simple)
- Shop owners have to register (Simple workflow : Email send with a
link for confirmation and activation)
- I like shops owners to be able to:
- Create one ore more shops with some informations (Adress, openg/
closing time etc )
- For each shop, they can add events
- Of course each shops owner can only access to shops and events
he has created himself

My question, is:
Do you thing it's better to use and customize the admin interface or
it's better to write all "from scratch".

My goal here is to setup a POOF and not necessary is project wich can
handle millions of hits :-)


Feel free to ask further information if needed.

Thanks in advance for your time.


Alain

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



Re: Disable debugging for all, but allow debug toolbar for one host

2011-11-07 Thread Tom Evans
On Sun, Nov 6, 2011 at 12:30 AM, Gelonida N  wrote:
> Hi,
>
> If I understood well, then the Django debug toolbar is only working if
> debugging is enabled.
>
> What I wanted to do is is to disable the explicit django error messages
> for all but one specific IP address and to disable the django debug
> toolbar for this one address.
>

You've not understood well. Whether the toolbar is displayed depends
upon a number of things, as explained in the docs:

https://github.com/django-debug-toolbar/django-debug-toolbar

See in particular INTERNAL_IPS and SHOW_TOOLBAR_CALLBACK.

Cheers

Tom

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



Re: bar charts

2011-11-07 Thread kenneth gonsalves
On Mon, 2011-11-07 at 19:36 +0800, skysb...@gmail.com wrote:
> On 2011年11月07日 18:16, kenneth gonsalves wrote:
> > On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:
> >> Here's the Quick Start page: http://goo.gl/g5I7X
> > that is easy - how does one populate with data from django?
> do you know how to populate with data with other develop language??
> 

no - I was looking at gviz_api, which I got to work in python, but not
with django.

-- 
regards
Kenneth Gonsalves

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



Re: bar charts

2011-11-07 Thread skysb...@gmail.com

On 2011年11月07日 18:16, kenneth gonsalves wrote:

On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:

Here's the Quick Start page: http://goo.gl/g5I7X

that is easy - how does one populate with data from django?

do you know how to populate with data with other develop language??

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



"Key 'Content-Type' not found in Form"

2011-11-07 Thread bentzy
Hello,

I have a page displaying a list of "Data" objects and I placed at the
same page a "submit" button opening a form that updates the "Data"
table at DB. Pretty simple.

class Thing(models.Model):
thing_id = models.BigIntegerField(primary_key=True)
etc...

class Data(models.Model):
data_id = models.AutoField(primary_key=True)
thing = models.ForeignKey(Thing)
key = models.CharField(max_length=200, blank=False)
value = models.CharField(max_length=200, blank=False)
def __unicode__(self):
return unicode(self.thing)

I've created then a form:

class DataForm(ModelForm):
class Meta:
model = Data


At my template I've added:

{% csrf_token %}
{{ form.as_p }}



The issue,
I get the following after clicking "Submit":

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
line 280, in run
self.result = application(self.environ, self.start_response)
  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
line 674, in __call__
return self.application(environ, start_response)
  File "/usr/lib/pymodules/python2.7/django/core/handlers/wsgi.py",
line 252, in __call__
response = middleware_method(request, response)
  File "/usr/lib/pymodules/python2.7/django/middleware/csrf.py", line
221, in process_response
if response['Content-Type'].split(';')[0] in _HTML_TYPES:
  File "/usr/lib/pymodules/python2.7/django/forms/forms.py", line 106,
in __getitem__
raise KeyError('Key %r not found in Form' % name)
KeyError: "Key 'Content-Type' not found in Form"


I've already added at settings.py:
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',

p.s.
I've also tried to change my models using use the contenttypes
framework - but it didn't help. I got the same error.

Any help will be really appreciated!

Thanks in advance.


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



Re: bar charts

2011-11-07 Thread kenneth gonsalves
On Mon, 2011-11-07 at 04:28 -0500, Joey Espinosa wrote:
> Here's the Quick Start page: http://goo.gl/g5I7X

that is easy - how does one populate with data from django?
-- 
regards
Kenneth Gonsalves

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



"Premature end of script headers" and {% url %} template tag

2011-11-07 Thread beh
Hi! I have a problem.
Apache returns 500 error like this
[Mon Nov 07 11:34:37 2011] [error] [client 123.123.123.123] Premature
end of script headers: django.wsgi

I create simple view for tests on server.
@render_to('dummy.html')
def test_permature(request):
return {}

dummy.html is empty by default.

if dummy.html contains the template tag which renders a url by {% url
%} tag, then server returns 500 and in log "Premature end of script
headers"
dummy.html
--
{% load ecko_theme_tags %}
{% cart_products_counter %}

cart_products_counter.html
-
{% url cart %}

If dummy.html contains only {% url %} tag, then all works fine.
dummy.html
--
{% load ecko_theme_tags %}
{% url cart %}
And more, if add to dummy cart_products_counter tag, then all works
fine UNTIL NEXT RESTART of apache. The server returns 500 and in log
"Premature end of script headers" after restart.

In what may be the reason?
How can it be solve?

hosting enviroment
Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze3 with Suhosin-Patch
mod_wsgi/3.3 Python/2.6.6 Phusion_Passenger/3.0.8 mod_perl/2.0.4 Perl/
v5.10.1

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



Re: bar charts

2011-11-07 Thread Joey Espinosa
Kenneth,

It's a Google API. Like other Google tools, you can connect using
google.load() within JavaScript code. It wouldn't integrate directly with
Django, but rather through your templates by using JavaScript.
--
Joey "JoeLinux" Espinosa*
*





On Mon, Nov 7, 2011 at 2:39 AM, kenneth gonsalves wrote:

> On Mon, 2011-11-07 at 00:04 -0500, Kevin Anthony wrote:
> > Google charts api
> >
> >
>
> any clues on how to integrate this with django?
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



CSRF failures for users that block all cookies. Is my planned solution stupid?

2011-11-07 Thread Benjamin Wohlwend
Hi,

I have recently updated a fairly high-traffic website from Django 1.0 to 
1.3. I added the csrf token to every form on the website, but nevertheless 
we regularly hear back from users that get the dreaded 403 error on form 
submits. I added some logging to the csrf error view (thanks Sentry to make 
this so easy), and what I found out is that the failing requests have no 
cookies at all. After observing this for a couple of days, it seems that 
~5% of our users have blocked cookies completely. This amounts to dozens of 
CSRF failures a day that are not attacks, but normal users trying to submit 
a contact form or some such.

After thinking about this for a while, I came up with the following idea: 
CSRF attacks make use of the session cookie to make malicious requests in 
the name of the user. But in the case of the user blocking cookies, there 
is no session cookie to abuse. So what if I modified (through inheritance) 
the behavior of the CsrfViewMiddleware in such a way that it accepts 
requests that have no cookies at all? Would that open any attack vectors?

Kind regards,
Benjamin

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



Re: bar charts

2011-11-07 Thread skysb...@gmail.com

On 2011年11月07日 12:57, kenneth gonsalves wrote:

hi,

what do people use to display bar charts in their sites?

a lot choices, like html5 chart, flash chart.

amchart,zingchart, i'm trying to use zingchart in my site now, it 
provide both flash and html5 solution.


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