Django code patterns

2012-02-09 Thread Rune Kaagaard
Dear django-users I keep doing patterns like: has_changed = False if resource.user.email != request.POST['email']: resource.user.email = request.POST['email'] has_changed = True if resource.user.is_active != request.POST['is_active']: re

django-digested 0.1.2

2012-02-09 Thread Jerome Baum
I hope here's the right place to announce this: I've just released the [django-digested][1] package to PyPI. It supports instant notifications, daily and weekly digests, and individual preferences for different groups of updates. The package handles the "digest" part of your notifications. For ea

Re: Django code patterns

2012-02-09 Thread Jerome Baum
On Feb 9, 9:41 am, Rune Kaagaard wrote: >         has_changed = False >         if resource.user.email != request.POST['email']: >             resource.user.email = request.POST['email'] >             has_changed = True >         if resource.user.is_active != request.POST['is_active']: >          

Import a custom py file into views.py

2012-02-09 Thread Alessandro Candini
Hi list. In my project named STO I have the 'jsonopenlayers' app with the following structure: STO ├── __init__.py ├── jsonopenlayers │ ├── ingestion │ │ └── ingestShp.py │ ├── __init__.py │ ├── models.py │ └── views.py ├── manage.py └── settings.py What I would like to do is to import the fun

Re: Import a custom py file into views.py

2012-02-09 Thread Daniel Roseman
On Thursday, 9 February 2012 10:21:29 UTC, Alessandro Candini wrote: > > Hi list. > In my project named STO I have the 'jsonopenlayers' app with the > following structure: > > STO > ├── __init__.py > ├── jsonopenlayers > │ ├── ingestion > │ │ └── ingestShp.py > │ ├── __init__.py > │ ├── models.py

Re: Import a custom py file into views.py

2012-02-09 Thread Adnan Sadzak
How python treat some folder as module? You need to add __init__.py into it. On Thu, Feb 9, 2012 at 11:33 AM, Daniel Roseman wrote: > > On Thursday, 9 February 2012 10:21:29 UTC, Alessandro Candini wrote: >> >> Hi list. >> In my project named STO I have the 'jsonopenlayers' app with the >> follo

WSGIHandler freezes, how do I find out why?

2012-02-09 Thread Demetrio Girardi
I have a single django project, deployed on two separate installations of Apache + python + mod_wsgi. The first installation has python 2.6 and everything works fine. The second installation has python 2.7. With this one, a few things work correctly - namely django's debug 404 pages, the login pa

Re: Django code patterns

2012-02-09 Thread bruno desthuilliers
On Feb 9, 9:41 am, Rune Kaagaard wrote: > Dear django-users > > I keep doing patterns like: > >         has_changed = False >         if resource.user.email != request.POST['email']: >             resource.user.email = request.POST['email'] >             has_changed = True >         if resource.us

Re: Can anyone please explain the following settings?

2012-02-09 Thread bruno desthuilliers
On Feb 9, 3:39 am, John Yeukhon Wong wrote: (snip code) > I just don't understand what each of the options above mean Can > someone please explain them?  Thanks. https://docs.djangoproject.com/en/1.3/ref/settings/ -- You received this message because you are subscribed to the Google Group

Re: how to make a small change for apps installed under /site-packages dir

2012-02-09 Thread bruno desthuilliers
On Feb 8, 7:01 pm, Tom Lesters wrote: > > Generally speaking, using virtualenv (no-site-packages) + pip (with a > > requirement file you keep in your project) is a GoodPractice(tm) when > > it comes to dependencies. > > I'm actually using virtuallenv + pip now, thanks for advice anyways! GoodBoy(

django error

2012-02-09 Thread anand jeyahar
Hi, Am rather new to django and this error makes no sense to me.. Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/django/db/models/ base.py", line 460, in save self.save_base(using=using, force_insert=force_insert, force_update=force

Re: Models inheritance in django: how to change PK "_ptr_id" on "id"?

