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().  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 most folks probably can't think of a good
> use for slicing here,
> the maintainers probably just haven't implemented slicing.
>
> Since a list of fields is just a list of references, and doesn't
> involve actually copying
> the fields, it's cheap enough to make such a list (preferably in your
> view function),
> pass that, and slice it.  (lists do, of course, implement slicing.)
> Something at least
> that complicated would need to be going on inside the code that would 
> implement
> slicing on the form anyway, so this shouldn't have a negative
> performance impact.
>
> Bill
>
> On Mon, Nov 23, 2009 at 10:16 AM, gentlestone  wrote:
> > 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 up into two parts?
>
> >> {% with form|slice:":2" as formslice %}
> >>     (% for field in formslice %}
>
> >> -Doug
>
> >> > --
>
> >> > 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.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/django-users?hl=.
>
> > --
>
> > 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.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 serve admin
media files from the same subdomain, I changed the settings this way:

ADMIN_MEDIA_PREFIX = 'http://media.bud-inform.co.ua/admin%5Fmedia/',

and expected that all calls to media from my admin site will be made
to this url But actually it didn't work this way, I still see
paths to CSS made as following:

http://bud-inform.co.ua/media/css/login.css

Could you suggest how to serve admin media files correctly

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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/
web.py

from django.conf.urls.defaults import *
from project.models import WebProject

web_project_info_dict = {
'queryset': WebProject.objects.all(),
}

urlpatterns = patterns('django.views.generic.list_detail',
(r'^$', 'object_list', web_project_info_dict),
(r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict),
)

On Nov 23, 5:32 pm, Karen Tracey  wrote:
> 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
> >        entries.py
> >        links.py
> >        tags.py
>
> I don't see a file blog/urls/blog.py in which there is a "from blog.models
> import something"
>
> > projects/
> >    __init__.py
> >    admin.py
> >    models.py
> >    tests.py
> >    urls/
> >        __init__.py
> >        projects.py
>
> The problem is the duplicate projects in projects/urls/projects.py combined
> with trying, in projects.py "from projects.models import something".  "from
> projects", inside projects.py, is going to look inside projects.py to
> satisfy the import.
>
> Karen

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 assuming that null=True is best avoided in
these case also, "unless you have an excellent reason."?

I am hoping Django has code to deal with the empty string value in
these fields. For example, I am hoping that Django understands that an
empty string in an ImageField means there is no corresponding image.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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:
> 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 address from requested url as 'testing, testing 1,
> testing 2.'
>
> i.e.,
>
> >>> ModelName.objects.filter(address__icontains=  'testing, testing 1, 
> >>> testing 2.')
> >>> []
>
> Getting [] since the address is being stored in the model  as
> u'testing,\r\ntesting 1,\r\ntesting 2.'
>
> How can I search address by omitting some special characters such as
> '\r\n', ',' etc. since I'm not sure how end users will add data via
> django admin page.
>
> Thanks in advance,
> Leppy.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 model (I haven't tried passing them in the form - that shouldn't be
necessary - but I probably will, next).  If I create a form from the POST
data, it complains that required fields are missing.

My reading of the docs is that if I supply the primary key and the row
exists, an UPDATE should happen, which won't care if required fields are
present or not (since I don't want to change those values).  But that's not
happening - no matter what I do, it seems to be generating an error that
indicates it is trying to create a new row with a duplicate ID.

Anybody have a working example of a form that updates, rather than inserts?
Oh, and forcing an update in the save method doesn't solve the problem.

I have no problem performing updates outside of the context of forms - I
just can't figure out how to get it to work with forms.

Thanks in advance,

Nick

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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_TERMCAP_mb=$'\E[01;31m'      # begin blinking
> export LESS_TERMCAP_md=$'\E[01;31m'      # begin bold
> export LESS_TERMCAP_me=$'\E[0m'          # end mode
> export LESS_TERMCAP_se=$'\E[0m'          # end standout-mode
> export LESS_TERMCAP_so=$'\E[01;44;33m'   # begin standout-mode - info box
> export LESS_TERMCAP_ue=$'\E[0m'          # end underline
> export LESS_TERMCAP_us=$'\E[01;32m'      # begin underline
>
> What I need now is color settings to make the sqlall output contrasty enough 
> as well. The default colors don't allow me to see the generated table names.
>
> It may be that there isn't an easy or convenient way to colorize the output 
> of manage.py commands, but I am hoping I'm not the only person wanting to 
> work with Django in a dark color console window.

Right now, there isn't any way to customize the colors that Django
uses. However, it has been a topic of discussion recently.

http://code.djangoproject.com/ticket/12112
http://groups.google.com/group/django-users/browse_thread/thread/ea3cd915067438ba

I'd like to see a solution to this; it's just waiting on an acceptable
solution and implementation.

Yours,
Russ Magee %-)

--

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




Re: 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 someone help me out?
>
> TIA,
> Brandon

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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_args,
> **callback_kwargs)
> File "/usr/lib/python2.4/site-packages/django/views/static.py" in
> serve
>  51. if os.path.isdir(fullpath):
>
> Exception Type: UnicodeEncodeError at /upload/snap/屏幕快照_2009-11-19_下午
> 09.54.12.png
> Exception Value: 'ascii' codec can't encode characters in position
> 39-42: ordinal not in range(128)
>
>
This generally indicates an incorrect LANG setting for Apache.  See:

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

Karen

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 also suggestions to use JQuery to
handle AJAX requests.

I'm trying to understand how to take the next step -- to make the
required GXmlHttp GET requests calling a Django view that returns
marker points, while not violating the RESTful nature of Django URLs.

What would be the recommendation?

To help the discussion along with an example, this might be the
implementation of a pure AJAX solution returning XML with a Get
request to a PHP page:

