Re: Missing attribute on User

2009-11-23 Thread Hanne Moa
On Mon, Nov 23, 2009 at 00:46, Russell Keith-Magee wrote: > On Mon, Nov 23, 2009 at 1:59 AM, Hanne Moa wrote: >> I have models M, N, which both have a foreignkey to User. When in the >> shell/runserver, User has attributes for both M and N, but in a >> batchfile ($ DJANGO_SETTINGS_MODULE=settings

how to symlink to django-admin.py from some place on path?????.

2009-11-23 Thread ccl4r
Hello, I'm tryin to install django on my windows machine, but I got stuck in the followin line "Consider symlinking to django-admin.py from some place on your path, such as /usr/local/bin." I'm not too techno- savvy...can someone point me in the right direction as to what that means and/or how I g

Re: Is there a way to integrate php to a django app?

2009-11-23 Thread GreatEntrepreneur
HI! I am also really wondering this. Cuz our project is not started yet and we haven't decided which framework we will use. But I wanna develop certain part like login or bulletin board with DJango before actual project starts. So, Even though later my supervisor develops php or jsp for whole w

Re: Missing attribute on User

2009-11-23 Thread Daniel Roseman
On Nov 23, 8:34 am, Hanne Moa wrote: > On Mon, Nov 23, 2009 at 00:46, Russell Keith-Magee > > > > > > wrote: > > On Mon, Nov 23, 2009 at 1:59 AM, Hanne Moa wrote: > >> I have models M, N, which both have a foreignkey to User. When in the > >> shell/runserver, User has attributes for both M and N

Re: has_delete_permission not called in an admin template?

2009-11-23 Thread rd-london
OK, so my conclusion having examined the code listed at http://bit.ly/7ZrKHl is that my solution is thread-safe. There's no if...else... type logic happening in my solution so should be fine. R On Nov 20, 5:22 pm, rd-london wrote: > And ... yes there does seem to be a better way. > > Define ow

Search by omitting special characters

2009-11-23 Thread leppy
Hi all, I have a TextFeild() in my application for storing addresses. It contains address as comma separated, or space separated, or with linefeed characters. When I try to search the field using 'icontains' by giving address as comma separated value, I am getting a null query set. I am getting a

Re: time date formatting

2009-11-23 Thread David De La Harpe Golden
matches wrote: > If I want to format the current datetime for an rss feed, I do: > > {% now "r" %} > > I want to format a date the same way coming from a DB in this format > "2009-11-18 08:00:00" > > Is there a way to format it with that same "r" format from a template > level? > > This clearly

Re: Shortcut to create and update a model object?

2009-11-23 Thread Daniel Roseman
On Nov 20, 8:31 am, "Boris Schaeling" wrote: > Is there a shortcut to create and update a model object from a form? For   > example I'd like to write something like: > > MyModel.objects.create(mymodel_form.cleaned_data) > > or > > model_obj = get_object_or_404(MyModel, pk=id) > model_obj.update(my

form fields slicing

2009-11-23 Thread gentlestone
why this piece of code doesn't work? {% for field in form|slice:":2" %} the result is iterating over all fields, not just the first two fields -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@go

Re: how to symlink to django-admin.py from some place on path?????.

2009-11-23 Thread Tim Chase
> I'm tryin to install django on my windows machine, but I got stuck in > the followin line "Consider symlinking to django-admin.py from some > place on your path, such as /usr/local/bin." I'm not too techno- > savvy...can someone point me in the right direction as to what that > means and/or how

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-23 Thread Matt Schinckel
On Nov 20, 7:52 pm, leoz01 wrote: > I think the easiest way is to make your own widget or otherwise you > can make your own form field. > > On 19 nov, 10:19, Benjamin Wolf wrote: > > > > > Hello, > > > I'm using Django's form and ModelMultipleChoiceField. > > ModelMultipleChoiceField produces a s

Re: form fields slicing

2009-11-23 Thread Doug Blank
On Mon, Nov 23, 2009 at 7:16 AM, gentlestone wrote: > why this piece of code doesn't work? > > {% for field in form|slice:":2" %} > > the result is iterating over all fields, not just the first two fields Perhaps break this up into two parts? {% with form|slice:":2" as formslice %} (% for fi

Count by date

2009-11-23 Thread Simon
Hi all, I am sure this must be a real noob question as it's so easy to do in SQL. I am trying to replicate something like the following in Django: SELECT DATE(created) AS created_day, COUNT(id) AS NumberOf FROM my_table GROUP BY created_day Effectively, all I want to do is a count grouped by

Re: Count by date

2009-11-23 Thread Martin Ostrovsky
You can limit your search by year, month or day. See http://docs.djangoproject.com/en/dev/ref/models/querysets/#year On Nov 20, 1:59 pm, Simon wrote: > Hi all, > > I am sure this must be a real noob question as it's so easy to do in > SQL. > I am trying to replicate something like the following

Re: Model inheritance - filtering base model only

2009-11-23 Thread lfrodrigues
I guess this solution works but for +50 the performance should be terrible... Shouldn't django have some option for this? On 23 Nov, 04:53, Preston Holmes wrote: > Perhaps there is a more efficient way, but in my quick test, one can't > filter() a queryset based on __class__ of the model, bu

add permission by name?

2009-11-23 Thread Adonis
Hi, I have been going through the permission documentation and i know i can assign users with permissions like this, * request.user.user_permissions.add(1) * But having 100 or more permissions i find this method a bit weird. Is not there a way to say, * request.user.user_permissions.add('auth.d

accessing pk of an existing object in ModelForm

2009-11-23 Thread hg7581
Hello there, For doing some sanity checks, I need the primary key (pk) of an (already existing) object in a ModelForm. What works for me in the meantime, ist the following (admin interface): class NF(ModelForm): def __init__(self,*args,**kwargs): self._args = args self._kwargs = kwargs

Re: accessing pk of an existing object in ModelForm

2009-11-23 Thread Daniel Roseman
On Nov 23, 2:57 pm, hg7581 wrote: > Hello there, > For doing some sanity checks, I need the primary key (pk) of an > (already existing) object in a ModelForm. > > What works for me in the meantime, ist the following (admin interface): > > class NF(ModelForm): > def __init__(self,*args,**kwargs): >

Re: Model inheritance - filtering base model only

2009-11-23 Thread Doug Blank
On Mon, Nov 23, 2009 at 9:09 AM, lfrodrigues wrote: > I guess this solution works but for +50 the performance should be > terrible... > > Shouldn't django have some option for this? Could you set a field's value which is true for one, and false for the other? Otherwise, could you just have tw

Re: accessing pk of an existing object in ModelForm

2009-11-23 Thread Gregor Kling
Daniel Roseman wrote: > On Nov 23, 2:57 pm, hg7581 wrote: > >> Hello there, >> For doing some sanity checks, I need the primary key (pk) of an >> (already existing) object in a ModelForm. >> >> What works for me in the meantime, ist the following (admin interface): >> >> class NF(ModelForm): >>

Re: form fields slicing

2009-11-23 Thread gentlestone
the same result :( On 23. Nov, 13:47 h., Doug Blank wrote: > On Mon, Nov 23, 2009 at 7:16 AM, gentlestone wrote: > > why this piece of code doesn't work? > > > {% for field in form|slice:":2" %} > > > the result is iterating over all fields, not just the first two fields > > Perhaps break this u

Re: how to symlink to django-admin.py from some place on path?????.

2009-11-23 Thread Bill Freeman
Nice cheat sheet, but I'm not sure that it helps our Windows user. I believe, that on windows, you can check the path by, at a command, or more likely, cmd, prompt, typing: echo %PATH% It's actually set, and you can check it in, the my computer properties tool. That is, right click on my co

Re: Is there a way to integrate php to a django app?

2009-11-23 Thread Alex Robbins
Great, If you want to get any sort of meaningful feedback you are going to have to be much more specific when you say integrate. Honestly, this type of post is normally just ignored because no one really knows what you are talking about. You only get (good) feedback if you ask good questions. Can

Re: form fields slicing

2009-11-23 Thread Bill Freeman
Possibly the form class is not written to support slicing. Supporting itteration only requires methods for __iter__() and next(). Slicing, like indexing requires implementation of __getitem__(), and for slicing to work, this method must check for receiving a 'slice' object as an index. Since mos

Why are collapsed fieldsets expanded on submit in the admin?

2009-11-23 Thread Benjamin Wohlwend
Hi, currently, when a form in the admin has collapsed fieldsets, those fieldsets are expanded on submit. As I find this rather distracting and couldn't find an explanation why this should be desired behavior, I suspected that this is probably a hard to find bug somewhere in between CSS, HTML and D

Avoiding MIME_BASE64_TEXT SpamAssassin Test when sending Email From Django?

2009-11-23 Thread rmschne
I'm using Django's email sending functions (http:// docs.djangoproject.com/en/dev/topics/email/#topics-email) to send mail. I construct the simple HTML mail with a small bit of Python code which is based on data from a database accessed via Django and using a Django template to construct the html

Filtering using several parameters

2009-11-23 Thread Aizen
Hi, I'd like to implement filtering for my app...currently, the filtering I have is stateless and so I can't add onto whatever value the user last selected. I've also implemented each filter separately, so I'd like to know how I can condense the five filters into one. The code for my filters is

Re: how to symlink to django-admin.py from some place on path?????.

2009-11-23 Thread Ken MacDonald
Actually, ".py" or any other extension can become an executable type by defining the extension via the commands "assoc" and "ftype". I believe that Python installation on Windows probably does something like this, as any of my "xxx.py" files (and Django-supplied files such as django-admin.py and ma

Re: Filtering using several parameters

2009-11-23 Thread Preston Holmes
On Nov 23, 8:51 am, Aizen wrote: > Hi, > > I'd like to implement filtering for my app...currently, the filtering > I have is stateless and so I can't add onto whatever value the user > last selected.  I've also implemented each filter separately, so I'd > like to know how I can condense the five

[django-ajax-selects] Using ajax-selects on GenericStackedInline

2009-11-23 Thread eka
Been looking at http://code.google.com/p/django-ajax-selects/ and seems to be good. One thing though is I don't seem to understand if I can apply that on a GenericStackedInline. Any tip is appreciated. Regards Eka -- You received this message because you are subscribed to the Google Groups "Dj

Re: Helsinki area djangonauts: Let's meet up

2009-11-23 Thread Jukka Välimaa
Hi all, The meet-up was a success, and we had good time. At the meet-up we decided to set up a group for djangonauts in Finland, so that it won't be necessary to spam django-users with local stuff any more. So, if you're a djangonaut living in Finland, or otherwise interested, do join up

Big issue serving big files through a view

2009-11-23 Thread Adrián Ribao
Hello, I have created a website where you can buy and download some files. For security reasons all the files are served through a view, where comprobations are made in order to assure that the user bought the product. The problem is that the files are at least 400Mb and some of them are nearly 1

Re: Application scope variable

2009-11-23 Thread Christophe Pettus
On Nov 22, 2009, at 9:58 PM, aurphir wrote: > How can I have an application scope variable which should be loaded > everytime the app starts app, be in memory and accessible by all until > the app stops. I also forgot to mention: If the variable is more or less read-only, and does not need to p

Re: Big issue serving big files through a view

2009-11-23 Thread Javier Guerra
On Mon, Nov 23, 2009 at 12:18 PM, Adrián Ribao wrote: > The problem is that the files are at least 400Mb and some of them are > nearly 1Gb. Using this view is inefficient since all the content is > loaded into memory and it kills the server: > > ... > > How could I solve this problem? keep y

Re: Big issue serving big files through a view

2009-11-23 Thread Benjamin Wohlwend
Hi Adrian, if you use Apache, you can use mod_xsendfile[1] (other servers have similar functionalities). Then you write somethink like this in your view: import mimetypes [...] mimetype, encoding = mimetypes.guess_type(path) response = HttpResponse("", content_type=mimetype) r

Re: Filtering using several parameters

2009-11-23 Thread Aizen
I'd already looked at django-filter...the implementation of this is not how I'd like to do it in my app. The filters are based on a certain year, make, model, colour, or body style. So if the user selects 2009, all vehicle records in the year 2009 are displayed. Next, if the user selects Acura, a

Re: Big issue serving big files through a view

2009-11-23 Thread Bill Freeman
1. You could read (and thus write) in smaller chunks, by giving read() an argument indicating the number of bytes to read: f = open(file) # The mode 'r' is default for buf in read(1024*32): response.write(buf) f.close() 2. You could, instead, let Apache serve the files in encrypte

Re: Big issue serving big files through a view

2009-11-23 Thread Adrián Ribao
I have implemented something included in django: from django.core.servers.basehttp import FileWrapper wrapper = FileWrapper(file(filepath)) response = HttpResponse(wrapper, mimetype=type) It works great, but anyway I'm gonna study your solutions. Which would you recommend me? Regards, Adrian.

postgresql errors (works in sqlite)

2009-11-23 Thread Some Guy
Hi, I was switching from sqlite3 to postgres, the data was imported ok. But now certain view queries are failing. i.e. counts[i] = Submission.objects.all().filter(status__exact=i).count() fails with ... File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", line 2369, in execute_

Re: postgresql errors (works in sqlite)

2009-11-23 Thread Bill Freeman
counts[i] = Submission.objects.all().filter(status__exact=str(i)).count() If you really intended status to be an integer, you might prefer to alter your table to make the column the right type. The alter table command required is beyond my sql confidence. Older postgresql and lots of other datab

Re: postgresql errors (works in sqlite)

2009-11-23 Thread Some Guy
gah, after a few hours of fighting with postgres, I missed that somehow, duh. I thought I had made it an int, sqlite3 was fixing it for me. thanks for the reply. On Nov 23, 10:35 am, Bill Freeman wrote: > counts[i] = Submission.objects.all().filter(status__exact=str(i)).count() > > If you really

Re: Model inheritance - filtering base model only

2009-11-23 Thread esatterwh...@wi.rr.com
a simple solution would be to put pass the contentype id and object id around in your url scheme domain.com/ct_id-object_id/ from there you can get the content type, which will be able to tell you the model, type, and give you the object. type = ContentType.objects.get(pk=ct_id) model =

Configuring a multiselect field in django admin

2009-11-23 Thread rc
I am fairly new to Django and I am trying to get a few things working in Django Admin. I have the models shown below. I have a profile table and a test table. I have a joining table called testsuite which allows me to map multiple tests to a profile. This all works fine, but in the admin part I ha

url import causing strange errors

2009-11-23 Thread neridaj
I've noticed that sometimes errors in my url conf will cause strange unrelated errors that have sent me down paths that don't need to be followed because it's a simple typo. I can't seem to find it here but maybe I need another set of eyes on it. (r'^projects/', include('projects.urls.projects

Re: url import causing strange errors

2009-11-23 Thread neridaj
I keep getting these errors but the module is right where it should be. Exception Type: ImportError Exception Value:No module named models Exception Location: /Users/username/django-projects/mysite.com/mysite/ projects/urls/projects.py in , line 2 On Nov 23, 11:46 am, neridaj

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-23 Thread aa56280
leoz01, Django comes with a widget for precisely this use case (check link above). Creating your own would be a complete waste of time. On Nov 20, 3:52 am, leoz01 wrote: > I think the easiest way is to make your own widget or otherwise you > can make your own form field. > > On 19 nov, 10:19, Ben

Designing base template - how to include media properly?

2009-11-23 Thread Todd Blanchard
I've read this: http://docs.djangoproject.com/en/dev/topics/forms/media/ Nifty. Now, how exactly do I make sure that the media urls get spewed properly into the head section of the page? This is apparently omitted everywhere I've looked. The admin template seems to pull it off properly but

Autocomplete for Generic Foreign Keys

2009-11-23 Thread eka
Hi, Is there an autocomplete solution for Generic Foreign Keys? Found this: http://code.djangoproject.com/wiki/AutoCompleteSolutions But they don't work. Regards -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: url import causing strange errors

2009-11-23 Thread Karen Tracey
On Mon, Nov 23, 2009 at 2:46 PM, neridaj wrote: > I've noticed that sometimes errors in my url conf will cause strange > unrelated errors that have sent me down paths that don't need to be > followed because it's a simple typo. I can't seem to find it here but > maybe I need another set of eyes o

Re: Designing base template - how to include media properly?

2009-11-23 Thread Mark (Nosrednakram)
Hello, I have something like the following in my generic genericform.html. I think this is what you're looking for if not hope you find a better answer. The extramedia block is back in my base.html template and my form template extends it. I'm not sure if it's in the admin base.html but you can

Re: Autocomplete for Generic Foreign Keys

2009-11-23 Thread Tim Valenta
What's the context, exactly? When used as an inline, the Generic- family isn't any different than a normal inline. I'm not sure why you specify that you're looking for a solution for *Generic* foreign keys. If you register a generic model directly to the admin, it gets kind of kooky, so is that

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-23 Thread Tim Valenta
That widget doesn't seem to look right on *any* browser. It's got this weird step-like appearance. Firefox is the only browser where it appears even close to acceptable. I might be submitting a patch for the CSS soon... It's horrible. On Nov 23, 1:14 pm, aa56280 wrote: > leoz01, Django comes

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-23 Thread Tim Valenta
Actually-- quick followup: The widget looks alright if you haven't got the 'aligned' css class on the fieldset. But if you do, watch out :P On Nov 23, 4:20 pm, Tim Valenta wrote: > That widget doesn't seem to look right on *any* browser.  It's got > this weird step-like appearance.  Firefox is

Form validation: Add at least one item to inline model

2009-11-23 Thread Brandon Taylor
Hi everyone, I need to validate that at lease one item has been added to an inline model in Django admin. I'm not quite sure where to put this validation...can someone help me out? TIA, Brandon -- You received this message because you are subscribed to the Google Groups "Django users" group. T

Re: Forms ModelMultipleChoiceField with checkboxes?

2009-11-23 Thread Benjamin Wolf
Hi there, very nice, the CheckboxSelectMultiple is what I want. But one thing: The default rendering of the checkboxes is Lagerbevorratung it would be great if I could display the input-element outside of the label-tag. Perhaps it is possible to iterate over the options of the CheckboxS

Re: url import causing strange errors

2009-11-23 Thread neridaj
I don't see the difference between how the urls are setup for my blog app and my projects app: blog/ __init__.py admin.py feeds.py models.py views.py urls/ __init__.py categories.py entries.py links.py tags.py projects/ __init__.

Re: url import causing strange errors

2009-11-23 Thread Karen Tracey
On Mon, Nov 23, 2009 at 8:21 PM, neridaj wrote: > I don't see the difference between how the urls are setup for my blog > app and my projects app: > > blog/ >__init__.py >admin.py >feeds.py >models.py >views.py >urls/ >__init__.py >categories.py >en

having multiple organizations use the same admin?

2009-11-23 Thread django_jedi
Hi All, I'd like to get an opinion from the django community on this one. Let's say I'm considering using a django app to be used by several counterpart organizations who cover different geographic regions. The sites could share content from the app, such as news, but they would each have separat

Re: having multiple organizations use the same admin?

2009-11-23 Thread django_jedi
Did I say option "B"? I meant option 2. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com

when my url contains utf-8 characters such as chinese, it's occurs an UnicodeEncodeError

2009-11-23 Thread VespertineR Lau
when my url contains utf-8 characters such as chinese, it's occurs an UnicodeEncodeError: UnicodeEncodeError at /upload/snap/屏幕快照_2009-11-19_下午09.54.12.png 'ascii' codec can't encode characters in position 39-42: ordinal not in range(128) Request Method: GET Request URL: http://192.16

manage.py sqlall output color

2009-11-23 Thread Mark H. Nichols
All - Working on Mac OS X I have my Terminal background color set to a dark blue. I've already added color settings to my .profile to provide enough contrast to view man page output, like so: # Color man pages: export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking export LESS_TERMCAP_md=$'\

Django with GXmlHttp

2009-11-23 Thread 504Django
There seems to be a dearth of examples illustrating best practices in deploying Google Maps with Django. Common recommendations are to use GeoDjango. Of course, it doesn't have to be Google Maps. It could be OpenSteetMap, Yahoo Maps, or some other mapping API. Not necessarily related, there are

Re: when my url contains utf-8 characters such as chinese, it's occurs an UnicodeEncodeError

2009-11-23 Thread Karen Tracey
2009/11/23 VespertineR Lau > when my url contains utf-8 characters such as chinese, it's occurs an > UnicodeEncodeError: > > [snip] > Traceback: > File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" > in get_response > 92. response = callback(request, *callback_a

Re: Form validation: Add at least one item to inline model

2009-11-23 Thread Brandon Taylor
http://wadofstuff.blogspot.com/2009/08/requiring-at-least-one-inline-formset.html On Nov 23, 6:06 pm, Brandon Taylor wrote: > Hi everyone, > > I need to validate that at lease one item has been added to an inline > model in Django admin. I'm not quite sure where to put this > validation...can som

Re: manage.py sqlall output color

2009-11-23 Thread Russell Keith-Magee
On Tue, Nov 24, 2009 at 11:53 AM, Mark H. Nichols wrote: > All - > > Working on Mac OS X I have my Terminal background color set to a dark blue. > I've already added color settings to my .profile to provide enough contrast > to view man page output, like so: > > # Color man pages: > export LESS_

Can't get form to update, rather than insert

2009-11-23 Thread Nick Arnett
I have a form that I've tried creating a couple of ways, including as a ModelForm, which doesn't seem to want to perform an UPDATE operation. I'm hoping for some help here... If I create it as a ModelForm, it doesn't validate, I'm guessing because the form doesn't include the foreign keys in the m

Re: Search by omitting special characters

2009-11-23 Thread jai_python
HI Leepy, Even am also got stuck with the same issue. Did you find any solution? I want to search content inside TEXTFEILD without any condition like (comma, line break, space)Can anyone here to help me out to solve this issue. Thanks & Regards, Jai Python On Nov 23, 4:15 pm, leppy wrote: >

string-based fields and null

2009-11-23 Thread chefsmart
The Django docs suggest "Avoid using null on string-based fields such as CharField and TextField unless you have an excellent reason." ImageField, EmailField, FileField, FilePathField, IPAddressField, SlugField, URLField, XMLField are also a string-based fields at the db level, so am I right in as

Re: url import causing strange errors

2009-11-23 Thread neridaj
I changed my app name, model names, and url names to the following and still get the error: project/ __init__.py admin.py models.py views.py urls/ __init__.py web.py mysite/ urls.py (r'^sites/', include('project.urls.web')), project/ urls/

Serving admin media files

2009-11-23 Thread Oleg Oltar
Hi I am trying to serve static files from another domain (sub domain of current domain). To serve all media files I used this settings: MEDIA_URL = 'http://media.bud-inform.co.ua/' So when in template I used {{ MEDIA_URL }} it was replace with the setting above. Now I am trying to serv

Re: form fields slicing

2009-11-23 Thread gentlestone
"it's cheap enough to make such a list (preferably in your view function)" thx, it's easy and simple - good idea On 23. Nov, 16:44 h., Bill Freeman wrote: > Possibly the form class is not written to support slicing.  Supporting > itteration only > requires methods for __iter__() and next().  Sli