error : python manage.py shell

2010-06-11 Thread Jagdeep Singh Malhi
i am using Django Version: 1.2.1 I follow this Tutorial http://docs.djangoproject.com/en/1.2/intro/tutorial01/ and Edit the polls/models.py file so it looks like this: class Poll(models.Model): # ... def __unicode__(self): return self.question class Choice(models.Model): #

Re: CSRF token not adding hidden form field

2010-06-11 Thread Ali Kusnadi
On 6/11/10, Joel Klabo wrote: > yeah, still 403. CSRF token missing or incorrect. > try add the 'django.core.context_processors.csrf' in your settings.py TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.csrf', ) > > -- > You received this

Controlling access to objects

2010-06-11 Thread Wiiboy
Hi guys, I don't know whether the built-in permissions system would be appropriate here, but I want to control access to objects in one of my models, based on profile fields, like gender, age, etc. I planned to create a model "MyModelPermissions" like so: class MyModelPermissions(models.Model):

Re: Thinking of Patterns

2010-06-11 Thread James O'Connor
Wel what I have in mind is wondering if it would be useful to build full implementations of what would normally be called "Analysis Patterns", like Designed Patterns but commone object modeling solutions to common domain problems. The simplest is problem the Item- ItemDecription pattern, which as

Re: Model named FOOD_DES shows as "foo d_des" in admin

2010-06-11 Thread creecode
Hello all, The line < http://code.djangoproject.com/browser/django/trunk/django/db/models/options.py#L15 > in the trunk at this moment is where the action is happening. We get "foo d_des" because the "_D" in the model name is matched in the regular expression pattern and the substitution

Re: Simplification of a DB "query"

2010-06-11 Thread Dan Harris
This is totally off the top of my head and may not compile or work :) But something like this might be what you're looking for: # Example Model class MyModel(models.Model): start_time = models.TimeField() # Example query from django.db.models import Q from django.db.model import Max # Get

Re: Simplification of a DB "query"

2010-06-11 Thread Cesar Devera
I'm not sure how to do directly in Django ORM, but if you use plain SQL queries, you could do try: select * from conference_room cr1 where cr1.start_time >= (select max(start_time) from conference_room cr2 where cr2.start_time < :yout_filter_time) and cr1.start_time < :your_filter_time

Re: syncdb always indicates there are no fixtures

2010-06-11 Thread eXt
On 11 Cze, 12:19, tsmets wrote: > The problem was just the naming convention ... > They should have been named initial_data.json as mentionned in the URL > provided by Xavier. > > Any help on how to run python scripts directly to create my data > sets ? > What I do now is

Re: Model named FOOD_DES shows as "foo d_des" in admin

2010-06-11 Thread creecode
Hello Dan, On Jun 11, 11:48 am, Dan Harris wrote: > If verbose_name isn't provided the docs say that "Django will use a > munged version of the class name: CamelCase becomes camel case." Thanks again for the info. > This > might explain your problem, it looks at FOOD_DES

Re: User-level permissions?

2010-06-11 Thread bax...@gretschpages.com
Still looking for an clue on this. Permissions are simply not there. On Jun 7, 3:03 pm, "bax...@gretschpages.com" wrote: > OK, I'm going nuts. For some reason, my user-levelpermissionshave > disappeared. I can changepermissionsat the group level, but at the > user level I

Re: Model named FOOD_DES shows as "foo d_des" in admin

2010-06-11 Thread Dan Harris
If verbose_name isn't provided the docs say that "Django will use a munged version of the class name: CamelCase becomes camel case." This might explain your problem, it looks at FOOD_DES and assumes that the first F and first O are camel cased words and splits them into two words, hence the space.

Re: Model named FOOD_DES shows as "foo d_des" in admin

2010-06-11 Thread creecode
Hello Dan, Thanks for the info. verbose_name does take care of the display problem and I may end up using that option for a more user friendly experience. @ALL: I would like to understand where the space is being added. I have looked around a bit in the source for Django but I haven't seen

Re: Using array of URLs for MEDIA_URL