var request = GXmlHttp.create();
request.open('GET','query.php?var1=' + val1 + '=' + val1, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
if (request.status == 200) {
var xmlsource = request.responseXML;
var markers = 
xmlsource.documentElement.getElementsByTagName
("marker");
for (var i = 0; i < markers.length; i++) {
var lat = 
parseFloat(markers[i].getAttribute("lat"));
var lng = 
parseFloat(markers[i].getAttribute("lng"));
var latlng = new GLatLng(lat,lng);

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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=$'\E[01;31m'  # begin bold
export LESS_TERMCAP_me=$'\E[0m'  # end mode
export LESS_TERMCAP_se=$'\E[0m'  # end standout-mode 
export LESS_TERMCAP_so=$'\E[01;44;33m'   # begin standout-mode - info box   
   
export LESS_TERMCAP_ue=$'\E[0m'  # end underline
export LESS_TERMCAP_us=$'\E[01;32m'  # begin underline

What I need now is color settings to make the sqlall output contrasty enough as 
well. The default colors don't allow me to see the generated table names.

It may be that there isn't an easy or convenient way to colorize the output of 
manage.py commands, but I am hoping I'm not the only person wanting to work 
with Django in a dark color console window.

Thanks,
Mark

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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.168.10.220:8000/upload/snap/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7_2009-11-19_%E4%B8%8B%E5%8D%8809.54.12.png
Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode characters in position 39-42: ordinal not
in range(128)

Exception Location: /usr/lib/python2.4/site-packages/django/views/
static.py in serve, line 51
Python Executable:  /usr/local/bin/python
Python Version: 2.4.4
Python Path:['/home/vinnie/django/mysite', '/usr/lib/python24.zip',
'/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/
python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/local/lib/
python2.4/site-packages', '/usr/lib/python2.4/site-packages', '/usr/
lib/python2.4/site-packages/PIL', '/var/lib/python-support/python2.4']





Environment:

Request Method: GET
Request URL:
http://192.168.10.220:8000/upload/snap/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7_2009-11-19_%E4%B8%8B%E5%8D%8809.54.12.png
Django Version: 1.1.1
Python Version: 2.4.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'mysite.helloworld']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.4/site-packages/django/views/static.py" in
serve
  51. if os.path.isdir(fullpath):

Exception Type: UnicodeEncodeError at /upload/snap/屏幕快照_2009-11-19_下午
09.54.12.png
Exception Value: 'ascii' codec can't encode characters in position
39-42: ordinal not in range(128)









can anyone help~? thanks~ my wrong system setting or wrong django
setting~?

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=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 separate and distinct staffs who may or may not cooperate on
other matters.

I could:

1 - use a single django app (and admin) and let Org A's staff edit all
content, including that of Org B

2 - use a single app/admin but extend users and content so that Org A
staff could only access/view/edit their own content

3 - build separate django apps that talk to the same database and use
different SITE IDs to tag submitted content

4 - have completely separate apps/sites that use some sort of XML pull/
feed to grab data from the other site (this seems to defeat the whole
purpose of Django)

Have any of you ever done this sort of thing?

I'm leaning towards option B, but that seems to limit the ability for
an admin user to view/edit user accounts, since to give them access to
manipulating users would give them the ability to alter users from
other orgs, which may not be supported by a high enough level of trust
among the participating org's.

Thanks in advance.  I appreciate your thoughts.



--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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
>entries.py
>links.py
>tags.py
>
>
I don't see a file blog/urls/blog.py in which there is a "from blog.models
import something"


> projects/
>__init__.py
>admin.py
>models.py
>tests.py
>urls/
>__init__.py
>projects.py
>
>
The problem is the duplicate projects in projects/urls/projects.py combined
with trying, in projects.py "from projects.models import something".  "from
projects", inside projects.py, is going to look inside projects.py to
satisfy the import.

Karen

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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__.py
admin.py
models.py
tests.py
urls/
__init__.py
projects.py

On Nov 23, 1:38 pm, Karen Tracey  wrote:
> 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 on it.
>
> >    (r'^projects/', include('projects.urls.projects')),
>
> > # projects/urls/projects.py
>
> > from django.conf.urls.defaults import *
> > from projects.models import Project
>
> Your projects module (that contains urls and models and whatever) is hidden,
> for code inside projects.py by the projects.py module itself. THAT projects
> module does not have a submodule named models, so the import here will fail.
>
> Karen

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




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 
CheckboxSelectMultiple-Field in the template?

Thanks again,
greets b

Tim Valenta schrieb:
> 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 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 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, Benjamin Wolf  wrote:
 
> Hello,
>   
> I'm using Django's form and ModelMultipleChoiceField.
> ModelMultipleChoiceField produces a select list with multiple options.
> Is it possible to use
> checkboxesinstead?
>   
> Thanks,
> Greets Ben
>   
>
> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>   

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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.
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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 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 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, Benjamin Wolf  wrote:
>
> > > > Hello,
>
> > > > I'm using Django's form and ModelMultipleChoiceField.
> > > > ModelMultipleChoiceField produces a select list with multiple options.
> > > > Is it possible to use
> > > >checkboxesinstead?
>
> > > > Thanks,
> > > > Greets Ben

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 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, Benjamin Wolf  wrote:
>
> > > Hello,
>
> > > I'm using Django's form and ModelMultipleChoiceField.
> > > ModelMultipleChoiceField produces a select list with multiple options.
> > > Is it possible to use
> > >checkboxesinstead?
>
> > > Thanks,
> > > Greets Ben

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 what you're doing?

On Nov 23, 1:38 pm, eka  wrote:
> 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 to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 take a look at if for there media blocks I believe are
something like extrastyle etc...

{% block extramedia %}
 {% if forms %}
{% for form in forms %}
   {{ form.media }}
{% endfor %}
 {% else %}
   {{ form.media }}
 {% endif %}

Mark


On Nov 23, 1:31 pm, Todd Blanchard  wrote:
> 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 I cannot figure 
> out how.  Seems like I should be able to do something like
>
> 
> 
> {{ media }}  
> 
>
> but I cannot figure out exactly how to properly aggregate all the forms' 
> media's and get them spewed into the templates properly.
>
> -Todd

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 on it.
>
>(r'^projects/', include('projects.urls.projects')),
>
> # projects/urls/projects.py
>
> from django.conf.urls.defaults import *
> from projects.models import Project
>
>
Your projects module (that contains urls and models and whatever) is hidden,
for code inside projects.py by the projects.py module itself. THAT projects
module does not have a submodule named models, so the import here will fail.


Karen

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 I cannot figure 
out how.  Seems like I should be able to do something like



{{ media }}  


but I cannot figure out exactly how to properly aggregate all the forms' 
media's and get them spewed into the templates properly.

-Todd

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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, Benjamin Wolf  wrote:
>
> > Hello,
>
> > I'm using Django's form and ModelMultipleChoiceField.
> > ModelMultipleChoiceField produces a select list with multiple options.
> > Is it possible to use
> >checkboxesinstead?
>
> > Thanks,
> > Greets Ben

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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  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 on it.
>
>     (r'^projects/', include('projects.urls.projects')),
>
> # projects/urls/projects.py
>
> from django.conf.urls.defaults import *
> from projects.models import Project
>
> project_info_dict = {
>     'queryset': Project.objects.all(),
>
> }
>
> urlpatterns = patterns('django.views.generic.list_detail',
>     (r'^$', 'object_list', project_info_dict),
>     (r'^(?P[-\w]+)/$', 'object_detail', project_info_dict),
> )
>
> Thanks,
>
> J

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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')),

# projects/urls/projects.py

from django.conf.urls.defaults import *
from projects.models import Project

project_info_dict = {
'queryset': Project.objects.all(),
}

urlpatterns = patterns('django.views.generic.list_detail',
(r'^$', 'object_list', project_info_dict),
(r'^(?P[-\w]+)/$', 'object_detail', project_info_dict),
)


Thanks,

J

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 have to add one profile/test at a time. What I want to be able
to do is select a profile and select multiple tests and add them at
the same time. I would also like to be able to select a profile and
see the test already assigned to it and be able to edit them and add
or remove tests.
Is it possible to do this?

My admin file looks like this. Just the basic register lines.

---
Admin
---
from django.contrib import admin
from bisite.models import   Testcase, Testsuite, Profile, Source

admin.site.register(Profile)
admin.site.register(Source)
admin.site.register(Testcase)
admin.site.register(Testsuite)


---
Models
--

class Profile(models.Model):
profile_id = models.AutoField(primary_key=True)
profile_name = models.CharField(max_length=75)
description = models.CharField(max_length=1500, blank=True)
def __unicode__(self):
return self.profile_name
class Meta:
db_table = u'profile'

class Testcase(models.Model):
test_id = models.AutoField(primary_key=True)
test_name = models.CharField(max_length=300)
src = models.ForeignKey(Source, null=True, blank=True)
bitrate = models.IntegerField(null=True, blank=True)
test_type = models.CharField(max_length=300)
output_resolution = models.CharField(max_length=15, blank=True)
description = models.CharField(max_length=3000, blank=True)
ref_file = models.CharField(max_length=765, blank=True)
ref_encode_filesize = models.IntegerField(null=True, blank=True)
ref_y_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
ref_u_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
ref_v_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
ref_yuv_psnr = models.DecimalField(null=True, max_digits=7,
decimal_places=2, blank=True)
highmark_version = models.CharField(max_length=60, blank=True)
def __unicode__(self):
return self.test_name
class Meta:
db_table = u'testcase'

class Testsuite(models.Model):
testsuite_id = models.AutoField(primary_key=True)
profile = models.ForeignKey(Profile, related_name='profile')
test = models.ForeignKey(Testcase, related_name='test')
#def __unicode__(self):
#   return
self.testsuite_id
def __unicode__(self):
   return '%s,%s' % (self.profile, self.test)
class Meta:
db_table = u'testsuite'

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 = type.model_class()
obj = model.objects.get(pk=obj_id)

this would also cut down on the number of view functions you need to
write. It's a mini generic view for you app, just figure out a naming
convention for templates based on the model you have :

template = template_name or "appfolder/%s_detail.html" % type.model

you can have 1 url handle just about anything

Done and Done

On Nov 22, 6:32 pm, lfrodrigues  wrote:
> Hello,
>
> I have these models:
>
> class Player(models.Model):
>     .
>
> class PlayerM(Player):
>     ...
>
> If I do PlayerM.objects.all() e get all PlayerM objects and for
> Player.objects.all() I get all Player and PlayerM as expected.
>
> How can get only the objects of type Player (only retrieve the objects
> that were created with Player() constructor)?
>
> Regards,
>
> Luis

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 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 databases will automatically cast
> things that look like integers to integers if needed for comparison,
> but newer postgresql, and probably others, in time, require you to
> say what you mean, and this is probably a (tm) good thing, in that
> the automatic casting hides subtle bugs that are hard to find.
>
> Or you could downgrade postgresql if you like.  But eventually you're
> likely to want some new feature, so fixing your column seems to me
> the right thing.
>
> Bill
>
>
>
> On Mon, Nov 23, 2009 at 1:17 PM, Some Guy  wrote:
> > 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_sql
> > cursor.execute(sql, params)
>
> > ProgrammingError: operator does not exist: character varying = integer
> > LINE 1: ...ons_submission" WHERE "submissions_submission"."status" =
> > 0
> > ^
> > HINT: No operator matches the given name and argument type(s). You
> > might need to add explicit type casts.
>
> > using postgres 8.3. any advise would help. including up/downgrading
> > postgres (seems to be a lot of issues on the trac, is 8.3 even
> > supported?)
>
> > --
>
> > 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.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 databases will automatically cast
things that look like integers to integers if needed for comparison,
but newer postgresql, and probably others, in time, require you to
say what you mean, and this is probably a (tm) good thing, in that
the automatic casting hides subtle bugs that are hard to find.

Or you could downgrade postgresql if you like.  But eventually you're
likely to want some new feature, so fixing your column seems to me
the right thing.

Bill

On Mon, Nov 23, 2009 at 1:17 PM, Some Guy  wrote:
> 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_sql
> cursor.execute(sql, params)
>
> ProgrammingError: operator does not exist: character varying = integer
> LINE 1: ...ons_submission" WHERE "submissions_submission"."status" =
> 0
> ^
> HINT: No operator matches the given name and argument type(s). You
> might need to add explicit type casts.
>
> using postgres 8.3. any advise would help. including up/downgrading
> postgres (seems to be a lot of issues on the trac, is 8.3 even
> supported?)
>
> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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_sql
cursor.execute(sql, params)

ProgrammingError: operator does not exist: character varying = integer
LINE 1: ...ons_submission" WHERE "submissions_submission"."status" =
0
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.

using postgres 8.3. any advise would help. including up/downgrading
postgres (seems to be a lot of issues on the trac, is 8.3 even
supported?)

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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.


On 23 nov, 18:38, Bill Freeman  wrote:
> 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 encrypted form,
> and sell the
> user a decryption key.
>
> On Mon, Nov 23, 2009 at 12:18 PM, Adrián Ribao  wrote:
> > 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 1Gb. Using this view is inefficient since all the content is
> > loaded into memory and it kills the server:
>
> > type, encoding = mimetypes.guess_type(file)
> > name = os.path.basename(file)
> > response = HttpResponse(mimetype=type)
> > response['Content-Disposition'] = 'attachment; filename=%s' %
> > (smart_str(name),)
>
> > f = open(file, 'r')
> > response.write(f.read())
> > f.close()
> > return response
>
> > How could I solve this problem?
>
> > Regards,
>
> > Adrian.
>
> > --
>
> > 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.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 encrypted form,
and sell the
user a decryption key.

On Mon, Nov 23, 2009 at 12:18 PM, Adrián Ribao  wrote:
> 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 1Gb. Using this view is inefficient since all the content is
> loaded into memory and it kills the server:
>
> type, encoding = mimetypes.guess_type(file)
> name = os.path.basename(file)
> response = HttpResponse(mimetype=type)
> response['Content-Disposition'] = 'attachment; filename=%s' %
> (smart_str(name),)
>
> f = open(file, 'r')
> response.write(f.read())
> f.close()
> return response
>
> How could I solve this problem?
>
> Regards,
>
> Adrian.
>
> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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, all the records in the year 2009 and
make Acura are displayed...I think you get my point here.

I'm also looking for a way of factoring out the query building code
out of the views and chain them together in any view as you've seen.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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)
response['X-Sendfile'] = absolute_path_to_file
response['Content-Disposition'] = 'attachment; file=%s' %
os.path.split(path)[-1]
return response

Apache will see the X-Sendfile header and handle the rest for you.

If this is a high volume site, you'd probably better use a lightweight
reverse proxy like nginx[1], [2].

Regards,
Benjamin

[1] http://wiki.nginx.org/Main
[2] http://wiki.nginx.org/NginxXSendfile

On 23 Nov., 18:18, Adrián Ribao  wrote:
> 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 1Gb. Using this view is inefficient since all the content is
> loaded into memory and it kills the server:
>
> type, encoding = mimetypes.guess_type(file)
> name = os.path.basename(file)
> response = HttpResponse(mimetype=type)
> response['Content-Disposition'] = 'attachment; filename=%s' %
> (smart_str(name),)
>
> f = open(file, 'r')
> response.write(f.read())
> f.close()
> return response
>
> How could I solve this problem?
>
> Regards,
>
> Adrian.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 your views doing all the needed checking; but replace the data
serving itself (everything from "f = open(..." until "return
response")  with an empty response that just sets the headers to make
your front web server do the serving itself.  Apache, lighttpd and
nginx (at least) have this capability, but using different headers.

-- 
Javier

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 persist across server restarts, consider storing  
it memcached instead of the database.

--
-- Christophe Pettus
   x...@thebuild.com

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 1Gb. Using this view is inefficient since all the content is
loaded into memory and it kills the server:

type, encoding = mimetypes.guess_type(file)
name = os.path.basename(file)
response = HttpResponse(mimetype=type)
response['Content-Disposition'] = 'attachment; filename=%s' %
(smart_str(name),)

f = open(file, 'r')
response.write(f.read())
f.close()
return response

How could I solve this problem?

Regards,

Adrian.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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
.

--Jukka

On Mon, Nov 9, 2009 at 11:25 AM, akaihola  wrote:

>
> Count me in. Also sent the message to three djangonauts I know who are
> not on djangopeople.
> --~--~-~--~~~---~--~~
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en
> -~--~~~~--~~--~--~---
>
>

--

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




[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 
"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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 filters into one.  

There are a couple of confounding points in your question.

First question is about combining your filters.  The solution there
seems to be to factor out your query building code out of your views
and return the the resulting queryset.  Then, these can be chained
together in any of your views just like any other queryset.

The other question seems to be about "refining" a filter?  That is
confining a filter operation to an existing found set, and have that
functionality spread across multiple requests.  You basically will
need to figure out a way to pass this along between requests, using
either hidden form fields, or session framework.

I started to work on adding this as a feature to Alex Gaynor's django-
filter, but got bogged down working out some details.  Either way you
should check out that project as it would at least make your existing
implementation easier.

http://github.com/alex/django-filter

-Preston

> The code
> for my filters is as follows:
>
> def year_filter(request, year):
>    vehicle_query = Vehicle.objects.filter(
>         common_vehicle__year__year__exact=year
>         ).exclude(status__status='Incoming')
>
>    vehicle_list = vehicle_query.order_by(
>         'common_vehicle__series__model__manufacturer__manufacturer',
>         'common_vehicle__series__model__model',
>         'common_vehicle__year'
>    )
>
>    vehicle = paginate(request, vehicle_list)
>
>    year_count = vehicle_query.order_by(
>         '-common_vehicle__year__year')
>         .values('common_vehicle__year__year')
>         .annotate(count=Count('id')
>    )
>    make_count = vehicle_query.order_by(
>       'common_vehicle__series__model__manufacturer__manufacturer')
>       .values
> ('common_vehicle__series__model__manufacturer__manufacturer')
>       .annotate(count=Count('id')
> )
>     style_count = vehicle_query.order_by(
>        'common_vehicle__body_style__style')
>        .values('common_vehicle__body_style__style')
>        .annotate(count=Count('id')
> )
>     color_count = vehicle_query.order_by(
>        'exterior_colour__exterior_colour')
>        .values('exterior_colour__exterior_colour')
>        .annotate(count=Count('id')
> )
>
>     return render_to_response('vehicles.html', {
>       'vehicle': vehicle,
>       'make_count': make_count,
>       'year_count': year_count,
>       'style_count': style_count,
>     })
>
> def make_filter(request, make):
>    vehicle_query = Vehicle.objects.filter(
>       common_vehicle__series__model__manufacturer__manufacturer=make)
>       .exclude(status__status='Incoming')
>
>    vehicle_list = vehicle_query.order_by(
>       'common_vehicle__series__model__manufacturer__manufacturer',
>       'common_vehicle__series__model__model',
>       'common_vehicle__year'
>    )
>
>    vehicle = paginate(request, vehicle_list)
>
>    year_count = vehicle_query.order_by(
>         '-common_vehicle__year__year')
>         .values('common_vehicle__year__year')
>         .annotate(count=Count('id')
>    )
>    make_count = vehicle_query.order_by(
>       'common_vehicle__series__model__manufacturer__manufacturer')
>       .values
> ('common_vehicle__series__model__manufacturer__manufacturer')
>       .annotate(count=Count('id')
>    )
>     style_count = vehicle_query.order_by(
>        'common_vehicle__body_style__style')
>        .values('common_vehicle__body_style__style')
>        .annotate(count=Count('id')
>     )
>     color_count = vehicle_query.order_by(
>        'exterior_colour__exterior_colour')
>        .values('exterior_colour__exterior_colour')
>        .annotate(count=Count('id')
>     )
>
>     return render_to_response('vehicles.html', {
>       'vehicle': vehicle,
>       'make_count': make_count,
>       'year_count': year_count,
>       'style_count': style_count,
>     })
>
> def series_filter(request, model):
>    vehicle_query = Vehicle.objects.filter(
>       common_vehicle__series__series=model)
>       .exclude(status__status='Incoming')
>
>    vehicle_list = vehicle_query.order_by(
>       'common_vehicle__series__series',
>       'common_vehicle__series__model__model',
>           'common_vehicle__year')
>
>    vehicle = paginate(request, vehicle_list)
>
>    year_count = vehicle_query.order_by(
>         '-common_vehicle__year__year')
>         .values('common_vehicle__year__year')
>         .annotate(count=Count('id')
>    )
>    make_count = vehicle_query.order_by(
>       'common_vehicle__series__model__manufacturer__manufacturer')
>       .values
> ('common_vehicle__series__model__manufacturer__manufacturer')
>       .annotate(count=Count('id')
>     )
>     style_count = 

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
manage.py) can be run from the command prompt directly, and include support
for command-line parameters as well. Looking at the output from "assoc",
you'll find that even ".bat" and ".exe" extensions are defined in this
manner.
Ken

But a bigger problem on Windows is that on windows .py files are not
> an executable type.
>

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 as follows:

def year_filter(request, year):
   vehicle_query = Vehicle.objects.filter(
common_vehicle__year__year__exact=year
).exclude(status__status='Incoming')

   vehicle_list = vehicle_query.order_by(
'common_vehicle__series__model__manufacturer__manufacturer',
'common_vehicle__series__model__model',
'common_vehicle__year'
   )

   vehicle = paginate(request, vehicle_list)

   year_count = vehicle_query.order_by(
'-common_vehicle__year__year')
.values('common_vehicle__year__year')
.annotate(count=Count('id')
   )
   make_count = vehicle_query.order_by(
  'common_vehicle__series__model__manufacturer__manufacturer')
  .values
('common_vehicle__series__model__manufacturer__manufacturer')
  .annotate(count=Count('id')
)
style_count = vehicle_query.order_by(
   'common_vehicle__body_style__style')
   .values('common_vehicle__body_style__style')
   .annotate(count=Count('id')
)
color_count = vehicle_query.order_by(
   'exterior_colour__exterior_colour')
   .values('exterior_colour__exterior_colour')
   .annotate(count=Count('id')
)

return render_to_response('vehicles.html', {
  'vehicle': vehicle,
  'make_count': make_count,
  'year_count': year_count,
  'style_count': style_count,
})

def make_filter(request, make):
   vehicle_query = Vehicle.objects.filter(
  common_vehicle__series__model__manufacturer__manufacturer=make)
  .exclude(status__status='Incoming')

   vehicle_list = vehicle_query.order_by(
  'common_vehicle__series__model__manufacturer__manufacturer',
  'common_vehicle__series__model__model',
  'common_vehicle__year'
   )

   vehicle = paginate(request, vehicle_list)

   year_count = vehicle_query.order_by(
'-common_vehicle__year__year')
.values('common_vehicle__year__year')
.annotate(count=Count('id')
   )
   make_count = vehicle_query.order_by(
  'common_vehicle__series__model__manufacturer__manufacturer')
  .values
('common_vehicle__series__model__manufacturer__manufacturer')
  .annotate(count=Count('id')
   )
style_count = vehicle_query.order_by(
   'common_vehicle__body_style__style')
   .values('common_vehicle__body_style__style')
   .annotate(count=Count('id')
)
color_count = vehicle_query.order_by(
   'exterior_colour__exterior_colour')
   .values('exterior_colour__exterior_colour')
   .annotate(count=Count('id')
)

return render_to_response('vehicles.html', {
  'vehicle': vehicle,
  'make_count': make_count,
  'year_count': year_count,
  'style_count': style_count,
})

def series_filter(request, model):
   vehicle_query = Vehicle.objects.filter(
  common_vehicle__series__series=model)
  .exclude(status__status='Incoming')

   vehicle_list = vehicle_query.order_by(
  'common_vehicle__series__series',
  'common_vehicle__series__model__model',
  'common_vehicle__year')

   vehicle = paginate(request, vehicle_list)

   year_count = vehicle_query.order_by(
'-common_vehicle__year__year')
.values('common_vehicle__year__year')
.annotate(count=Count('id')
   )
   make_count = vehicle_query.order_by(
  'common_vehicle__series__model__manufacturer__manufacturer')
  .values
('common_vehicle__series__model__manufacturer__manufacturer')
  .annotate(count=Count('id')
)
style_count = vehicle_query.order_by(
   'common_vehicle__body_style__style')
   .values('common_vehicle__body_style__style')
   .annotate(count=Count('id')
)
color_count = vehicle_query.order_by(
   'exterior_colour__exterior_colour')
   .values('exterior_colour__exterior_colour')
   .annotate(count=Count('id')
)

return render_to_response('vehicles.html', {
  'vehicle': vehicle,
  'make_count': make_count,
  'year_count': year_count,
  'style_count': style_count,
})


def body_filter(request, body):
   vehicle_query = Vehicle.objects.filter(
  common_vehicle__body_style__style=body)
  .exclude(status__status='Incoming')

   vehicle_list = vehicle_query.order_by(
  'common_vehicle__series__model__manufacturer__manufacturer',
  'common_vehicle__series__model__model',
  'common_vehicle__year'
)

   vehicle = paginate(request, vehicle_list)

   year_count = vehicle_query.order_by(
'-common_vehicle__year__year')
.values('common_vehicle__year__year')
.annotate(count=Count('id')
   )
   make_count = vehicle_query.order_by(
  'common_vehicle__series__model__manufacturer__manufacturer')
  .values

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 text.  I pass this text to
Django's email functions, e.g.

msg=EmailMessage(subject, html_content, from_email, [to])
msg.content_subtype="html"
msg.send

The mail goes just fine.  In testing I'm sending mail to myself.  My
own SpamAssassin filter is trapping the mail as "spam" !!
 --
--
1.7 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
2.8 MIME_BASE64_TEXT   RAW: Message text disguised using base64
encoding

I'm trying want to NOT send in base64 encoding so as to not attract
this SpamAssassin.  How when constructing the text for the mail in
Python/Django to avoid this?

I have nothing but text in the email.  The html is simple.  It has a
style sheet in the header.  The header looks like this:


   
   
   The Scottish Oil Club
   

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 Django's JavaScript code.

When I finally took a look at the code, I was quite surprised that
this isn't a bug, but a feature:

>if (collapsed_seen) {
>// Expand all collapsed fieldsets when form is submitted.
>addEvent(findForm(document.getElementsByTagName('fieldset')[0]), 
> 'submit', function() { CollapsedFieldsets.uncollapse_all(); });
>}

This code is in the admin since revision 96 [1]. But why? From a
technical view, both the client and the server couldn't care less if
the form fields are visible or not, they process them all the same.
Was it UI-motivated?

I, for one, find it quite disturbing that input fields appear all over
the place when I click submit, just to vanish moments later to be
replaced by a new page :)

Regards,
Benjamin

[1] 
http://code.djangoproject.com/browser/django/trunk/media/js/admin/CollapsedFieldsets.js?rev=96#L50

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 most folks probably can't think of a good
use for slicing here,
the maintainers probably just haven't implemented slicing.

Since a list of fields is just a list of references, and doesn't
involve actually copying
the fields, it's cheap enough to make such a list (preferably in your
view function),
pass that, and slice it.  (lists do, of course, implement slicing.)
Something at least
that complicated would need to be going on inside the code that would implement
slicing on the form anyway, so this shouldn't have a negative
performance impact.

Bill

On Mon, Nov 23, 2009 at 10:16 AM, gentlestone  wrote:
> 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 up into two parts?
>>
>> {% with form|slice:":2" as formslice %}
>>     (% for field in formslice %}
>>
>> -Doug
>>
>> > --
>>
>> > 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.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=.
>
> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 both django and php/jsp share a database? Sure. Databases can have
lots of connections, even from different programs.

Can a single server serve both php and python? Sure, although web
server optimization will be a little tricky.

However, as Juan said, using a whole different framework is probably
not worth it. Especially if you are only implementing the login and a
bulletin board. Getting the login/auth accounts to work on both PHP
and django will be far more work than implementing a bulletin board in
any sane web framework.

Hope that helps,
Alex





On Nov 20, 8:01 am, GreatEntrepreneur  wrote:
> 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
> website, my app will be well integrated?
>
> Let's say, my supervisor will develop php webframework, and my app
> should be worked on php webframework.
>
> Hm..just setup apache configs may solve my worry? :)
>
> Like Juan said, it looks possible. But I am not good at web
> programming yet.
>
> I will really appreciate if someone give me more detail info about how
> to integrate with php whatever webframework.
>
> Thanks in advance.!!

--

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




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 computer, choose properties.  (There's another way to get to
this, from the control
panel, I think, but I don't remember the details.)  On one of the tabs
there's a button labeled
something like "Advanced Settings", which opens a sub tool that lets
you set two lists from
which the path is made, one system wide, the other user specific.

I don't actually suggest adding the directory in which django-admin.py
exists on the path,
but you ought to have at least one directory on it with the philosophy
of the *nix /usr/local/bin,
that is, product installers don't know about it, and won't put stuff
there, or remove stuff there,
or replace stuff there.

Once you have such a directory, you could go to the effort of figuring
out how to make the
Windows equivalent of a symbolic link, but you can also just copy the
file (it's not very big).
One downside of this approach in general is that if you later upgrade
django, you have to
separately remember to re-copy this file, since the django installer
(or tarball or zip) doesn't
know about it.

But a bigger problem on Windows is that on windows .py files are not
an executable type.
They need to be run as an argument to the (appropriate version, should
you someday get
fancy and be developing different things using different versions of
python, or) python.exe
program.  Now, it does work when you double click on a .py file in the
GUI, because that
extension is registered with the GUI as being "opened" with
python.exe, but that registration
does not extend (unless things have changed) to where cmd.exe looks
for the programs that
you ask it to run.  And you need to run django-admin.py from the
command line so that you
can give it arguments, like "startproject" and "foo".

So what I would suggest is a batch file (the authorship of which is
beyond my current windows
chops), that you place in the above mentioned on the path directory, maybe named
'django-admin.bat', which, inside, invokes your choice, by using full
path, of python.exe, on,
again using full path, django-admin.py, and passing along (this is the
part that I don't know
how to do in a bat file) any arguments that were on the batch file's
command line as additional
arguments to python.exe, after the full path to django-admin.py .

Alternatively, starting a project is relatively rare, and it is the
only thing that I've needed
django-admin for.  Everything else can be done with manage.py, and you
should be cd'ed to
it's directory whenever using it anyway, so it's (relative) path
becomes trivial.  It still needs to
be an argument to python, though, rather than being the command itself.

(As an aside, the reason that this is all simpler on *nix is that any
file can be marked as an
executable, and if it is, the OS looks at the first two bytes in the
file, and if they are '#!', it treats
the first line of the file (which had better end with '\n', not '\r\n'
if your fond of editing stuff on
windows and running it on *nix) as a command to run instead, passing
the file itself to the
command being run.  Because most "interpreters", such a python, have
been arranged to
treat '#' as the beginning of a comment, this extra line does not confuse them.)

Bill

On Mon, Nov 23, 2009 at 7:40 AM, Tim Chase
 wrote:
>> 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 go about doing that???
>
> This assumes you're running a *nix-like OS instead of Windows
> (you can make links in Windows but it's a pain).
>
> Executive Cheat-code for the impatient:
> ===
>
>   bash$ ln -s /path/to/existing/django-admin.py
> /some/place/on/path/django-admin.py
>
>
>
> More detailed explanation:
> ==
> In most instances, the Django install doesn't drop its
> "django-admin.py" outside its own subdirectory.  This means that
> to run it, you have to specify its full path
>
>   bash$ /path/to/django-admin.py startproject foo
>
> If, however, it's on your path (the list of places your shell
> looks to find executables), you can get away with just typing
>
>   bash$ django-admin.py startproject foo
>
> The best geeks are lazy, so that 2nd one appeals after you've
> typed the full path more than once.  Therefore the docs suggest
> that you create a link from its existing loction to some place on
> your path.  You can show your path with
>
>   bash$ echo $PATH
>
> Because this is likely outside the domain of your OS's stock
> install, 

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 up into two parts?
>
> {% with form|slice:":2" as formslice %}
>     (% for field in formslice %}
>
> -Doug
>
> > --
>
> > 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.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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):
>> def __init__(self,*args,**kwargs):
>> self._args = args
>> self._kwargs = kwargs
>> super(NF,self).__init__(*args,**kwargs)
>>
>> class NA(ModelAdmin):
>> form = NF
>>
>> and deeper in the underground in a method
>> I use the following for the checks.
>> self._kwargs.has_key('instance'):
>> pk = self._kwargs['instance'].pk
>>
>> Now the question. Is there a more canonical form of accessing
>> this data ?
>>
>> thanks
>> gregor
>> 
>
> Why not just use self.instance?
>   
ahm. Good point.
But what I mean is, if this a safe access respective to the public api.

gregor
> --
> DR.
>
> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>   

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 two tables?

I wonder if ContentType could help?

obj_type = ContentType.objects.get_for_model(player)
source_refs = PlayerM.filter(object_type=obj_type)

(object_type gets created with generic relations)

-Doug

> 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, but seems one can
>> manually filter it afterwords:
>>
>> qs = Player.objects.all()
>> for i,obj in enumerate(qs):
>>     if obj.__class__ != Player:
>>         del(qs[i])
>>
>> On Nov 22, 4:32 pm, lfrodrigues  wrote:
>>
>> > Hello,
>>
>> > I have these models:
>>
>> > class Player(models.Model):
>> >     .
>>
>> > class PlayerM(Player):
>> >     ...
>>
>> > If I do PlayerM.objects.all() e get all PlayerM objects and for
>> > Player.objects.all() I get all Player and PlayerM as expected.
>>
>> > How can get only the objects of type Player (only retrieve the objects
>> > that were created with Player() constructor)?
>>
>> > Regards,
>>
>> > Luis
>
> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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):
>     self._args = args
>     self._kwargs = kwargs
>     super(NF,self).__init__(*args,**kwargs)
>
> class NA(ModelAdmin):
>     form = NF
>
> and deeper in the underground in a method
> I use the following for the checks.
> self._kwargs.has_key('instance'):
>     pk = self._kwargs['instance'].pk
>
> Now the question. Is there a more canonical form of accessing
> this data ?
>
> thanks
> gregor

Why not just use self.instance?
--
DR.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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
super(NF,self).__init__(*args,**kwargs)

class NA(ModelAdmin):
form = NF

and deeper in the underground in a method
I use the following for the checks.
self._kwargs.has_key('instance'):
pk = self._kwargs['instance'].pk

Now the question. Is there a more canonical form of accessing
this data ?

thanks
gregor

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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.delete_permission') or what i
found in an other post,
*

*
def get_permission_object(perm_label):
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
app_label,perm_code_name = perm_label.split('.')
content_type = ContentType.objects.get(app_label=app_label)
perm = Permission.objects.get
(content_type=content_type,codename=perm_code_name)
return perm

def add_perm_to_user(user,perm_label):
user.user_permissions.add(get_permission_object(perm_label))
user.save()
return user
*

Any suggestions?
Thanks in advance!

--

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




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, but seems one can
> manually filter it afterwords:
>
> qs = Player.objects.all()
> for i,obj in enumerate(qs):
>     if obj.__class__ != Player:
>         del(qs[i])
>
> On Nov 22, 4:32 pm, lfrodrigues  wrote:
>
> > Hello,
>
> > I have these models:
>
> > class Player(models.Model):
> >     .
>
> > class PlayerM(Player):
> >     ...
>
> > If I do PlayerM.objects.all() e get all PlayerM objects and for
> > Player.objects.all() I get all Player and PlayerM as expected.
>
> > How can get only the objects of type Player (only retrieve the objects
> > that were created with Player() constructor)?
>
> > Regards,
>
> > Luis

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 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 a specific day,
> week or month.
> I assumed I could use something like
>
>     MyTable.objects.annotate(Count('created'))
>
> but I can't find a way to format the "created" date such that it
> ignores the less significant elements, such as the hours and minutes
> and only counts entries based on the unit I want.
>
> Anyone any ideas how to do this?
> Thanks

--

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




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 a specific day,
week or month.
I assumed I could use something like

MyTable.objects.annotate(Count('created'))

but I can't find a way to format the "created" date such that it
ignores the less significant elements, such as the hours and minutes
and only counts entries based on the unit I want.

Anyone any ideas how to do this?
Thanks

--

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




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 field in formslice %}

