Re: problem with permalink

2008-07-22 Thread mwebs

Yes,
I tried this but the problem still exists.

it s the same when I do like this:

@permalink
def get_url(self):
  return ('experiment_view', (), {'exp_id': self.id})

and the same when I do it like in the example [1]:

def get_url(self):
  return ('experiment_view', (), {'exp_id': self.id})

get_url = permalink(get_url)

For me it seems as if django could not figure out the corresponding
url. any ideas?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with permalink

2008-07-22 Thread mwebs

Hello,

I have a very strange problem with the permalink-decorator:

model:

def get_url(self):
  return permalink('experiment_view', (), {'exp_id': self.id})


urls.py:
...
url(r'^(?P\d+)$', 'edit_experiment', name='experiment_view'),


in my template {{exp.get_url}} returns an empty string. But
the function get_url() is invoked. The problem is the permalink
decorator. It seems as if he can not resolve the url.

I dont have any idea what I am doing wrong.
Thanks for your help.
Toni


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



Re: Migrating to newforms-admin and classes already registered error

2008-07-22 Thread Peter Bailey

That works much better Malcolm, thank you very much. Appreciate the
explanations too.

Cheers,

Peter


On Jul 22, 3:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-22 at 12:21 -0700, Peter Bailey wrote:
> > Hi all. I am attempting to convert an app I am writing to use the nfa.
> > I have looked at all the docs available about this, but must have
> > missed something. I am using:
>
> > Django version 1.0-alpha-SVN-8053
>
> > Anyway, I have changed my urls.py file to be like so:
>
> > from django.contrib import admin
>
> >     (r'^admin/(.*)', admin.site.root),  # in urlpatterns
>
> > and in my models file I have:
>
> > from django.contrib import admin
>
> > and then after my Page class declaration I have
>
> > admin.site.register(Page)
>
> > which creates the following error at runtime:
>
> > ImproperlyConfigured at /
> > Error while importing URLconf 'generator.urls': The model Page is
> > already registered
>
> > I have tried using the autodiscover and not using it - same result - I
> > also see some people are using an admin.py file and some are just
> > modifying the model.py file.
>
> > Can anyone point me at some info or tell me what I am doing wrong.
> > Feeling kinda stupid about now...
>
> The recommended approach (and the reason for autodiscover()) is to put
> the admin classes and registration into admin.py. Your models.py files
> are imported more than once, which is leading to the duplicate
> registration error (which is a real error in other situations, which is
> why it exists).
>
> Putting things in admin.py is a way to make sure they're only registered
> once.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ticket #6755 closed: Model Inheritance doesn't work in the admin.

2008-07-22 Thread Andre Meyer
hi all

wow, ticket #6755  is closed!

so, just tried it out and got an error, oh my dear!

is it me or is there still a problem? here is the code (simplified)


*model.py*

class Item(models.Model):
pass

class Note(models.Model):
text = models.TextField(null=True, blank=True)

class Dossier(Item):
pass

class Action(Item):
pass

*admin.py*

class NoteInline(admin.StackedInline):
model = Note
extra = 1

class ItemOptions(admin.ModelAdmin):
model = Item
inlines = [NoteInline]

class DossierOptions(admin.ModelAdmin):
model = Dossier
inlines = [NoteInline]

class ActionOptions(admin.ModelAdmin):
model = Action
inlines = [NoteInline]

admin.site.register(Note)
admin.site.register(Item, ItemOptions)
admin.site.register(Dossier, DossierOptions)
admin.site.register(Action, ActionOptions)

*result when viewing a dossier in admin (running trunk 1.0-alpha-SVN-8052)
*
Exception at /admin/dossiers/dossier/37/  has no ForeignKey to  Request Method: GET  Request URL:
http://localhost:/admin/dossiers/dossier/37/  Exception Type:
Exception  Exception
Value:  has no ForeignKey to   Exception Location:
c:\usr\django\trunk\django\forms\models.py
in _get_foreign_key, line 453
the same happens with Action, but it does work with Item, of course.

somehow the notes property is not inherited properly. it does exist when
accessing it in the shell, though:

>>> from mysite.dossiers.models import *
>>> d = Dossier.objects.get(dossier_number=42)
>>> d.notes

>>>

what's happening here?

thanks
André

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



AttributeError: 'module' object has no attribute

2008-07-22 Thread Tom

From: Morgan Packard  gmail.com>
Subject: newbie -- hiccups in following tutorial
Newsgroups: gmane.comp.python.django.user
Date: 2008-07-22 09:02:56 GMT (13 hours and 48 minutes ago)

Hello all,

I'm going through the tutorial at 
http://www.djangoproject.com/documentation/tutorial01/,
and am having trouble with the second page (http://
www.djangoproject.com/documentation/tutorial01/).

The tutorial instructs me to add "admin.site.register(Poll)" to the
bottom of models.py. I've done that, and now the sever gives me the
following error:  AttributeError: 'module' object has no attribute
'site'

Everything else has worked perfectly up to this point.  This is how my
models.py looks:


from django.db import models
from django.contrib import admin
import datetime

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return self.question

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice

admin.site.register(Poll)


One possible clue is the fact that the urls.py Django generated for me
differes from the one in the tutorial. The urls.py Django gave me is
missing the following lines which are shown in the tutorial:


from django.contrib import admin
admin.autodiscover()


thanks so much!

-Morgan

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



Re: Overriding save_add/save_change fails when using NFA?

2008-07-22 Thread Joseph Kocherhans

On Tue, Jul 22, 2008 at 5:12 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> I'd appreciate it if someone else chimed in, but it appears as though
> the HOWTO contains a typo.  I've looked at the older versions of
> Django and the NFA branch and none of them include the "model"
> parameter in the "save_add" method.
>
> Anyone else agree?

Yeah, the HOWTO is wrong. I removed the model argument from the
parameters list last week because it is accessible via self.model. I
think passing it around was something that was carried over from much
older versions that didn't make sense anymore.

Joseph

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



Re: WSGIScriptAlias and change #8015

2008-07-22 Thread arsyed

On Tue, Jul 22, 2008 at 2:29 PM, Marty Alchin <[EMAIL PROTECTED]> wrote:
>
> On Tue, Jul 22, 2008 at 4:40 AM, arsyed <[EMAIL PROTECTED]> wrote:
>> urlpatterns = patterns('',
>>(r'^/foo$', foo),
>> )
>>
>> --error message
>>
>> GET http://localhost/mysite/foo  results in:
>>
>> Using the URLconf defined in proj.urls, Django tried these URL
>> patterns, in this order:
>>
>>   1. ^/foo$
>>
>> The current URL, mysite/foo, didn't match any of these.
>
> For what it's worth, you're probably running into something a lot
> simpler than the site prefix thing. Django's URLs are matched
> *without* the leading slash, so your URL pattern should look like this
> instead:
>
> urlpatterns = patterns('',
>(r'^foo$', foo),
> )
>
> Hopefully that should clear it up for you.
>
> -Gul
>

Ack. You're right - I forgot to remove the leading slash along with
the mysite prefix. Thanks for the help!

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



Re: WSGIScriptAlias and change #8015

2008-07-22 Thread arsyed

On Tue, Jul 22, 2008 at 2:05 PM, Malcolm Tredinnick
<[EMAIL PROTECTED]> wrote:
>
>
> On Tue, 2008-07-22 at 10:58 -0700, Malcolm Tredinnick wrote:
>>
>> On Tue, 2008-07-22 at 04:40 -0400, arsyed wrote:
>> > Hi - With the change in 8015:
>> >
>> > http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
>> >
>> > it sounds like I shouldn't need to specify the WSGIScriptAlias in the
>> > URLConf file. But this doesn't work for me (setup pasted below).  Does
>> > this mean I should continue to prefix "/mysite" in urls.py or is there
>> > a way to avoid this?
>>
>> The whole idea of that change is so that you don't need the site prefix
>> in your urls.py file. That way you can easily move the code from
>> under /mysite to /my_other_site without having to change anything. This
>> makes it particularly straightforward to, for example, develop on your
>> local machine without having to worry about the prefix it is deployed
>> under in production.
>>
>> So, yes, removing the "/mysite" prefix is exactly the change required
>> here.
>
> I mean remove this prefix from your urls.py file. Keeping the
> WSGIScriptAlias intact is the way to go here. You should only need to
> modify your Django applications, not your webserver-related config.
>
> Regards,
> Malcolm
>
>
>

It turns out my problem was in urls.py. But you're right, this change
makes it much nicer when moving between my production and local setups
since I can remove some cruft from my urls and settings files. Thanks
for clarifying.

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