2010-06-11 Thread Martin Siniawski
Alex, Thanks for the answer. I tried doing something like the first thing you proposed (MEDIA_URL as a callable) but I had to tweak it a little bit because the template wasn't calling the callable, but rather printing 'function object .'. What do you think of the solution I posted? Best,

Re: Using array of URLs for MEDIA_URL

2010-06-11 Thread Martin Siniawski
Steven and Alex, This is what I coded, and tried it out and works. I still have to benchmark it. from django.conf import settings class RoundRobinMediaUrl(): current_url = 0 try: media_urls = settings.MEDIA_URLS except: media_urls = (settings.MEDIA_URL,) def

Re: Model named FOOD_DES shows as "foo d_des" in admin

2010-06-11 Thread Dan Harris
I'm not sure why you are seeing the space in the admin, but here's a bit of info regarding changing what is displayed: You can change a meta option on your model to set what the name will be displayed as in the admin like so: class MyModel(models.Model): field =

Re: Using array of URLs for MEDIA_URL

2010-06-11 Thread Martin Siniawski
Steven, Thanks again for the answer. I couldn't quite understand the comment regarding the round robin server setup. In order to workaround the browser's limitations to simultaneous connections that can be opened to a host, the links to static content in the HTML content must be to different

Re: HIPAA experience

2010-06-11 Thread Mario
Hello, >From what I have read it looks like you want to provide your clients the assurance that the information being presented is not compromised in addition to meeting the HIPAA and HITECH requirements. This is not entirely a Django/Python implementation, but falls in line with the Database

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread Scott Gould
Apologies for the "__initial__" stuff -- damn iPhone autocomplete! On Jun 11, 11:15 am, rahul jain wrote: > It was rw-r--r-- . I also modified it to 777 by" chmod -R 777". But > did not fix my problem. > > This is the error which I am getting > ImportError: cannot import

Re: Running syncdb from an install script in django_project/install

2010-06-11 Thread Stodge
"Is there some .py file in your install directory that matches the name of an app you have listed in installed apps?" I think this was the problem. Thanks!! On Jun 11, 11:37 am, Karen Tracey wrote: > On Fri, Jun 11, 2010 at 9:11 AM, Stodge wrote: > > I'm

Model named FOOD_DES shows as "foo d_des" in admin