-Doug

> --
>
> 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.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=.
>
>
>

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 select list with multiple options.
> > Is it possible to use
> > checkboxes instead?
>
> > Thanks,
> > Greets Ben

I seem to remember coming across a MultiCheckboxWidget somewhere.

In fact, it is called CheckboxSelectMultiple, and there is a post in
this forum about it:

http://groups.google.com/group/django-users/browse_thread/thread/97d0c9bf70757e2e/d723ff480aef0cc2?lnk=raot

And a post on Stack Overflow:

http://stackoverflow.com/questions/1268209/django-modelform-checkbox-widget

Matt.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 I go about doing that???

This assumes you're running a *nix-like OS instead of Windows 
(you can make links in Windows but it's a pain).

Executive Cheat-code for the impatient:
===

   bash$ ln -s /path/to/existing/django-admin.py 
/some/place/on/path/django-admin.py



More detailed explanation:
==
In most instances, the Django install doesn't drop its 
"django-admin.py" outside its own subdirectory.  This means that 
to run it, you have to specify its full path

   bash$ /path/to/django-admin.py startproject foo

If, however, it's on your path (the list of places your shell 
looks to find executables), you can get away with just typing

   bash$ django-admin.py startproject foo

The best geeks are lazy, so that 2nd one appeals after you've 
typed the full path more than once.  Therefore the docs suggest 
that you create a link from its existing loction to some place on 
your path.  You can show your path with

   bash$ echo $PATH