2012-02-09 Thread Jean-Mark
You can also use the south application to manage migrations. pip install south Then add 'south' to the list of installed apps. To start off you can do ./manage.py schemamigration --initial appname ./manage.py migrate appname Then whenever you make a change to your models: ./manage.py schemamigra

Re: django error

2012-02-09 Thread Daniel Roseman
On Thursday, 9 February 2012 11:29:52 UTC, anand jeyahar wrote: > > Hi, >Am rather new to django and this error makes no sense to me.. > > > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.7/dist-packages/django/db/models/ > base.py", line 460,

Re: Can anyone please explain the following settings?

2012-02-09 Thread Jean-Mark
You can have a look here for Django's docs on these... https://docs.djangoproject.com/en/dev/ref/settings/ https://docs.djangoproject.com/en/dev/topics/files/ The media stuff are for where files are stored typically after upload. So for example, there's the ImageField that you can use as a field o

Re: django error

2012-02-09 Thread anand jeyahar
Hi > There's no searching going on here. You create a lock instance, > passing two positional arguments, which Django interprets as the first > fields, ID and name. > > That's why you should never use positional arguments when instantiating - > always do it via keyword arguments: > lock = Lock(

Re: Django code patterns

2012-02-09 Thread Rune Kaagaard
> Why are you only saving if you've made a change? (Just make sure you > aren't optimizing prematurely.) I have a lot of signals going round, so I wan't to keep saves to a minimum. But nothing bad would happen if I always saved in this case. Thus the code would look: resource.user.email = requ

Re: Django (or other) templates for untrusted users?

2012-02-09 Thread graeme
I missed the reply , so apologies for reviving this thread after more than a week. On Jan 27, 1:28 am, Bill Freeman wrote: > I think that depends upon the context the view provides, and upon what > tag libraries can be loaded. I think can work with that > Objects in the context can have their m

Re: django error

2012-02-09 Thread Daniel Roseman
On Thursday, 9 February 2012 13:41:31 UTC, anand jeyahar wrote: > > > Hi > > > > >> There's no searching going on here. You create a lock instance, >> passing two positional arguments, which Django interprets as the first >> fields, ID and name. >> >> That's why you should never use positional a

Re: Django code patterns

2012-02-09 Thread Rune Kaagaard
Maybe something like the following untested code: def submit_if_any(a, b, conditions, submit_func): has_any = False for condition in conditions: if condition(a, b): has_any = True

regarding an error in settings.py

2012-02-09 Thread kalyani ram
Hey all, Tday is my first day with django and i tried configuring postgresql as a backend and got an error like this: raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2 Please h

Re: regarding an error in settings.py

2012-02-09 Thread Stanwin Siow
Hi You need to install the package psycopg2. Google and install the package. It should work Best Regards, Stanwin Siow On Feb 9, 2012, at 10:10 PM, kalyani ram wrote: > Hey all, > Tday is my first day with django and i tried configuring postgresql as > a backend and got an error like thi

passing kwargs to forms of a formset - why is this working?