2010-06-11 Thread creecode
Hello all, I have a model named FOOD_DES (the name if from an existing schema that I'm trying to mirror). When I view it in the admin it's name is shown as "foo d_des", notice the space. Any thoughts on why/where the space is added and how I can get rid of it? I'm wondering if this something

Import error with current_datetime

2010-06-11 Thread JRMAbock
I have configured my url to call ^time/$, current_datetime ive also imported datetime into my views.py file which the django tutorial ahs told me. I keep getting an import error unable to import current datetime I also have tried simply reateign the module now which calls the current dateime

Re: select_related() depth when specifying fields

2010-06-11 Thread Michael Hrivnak
I really appreciate your help Dan, but I don't think the answer to my question is in the docs. I did my due diligence there before asking. Regarding your suggestion, from the docs: "It's an error to use both a list of fields and the depth parameter in the same select_related() call, since they

Re: ManyToMany autocomplete field and large amounts of autocomplete data

2010-06-11 Thread felix
http://code.google.com/p/django-ajax-selects/ satisfies all requirements the channels will allow even finer customization for the queries and the display. On Jun 11, 12:01 pm, akaariai wrote: > Hello all, > > I am looking for an m2m autocomplete field which should have

Re: syncdb always indicates there are no fixtures

2010-06-11 Thread Bill Freeman
On Fri, Jun 11, 2010 at 6:19 AM, tsmets wrote: ... > > Any help on how to run python scripts directly to create my data > sets ? > What I do now is fine but could be better automated ? > ... One possibility is to write yourself one or more management commands which you

Re: CSRF token not adding hidden form field

2010-06-11 Thread shacker
On Jun 10, 8:41 pm, Joel Klabo wrote: > yeah, still 403. CSRF token missing or incorrect. Not to state the obvious, but are you positive you're working with the right set of templates? I only ask because this happened to me recently - the CSRF tokens not showing up in the

Re: Multiple AJAX sends within a views.py-function

2010-06-11 Thread Rafael Nunes
Can't you use XMPP? On Fri, Jun 11, 2010 at 12:36 PM, Euan Goddard wrote: > If you're worried about the data getting out of order use a counter in > JS and always ensure that you only update the page when you get the > correct (i.e. current) counter back. > > I

Re: Running syncdb from an install script in django_project/install

2010-06-11 Thread Karen Tracey
On Fri, Jun 11, 2010 at 9:11 AM, Stodge wrote: > I'm writing an install script that resides in django_project/install > and one of things it does, is programmatically run syncdb. My current > code for this is correct if I do: > > cd .. > python > import os >

Re: Multiple AJAX sends within a views.py-function

2010-06-11 Thread Euan Goddard
If you're worried about the data getting out of order use a counter in JS and always ensure that you only update the page when you get the correct (i.e. current) counter back. I think what you're talking about isn't possible in normal HTTP. I think you have a one request, one response situation.

Re: ordering integers with regroup

2010-06-11 Thread Euan Goddard
It should be easy enough to write your own tag providing you're expecting your input in the form . I've written a bit of code that should do this: import re LABEL_RE = re.compile(r'^(\w+) (\d+)$') def order_by_number(unordered_data): tokenized_data = [] for item in unordered_data:

Re: Running syncdb from an install script in django_project/install

2010-06-11 Thread Stodge
Good point. I tried adding the Django project's path to sys.path and tried your suggestions for the settings, but it still gives me the same error. Thanks # Add the Django project path to sys.path. sys.path.append(config.INSTALL_DIR) # Add the parent path too.

Re: Using array type data in Django/ Postgresql

2010-06-11 Thread Euan Goddard
I'd just create a related model and use a many-to-many field. Alternatively you could write your own field, but this would restrict your application to postgres only. Euan On Jun 10, 1:03 pm, bjja wrote: > Hi > > Psycopg2 supports array types but I can not find any

Multiple AJAX sends within a views.py-function

2010-06-11 Thread Christoph
Hi, normally in views.py I have a function that takes a request and returns a render_to_response or the like. I, however, would like it to take a request and have Django reply with multiple responses. Is there a way to do this, or is this not possible with HTTP anyway? What I am trying to

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread rahul jain
It was rw-r--r-- . I also modified it to 777 by" chmod -R 777". But did not fix my problem. This is the error which I am getting ImportError: cannot import name --RJ On Fri, Jun 11, 2010 at 7:59 AM, Tom Evans wrote: > On Fri, Jun 11, 2010 at 3:47 PM, rahul jain

Re: Running syncdb from an install script in django_project/install

2010-06-11 Thread Euan Goddard
This sounds like a path type issue and these sorts of things are a PITA to sort out. Have you tried setting the settings path a bit more explitly: os.environ["DJANGO_SETTINGS_MODULE"]="django_project.settings" I had some trouble with kind of thing in a project I was working on

Re: Get last object with certain value

2010-06-11 Thread Euan Goddard
Hi, I've done something similar to this using annotation. It is a bad nasty, but should work. Firstly annotate all the MyModel instances with the max value of the pk of the MyOtherModel: qs = MyModel.objects.annotate(last_pk=Max('myothermodel__pk')) Then filter these based on the myString: qs

Re: How do I set my default language ???

2010-06-11 Thread Jeliuc Alexandr
Contra question... do You use something like geoip in your application? On Jun 11, 5:48 pm, Ariel wrote: > Hi everybody, I write in my settings.py LANGUAGE_CODE = 'fr' to make french > the default language but it does'nt seem to work because the spanish is > still the

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread Tom Evans
On Fri, Jun 11, 2010 at 3:47 PM, rahul jain wrote: > Hi Tim, > > Here is my structure > > app > |-- __init__.py > |-- models.py (all  my models) > |-- auth.py  (python functions referencing models defined in models.py) > |-- blogs.py (python functions referencing models

Re: How do I set my default language ???

2010-06-11 Thread Jeliuc Alexandr
Please try 'fr-FR' On Jun 11, 5:48 pm, Ariel wrote: > Hi everybody, I write in my settings.py LANGUAGE_CODE = 'fr' to make french > the default language but it does'nt seem to work because the spanish is > still the default language, Do I need to do something else to make

How do I set my default language ???

2010-06-11 Thread Ariel
Hi everybody, I write in my settings.py LANGUAGE_CODE = 'fr' to make french the default language but it does'nt seem to work because the spanish is still the default language, Do I need to do something else to make french the default language ??? I need help !!! Thanks in advanced Regards -- You

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread rahul jain
Hi Tim, Here is my structure app |-- __init__.py |-- models.py (all my models) |-- auth.py (python functions referencing models defined in models.py) |-- blogs.py (python functions referencing models defined in models.py) |-- views.py (python functions referencing models defined in models.py)

Re: UnboundLocalError: local variable 'resolver' referenced before assignment

2010-06-11 Thread bruno desthuilliers
On 11 juin, 15:26, Marcus Whybrow wrote: > I have found a ticket already open for this problem (http:// > code.djangoproject.com/ticket/13684), > The problem was in fact that I had a settings.py file and a module > called settings with default and local settings residing

Re: 404 error in admin interface with mod_python and >=django-1.1

2010-06-11 Thread Jan Meier
On 11 Jun., 15:30, Karen Tracey wrote: > Yes, you've got your admin registrations in your models.py file. models.py > won't necessarily be loaded early in a production environment with > DEBUG=False, so these registration calls are not running before you start > using admin.

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread Tom Evans
I'll give you the benefit of the doubt since it seems some of this is getting lost in translation. Your app must have this sort of structure: app |-- __init__.py |-- models | |-- __init__.py | |-- auth.py | `-- blogs.py `-- views.py If app/models/auth.py defines a User class, and

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread rahul jain
@also I meant .objects. all(). It will give import error that cannot be imported. On Fri, Jun 11, 2010 at 7:09 AM, rahul jain wrote: > Yes I have the __init__.py inside my app directory. Also, all my split > files are inside the same directory. If possible can you

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread rahul jain
Yes I have the __init__.py inside my app directory. Also, all my split files are inside the same directory. If possible can you test Create views1.py (not views.py) > > import your model class > > and in one of the functions do > .objects. all() > > and then run python manage.py runserver. I

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread rahul jain
@bruno: yes functions. So in some other file I want to use models methods like .objects. all For that I have to import the . But I am not able to. Import works fine on views.py Also, can you test this for me Create views1.py (not views.py) import your model class and in one of the

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread Tom Evans
On Fri, Jun 11, 2010 at 2:53 PM, rahul jain wrote: > Yes they are in the same directory. How to use __initial__.py ? > It's called __init__.py. It must exist in any python module (directory), and need not contain anything. You were linked to this earlier in the thread,

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread rahul jain
Yes they are in the same directory. How to use __initial__.py ? On Fri, Jun 11, 2010 at 3:38 AM, Scott Gould wrote: > Did you put Test1.py and Test2.py into a "models" directory where > models.py would normally be, and add an __initial__.py file to it? > > On Jun 10, 5:18 pm,

Re: 404 error in admin interface with mod_python and >=django-1.1

2010-06-11 Thread Karen Tracey
On Fri, Jun 11, 2010 at 4:49 AM, Jan Meier wrote: > And my model my_app/models.py looks as follows: > > from django.db import models > from django.contrib import admin > > class Blubb(models.Model): >x = models.IntegerField() > > admin.site.register(Blubb) > > Any

Re: Introducing ImageFlow for Django (Django-ImageFlow)

2010-06-11 Thread backdoc
The examples are pretty slick. On Tue, Jun 8, 2010 at 1:22 AM, simon wrote: > Hi everyone, > > ImageFlow is a platform-independent JavaScript picture gallery > inspired by the Cover Flow technique currently used in iTunes and the > file browser of OSX. The standard ImageFlow

Re: UnboundLocalError: local variable 'resolver' referenced before assignment

2010-06-11 Thread Marcus Whybrow
I have found a ticket already open for this problem (http:// code.djangoproject.com/ticket/13684), The problem was in fact that I had a settings.py file and a module called settings with default and local settings residing inside it. There must have been some confusion and moving the settings.py

Running syncdb from an install script in django_project/install

2010-06-11 Thread Stodge
I'm writing an install script that resides in django_project/install and one of things it does, is programmatically run syncdb. My current code for this is correct if I do: cd .. python import os os.environ["DJANGO_SETTINGS_MODULE"]="settings" from django.core.management import call_command

404 error in admin interface with mod_python and >=django-1.1

2010-06-11 Thread Jan Meier
Hi, I am serving my django project with mod_python and ran into a problem regarding the admin interface (django.contrib.admin). If DEBUG = False is set in settings.py the admin interface generates 404 error messages when clicking on any of my models, for example to add a new entry. The django

Re: UnboundLocalError: local variable 'resolver' referenced before assignment

2010-06-11 Thread bruno desthuilliers
On 11 juin, 00:45, Marcus Whybrow wrote: > mod_wsgi (pid=2639): Exception occurred processing WSGI script '/home/ > webapps/apache/tinygraph.wsgi'. > Traceback (most recent call last): >   File "/home/webapps/.virtualenvs/tinygraph/lib/python2.6/site- >

Get last object with certain value

2010-06-11 Thread Odd
I have these two rather simple models that looks something like this: class MyModel(models.Model): myName=models.CharField(max_length=60) class MyOtherModel(models.Model): myString=models.CharField(max_length=60) myModel=models.ForeignKey(MyModel) I will eventually have

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread bruno desthuilliers
On 10 juin, 23:18, rahul jain wrote: > HI Dan, > > Thanks for your response but that will not solve my problem. > > I am not splitting models. I am splitting actions I assume you mean "functions" ? > defined in the > models  across multiple files. (snip) > > But I

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread bruno desthuilliers
On 11 juin, 12:38, Scott Gould wrote: > Did you put Test1.py and Test2.py into a "models" directory where > models.py would normally be, and add an __initial__.py file to it? > s/__initial__/__init__/ -- You received this message because you are subscribed to the Google

Re: error: unsupported operand type(s) for *: 'Decimal' and 'float'

2010-06-11 Thread Dan Harris
That looks ok from a code readability point of view, however you will still need to cast the form values to float or cast the float values (i.e. pow(2,2) and pow(2*math.pi*v,2) to Decimals otherwise will you will get an UnsupportedOperation exception. Dan Harris dih0...@gmail.com On Jun 11, 6:58 

Re: annotate with query set for distinct values

2010-06-11 Thread Scott Gould
It's not really a matter of "working around" it. Your .xxx method/ property is an attribute of the object. What you evidently want from the database is *not* a list of those objects, but rather a summary representation of them. Trying to apply your .xxx is meaningless as you don't have a discrete

Re: How to serve a static html file instead of rendering it as a template.

2010-06-11 Thread Antoni Aloy
Just modify your server configuration to directly serve the folder and do not sent it to django. It's the same you'll do for media files. Hope it helps! -- Antoni Aloy López Blog: http://trespams.com Site: http://apsl.net -- You received this message because you are subscribed to the Google

Re: error: unsupported operand type(s) for *: 'Decimal' and 'float'

2010-06-11 Thread Waleria
Dan, Do you speak for me to do this? for the example... http://paste.pocoo.org/show/224233 On 10 jun, 16:51, felix wrote: > use > > float( form.cleaned_data['a'] ) > > etc > > also, when retreiving the field from the db it will be a Decimal > object and needs to be

Re: not able to recognize non-default python files in app + project directory

2010-06-11 Thread Scott Gould
Did you put Test1.py and Test2.py into a "models" directory where models.py would normally be, and add an __initial__.py file to it? On Jun 10, 5:18 pm, rahul jain wrote: > HI Dan, > > Thanks for your response but that will not solve my problem. > > I am not splitting

Re: syncdb always indicates there are no fixtures

2010-06-11 Thread Alexandre González
I have a XML fixture with the language codes if you need it: http://pastebin.com/U4cAxXzY On Fri, Jun 11, 2010 at 12:19, tsmets wrote: > The problem was just the naming convention ... > They should have been named initial_data.json as mentionned in the URL > provided by

Re: syncdb always indicates there are no fixtures

2010-06-11 Thread tsmets
The problem was just the naming convention ... They should have been named initial_data.json as mentionned in the URL provided by Xavier. Any help on how to run python scripts directly to create my data sets ? What I do now is fine but could be better automated ? [code] from

Re: syncdb always indicates there are no fixtures

2010-06-11 Thread Alexandre González
¿Are you setting the variable FIXTURES_DIR in settings.py? On Fri, Jun 11, 2010 at 12:03, Kenneth Gonsalves wrote: > On Friday 11 June 2010 14:20:59 tsmets wrote: > > But I have json's files in multiple "fixtures" directories. > > [code] > >

ManyToMany autocomplete field and large amounts of autocomplete data

2010-06-11 Thread akaariai
Hello all, I am looking for an m2m autocomplete field which should have the following characteristics: 1. It should not at any point execute choices.all(). I have about 2 choices, so this will be a performance killer. 2. It should allow the user to type in some text, and select from a list

Re: syncdb always indicates there are no fixtures

2010-06-11 Thread Xavier Ordoquy
Hello, Fixtures are described in the documentation, especially there: http://docs.djangoproject.com/en/dev/howto/initial-data/#automatically-loading-initial-data-fixtures You have to follow the name convention to get them automatically loaded. Regards, Xavier. -- You received this message

Re: How to serve a static html file instead of rendering it as a template.

2010-06-11 Thread tsmets
I think it is all explained in here : http://docs.djangoproject.com/en/dev/howto/static-files/ As mentionned by every body around... It is ok in DEV but ... you should not do so in other environment. \T, On Jun 11, 8:12 am, lalaba wrote: > Hi all, > I am wondering how I

syncdb always indicates there are no fixtures

2010-06-11 Thread tsmets
When I run the syncdb : [code] Thomas-SMETSs-MacBook-Pro:sportotop tsmets$ ./manage.py syncdb Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating

Re: How to serve a static html file instead of rendering it as a template.

2010-06-11 Thread Daniel Roseman
On Jun 11, 7:12 am, lalaba wrote: > Hi all, > I am wondering how I can serve an html file without having to have > Django think it's a template file. > > In my html file, because there are markups that confuse Django, I'd > like to serve it as it is. I tried to read the html

Re: PendingDeprecationWarning during tests

2010-06-11 Thread Bzyczek
Thank you very much to make it clear for me. Regards Michal On 11 čvn, 02:26, Russell Keith-Magee wrote: > On Thu, Jun 10, 2010 at 9:05 PM, Plovarna wrote: > > Hello, > > I recently migrated from Django 1.1.2 to 1.2.1. When I run my test now, I > >

How to serve a static html file instead of rendering it as a template.

2010-06-11 Thread lalaba
Hi all, I am wondering how I can serve an html file without having to have Django think it's a template file. In my html file, because there are markups that confuse Django, I'd like to serve it as it is. I tried to read the html file directly into Django, and use HttpRespont(htmlText) to get

Re: Error I continue to get

2010-06-11 Thread Kenneth Gonsalves
On Friday 11 June 2010 12:05:50 Sam Lai wrote: > That error message looks like Windows to me. try adding the word > python at the start of that command. > yes, it did not look like a linux error message - although last time I looked windows would say 'bad command or file name' -- Regards

Re: Error I continue to get

2010-06-11 Thread Sam Lai
That error message looks like Windows to me. try adding the word python at the start of that command. If you are indeed on Windows, how did you install Python? The easiest one I've used is the ActiveState's ActivePython distribution for Windows; sets everything up properly, including proper file

Re: unable to download django

2010-06-11 Thread Kenneth Gonsalves
On Friday 11 June 2010 00:32:38 JRMAbock wrote: > I did finally get Django 1.2.1 downloaded but now it wont install. > what do you mean by 'won't install'? all you need to do is symlink django to the site-packages directory and symlink django-admin.py to somewhere in your path and you are done