Re: URL problems after newforms admin migration

2008-07-22 Thread Matthew

Hmm, unfortunately I'm running this test environment on a Media Temple
Gridserver container, so I have no access to the httpd.conf for
changing stuff like that :( I'm not too bothered with the problem
whilst I'm testing it, but I wouldn't want this to crop up when I'm
trying to move it all across to my "production" server :\

That link does seem similar to trouble I'm having though, thanks for
that Karen.

On 22 Jul, 21:30, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 22, 2008 at 2:17 PM, Matthew <[EMAIL PROTECTED]> wrote:
>
> > Hey everyone, I recently updated a development version of my Django
> > site to use the newforms admin, following the tutorial here
>
> >http://oebfare.com/blog/2008/jul/20/newforms-admin-migration-and-scre...
> > It all went fairly well, but I do have one major problem though, and I
> > don't know whether its connected to this. I suspect it is anyway
> > because it only arose after migration.
>
> > The problem is that whenever I am editing in the admin site, and I
> > click on a 'Save' button for instance, I get a 404 error.
>
> > "Page not found (404)
> > Request Method:         GET
> > Request URL:
> >http://10.2.140.72:2013/main.fcgi/main.fcgi/admin/events/event/2/";
>
> > Obviously it appears that the admin is trying to redirect me to an
> > address such as /main.fcgi/main.fcgi/admin/events/event/2/ rather
> > than /admin/events/event/2/
>
> > After getting the 404, if I remove the /main.fcgi/ from the address
> > and go to /admin/events/event/2/ I get to the correct page. The
> > changes that are to be saved are actually being saved too, but
> > obviously this is a big hindrance to a smooth site running.
>
> > Can anyone help, or is this something unrelated to the newforms admin?
>
> Not sure, but it might be related to this change:
>
> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Chang...
>
> rather than newforms-admin.
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form.clean() and custom error handling

2008-07-22 Thread Malcolm Tredinnick


On Tue, 2008-07-22 at 15:20 -0700, John-Scott wrote:
> All,
> 
> I had previously been using a bit of a hack (thought I found examples
> of this on the mailing list, but can't find any evidence now) so that
> I could actually associated field specific errors with the actual
> field instead of having everything stuffed into __all__ /
> non_field_errors.
> 
> The hack went something like this:
> 
> class MyForm(forms.Form):
> field_A = forms.SomeField()
> # many other fields etc.
> field_Z = forms.SomeField(required=False) # not required in
> isolation, but required if field_A...
> 
> def clean(self):
> if 'field_A' in self.cleaned_data and 'field_Z' not in
> self.cleaned_data:
> self.errors['field_Z'] = forms.util.ErrorList([u"Field Z
> is required if-and-only-if Field A has input, and passes validation"])
> return self.cleaned_data
> 
> I have a very long complicated form with many interrelated fields, so
> it helps to have the errors physically near the fields that need
> attention, rather than just say at the top "These 5 field names had
> errors, now go find the fields!" (I wish the form were more sane, but
> I have no control over this, I just have to deal as best I can).
> 
> Obviously the first step is to stop using the hack,

Well, no. Why is this a hack? You have multi-field cleaning to do, so
Form.clean() is the first place it's valid to do that, since all the
fields will be available. You have access to self._errors in the
subclass if you want to adjust it like this. Your usability case is
thought out as being something that works (and I have to say that I do
the same thing for inter-related stuff).

So I'm not granting your premise here. Aside from "my greengrocer said
this was a bad idea and I should buy more milk", so you thought you'd
remove this, what is the actual problem you're having? Your setup looks
like something workable to me, so is there something else that's a
problem?

Regards,
Malcolm



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



Re: Streaming uploads help

2008-07-22 Thread Marty Alchin

On Tue, Jul 22, 2008 at 5:50 PM, Chris <[EMAIL PROTECTED]> wrote:
> Right now I am simply doing this which obviously does not get the
> directory structure that I want.
>
> PATH_ROOT = os.path.join(MEDIA_ROOT, 'event-photos', ph.name)
> IMAGE_PATH = os.path.join('event-photos', ph.name)
> destination = open(PATH_ROOT, 'wb+')
> for chunk in ph.chunks():
>destination.write(chunk)
> destination.close()
> p = Photo(event=event)
>  p.photo = IMAGE_PATH
> p.save()
>
> Is there an easier way?

I could be missing something, but you should be able to just do this:

p = Photo(event=event)
p.save_photo_file(ph.name, ph)

You just pass the file object itself, and Django knows what to do with
the rest of it.

-Gul

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



Re: superuser has no rights with newforms admin

2008-07-22 Thread stranger

I am using django (revision 8055.). after updating the site seems to
work fine but the admin panel still shows me

You don't have permission to edit anything.

I do have admin.autodiscover() and induvidually registered models in
admin.py in all apps. I tried commenting out the admin.site.register()
but it still shows me permission denied. I am the only super user on
the site. Any recommendations.




On Jul 21, 12:46 am, "Justin Wong" <[EMAIL PROTECTED]> wrote:
> Never mind,newforms-adminworks great. :)
>
> I forgot that I had copied a custom version of the old admin templates
> and it was parsing that instead.
>
> Cheers!
> Justin
>
> On Sun, Jul 20, 2008 at 7:27 PM, Justin Wong <[EMAIL PROTECTED]> wrote:
> > Well, I tracked down the admin/index.html page and I see that it
> > checks the variable app_list.
>
> > Going to django/contrib/admin/sites.py, I put a print statement to
> > print out my app_list.  Can anyone spot anything wrong?
>
> > [   {   'has_module_perms': True,
> >        'models': [   {   'admin_url': 'auth/group/',
> >                          'name':  > object at 0x89ad60c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'auth/user/',
> >                          'name':  > object at 0x89ad80c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}}],
> >        'name': 'Auth'},
> >    {   'has_module_perms': True,
> >        'models': [   {   'admin_url': 'blog/entry/',
> >                          'name': u'Entries',
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}}],
> >        'name': 'Blog'},
> >    {   'has_module_perms': True,
> >        'models': [   {   'admin_url': 'database/article/',
> >                          'name':  > object at 0x89adfac>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/artist/',
> >                          'name':  > object at 0x89ada8c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/dictionary/',
> >                          'name': u'Dictionary entries',
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/event/',
> >                          'name':  > object at 0x89ad68c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/image/',
> >                          'name':  > object at 0x89ada6c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/poem/',
> >                          'name':  > object at 0x8967e4c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/signature/',
> >                          'name':  > object at 0x89addec>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/stamp/',
> >                          'name':  > object at 0x89ade0c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/style/',
> >                          'name':  > object at 0x89ad98c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'database/word/',
> >                          'name':  > object at 0x89ad92c>,
> >                          'perms': {   'add': True,
> >                                       'change': True,
> >                                       'delete': True}},
> >                      {   'admin_url': 'd

Form.clean() and custom error handling

2008-07-22 Thread John-Scott

All,

I had previously been using a bit of a hack (thought I found examples
of this on the mailing list, but can't find any evidence now) so that
I could actually associated field specific errors with the actual
field instead of having everything stuffed into __all__ /
non_field_errors.

The hack went something like this:

class MyForm(forms.Form):
field_A = forms.SomeField()
# many other fields etc.
field_Z = forms.SomeField(required=False) # not required in
isolation, but required if field_A...

def clean(self):
if 'field_A' in self.cleaned_data and 'field_Z' not in
self.cleaned_data:
self.errors['field_Z'] = forms.util.ErrorList([u"Field Z
is required if-and-only-if Field A has input, and passes validation"])
return self.cleaned_data

I have a very long complicated form with many interrelated fields, so
it helps to have the errors physically near the fields that need
attention, rather than just say at the top "These 5 field names had
errors, now go find the fields!" (I wish the form were more sane, but
I have no control over this, I just have to deal as best I can).

Obviously the first step is to stop using the hack, but without any
concrete examples in the official documentation[1], it's not easy to
figure out the 'best practices' here. Ideally, I should be able to
raise/add field specific error messages in the Form.clean() method
(not entirely sure what the utility of __all__ is, but everyone has
their own use cases).

Another issue, what if I also need to check that field_K is present if
field_J is? At the `clean_field_K` level the answer is to `raise
forms.ValidationError`, but I can't exactly `raise
forms.ValidationError` errors twice in the same Form.clean() method
and expect both of these errors to be returned can I?

Thanks,
John-Scott

[1] 
http://www.djangoproject.com/documentation/forms/#custom-form-and-field-validation
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overriding save_add/save_change fails when using NFA?

2008-07-22 Thread Huuuze

I'd appreciate it if someone else chimed in, but it appears as though
the HOWTO contains a typo.  I've looked at the older versions of
Django and the NFA branch and none of them include the "model"
parameter in the "save_add" method.

Anyone else agree?

On Jul 22, 5:05 pm, Huuuze <[EMAIL PROTECTED]> wrote:
> I am using Django 1.0alpha and I'm attempting to modify the add/change
> behavior of my ModelAdmin.  As such, I'm following this example found
> on the Django wiki:
>
> http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowcanIchangewhere...
>
> Unfortunately, the method definition leads to the following error:
>
> >> TypeError at /admin/person/book/add/
> >> save_add() takes exactly 6 arguments (5 given)
>
> After reviewing the stack trace, the "options.py" file found in
> django.contrib.admin is only passing 4 explicit arguments (Line 487 in
> today's SVN trunk):
>
>     if all_valid(inline_formsets) and form.is_valid():
>         return self.save_add(request, form, inline_formsets, '../%s/')
>
> The example in the wiki includes a reference to a "model" parameter
> which isn't found on Line 487:
>
>     def save_add(self, request, model, form, formsets,
> post_url_continue):
>         pass
>
> If I remove that parameter from the method definition, a new error
> pops-up:
>
> >> AttributeError at /admin/person/book/add/
> >> 'NoneType' object has no attribute 'has_header'
>
> At this point, I've either encountered a bug or I'm not doing
> something right.  Any help you can provide is appreciated!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Streaming uploads help

2008-07-22 Thread Chris

Hello I have an image field in my photos model that has an
upload_to='event-photos/%Y/%m/%d/' variable but I am not sure how I
can reference this using streaming uploads.

before streaming uploads you could do something like:
p = Photo(**params)
p.save_photo_file(photo.filename, photo.content)

Is there a streaming uploads method that allows me to do something
simple like the above?

Right now I am simply doing this which obviously does not get the
directory structure that I want.

PATH_ROOT = os.path.join(MEDIA_ROOT, 'event-photos', ph.name)
IMAGE_PATH = os.path.join('event-photos', ph.name)
destination = open(PATH_ROOT, 'wb+')
for chunk in ph.chunks():
destination.write(chunk)
destination.close()
p = Photo(event=event)
 p.photo = IMAGE_PATH
p.save()

Is there an easier way?

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



Overriding save_add/save_change fails when using NFA?

2008-07-22 Thread Huuuze

I am using Django 1.0alpha and I'm attempting to modify the add/change
behavior of my ModelAdmin.  As such, I'm following this example found
on the Django wiki:

http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowcanIchangewhereIgetsentaftersavinganewentrytothedatabase

Unfortunately, the method definition leads to the following error:

>> TypeError at /admin/person/book/add/
>> save_add() takes exactly 6 arguments (5 given)

After reviewing the stack trace, the "options.py" file found in
django.contrib.admin is only passing 4 explicit arguments (Line 487 in
today's SVN trunk):

if all_valid(inline_formsets) and form.is_valid():
return self.save_add(request, form, inline_formsets, '../%s/')

The example in the wiki includes a reference to a "model" parameter
which isn't found on Line 487:

def save_add(self, request, model, form, formsets,
post_url_continue):
pass

If I remove that parameter from the method definition, a new error
pops-up:

>> AttributeError at /admin/person/book/add/
>> 'NoneType' object has no attribute 'has_header'

At this point, I've either encountered a bug or I'm not doing
something right.  Any help you can provide is appreciated!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Which Postgresql/Psycopg2 version should we use?

2008-07-22 Thread Steve

I ended up rebuilding everything with postgresql 8.29/pyscopg2.07 and
everything works fine. Email me if you have questions or a similar
problem as I never figured out why it didn't work with postgresql
8.33. I'd like to know what the issue was.

For now I'm just going to back away slowly from the database and pray
it doesn't spontaneously combust.

On Jul 22, 11:36 am, Steve <[EMAIL PROTECTED]> wrote:
> Recently we migrated from a working version of our site with MySQL
> with the MySIAM engine to Postgresql 8.3.3/Pyscopg2.07. I built/
> installed both on the site and after some finagling got our site to
> connect and ran syncdb successfully. All our unit tests passed, but
> the site behaves erratically now. We haven't begun to debug that but
> it sometimes allows us to enter data, and other times doesn't. Out
> unit tests don't include GET/POST tests, they only exercise the back
> end code.
>
> Before we spend an inordinate amount of time debugging this, I'm
> curious what version of Postgresql/Psycopg people are successfully
> using. We're using Django 0.96 on Ubuntu Gutsy Gibbons. 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Which Postgresql/Psycopg2 version should we use?

2008-07-22 Thread Malcolm Tredinnick


On Tue, 2008-07-22 at 13:36 -0700, Steve wrote:
> I ended up rebuilding everything with postgresql 8.29/pyscopg2.07 and
> everything works fine. Email me if you have questions or a similar
> problem as I never figured out why it didn't work with postgresql
> 8.33. I'd like to know what the issue was.

Without knowing for sure what the problem was (your description was
merely "behaves erratically", which lacks a little detail), I do know
that there is some work we need to do w.r.t. Django and PostgreSQL 8.3.
Prior to 8.3, PostgreSQL automatically did casting between fields of
different types and now (8.3) it requires explicit casting. However, I
would have thought that would show up as real exceptions, rather than
silent failures. It certainly shows up as explicit tracebacks in the bug
reports I've seen.

Regards,
Malcolm



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



importing model from html.py

2008-07-22 Thread Mayank Dhingra

Hi,

Was wondering what's wrong with importing a model or a function from
a  view which further imports a model.

Have been trying to tweak a default filter from html.py to use model
but unable to do so.

error: cannot import name models

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



Migrating to newforms-admin and classes already registered error

2008-07-22 Thread Peter Bailey

Hi all. I am attempting to convert an app I am writing to use the nfa.
I have looked at all the docs available about this, but must have
missed something. I am using:

Django version 1.0-alpha-SVN-8053

Anyway, I have changed my urls.py file to be like so:

from django.contrib import admin

(r'^admin/(.*)', admin.site.root),  # in urlpatterns

and in my models file I have:

from django.contrib import admin

and then after my Page class declaration I have

admin.site.register(Page)

which creates the following error at runtime:

ImproperlyConfigured at /
Error while importing URLconf 'generator.urls': The model Page is
already registered

I have tried using the autodiscover and not using it - same result - I
also see some people are using an admin.py file and some are just
modifying the model.py file.

Can anyone point me at some info or tell me what I am doing wrong.
Feeling kinda stupid about now...

Thanks,

Peter



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



Which Postgresql/Psycopg2 version should we use?

2008-07-22 Thread Steve

Recently we migrated from a working version of our site with MySQL
with the MySIAM engine to Postgresql 8.3.3/Pyscopg2.07. I built/
installed both on the site and after some finagling got our site to
connect and ran syncdb successfully. All our unit tests passed, but
the site behaves erratically now. We haven't begun to debug that but
it sometimes allows us to enter data, and other times doesn't. Out
unit tests don't include GET/POST tests, they only exercise the back
end code.

Before we spend an inordinate amount of time debugging this, I'm
curious what version of Postgresql/Psycopg people are successfully
using. We're using Django 0.96 on Ubuntu Gutsy Gibbons. 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: status of unicode support in 0.96?

2008-07-22 Thread Andrew D. Ball

We're working on testing things out on the trunk now.

It's just a case of my being very hesitant to use anything
that's not officially a stable release.  However, it looks
like in this case, using the trunk is the right thing to do.

Thanks for all of y'all's help!

Peace,
Andrew

On Mon, Jul 21, 2008 at 11:12:46AM -0700, John M wrote:
> 
> Any reason why you wouldn't just use the SVN version, given we're so
> close to 1.0?
> 
> Also, not sure if they will update .96 anymore other than security
> fixes.  It's very behind in features compared to SVN version.
> 
> JOhn
> 
> On Jul 21, 11:09 am, "Andrew D. Ball" <[EMAIL PROTECTED]> wrote:
> > Greetings.
> >
> > I haven't found any good documentation yet on how Django
> > supports Unicode in version 0.96.  The following webpage
> > has links for version 0.96 and 0.95, but those links don't
> > work. :-/ :
> >
> > http://www.djangoproject.com/documentation/unicode/
> >
> > Does anyone have some more information on using Unicode with
> > Django 0.96?
> >
> > Thanks for your help.
> >
> > Peace,
> > Andrew
> > --
> > ===
> > Andrew D. Ball
> > [EMAIL PROTECTED]
> > Software Engineer
> > American Research Institute, Inc.http://www.americanri.com/
> > 

-- 
===
Andrew D. Ball
[EMAIL PROTECTED]
Software Engineer
American Research Institute, Inc.
http://www.americanri.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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: WSGIScriptAlias and change #8015

2008-07-22 Thread Malcolm Tredinnick


On Tue, 2008-07-22 at 10:58 -0700, Malcolm Tredinnick wrote:
> 
> On Tue, 2008-07-22 at 04:40 -0400, arsyed wrote:
> > Hi - With the change in 8015:
> > 
> > http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
> > 
> > it sounds like I shouldn't need to specify the WSGIScriptAlias in the
> > URLConf file. But this doesn't work for me (setup pasted below).  Does
> > this mean I should continue to prefix "/mysite" in urls.py or is there
> > a way to avoid this?
> 
> The whole idea of that change is so that you don't need the site prefix
> in your urls.py file. That way you can easily move the code from
> under /mysite to /my_other_site without having to change anything. This
> makes it particularly straightforward to, for example, develop on your
> local machine without having to worry about the prefix it is deployed
> under in production.
> 
> So, yes, removing the "/mysite" prefix is exactly the change required
> here.

I mean remove this prefix from your urls.py file. Keeping the
WSGIScriptAlias intact is the way to go here. You should only need to
modify your Django applications, not your webserver-related config.

Regards,
Malcolm



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



Re: WSGIScriptAlias and change #8015

2008-07-22 Thread Malcolm Tredinnick


On Tue, 2008-07-22 at 04:40 -0400, arsyed wrote:
> Hi - With the change in 8015:
> 
> http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#ChangedthewayURLpathsaredetermined
> 
> it sounds like I shouldn't need to specify the WSGIScriptAlias in the
> URLConf file. But this doesn't work for me (setup pasted below).  Does
> this mean I should continue to prefix "/mysite" in urls.py or is there
> a way to avoid this?

The whole idea of that change is so that you don't need the site prefix
in your urls.py file. That way you can easily move the code from
under /mysite to /my_other_site without having to change anything. This
makes it particularly straightforward to, for example, develop on your
local machine without having to worry about the prefix it is deployed
under in production.

So, yes, removing the "/mysite" prefix is exactly the change required
here. I was having more than a little trouble explaining all the
necessary changes, but that's mentioned in the wiki fragment you mention
as something that needs to be done for all backends. mod_wsgi is
certainly one of the easier setups to port the code forwards for in this
case.

Regards,
Malcolm



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



Re: Django Newbie

2008-07-22 Thread James Matthews
I would recommend on learning python before looking at django. It would
explain why things have to be in your PYTHONPATH and answer many questions
Etc..

On Tue, Jul 22, 2008 at 2:01 AM, Kenneth Gonsalves <[EMAIL PROTECTED]>
wrote:

>
>
> On 22-Jul-08, at 12:36 PM, Sthembile Ngidi wrote:
>
> > I'm relatively new to python and I want to use django to create a
> > website.
>
> are you a newbie in web programming? Please tell us your previous
> experience in web programming so we can guide you.
>
> --
>
> regards
> kg
> http://lawgon.livejournal.com
> http://nrcfosshelpline.in/code/
>
>
>
>
> >
>


-- 
http://www.jewelerslounge.com
http://www.goldwatches.com/mens/

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



ANN: Django sprint in Washington DC area, August 1st

2008-07-22 Thread Benjamin Slavin

With 1.0 alpha upon us, I thought it would be a good time for an announcement.

On August 1st, just under two weeks from now, we will be hosting a
sprint in Washington, DC.  The focus will be on Django 1.0 beta 1.

This marks the first east-coast Django sprint (I think), so we're
trying to bring the community together in this drive toward 1.0.
Details about the sprint, and a sign-up list can be found on the wiki.

http://code.djangoproject.com/wiki/SprintDCAugust2008


If you're coming from out of town and need help with planning travel
or lodging, please let me know.

The exact location will be announced on the wiki tomorrow, but we can
guarantee it's Metro accessible.

The sprint is sponsored by GeniusRocket [0], with support from the
Dingman Center for Entrepreneurship. [1]


Join us in person or online!  Here's to 1.0!


Best,
 - Ben


[0] http://www.geniusrocket.com
[1] http://www.rhsmith.umd.edu/Dingman/

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



Re: similar method for get_or_create()

2008-07-22 Thread pihentagy

Hi!

I also have the same issue. I should write:

pp, pp_created =
WSProductPurchase.objects.get_or_create(purchase=purchase,
ws_product=ws_product, defaults=dict(quantity=quantity))
if not pp_created:
pp.quantity = quantity
pp.save()

I suspect leppy is trying to achieve something like this.

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



Re: Model Meta verbose_name setter

2008-07-22 Thread [EMAIL PROTECTED]

On 22 juil, 14:38, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 22, 2008 at 5:17 AM, James PIC <[EMAIL PROTECTED]> wrote:
> > I'm trying to use the value of a field of the model for Meta verbose_name.
>
> Do you mean an instance of the model? Like, if you have an Article
> whose title attribute is "Testing" you'd like  "Testing" to show up in
> the admin for that article? If that's the case, you're not after
> Meta's verbose_name at all. That's only for the model itself, not for
> any instances of it.

Actually, i'm trying to do so for the model itself, not for instances.
It looks like Django's assumption that a model name should be a static
string is not overloadable.

> To customize how model instances are displayed in the admin (and
> elsewhere), just define a __unicode__ method on your model, and have
> return whatever you'd like. In the Article example I mentioned, it
> might look like this:
>
> class Article(models.Model):
>     title = models.CharField(max_length=255)
>     #... other fields
>
>     def __unicode__(self):
>         return self.title
>
> Make sense? It has nothing to do with Meta options. Of course, if
> that's not really what you're after either, I'm not sure how else to
> help you.

Some features i need for model inheritance are broken in nfa.
I extended AdminSite to allow several ModelAdmin per Model, and put
all properties that should have been inherited into the parent Model.
(i don't mind making a migration script later)

But if i subclass AdminBase, i'll have to copy and paste ModelAdmin
to subclass my AdminBase child.

I'm still looking for a temporary solution, even if i should recode
the
models when model inheritance is fixed.

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



dynamic template?

2008-07-22 Thread Niels

Hello,

Does anyone has an suggestion how te create an fill a 'dynamic
template'?

Current situation:

index.html:



{% include 'nav.html' %}
{% include 'agenda.html' %}



with a view:
from django.shortcuts import render_to_response
def index(request):
return render_to_response('index.html', {'menu_active': 'home',})

but I want to achieve something like:



{{template_nav}}
{{template_agenda}}



with a view like (not working):
from django.shortcuts import render_to_response
def index(request):
return render_to_response('index.html', {'menu_active':
'home','template_nav':nav.html,'template_content':agenda.html})

So I have one 'main template' where I can include different html files
with I maintain in my view.
Someone a suggestion?

Niels

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



internal server error with new development version

2008-07-22 Thread ajo11

Hi,

After upgrading from development version 7933, I'm getting a 500
Internal Server Error page.  This doesn't happen every time.
Sometimes it gives the expected response & sometimes it gives a normal
500 page.
I think Apache is OK as another simple django project is working fine.

This is the Apache log error given by the Internal Server Error:

[Mon Jul 21 18:42:47 2008] [error] [client 131.111.39.48]
PythonHandler django.core.handlers.modpython: Traceback (most recent
call last):
[Mon Jul 21 18:42:47 2008] [error] [client 131.111.39.48]
PythonHandler django.core.handlers.modpython:   File "/usr/lib/
python2.4/site-packages/mod_python/apache.py", line 287, in
HandlerDispatch\nlog=debug)
[Mon Jul 21 18:42:47 2008] [error] [client 131.111.39.48]
PythonHandler django.core.handlers.modpython:   File "/usr/lib/
python2.4/site-packages/mod_python/apache.py", line 457, in
import_module\nmodule = imp.load_module(mname, f, p, d)
[Mon Jul 21 18:42:47 2008] [error] [client 131.111.39.48]
PythonHandler django.core.handlers.modpython:   File "/usr/lib/
python2.4/site-packages/django/core/handlers/modpython.py", line 7,
in ?\nfrom django.core.urlresolvers import set_script_prefix
[Mon Jul 21 18:42:47 2008] [error] [client 131.111.39.48]
PythonHandler django.core.handlers.modpython: ImportError: cannot
import name set_script_prefix

I expect something in my code must be causing the error but I have no
idea how to find the bug.


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



Re: Django on OS X Leopard - apache only forwards to mod_python on localhost

2008-07-22 Thread Mark Phillips

On Jul 22, 2008, at 7:07 AM, Matt wrote:

> Apache obviously isn't forwarding the request to the PythonHandler,
> but I don't know why.

I am not an expert at this but I am willing to share has worked here...

When setting up Django, I did not have much luck with the Location  
directive. I would like to learn more about how to use this directive  
effectively.

I found joy using a combination of the Alias and Directory directives.  
Here is an example based on a set up for CentOS 4. I tore down the Mac  
OS X install a while back but I suspect this would work as well. I use  
"usr/local" in the example only; on a production server you would want  
to choose a more appropriate place in the file system.

Alias /mysite /usr/local/mysite_dir


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonDebug On
PythonAutoReload On
Options None
AllowOverride All
order deny,allow
deny from all
allow from all


I am have a working draft of instructions for setting up Django on SME  
7.3 that covers a few more things. Perhaps you might find a useful  
tidbit there: 

hth,

Mark Phillips
Mophilly, technology for creative business

On the web at http://www.mophilly.com
On the phone at 619 444-9210





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



Re: django-admin.py not recognized in Windows Vista despite adding it to the PATH

2008-07-22 Thread Reed Bailey

I've seen this issue with path before when using WinOS. _Another_
possibility for an executable not recognized on WinOS is OS Path
variable is too long (the colon delimited list has too many characters).
The failure is silent: No message that delimited list is too long and no
truncation or end of line while entering. Only indicator is a message
that an executable is not recognized when trying to use that
executable. 

Solutions I recall:
* Remove some paths from System or User Path variable.
* If all are needed, then manually change path each time you
change your work (yes, this was a suggestion I recall, yikes). 
* Or consider another user with only difference between them is
User Path.
* Shorten your individual paths so total Path character count is
lowered.
* You already know of System and User Paths. You may also know
this, for a particular user, whether a path is listed under
System or User makes no difference. It only needs listed in one
place 

(Note: These suggestions are for <= WinXP. I have no knowledge of
WinVista. I no longer use WinOS. I've recalled all this from memory. My
memory is maximum character count of a System or User Path is 256
characters (this may be a bad memory) - no matter, I am certain there is
a fixed character limit.)

cheers,
Reed

PS: Another possibility is: In the django-admin.py path or somewhere
else in System or User Path there is a malformed element. I use element
because it may or may not show as a character on screen. The only
solution I know for this is visually verify each individual path is
correct *and* then _completely_ erase System or User Path and then
manually type each back in.

PSS: Does anyone know if "-" (minus sign) may cause "erratic" parsing
behavior in WinOS? It does in Bash!

On Sun, 2008-07-20 at 17:14 -0700, zippers24 wrote:
> I am completley new to this and am installing it for the first time, I
> am trying to create my first project in a file called djprojects. The
> windows command prompt says that django-admin.py is not recognized
> even though I added its location: C:\Python\Lib\site-packages\django
> \bin to both the user and system PATH. Does anybody have any ideas
> about this? I would appreciate any help.
> 
> > 


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



OR on filter vs. OR on Q objects

2008-07-22 Thread Ales Kozumplik

Hi,

I've encountered a similar problems like Julien here:
http://groups.google.com/group/django-users/browse_thread/thread/09e6d4f5c4f9cbfc

The case I have got is slightly more complex, and what is strange is
that it doesn't seem to be fixed by Queryset Refactor branch merge (my
django-trunk is revision 7871 from Jul-08 2008)

To use Julien's example:

model:
from django.db import models
from django.contrib.auth.models import User

class Project(models.Model):
name = models.CharField(max_length=200)
created_by = models.ForeignKey(User)

class Participant(models.Model):
project = models.ForeignKey(Project)
user = models.ForeignKey(User)

First query:
f1 = Project.objects.filter(created_by=user)
f2 =
Project.objects.filter(participant__user=user,name__startswith=name)
projects = f1 | f2

Second query:
q1 = Q(created_by=user)
q2 = Q(participant__user=user,name__startswith=name)
projects2 = Project.objects.filter(q1 | q2)

I would think (and please correct me if I'm wrong) that these two
queries should be the same, however when I have them printed out (like
"str(projects.query)") they are not, the difference is one uses
(correctly IMO) left outer join, the other one inner join:

SELECT "play_project"."id", "play_project"."name",
"play_project"."created_by_id" FROM "play_project" LEFT OUTER JOIN
"play_participant" ON ("play_project"."id" =
"play_participant"."project_id") WHERE ("play_project"."created_by_id"
= AnonymousUser OR ("play_project"."name" LIKE xxx% ESCAPE '\' AND
"play_participant"."user_id" = AnonymousUser ))

SELECT "play_project"."id", "play_project"."name",
"play_project"."created_by_id" FROM "play_project" INNER JOIN
"play_participant" ON ("play_project"."id" =
"play_participant"."project_id") WHERE ("play_project"."created_by_id"
= AnonymousUser OR ("play_project"."name" LIKE xxx% ESCAPE '\' AND
"play_participant"."user_id" = AnonymousUser ))

Is this really incorrect or can somebody explain this? Should I open a
ticket? (workaround of course is to go with the first query)
Thank you,
Ales

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



Re: newbie -- hiccups in following tutorial

2008-07-22 Thread Horst Gutmann

svn co http://code.djangoproject.com/svn/django/trunk/ django

:-)

-- Horst

On Tue, Jul 22, 2008 at 2:43 PM, Morgan Packard
<[EMAIL PROTECTED]> wrote:
> cool. thanks. what's the svn url for the version I want?
>
> -m-
>
> On Jul 22, 5:18 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
>> This tutorial applies to the trunk version of Django and this
>> particular part requires a very recent checkout (from not older than
>> the 18th of this month). You can normally get the version of Django
>> you're using by running `django-admin.py --version` :-)
>>
>> The problem you have seems to be related to the age of your version of
>> Django. You will need a very recent checkout (or the Alpha released
>> last night) for this :-)
>>
>> -- Horst
>>
>> On Tue, Jul 22, 2008 at 11:02 AM, Morgan Packard
>>
>> <[EMAIL PROTECTED]> wrote:
>> > Hello all,
>>
>> > I'm going through the tutorial 
>> > athttp://www.djangoproject.com/documentation/tutorial01/,
>> > and am having trouble with the second page (http://
>> >www.djangoproject.com/documentation/tutorial01/).
>>
>> > The tutorial instructs me to add "admin.site.register(Poll)" to the
>> > bottom of models.py. I've done that, and now the sever gives me the
>> > following error:  AttributeError: 'module' object has no attribute
>> > 'site'
>>
>> > Everything else has worked perfectly up to this point.  This is how my
>> > models.py looks:
>>
>> > 
>> > from django.db import models
>> > from django.contrib import admin
>> > import datetime
>>
>> > class Poll(models.Model):
>> >question = models.CharField(max_length=200)
>> >pub_date = models.DateTimeField('date published')
>>
>> >def __unicode__(self):
>> >return self.question
>>
>> >def was_published_today(self):
>> >return self.pub_date.date() == datetime.date.today()
>>
>> > class Choice(models.Model):
>> >poll = models.ForeignKey(Poll)
>> >choice = models.CharField(max_length=200)
>> >votes = models.IntegerField()
>> >def __unicode__(self):
>> >return self.choice
>>
>> > admin.site.register(Poll)
>> > 
>>
>> > One possible clue is the fact that the urls.py Django generated for me
>> > differes from the one in the tutorial. The urls.py Django gave me is
>> > missing the following lines which are shown in the tutorial:
>>
>> > 
>> > from django.contrib import admin
>> > admin.autodiscover()
>> > 
>>
>> > One last question:  how can I tell precisely which version of django I
>> > have? There doesn't seem to be a version number in the readme.
>>
>> > thanks so much!
>>
>> > -Morgan
>
> >
>

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



Re: Path Creation

2008-07-22 Thread Matthias Kestenholz

On Tue, 2008-07-22 at 11:02 +0200, Sthembile Ngidi wrote:
> How do u create a path in python?

http://www.google.com/search?q=python+create+path

Second hit.



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



Is the same request.method == "POST" and request.POST?

2008-07-22 Thread Juanjo Conti

I have used both ways in my views, now I am wondering know if one is
wrong and why.

Thanks in advance,
-- 
Juanjo Conti

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



Re: newbie -- hiccups in following tutorial

2008-07-22 Thread Morgan Packard

Thanks again. I"m pretty sure that's where my django install came
from. I _had_ installed one of the older versions, but had to upgrade
in order to follow the tutorial. I need to get on some other work now,
will give this another try in a day or two.

-Morgan

On Jul 22, 8:49 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
> svn cohttp://code.djangoproject.com/svn/django/trunk/django
>
> :-)
>
> -- Horst
>
> On Tue, Jul 22, 2008 at 2:43 PM, Morgan Packard
>
> <[EMAIL PROTECTED]> wrote:
> > cool. thanks. what's the svn url for the version I want?
>
> > -m-
>
> > On Jul 22, 5:18 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
> >> This tutorial applies to the trunk version of Django and this
> >> particular part requires a very recent checkout (from not older than
> >> the 18th of this month). You can normally get the version of Django
> >> you're using by running `django-admin.py --version` :-)
>
> >> The problem you have seems to be related to the age of your version of
> >> Django. You will need a very recent checkout (or the Alpha released
> >> last night) for this :-)
>
> >> -- Horst
>
> >> On Tue, Jul 22, 2008 at 11:02 AM, Morgan Packard
>
> >> <[EMAIL PROTECTED]> wrote:
> >> > Hello all,
>
> >> > I'm going through the tutorial 
> >> > athttp://www.djangoproject.com/documentation/tutorial01/,
> >> > and am having trouble with the second page (http://
> >> >www.djangoproject.com/documentation/tutorial01/).
>
> >> > The tutorial instructs me to add "admin.site.register(Poll)" to the
> >> > bottom of models.py. I've done that, and now the sever gives me the
> >> > following error:  AttributeError: 'module' object has no attribute
> >> > 'site'
>
> >> > Everything else has worked perfectly up to this point.  This is how my
> >> > models.py looks:
>
> >> > 
> >> > from django.db import models
> >> > from django.contrib import admin
> >> > import datetime
>
> >> > class Poll(models.Model):
> >> >    question = models.CharField(max_length=200)
> >> >    pub_date = models.DateTimeField('date published')
>
> >> >    def __unicode__(self):
> >> >        return self.question
>
> >> >        def was_published_today(self):
> >> >                return self.pub_date.date() == datetime.date.today()
>
> >> > class Choice(models.Model):
> >> >    poll = models.ForeignKey(Poll)
> >> >    choice = models.CharField(max_length=200)
> >> >    votes = models.IntegerField()
> >> >    def __unicode__(self):
> >> >        return self.choice
>
> >> > admin.site.register(Poll)
> >> > 
>
> >> > One possible clue is the fact that the urls.py Django generated for me
> >> > differes from the one in the tutorial. The urls.py Django gave me is
> >> > missing the following lines which are shown in the tutorial:
>
> >> > 
> >> > from django.contrib import admin
> >> > admin.autodiscover()
> >> > 
>
> >> > One last question:  how can I tell precisely which version of django I
> >> > have? There doesn't seem to be a version number in the readme.
>
> >> > thanks so much!
>
> >> > -Morgan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dynamic template?

2008-07-22 Thread Niels

Tsss...how stupid. Thanks

On Jul 22, 2:51 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Hi Niels.  See the documentation for the include tag:
>
> http://www.djangoproject.com/documentation/templates/#include
>
> It indicates that "[t]he template name can either be a variable or a
> hard-coded (quoted) string."
>
>   -- Scott
>
>
>
> On Tue, Jul 22, 2008 at 8:49 AM, Niels <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > Does anyone has an suggestion how te create an fill a 'dynamic
> > template'?
>
> > Current situation:
>
> > index.html:
> > 
> > 
> > 
> > {% include 'nav.html' %}
> > {% include 'agenda.html' %}
> > 
> > 
>
> > with a view:
> > from django.shortcuts import render_to_response
> > def index(request):
> >        return render_to_response('index.html', {'menu_active': 'home',})
>
> > but I want to achieve something like:
> > 
> > 
> > 
> > {{template_nav}}
> > {{template_agenda}}
> > 
> > 
>
> > with a view like (not working):
> > from django.shortcuts import render_to_response
> > def index(request):
> >        return render_to_response('index.html', {'menu_active':
> > 'home','template_nav':nav.html,'template_content':agenda.html})
>
> > So I have one 'main template' where I can include different html files
> > with I maintain in my view.
> > Someone a suggestion?
>
> > Niels
>
> --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



SQL data not loaded in testing suite

2008-07-22 Thread Adrián Ribao

Hello, I'm writing a test suite, and when the database is created,
everything seems ok, I can even see the:
Installing custom SQL for 

but the data is not inserted in the db.

Is it a bug?

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



Re: newbie -- hiccups in following tutorial

2008-07-22 Thread Morgan Packard

cool. thanks. what's the svn url for the version I want?

-m-

On Jul 22, 5:18 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
> This tutorial applies to the trunk version of Django and this
> particular part requires a very recent checkout (from not older than
> the 18th of this month). You can normally get the version of Django
> you're using by running `django-admin.py --version` :-)
>
> The problem you have seems to be related to the age of your version of
> Django. You will need a very recent checkout (or the Alpha released
> last night) for this :-)
>
> -- Horst
>
> On Tue, Jul 22, 2008 at 11:02 AM, Morgan Packard
>
> <[EMAIL PROTECTED]> wrote:
> > Hello all,
>
> > I'm going through the tutorial 
> > athttp://www.djangoproject.com/documentation/tutorial01/,
> > and am having trouble with the second page (http://
> >www.djangoproject.com/documentation/tutorial01/).
>
> > The tutorial instructs me to add "admin.site.register(Poll)" to the
> > bottom of models.py. I've done that, and now the sever gives me the
> > following error:  AttributeError: 'module' object has no attribute
> > 'site'
>
> > Everything else has worked perfectly up to this point.  This is how my
> > models.py looks:
>
> > 
> > from django.db import models
> > from django.contrib import admin
> > import datetime
>
> > class Poll(models.Model):
> >    question = models.CharField(max_length=200)
> >    pub_date = models.DateTimeField('date published')
>
> >    def __unicode__(self):
> >        return self.question
>
> >        def was_published_today(self):
> >                return self.pub_date.date() == datetime.date.today()
>
> > class Choice(models.Model):
> >    poll = models.ForeignKey(Poll)
> >    choice = models.CharField(max_length=200)
> >    votes = models.IntegerField()
> >    def __unicode__(self):
> >        return self.choice
>
> > admin.site.register(Poll)
> > 
>
> > One possible clue is the fact that the urls.py Django generated for me
> > differes from the one in the tutorial. The urls.py Django gave me is
> > missing the following lines which are shown in the tutorial:
>
> > 
> > from django.contrib import admin
> > admin.autodiscover()
> > 
>
> > One last question:  how can I tell precisely which version of django I
> > have? There doesn't seem to be a version number in the readme.
>
> > thanks so much!
>
> > -Morgan

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



Re: Model Meta verbose_name setter

2008-07-22 Thread Marty Alchin

On Tue, Jul 22, 2008 at 5:17 AM, James PIC <[EMAIL PROTECTED]> wrote:
> I'm trying to use the value of a field of the model for Meta verbose_name.

Do you mean an instance of the model? Like, if you have an Article
whose title attribute is "Testing" you'd like  "Testing" to show up in
the admin for that article? If that's the case, you're not after
Meta's verbose_name at all. That's only for the model itself, not for
any instances of it.

To customize how model instances are displayed in the admin (and
elsewhere), just define a __unicode__ method on your model, and have
return whatever you'd like. In the Article example I mentioned, it
might look like this:

class Article(models.Model):
title = models.CharField(max_length=255)
#... other fields

def __unicode__(self):
return self.title

Make sense? It has nothing to do with Meta options. Of course, if
that's not really what you're after either, I'm not sure how else to
help you.

-Gul

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



Deploying Django on Apache

2008-07-22 Thread Pepsi330ml

This is my file system structure
WebApplication
-> 0.9
 ->lib (log4py)
 ->src (the Django Code)

This is the command i used to run the Django Application from console.
$ PYTHONPATH=lib/:src/ DJANGO_SETTINGS_MODULE=settings src/manage.py
runserver

PYTHONPATN=lib/:src/
The above command is to set the environment path as my logger module
is not inside the main src folder.

Now to my question, i am unable to deploy the web application onto
Apache using the following commands in the httpd.conf

NameVirtualHost 127.1.1.1

ServerName 127.1.1.1
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonDebug On

PythonPath "['/home/Documents/WebApplication/0.1/', '/home/Documents/
WebApplication/0.1/src'] + sys.path"


SetEnv DJANGO_SETTINGS_MODULE src.settings
PythonInterpreter src



Error Message
"EnvironmentError: Could not import settings 'src.settings' (Is it on
sys.path? Does it have syntax errors?): No module named logger"

The module logger is in the lib folder

How do i configure my Apache to run my web application?
I am very lost now.

Thank you for all the help.

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



Re: problem with permalink

2008-07-22 Thread Alex Koshelev

Hi.
`permalink` - is a decorator [1], not an 'ordinary' function. So it
can be used like this:

@permalink
def get_url(self):
  return ('experiment_view', (), {'exp_id': self.id})

[1]: 
http://www.djangoproject.com/documentation/model-api/#the-permalink-decorator

On Jul 22, 1:30 pm, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a very strange problem with the permalink-decorator:
>
> model:
> 
> def get_url(self):
>       return permalink('experiment_view', (), {'exp_id': self.id})
>
> urls.py:
> ...
> url(r'^(?P\d+)$', 'edit_experiment', name='experiment_view'),
>
> in my template {{exp.get_url}} returns an empty string. But
> the function get_url() is invoked. The problem is the permalink
> decorator. It seems as if he can not resolve the url.
>
> I dont have any idea what I am doing wrong.
> Thanks for your help.
> Toni
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can't Send Password With Test Client

2008-07-22 Thread Russell Keith-Magee

On Tue, Jul 22, 2008 at 5:05 AM, James <[EMAIL PROTECTED]> wrote:
>
> It appears that the password value isn't printed for security reasons.
> The problem remains that the form will not validate.

Are you sure you have a test user? Remember, when you run the test
suite, you're not using the standard database - you're using a
temporary test database which will not contain any users by default.
You will need to create a test user before you can log in. Fixtures
are one easy way to do this; manually invoking
User.objects.create_user() is another.

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



Re: Deploying Django on Apache

2008-07-22 Thread Pepsi330ml

YES!!!

It worked!!

Now onto another problem.

Database settings, my original settings is postgresql_psycopg2
Running from command line, the web application can access the database
with no problem.

Running off apache, i have a interface error complaining the
connection is closed.

Then i change the database setting to postgresql, it worked.
Why is this so?
Did i miss out any configuration?

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



Extending Newforms Admin with functionality

2008-07-22 Thread gnijholt

Hello django-users,

What is the preferred way of extending the Admin interface with
functionality (not just a template override) (using the newforms
admin)? I ask because I'm trying to build something simple.

I have a model NewsletterSubscriber which has just a name, an active
boolean, and an e-mail field. Extending the 'change_list.html'
template enables me to display some sort of button within the 'object-
tools' block.

Now I'd like to attach functionality to this custom button. (I want to
loop through the mailinglist and send out mails)

Where do I start to look? Are there any guides that I've missed?

Thanks.
Gijs



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



Re: Deploying Django on Apache

2008-07-22 Thread arsyed

On Tue, Jul 22, 2008 at 5:47 AM, Pepsi330ml <[EMAIL PROTECTED]> wrote:
>
> like this?
>
> NameVirtualHost 127.1.1.1
> 
>...
>PythonDebug On
>
>PythonPath "[/home/Documents/WebApplication/
> 0.1/',#the
> main directory for the application
> '/home/Documents/WebApplication/0.1/
> src',   #add src
> for main web application module
> '/home/Documents/WebApplication/0.1/lib'] +
> sys.path"#add
> lib for logger module
>   ...
> 


That's what I was thinking. Did it have any effect after restarting apache?

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



Re: Model Meta verbose_name setter

2008-07-22 Thread James PIC

Hi Marty,

On Mon, Jul 21, 2008 at 9:18 PM, Marty Alchin <[EMAIL PROTECTED]> wrote:
>
> On Mon, Jul 21, 2008 at 2:55 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> This is why i need to code a little mechanism to set the verbose_name
>> property of Meta subclass of Model.
>> I can't get it to work!
>
> All of the options you're suggesting would work just fine if only Meta
> ever got instantiated into an object. Alas, it doesn't. Django doesn't
> really use it as a means to create an object, but more as a way to
> create a separate namespace for all the various options you can set,
> without getting in the way of model fields and methods.

Thanks for the tip!

> Unfortunately, from your examples, I can't really figure out what
> problem you're trying to solve, so I don't know what to recommend for
> you. All I can say is that none of your attempts will work without
> Meta being instantiated, which Django doesn't (and likely won't) do.

I'm trying to use the value of a field of the model for Meta verbose_name.

James

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



Re: Custom validation

2008-07-22 Thread Alex Rades

Well, as i said, overriding save() does not provide the ability to
raise an error which is field-specific.

What i want to do, was possible with validator_list. I actually don't
understand why this functionality has been removed.

On Mon, Jul 21, 2008 at 7:59 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> If that's what you want, then override the save() method of the model
> that throws an exception if it doesn't meet your requirements.
>
> -Jeff
>
> On Jul 21, 9:43 am, "Alex Rades" <[EMAIL PROTECTED]> wrote:
>> The point is that i see this validation as tied to the model, not to a
>> specific form. For me this as an integrity check, something which
>> should be done at model level.
>>
>> On Mon, Jul 21, 2008 at 3:20 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>>
>> > Sounds like you're looking at the oldforms documentation--that's all
>> > been deprecated.  Read this instead:
>> >http://www.djangoproject.com/documentation/newforms/
>>
>> > Especially this part:
>> >http://www.djangoproject.com/documentation/newforms/#custom-form-and-...
>>
>> > -Jeff
>>
>> > On Jul 21, 8:14 am, "Alex Rades" <[EMAIL PROTECTED]> wrote:
>> >> Hi,
>>
>> >> First of all, I'm using trunk :)
>>
>> >> I have a couple of models like:
>>
>> >> class User(model.Model):
>> >> group = models.ForeignKey(Group)
>>
>> >> Class Group(model.Model):
>> >> interest = models.ForeignKey(Interests)
>>
>> >> Basically i want to be possible to change in the admin the interest of
>> >> a Group *only if*:
>>
>> >> self.user_set.count() == 0
>>
>> >> The documentation is not very about custom validation, it says to pass
>> >> validator_list to the field definition, so i've tried with:
>>
>> >> interest = models.ForeignKey(interests, validator_list = [ myvalidator ])
>>
>> >> But it seems the custom validators are not called at all. Is this
>> >> possible? How do I perform custom validation on a specific form? Doing
>> >> it into the save() method of the model is not suitable (I want to
>> >> raise an error which is specific to a field and is displayed next to
>> >> the field itself)
>>
>> >> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newbie -- hiccups in following tutorial

2008-07-22 Thread Horst Gutmann

This tutorial applies to the trunk version of Django and this
particular part requires a very recent checkout (from not older than
the 18th of this month). You can normally get the version of Django
you're using by running `django-admin.py --version` :-)

The problem you have seems to be related to the age of your version of
Django. You will need a very recent checkout (or the Alpha released
last night) for this :-)

-- Horst

On Tue, Jul 22, 2008 at 11:02 AM, Morgan Packard
<[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I'm going through the tutorial at 
> http://www.djangoproject.com/documentation/tutorial01/,
> and am having trouble with the second page (http://
> www.djangoproject.com/documentation/tutorial01/).
>
> The tutorial instructs me to add "admin.site.register(Poll)" to the
> bottom of models.py. I've done that, and now the sever gives me the
> following error:  AttributeError: 'module' object has no attribute
> 'site'
>
> Everything else has worked perfectly up to this point.  This is how my
> models.py looks:
>
> 
> from django.db import models
> from django.contrib import admin
> import datetime
>
>
> class Poll(models.Model):
>question = models.CharField(max_length=200)
>pub_date = models.DateTimeField('date published')
>
>def __unicode__(self):
>return self.question
>
>def was_published_today(self):
>return self.pub_date.date() == datetime.date.today()
>
>
> class Choice(models.Model):
>poll = models.ForeignKey(Poll)
>choice = models.CharField(max_length=200)
>votes = models.IntegerField()
>def __unicode__(self):
>return self.choice
>
> admin.site.register(Poll)
> 
>
> One possible clue is the fact that the urls.py Django generated for me
> differes from the one in the tutorial. The urls.py Django gave me is
> missing the following lines which are shown in the tutorial:
>
> 
> from django.contrib import admin
> admin.autodiscover()
> 
>
> One last question:  how can I tell precisely which version of django I
> have? There doesn't seem to be a version number in the readme.
>
> thanks so much!
>
> -Morgan
>
> >
>

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



newbie -- hiccups in following tutorial

2008-07-22 Thread Morgan Packard

Hello all,

I'm going through the tutorial at 
http://www.djangoproject.com/documentation/tutorial01/,
and am having trouble with the second page (http://
www.djangoproject.com/documentation/tutorial01/).

The tutorial instructs me to add "admin.site.register(Poll)" to the
bottom of models.py. I've done that, and now the sever gives me the
following error:  AttributeError: 'module' object has no attribute
'site'

Everything else has worked perfectly up to this point.  This is how my
models.py looks:


from django.db import models
from django.contrib import admin
import datetime


class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def __unicode__(self):
return self.question

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()


class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __unicode__(self):
return self.choice

admin.site.register(Poll)


One possible clue is the fact that the urls.py Django generated for me
differes from the one in the tutorial. The urls.py Django gave me is
missing the following lines which are shown in the tutorial:


from django.contrib import admin
admin.autodiscover()


One last question:  how can I tell precisely which version of django I
have? There doesn't seem to be a version number in the readme.

thanks so much!

-Morgan

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



Assessing Django for our web presence

2008-07-22 Thread Daniele Procida

Hi. I'm the web officer for the medical school of a large British university.

We have decided to migrate our website to an Open Source content
management and publishing platform, and Django is one of the systems
we're investigating (Zope/Plone is another serious candidate).

I visited another university last week to see how they're using Django,
and was mightily impressed. So at the moment we're exploring Django.

There is some particular functionality we require from our CMS, and
though no doubt our programmers can develop the necessary code, it would
nice to know if modules exist already in the Django community for these.

So, if can point me in the direction of resources or reading that would
help in achieving any of the following I'd be very grateful:

*   menus

The University's webstyle mandates the use of a set of navigation menus,
some global and some local (and with fairly complex requirements)


*   teaser content on nearly all content items

By teaser content I mean a short summary of the item, like the news item
summaries at 


*   object-oriented linking

We need links to survive changes in URIs.

Say I have a page at:



for the Department of Pharmaceutical Medicine, and then the department
changes its name to Pharmacology - I'd like all links to that page (and
the pages below it in the structure) to be updated to point to the new URI.


*   LDAP integration

Our web authors' credentials will be taken from an LDAP databases, as
will visitors (for Intranet access control). I'd also like our staff
lists published on the web to be based on the LDAP database.


It looks to me that Flat pages is the best choice for the main structure
of our site, because the University mandates a hierarchical site
structure for its schools. Also, I think that a hierarchical structure
will help authors manage their content better.

Thanks for any pointers.

Daniele


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



Strange Postgresql Connection issue

2008-07-22 Thread madhav

A little bit of background to the problem:
I have a page, which will have dynamic right-side bar , dynamic center-
pane . Each bar is different from others. Think of it like,right-
sidebar is showing my subscribed categories of a news site and center-
pane is showing my actual news-posts list in the site. Each one is
extracted from a different table. ie.. Subscribed categories from
"subscribed" table, Posted News from "posted" table.
My Question is when I land at this page, is the django going to use
only one postgresql connection to serve all the data required or is it
going to use multiple database connections. One of my friends told me
its 1 connection per request, so even though 150 persons request the
same (personalized)page, only 150 connections are created right?? and
not 300 right?? Please forgive me for my ignorance. So my question is
how many postgresql connections are used per a single page.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Newbie

2008-07-22 Thread Horst Gutmann

How did you install Django? It seems like Django wasn't installed in
your PYTHONPATH. Also what version of Django are you trying to work
with? What operating system are you using? Could you please only post
complete error messages? :-)

-- Horst

On Tue, Jul 22, 2008 at 10:39 AM, Amie <[EMAIL PROTECTED]> wrote:
> I have installed Django and everything that I was told to.
> The problem is that I've started working with "The Basics of Dynamic
> Web Pages" in the django book (www.djangobook.com/en/1.0.chapter03/)
> and when i run the progarm, i get an error that says i dont have an
> http module. What do I do?
>
> On Jul 22, 9:43 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote:
>> Hi :-)
>>
>> What exactly didn't you understand in the tutorial? How far have you
>> come within the tutorial so far?
>>
>> -- Horst
>>
>> On Tue, Jul 22, 2008 at 9:06 AM, Sthembile Ngidi
>>
>> <[EMAIL PROTECTED]> wrote:
>>
>> > -- Forwarded message --
>>
>> > Morning,
>>
>> > I'm relatively new to python and I want to use django to create a website.
>> > I've gone to the website, django, and I don't quite catch the tutorial.
>> > Please if possible can you help me  in creating my first project, as well 
>> > as
>> > creating the forms and adding images to them as well as using the database
>>
>> > Any notes or pointers will be appreciated
>> > Thank You
>>
>> > Amanda Ngidi
>

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



Re: Django Page - Db Connections count

2008-07-22 Thread madhav

I am using the DebugFooterMiddleware, but it still doesn't show how
many postgresql connections are used to fetch all the components in a
page. What i want is the total number of db connections count. How can
I get that? Please forgive me for my ignorance.

On Jul 22, 12:30 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> You could try the debug middleware:http://www.djangosnippets.org/snippets/766/
>
> or the page stats 
> middleware:http://code.djangoproject.com/wiki/PageStatsMiddleware
>
> and this article by Simon Willison is a good general 
> resource:http://simonwillison.net/2008/May/22/debugging/
>
> Yours,
> Eric
>
> On Jul 22, 2008, at 3:02 PM, madhav wrote:
>
>
>
> > Guys, I need some middleware or utility to check how many postgresql
> > connections are actually used to generate a particular page in django.
> > Can We get that by any chance? I am in the real pinch, Please help me.
>
>
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple languages in Admin

2008-07-22 Thread Chris Ovenden

Looks great, thanks!

Chris

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



Re: Django Page - Db Connections count

2008-07-22 Thread Eric Abrahamsen

You could try the debug middleware:
http://www.djangosnippets.org/snippets/766/

or the page stats middleware:
http://code.djangoproject.com/wiki/PageStatsMiddleware

and this article by Simon Willison is a good general resource:
http://simonwillison.net/2008/May/22/debugging/


Yours,
Eric


On Jul 22, 2008, at 3:02 PM, madhav wrote:

>
> Guys, I need some middleware or utility to check how many postgresql
> connections are actually used to generate a particular page in django.
> Can We get that by any chance? I am in the real pinch, Please help me.
> >


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



Re: Getting an IndexError when using distinct() and order_by()

2008-07-22 Thread Malcolm Tredinnick


On Mon, 2008-07-21 at 15:57 -0700, Malcolm Tredinnick wrote:
> 
> On Mon, 2008-07-21 at 15:41 -0700, bhunter wrote:
> > Ahh, never mind.  Looks like it IS a bug, but a very new one:
> > 
> > http://code.djangoproject.com/ticket/7791
> 
> I haven't had a chance to look at that bug yet, except to reproduce it

This was fixed in [8052]. It turned out to be something very lame that I
did whilst addressing another bug. So now we have another useful test
case in the suite.

Malcolm


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



Re: Django Newbie

2008-07-22 Thread Horst Gutmann

Hi :-)

What exactly didn't you understand in the tutorial? How far have you
come within the tutorial so far?

-- Horst

On Tue, Jul 22, 2008 at 9:06 AM, Sthembile Ngidi
<[EMAIL PROTECTED]> wrote:
>
>
> -- Forwarded message --
>
>
> Morning,
>
> I'm relatively new to python and I want to use django to create a website.
> I've gone to the website, django, and I don't quite catch the tutorial.
> Please if possible can you help me  in creating my first project, as well as
> creating the forms and adding images to them as well as using the database
>
> Any notes or pointers will be appreciated
> Thank You
>
> Amanda Ngidi
>
>
> >
>

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



Saving tests' output to a file in Windows

2008-07-22 Thread Julien Phalip

Hi,

I'm running Django's whole test suite in Windows, from a clean
checkout. I get lots of errors and failures, but there's apparently
some known issues, as described in [1].

Anyway, I can't really debug these errors because the output doesn't
entirely fit in the command window. So I'd like to save the output in
a file, but it doesn't work. I tried:

set PYTHONPATH=E:\django
runtests.py --settings=settings > results.txt

But the file remains empty. I wonder if that's because Django crashes
and the writing is interrupted somehow.

Do you know how I can get it to write the whole output in a text file?

Thanks!

Julien

[1] http://code.djangoproject.com/wiki/DjangoOnWindows
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Page - Db Connections count

2008-07-22 Thread madhav

Guys, I need some middleware or utility to check how many postgresql
connections are actually used to generate a particular page in django.
Can We get that by any chance? I am in the real pinch, Please help me.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---