2012-02-09 Thread trubliphone
All, I have managed to get some code working that passes extra kwargs to the __init__() function of the member forms of a formset. This is good. But I have no idea why it works. Here is my basic code: class MyModel(models.Model): myField = models.CharField(max_length=10) class MyForm(

Re: Moving from python 3 to 2.x in windows 7 to use Django

2012-02-09 Thread 최국태
> > Hi! > > I have 2 python version ( Python 2.7 and 3.2 ) in Windows 7. But I use > Python 3.1 usually. ( I have 2 directories( Python27 and Python32 )) > I decided to use Django and tried to install it as guideline in > https://docs.djangoproject.com/en/1.3/topics/install/#installing-official-rel

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread bfrederi
Thanks Andy, I didn't know you could use a cache by name. That will be helpful. On Feb 8, 9:22 pm, Andy McKay wrote: > You can define multiple caches: > > https://docs.djangoproject.com/en/1.3/topics/cache/#django-s-cache-fr... > > You could then use a file system cache or your own local memcache

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread bfrederi
I tried akaariai's method, but I may have done the importing wrong. It seemed to make apache struggle mightily to the point where it was unusable for some reason. Doug, I don't see how the LazyFetch you wrote is much different than what akaariai shared? Can you explain to me what the difference is

Contribute to Django

2012-02-09 Thread Gath
Guys, What do i need to learn/know before i start contributing to django development? Thanks Gath -- 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 gro

Re: Contribute to Django

2012-02-09 Thread yati sagade
Django docs explain this quite nicely :) https://docs.djangoproject.com/en/dev/internals/contributing/?from=olddocs On Fri, Feb 10, 2012 at 12:46 AM, Gath wrote: > Guys, > > What do i need to learn/know before i start contributing to django > development? > > Thanks > > Gath > > -- > You recei

Re: Models inheritance in django: how to change PK "_ptr_id" on "id"?

2012-02-09 Thread JohnA
Glad you were able to resolve your problem. I use multi-table inheritance a lot and so far it always "just works" without me having to worry about or fiddle with the internal ids that Django uses to connect the derived class rows to the base class ones. -- John On Feb 8, 1:25 pm, Artyom Chernetz

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread Doug Ballance
> Doug, I don't see how the LazyFetch you wrote is much different than > what akaariai shared? Can you explain to me what the difference is? > And I'm not saying that in a condescending way, I'm saying I'm just > not sharp enough on my Python to recognize the difference. Slightly different impleme

Re: Dynamic settings variables (dynamic global variable)

2012-02-09 Thread bfrederi
Makes sense. I actually ended up using your example and it worked well as far as I can tell. And you actually explained the importing too, which is where I messed up previously. Also, I made the mistake of putting it in a file that was already importing a bunch of other things, so I got wrapped up

QuerySet and subselect

2012-02-09 Thread Олег Корсак
Hello. I have a model named MyModel and it has its own table named my_model (as an example). Is it possible to write ORM-way request to be same as this SQL: SELECT mo.* FROM (SELECT mi.* FROM my_model mi) AS mo WHERE mi.a=mo.a AND mi.b=mo.b; There is also an agregation+group by statements in subs

Re: QuerySet and subselect

2012-02-09 Thread akaariai
On Feb 10, 2:39 am, Олег Корсак wrote: > Hello. > I have a model named MyModel and it has its own table named my_model (as > an example). > > Is it possible to write ORM-way request to be same as this SQL: > SELECT mo.* FROM (SELECT mi.* FROM my_model mi) AS mo WHERE mi.a=mo.a > AND mi.b=mo.b; > >

Is it possible to implement an ODBC for Django

2012-02-09 Thread Python_Junkie
I wanted to know if the settings.py will support a generic ODBC connection and if it could what the syntax would be in the database section of the , settings.py file -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send ema

[Error] Mixing Two databases

2012-02-09 Thread Subhodip Biswas
Hi all, I am trying to use two database for my django(Django nonrel 1.3.1) project. One is Postgres and other is MongoDB. After filling in details in settings.py : DATABASES = { 'default': { 'ENGINE': 'django_mongodb_engine', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite

Re: Django code patterns

2012-02-09 Thread Michael Nacharov
09.02.2012 20:01, Rune Kaagaard пишет: Maybe something like the following untested code: def submit_if_any(a, b, conditions, submit_func): has_any = False for condition in conditions: if condition(a, b):

Re: [Error] Mixing Two databases

2012-02-09 Thread Subhranath Chunder
You might be using joins in one or more of your MongoDB model declarations. Check with the Meta section of the Mongo models. Infact, if you are trying to span across collections in your non-relational database on purpose, then something basic might be going wrong. On Fri, Feb 10, 2012 at 9:32 AM