Because this is likely outside the domain of your OS's stock 
install, it's recommended you not link into a "system" directory 
(usually /bin or /usr/bin are controlled by your package manager) 
but rather to use either a system-wide location like 
/usr/local/bin or /opt/bin which is designed for add-on programs 
outside of the stock-OS.  This would be for all users on the 
system.  If, however you just want it for yourself, many folks 
have a ~/bin in their home directory for just this purpose. 
However, you have to make sure you have that on your path.  So 
for example, in my .bash_profile or .bashrc I might have lines like

   PATH=$HOME/bin:$PATH
   export PATH

to add ~/bin to my $PATH, and then create a link from the 
existing django-admin.py into that folder with

   bash$ ln -s /path/to/django-admin.py ~/bin/django-admin.py

Lastly, as one more cheap trick, you don't need to keep the same 
name, so I tend to drop the ".py" when I do that:

   bash$ ln -s /path/to/django-admin.py ~/bin/django-admin

so I can just type

   bash$ django-admin startproject foo

Hope this helps explain so you can tweak as you need,

-tim






--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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(mymodel_form.cleaned_data)
>
> Not setting attributes individually would also make it easier to change  
> models later without adding or removing attributes in the views.
>
> Boris

Use a ModelForm.
--
DR.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 does not work ;)
> 
> {{ pick.date "r" }}
> 

