Multiple cache definitions all pointing to the same Redis instance. Is this okay?

2015-09-08 Thread EJ
Hi,

I'm still learning about Django's caching features and had a question about 
my specific setup.  My app uses a Redis-backed cache to store a variety of 
different data (including sessions, users, and other stuff).

In *settings.py*, I've defined several caches, as shown below.  These all 
point to the exact same Redis instance.  I've set it up like this because I 
really like the ability to set a VERSION for a specific subset of keys.  As 
the structure of the cached data changes in development, I can invalidate a 
whole set of cached keys just by bumping up the VERSION setting.  Or at 
least that's my idea right now.  I'm basically using cache definitions just 
to group keys.

Is it okay to do this?  On every request, the app hits several of these 
"caches".  Am I inadvertently opening up multiple connections to the same 
Redis instance on every page view?  Are there any other downsides to this 
kind of setup?  Or alternative ways of 'versioning' groups of keys?

Thanks in advance.

- EJ

CACHES = {
'default': {
"VERSION": 1,
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0",
"KEY_PREFIX" : "d",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
'sessions': {
"VERSION": 1,
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0",
"KEY_PREFIX" : "s",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
'users': {
"VERSION": 1,
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0",
"KEY_PREFIX" : "u",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
...
}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08897b49-2dbb-470f-aed6-3dca7482445c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Dynamically alter a list based on selections on other widgets

2015-09-08 Thread Baktha Muralidharan
Hello

I am looking to develop a GUI (Form?) in which I can display a list the 
contents of which change on the fly as the user makes other selections. For 
example, there could be a radio button (a simple yes/no button) - based on 
the selection, the displayed list needs to change dynamically.
the list could be too long and so, I would like to display it as a 
scrollable list.

Tips/thoughts on how I could accomplish this will be much appreciated. Of 
course, if someone has implemented and is willing to share the code, that 
will be much appreciated as well!

Thanks in advance,
/Baktha

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


Re: bulk add m2m relationship for multiple instances

2015-09-08 Thread yakkadesign
I reviewed my code and the slow speed I was talking about was when I said 
|if a in myList].  I switched to the dict and I haven't noticed a 
performance hit from keeping a pointer to a list.  

I ended up switching to Postgres COPY for the importing.  It's a lot 
faster.  

Brian

  


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


Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Malcolm Box
Hi,

I'm trying to add a dynamic method to a ModelAdmin so that I can have 
automatically generated thumbnail fields for any image by simply adding 
'_thumbnail' to the field definitions - which saves a lot of 
code when there's a load of admin classes with image fields that need 
thumbnails.

e.g.

class ThumbnailMixin(object):
def getattr(self, name):
 if name.endswith('_thumbnail'):
  # ... generate appropriate thumbnail method and return
  return thumbnail_function
 else:
 raise AttributeError

class ExampleAdmin(models.ModelAdmin, ThumbnailMixin):
 fields = ['image_thumbnail', 'image', ...]

This worked fine in Django 1.6/1.7, but it's now failing in 1.8 with a 
SystemCheckError (admin.E035 / admin.E108). If I silence the error, the 
admin actually works fine, but that feels icky.

The check fails because it checks for the field being on the ExampleAdmin 
class, not on an instance - whereas the admin always uses an instance, so 
it works.

What's the "right" way to do this in the 1.8 world - I've considered a 
custom metaclass, but that feels like overkill for a simple task like this. 
Should this even work, and if so is it a bug in the check framework?

Cheers,

Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/987461ae-f455-44f7-9c61-935a6d412c49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Oracle DB, some help needed

2015-09-08 Thread Jani Tiainen
Hi everyone,

I'm currently trying to maintain Oracle backends for Django and found
interesting issue that I would like Oracle users to run in their databases.

(I'm not sure can you run these in XE, you may try but I think these
require full Oracle)

Two SQL clauses that I would like you to run are located in my gist <
https://gist.github.com/jtiai/e3459777debf97458187>

Pay special attention to srsName value returned from queries, then please,
post your results and Oracle version your database is running.

If you don't want to post your results in public, private mail is
acceptable.

Thank you for your co-operation.

-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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


Re: Django for data management in a no-UI application?

2015-09-08 Thread jsachs
I think I failed to explain my situation clearly, and I need to try again.

I have been planning to develop a standard web application using Django. 
Due to a change in direction, the development plan has been changed to:


   1. Develop a suite of no-GUI applications that run in a command line 
   window on a server. One other application will run on *clients *in a 
   command line window, and will perform certain operations on the server 
   through a REST API service. However,
   2. All of the applications will use an SQL database that runs on the 
   server.
   3. In a later phase of the project, the server applications will be 
   combined and modified to present a GUI.

My question is this: Is it feasible to make all of the server applications 
use Django to communicate with the database server in step 1, and then use 
it to implement the GUI in step 3? By doing so, I would avoid having to (1) 
code all of the database operations without Django in step 1, then recode 
them with Django in step 3, or (2) end up with a "hybrid" application that 
implements the GUI in Django but the database operations outside Django.

I haven't looked at the "Django REST" link yet, but I appreciate the 
suggestion. The project will require a REST API, as I mentioned, although 
most of the applications will run on the server, and will *not* need an API.

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


Re: Django for data management in a no-UI application?

2015-09-08 Thread Carl Meyer
On 09/08/2015 04:06 PM, jsa...@nvidia.com wrote:
> I have been planning to develop a standard web application using Django.
> Due to a change in direction, the development plan has been changed to:
> 
>  1. Develop a suite of no-GUI applications that run in a command line
> window on a server. One other application will run on _clients _in a
> command line window, and will perform certain operations on the
> server through a REST API service. However,
>  2. All of the applications will use an SQL database that runs on the
> server.
>  3. In a later phase of the project, the server applications will be
> combined and modified to present a GUI.
> 
> My question is this: Is it feasible to make all of the server
> applications use Django to communicate with the database server in step
> 1, and then use it to implement the GUI in step 3? By doing so, I would
> avoid having to (1) code all of the database operations without Django
> in step 1, then recode them with Django in step 3, or (2) end up with a
> "hybrid" application that implements the GUI in Django but the database
> operations outside Django.

Sure, you can write the command-line server applications as Django
management commands, or just as Python scripts that use
`django.conf.settings.configure()` and call `django.setup()` before
using the ORM to communicate with the database.

And you can use the same ORM models to drive your REST API, built in Django.

How you approach step 3 depends on whether "browser-based GUI" is
acceptable, or you need to build an OS-native application. Django is
oriented towards the former, but you can certainly build an OS-native
Python application using a GUI toolkit like Qt or whatever, and still
use the Django ORM within it to talk to the database.

Carl

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


signature.asc
Description: OpenPGP digital signature


What frontend-tools to use for a new CRM project? Shall I use Django OR switch to Meteor.js?

2015-09-08 Thread ThomasTheDjangoFan
Hi guys,

I have invested quite a lot of time & energy into learning django and I 
feel comfy using it. (I have studied the 2 Scoops, the Tdd book and got the 
boook "Scaling Django" and "lightweight Django" right here next to me). 

It feels like I finally got the right tool, BUT:
I am about to implement my first big project - a *customer relation 
management system*. The userbase will be small - around 1 to 10 users.

During my planing I came accross javascript-framworks (like angular or 
meteor) and yes: *my project definetly needs some javaside-tricks on the 
client-side.*

So I used the last 7 days to stick my head into the javascript stuff and I 
am *sooo overwhelmed* by all the options out there (!!!). And it 
seems like there really is no good tutorial for the javascript-frontend 
stuff with django.

*Now I am going crazy and thinking about dropping django completely and 
switching to Meteor*. (By the way: The meteor-guys seem to be totally in 
love with react.js.)

*Before making a stupid decision I feel like I need some guidance from the 
real experts.*

*Now my question to you is:*
*If you were about to implement a quite-complex crm system (starting from 
the ground up): what tool would you use?*
Would you use Django (maybe in combination with React) or would you switch 
to Meteor?
If you would stick to Django - which js-framework can you recon? (I really 
need some good and clear tutorials to get me started)

I am really thankful for your tips

Kind regards
Thomas

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


Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Simon Charette
Hi Malcom!

I would suggest you have a look at the ModelAdmin.get_fields() 

 
method to append your thumbnail read-only field names.

As documented 
,
 
just make sure you also override ModelAdmin.get_readonly_fields() 

 
to return them as well.

Cheers,
Simon

Le mardi 8 septembre 2015 13:31:47 UTC-4, Malcolm Box a écrit :
>
> Hi,
>
> I'm trying to add a dynamic method to a ModelAdmin so that I can have 
> automatically generated thumbnail fields for any image by simply adding 
> '_thumbnail' to the field definitions - which saves a lot of 
> code when there's a load of admin classes with image fields that need 
> thumbnails.
>
> e.g.
>
> class ThumbnailMixin(object):
> def getattr(self, name):
>  if name.endswith('_thumbnail'):
>   # ... generate appropriate thumbnail method and return
>   return thumbnail_function
>  else:
>  raise AttributeError
>
> class ExampleAdmin(models.ModelAdmin, ThumbnailMixin):
>  fields = ['image_thumbnail', 'image', ...]
>
> This worked fine in Django 1.6/1.7, but it's now failing in 1.8 with a 
> SystemCheckError (admin.E035 / admin.E108). If I silence the error, the 
> admin actually works fine, but that feels icky.
>
> The check fails because it checks for the field being on the ExampleAdmin 
> class, not on an instance - whereas the admin always uses an instance, so 
> it works.
>
> What's the "right" way to do this in the 1.8 world - I've considered a 
> custom metaclass, but that feels like overkill for a simple task like this. 
> Should this even work, and if so is it a bug in the check framework?
>
> Cheers,
>
> Malcolm
>

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


django.db.utils.DatabaseError: ORA-12704: character set mismatch

2015-09-08 Thread Mohsen Bande
i faced a strange issue, trying to store a list of items (of length ~30)
into database via bulk_insert, i get django.db.utils.DatabaseError:
ORA-12704: character set mismatchbut inserting items one by one via save is
OK, even putting a few items(2~3) into bulk_insert sometimes works.

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


bug in migration squashing

2015-09-08 Thread ?manu*
I had experienced a problem after squashing migrations. The problem is 
described 
here: 
http://stackoverflow.com/questions/31606372/django-migrations-build-graph-has-a-bug

I have not a description of how to reproduce the bug, but I think I can say 
why the source code is wrong (see the link). Do you think this is enough to 
open a bug report?

E.

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


Re: What frontend-tools to use for a new CRM project? Shall I use Django OR switch to Meteor.js?

2015-09-08 Thread Gergely Polonkai
Hello,

this all depends: if I'm a JS expert, I'd go with Meteor or another JS
framework. If I'm a Python expert, I'd go with Django or another Python
framework.

Meteor's strength is in the fact that (almost) the same code runs on the
server and in the browser (wether it's good or not is another story, and
opinions will change developer by developer). It is more than possible that
your CRM's frontend will utilize JavaScript anyway, but for that, you may
want to use different frameworks like Angular or Bootstrap (if you can call
this latter a JS framework).

So I'm really sorry but I think no one will actually tell you what to do:
you must decide based on the requirements.

Oh, and don't stick with JS just because "it's a small app with 10 users";
if you see potential in your app, make it scalable. Maybe you will be able
to sell it latel to bigger corps. ;)

Best,
Gergely
On 9 Sep 2015 00:12, "ThomasTheDjangoFan" <
stefan.eichholz.ber...@googlemail.com> wrote:

> Hi guys,
>
> I have invested quite a lot of time & energy into learning django and I
> feel comfy using it. (I have studied the 2 Scoops, the Tdd book and got the
> boook "Scaling Django" and "lightweight Django" right here next to me).
>
> It feels like I finally got the right tool, BUT:
> I am about to implement my first big project - a *customer relation
> management system*. The userbase will be small - around 1 to 10 users.
>
> During my planing I came accross javascript-framworks (like angular or
> meteor) and yes: *my project definetly needs some javaside-tricks on the
> client-side.*
>
> So I used the last 7 days to stick my head into the javascript stuff and I
> am *sooo overwhelmed* by all the options out there (!!!). And it
> seems like there really is no good tutorial for the javascript-frontend
> stuff with django.
>
> *Now I am going crazy and thinking about dropping django completely and
> switching to Meteor*. (By the way: The meteor-guys seem to be totally in
> love with react.js.)
>
> *Before making a stupid decision I feel like I need some guidance from the
> real experts.*
>
> *Now my question to you is:*
> *If you were about to implement a quite-complex crm system (starting from
> the ground up): what tool would you use?*
> Would you use Django (maybe in combination with React) or would you switch
> to Meteor?
> If you would stick to Django - which js-framework can you recon? (I really
> need some good and clear tutorials to get me started)
>
> I am really thankful for your tips
>
> Kind regards
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5da587a8-204d-45c3-ae1a-5936e87861b4%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: django.db.utils.DatabaseError: ORA-12704: character set mismatch

2015-09-08 Thread Jani Tiainen

Hi,

Please provide following information:

Django version
Oracle database version
cx_Oracle version

If possible try to extract offending SQL.

On 09.09.2015 08:10, Mohsen Bande wrote:
i faced a strange issue, trying to store a list of items (of length 
~30) into database via |bulk_insert|, i get 
|django.db.utils.DatabaseError: ORA-12704: character set mismatch|but 
inserting items one by one via |save| is OK, even putting a few 
items(2~3) into |bulk_insert| sometimes works.

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

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFdu22qPQGQgv8iByO51bm7TaQMayPJYzT69PMoJAN1S9K4reQ%40mail.gmail.com 
.

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


--

Jani Tiainen

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


DJango coder required

2015-09-08 Thread Phillipnorcross
Hi there we require the services of a DJango coder to perform ongoing 
maintenance, small code changes and updates on an ongoing basis.
If you are interested please email me your details, experience and hourly 
rate
Regards
Phillip

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


CSRF error

2015-09-08 Thread kanyanwu

Hi, 

I have read through several post online about this CSRF issue and had no 
luck. I also read through the django documentation on CSRF and went 
step-by-step through the items needed to be added to the settings.py, 
template, etc for CSRF, and that was no luck as well. Here is what the 
webserver returned :

Reason given for failure:

CSRF cookie not set.


The following are snippets of my files ...

1. Settings.py

MIDDLEWARE_CLASSES = (

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.common.CommonMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.auth.middleware.SessionAuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

'django.middleware.clickjacking.XFrameOptionsMiddleware',

'django.middleware.security.SecurityMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

)

2. views.py:

def menu(request):

return render_to_response('home/base_1.html', context_instance = 
RequestContext(request, {}) )

3. base.html:

   
{% csrf_token %}


  



  
   

   
   Log In

4. login.js :

function logIn ()
{

alert('Form has been submitted');
document.getElementById('loginform').submit();

}

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