Is pick bound to a django orm model instance and date actually the name
of a field of that object?  {{pick.date|date:"r"}}

Or maybe pick is holding a date directly, in which case you
want  {{pick|date:"r"}}

http://docs.djangoproject.com/en/dev/ref/templates/builtins/







--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 address from requested url as 'testing, testing 1,
testing 2.'

i.e.,
>>> ModelName.objects.filter(address__icontains=  'testing, testing 1, testing 
>>> 2.')
>>> []

Getting [] since the address is being stored in the model  as
u'testing,\r\ntesting 1,\r\ntesting 2.'

How can I search address by omitting some special characters such as
'\r\n', ',' etc. since I'm not sure how end users will add data via
django admin page.

Thanks in advance,
Leppy.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 own version of "changelist_view" e.g.:
>
>     def changelist_view(self, request, extra_context=None):
>         extra_context={ 'has_delete_permission': self.has_delete_permission
> (request) }
>         return super(MyCommentsAdmin, self).changelist_view(request,
> extra_context)
>
> However - as this post suggests -http://bit.ly/7ZrKHl- is this
> thread safe?
> Thanks for any thoughts anyone.
>
> R
>
> On Nov 20, 5:02 pm, rd-london  wrote:
>
>
>
> > Right, I've worked out why this is:
>
> > django/contrib/admin/options.py - def changelist_view(self, request,
> > extra_context=None): contains the line:
>
> >         context = {
> >             'title': cl.title,
> >             'is_popup': cl.is_popup,
> >             'cl': cl,
> >             'media': media,
> >             'has_add_permission': self.has_add_permission(request),
> >             'root_path': self.admin_site.root_path,
> >             'app_label': app_label,
> >             'action_form': action_form,
> >             'actions_on_top': self.actions_on_top,
> >             'actions_on_bottom': self.actions_on_bottom,
> >         }
>
> > So, it doesn't add "has_delete_permission" to the context (nor
> > "has_change_permission") for that matter. Simple fix:
>
> >         context = {
> >             'title': cl.title,
> >             'is_popup': cl.is_popup,
> >             'cl': cl,
> >             'media': media,
> >             'has_add_permission': self.has_add_permission(request),
> > addedhere     --->       'has_delete_permission':
> > self.has_delete_permission(request),         <- added here
> >             'root_path': self.admin_site.root_path,
> >             'app_label': app_label,
> >             'action_form': action_form,
> >             'actions_on_top': self.actions_on_top,
> >             'actions_on_bottom': self.actions_on_bottom,
> >         }
>
> > ... but ... but ... surely that comes from the land of Harry the
> > Hacker?
> > Isn't there a better way to do this, or is this a genuine bug?
>
> > Any help or thoughts very welcome,
>
> > Cheers
> > R
>
> > On Nov 20, 3:18 pm, rd-london  wrote:
>
> > > Hi,
> > > Wonder if anyone can help.
>
> > > Have following chunk in my own change_list.html template:
>
> > >     {% block object-tools %}
> > >         
> > >           {% if has_add_permission %}
> > >           
> > >              > > title="Add Comment" class="addlink">
> > >               {% blocktrans with cl.opts.verbose_name as name %}Add
> > > {{ name }}{% endblocktrans %}
> > >             
> > >           
> > >           {% endif %}
> > >           {% if has_delete_permission %}
> > >           
> > > My thing goes here
> > >           
> > >           {% endif %}
> > >         
>
> > >     {% endblock %}
>
> > > Created a user that has delete permissions. Got my own ModelAdmin and
> > > have checked using the debugger that the user does indeed have delete
> > > permissions.
>
> > > The "def has_add_permission" fn in contrib/admin/options.py *is* being
> > > called (I've put "import pdb;pdb.set_trace()" there to check), whereas
> > > def has_delete_permission is not - and I can't work out for the life
> > > of me why not.
>
> > > Anyone help at all?
>
> > > Thanks,
> > > R

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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, but in a
> >> batchfile ($ DJANGO_SETTINGS_MODULE=settings python batch.py) only M
> >> is reachable from User while trying to get N leads to
>
> >> AttributeError: 'User' object has no attribute 'N_set'
>
> >> Wherever and how do I start debugging something like this?
>
> > If model X has a foreign key pointing to model Y, model Y won't get
> > the X_set attribute until model X is actually imported. This means
> > that if X isn't imported, attributes will appear to be missing from Y.
>
> > When you run under runserver, the INSTALLED_APPS setting is
> > effectively an implied import of all the models listed.
>
> So, settings isn't actually run properly (and thus the apps in
> INSTALLED_APPS aren't all imported)  when doing
>
> $ DJANGO_SETTINGS_MODULE=settings python script.py
>
> ?
>
> So how is one supposed to do such things without going trough manage.py then?
>
> HM

*Do* go through manage.py. Write your script as a custom manage.py
command, which will take care of all this:
http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
--
DR.

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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
website, my app will be well integrated?

Let's say, my supervisor will develop php webframework, and my app
should be worked on php webframework.

Hm..just setup apache configs may solve my worry? :)

Like Juan said, it looks possible. But I am not good at web
programming yet.

I will really appreciate if someone give me more detail info about how
to integrate with php whatever webframework.

Thanks in advance.!!

--

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




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 go about doing that???

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




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 python batch.py) only M
>> is reachable from User while trying to get N leads to
>>
>> AttributeError: 'User' object has no attribute 'N_set'
>>
>> Wherever and how do I start debugging something like this?
>
> If model X has a foreign key pointing to model Y, model Y won't get
> the X_set attribute until model X is actually imported. This means
> that if X isn't imported, attributes will appear to be missing from Y.
>
> When you run under runserver, the INSTALLED_APPS setting is
> effectively an implied import of all the models listed.

So, settings isn't actually run properly (and thus the apps in
INSTALLED_APPS aren't all imported)  when doing

$ DJANGO_SETTINGS_MODULE=settings python script.py

?

So how is one supposed to do such things without going trough manage.py then?


HM

--

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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.