Re: Querying a User profile

2008-06-29 Thread AdamC

On Mon, Jun 30, 2008 at 12:08 AM, Peter Rowell <[EMAIL PROTECTED]> wrote:
>
>> Any advice on how to query User for a particular team name?
>
> Since the relationship is between Team and UserProfile, I believe
> that's where you need to start. Something like this would work:
>
> team = Team.objects.get(team=team_name)
> ups = UserProfile.objects.filter(team=team)
> users = [up.user for up in ups]
>
> You now have a list of users on the team. There may be another way to
> do this, but none leaps to mind.

Thanks Peter. Works a treat.

--
You back your data up on the same planet?
http://www.monkeez.org
PGP key: 0x7111B833

--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread [EMAIL PROTECTED]

Hi

On Jun 29, 7:31 pm, spacetaxi <[EMAIL PROTECTED]> wrote:
> Currently, I'm thinking about implementing some kind of http-proxy
> within my django-app, so django would forward the incoming requests
> (get/post) to the particular application.

This is good idea, but probably should be implemented on a layer upper
- inside
of apache. Probably in mod_python.

> When receiving the response,
> django could modify the html source so the content gets embedded into
> my common page template (with the menu bar at the top of the page).

In fact, that is very close to the working implementations I've seen
so far.
To achieve great integration, you definitely need to be able to form
single
page output from all 3 components. For example, on some sites we've
made
some part of functionality is done in Django, some in PHP, and we need
to print
out information on page from both appplications. The simplest way
seems
to be just to use, for example PHP to render it once, and Django to
render PHP
output - this should be done inside of apache handler for performance
reasons. Another (more complicated) way is to write function handlers
so one application
can ask another application for certain functionality, and then render
page - this can be done with software bridges like this one:
http://developers.facebook.com/thrift/

At one of projects we are currently integrating we used different
approach. We have
duplicated HTML templates, and made session data available from PHP to
Django
by running Django as 'apache' user, and reading PHP Session data via
PHPUnserialize.py. Then, we wrote our own decorators login_required,
etc to get
the clean integration.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Using template_utils to get latest modified object.

2008-06-29 Thread chatchai

If I have a 'modified' filed like this,
modified = models.DateTimeField(auto_now=True)

The question is, How to setup the GENERIC_CONTENT_LOOKUP_KWARGS to get
latest object for model using get_latest_ovject template tag.

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: how to? : non-required admin fields

2008-06-29 Thread eddie

Thanks Jeff.

On Jun 29, 10:41 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> eddie wrote:
> > Hi.  I'm looking to find out how you make form fields in the admin
> > section non-required.  I've done a few hours of searching, but haven't
> > found the answer yet.  If anyone can let me know where I can find it,
> > it would be much appreciated.
>
> Put blank=True and null=True in your models.py for the field in question.
>
>  signature.asc
> 1KDownload
--~--~-~--~~~---~--~~
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: how to? : non-required admin fields

2008-06-29 Thread Jeff Anderson

eddie wrote:

Hi.  I'm looking to find out how you make form fields in the admin
section non-required.  I've done a few hours of searching, but haven't
found the answer yet.  If anyone can let me know where I can find it,
it would be much appreciated.
  

Put blank=True and null=True in your models.py for the field in question.



signature.asc
Description: OpenPGP digital signature


how to? : non-required admin fields

2008-06-29 Thread eddie

Hi.  I'm looking to find out how you make form fields in the admin
section non-required.  I've done a few hours of searching, but haven't
found the answer yet.  If anyone can let me know where I can find it,
it would be much appreciated.

Thanks!
-e

--~--~-~--~~~---~--~~
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: Bug with unique_together on mod_wsgi?

2008-06-29 Thread Graham Dumpleton

Was your mod_python setup using single threaded prefork? Is your
mod_wsgi setup also using single threaded prefork, or have you moved
to using multithread worker MPM and/or multithreaded daemon processes?
Maybe you are seeing a multithreading issue.

Graham

On Jun 29, 8:13 pm, Julien <[EMAIL PROTECTED]> wrote:
> Ok, thanks.
> I too found strange that it could be related. But the problem only
> appeared on the production server just after we switched tomod_wsgi.
> I'll investigate a bit further and post here if I can fix it.
>
> On Jun 29, 6:23 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > `unique_together` is a database level feature so it cannot depend on
> > web-server and its modules.
> > When you don't give any code to see where you add new entry and
> > retrieve.
>
> > On Jun 29, 10:32 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > Since I switched my site from mod_python tomod_wsgi, the meta
> > > attribute 'unique_together' stopped working properly. When creating a
> > > duplicate entry, instead of getting the error message "Entry with this
> > > date already exists for the given slug." I get an exception:
>
> > > "MultipleObjectsReturned: get() returned more than one Entry-- it
> > > returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
> > > 'slug__iexact': u'example-title'}"
>
> > > (Full traceback given below.)
>
> > > Also, some duplicates have slipped through when entries have been
> > > added by the administrators of the site. So, apparently, that
> > > exception is not always raised or at least it fails silently.
>
> > > It works fine on the development server which runs with mod_python
>
> > > Has someone got similar issues, and would you see what I'm missing
> > > here?
>
> > > Thanks a lot!
>
> > > Julien
>
> > > PS: Traceback:
>
> > >  File "/MY_PATH/django/core/handlers/base.py", line 82, in
> > > get_response
> > >    response = callback(request, *callback_args, **callback_kwargs)
>
> > >  File "/MY_PATH/django/contrib/admin/views/decorators.py", line 62, in
> > > _checklogin
> > >    return view_func(request, *args, **kwargs)
>
> > >  File "/MY_PATH/django/views/decorators/cache.py", line 44, in
> > > _wrapped_view_func
> > >    response = view_func(request, *args, **kwargs)
>
> > >  File "/MY_PATH/django/contrib/admin/views/main.py", line 334, in
> > > change_stage
> > >    errors = manipulator.get_validation_errors(new_data)
>
> > >  File "/MY_PATH/django/oldforms/__init__.py", line 62, in
> > > get_validation_errors
> > >    errors.update(field.get_validation_errors(new_data))
>
> > >  File "/MY_PATH/django/oldforms/__init__.py", line 379, in
> > > get_validation_errors
> > >    self.run_validator(new_data, validator)
>
> > >  File "/MY_PATH/django/oldforms/__init__.py", line 369, in
> > > run_validator
> > >    validator(new_data.get(self.field_name, ''), new_data)
>
> > >  File "/MY_PATH/django/utils/functional.py", line 55, in _curried
> > >    return _curried_func(*(args+moreargs), **dict(kwargs,
> > > **morekwargs))
>
> > >  File "/MY_PATH/django/db/models/manipulators.py", line 302, in
> > > manipulator_validator_unique_together
> > >    old_obj = self.manager.get(**kwargs)
>
> > >  File "/MY_PATH/django/db/models/manager.py", line 82, in get
> > >    return self.get_query_set().get(*args, **kwargs)
>
> > >  File "/MY_PATH/django/db/models/query.py", line 199, in get
> > >    % (self.model._meta.object_name, num, kwargs))
>
> > > MultipleObjectsReturned: get() returned more than one Entry-- it
> > > returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
> > > 'slug__iexact': u'example-title'}
--~--~-~--~~~---~--~~
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 upload

2008-06-29 Thread Graham Dumpleton

On Jun 30, 6:15 am, umrzyk <[EMAIL PROTECTED]> wrote:
> hi there,
> i would like to give my users ability to upload a huge (i.e. 10-20 MB)
> files, mostly images. standard uploading using django newforms and
> FileField is at the moment not an option. it kills my
> server immediately. recently i read about streaming upload, and.. wow,
> that's it! so i patched my django sources with 2070-r7728.patch (no
> conflicts) and gave it a try. here are the problems:
>
> - for small files (i didn't check what is a small file, i guess it's
> something < 2.5MB as mentioned in doc) i got a validation message:
> "the
> submitted file is empty"
>
> - for larger files (i tried 11MB) i got an error from server: "413
>   Request Entity Too Large"
>
> i'm sure i'm doing something wrong, actually i'm the beginner. could
> you
> suggest where should i start searching? Or could you help me with a
> sample snippet that would upload the file in a given directory?
>
> running server is nginx 0.7.1 withmod_wsgi

You may have to to ask the author of nginx mod_wsgi whether streaming
uploads is even possible.

I vaguely remember from discussions, that due to nginx mod_wsgi being
an event driven system, rather than using a threaded model, that it
may have to read complete request content into memory or onto disk
before it even executes the application. If it is into memory, then
what you are trying to do may not help as far as memory usage.

Graham
--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread Alex Ezell

On Sun, Jun 29, 2008 at 12:41 PM, spacetaxi <[EMAIL PROTECTED]> wrote:
>
> On 29 Jun., 18:44, "Alex Ezell" <[EMAIL PROTECTED]> wrote:
>> It's pretty simple to get Django and PHP to share the same
>> session information once a user has been logged in on the
>> PHP side.
>
> I'd like to do it the other way around: Login with django and share
> the authentication with PHP and Zope2.

It shouldn't matter which way you go. Whether you use a memcache
backend or file backend or some other backend (database, by default in
django) to store the session/authentication info, you're essentially
going to need to write some middleware that overrides the methods of
whichever backend you use. Then, in that middleware, you'll be
serializing or unserializing the session info so that one system or
the other can access it.

/alex

--~--~-~--~~~---~--~~
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: get admin url patch on db/models/base.py

2008-06-29 Thread Malcolm Tredinnick


On Sun, 2008-06-29 at 17:27 -0700, Milan Andric wrote:
> I was just curious if anything like this get_admin_url patch was
> already available in django trunk somewhere and I can eliminate the
> patch from my patched version of django.  Or is there a more
> appropriate way to do this so it doesn't cause a conflict?
> 
> Link: http://dpaste.com/59850/

Code like that doesn't really have any place in the Models class, so
it's not likely to be in core. It would promote the admin application to
some kind of special treatment by hardcoding it in and we try very hard
to avoid doing that. Remember that we are in the process of moving admin
dependencies *out* of the Model class not putting them in.

Adding a method like that to a class sounds more like something that
would be done by the admin class (I'm thinking about newforms-admin
here, since existing admin is on life-support only) as part of
initialiasing that. However, it doesn't make sense to do it by default,
since each model won't necessarily have a unique admin URL. But it's
certainly something you could do as a custom addition to the admin class
for particular models with newforms-admin.

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
-~--~~~~--~~--~--~---



get admin url patch on db/models/base.py

2008-06-29 Thread Milan Andric

I was just curious if anything like this get_admin_url patch was
already available in django trunk somewhere and I can eliminate the
patch from my patched version of django.  Or is there a more
appropriate way to do this so it doesn't cause a conflict?

Link: http://dpaste.com/59850/

Pasted:
svn diff /opt/local/lib/python2.5/site-packages/django/db/models/
base.py
Index: /opt/local/lib/python2.5/site-packages/django/db/models/base.py
===
--- /opt/local/lib/python2.5/site-packages/django/db/models/base.py
(revision 7787)
+++ /opt/local/lib/python2.5/site-packages/django/db/models/base.py
(working copy)
@@ -8,6 +8,7 @@
 import django.db.models.manager # Ditto.
 from django.core import validators
 from django.core.exceptions import ObjectDoesNotExist,
MultipleObjectsReturned, FieldError
+from django.core.urlresolvers import reverse
 from django.db.models.fields import AutoField, ImageField,
FieldDoesNotExist
 from django.db.models.fields.related import OneToOneRel,
ManyToOneRel, OneToOneField
 from django.db.models.query import delete_objects, Q,
CollectedObjects
@@ -524,6 +525,8 @@
 setattr(self, cachename, get_image_dimensions(filename))
 return getattr(self, cachename)

+def get_admin_url(self):
+return
reverse('django.contrib.admin.views.main.change_stage',
args=(self._meta.app_label, self._meta.module_name, self.pk,))
 
 # HELPER FUNCTIONS (CURRIED MODEL METHODS) #
 


--
Milan
--~--~-~--~~~---~--~~
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: html and TextField

2008-06-29 Thread Malcolm Tredinnick


On Sun, 2008-06-29 at 14:12 -0700, greg wrote:
[...]
> 
> I could use the fields defined above and just allow text in the actual
> body, possible with a link to attachments (I have an "Attachments"
> table that links to announcements).  This would limit what could be
> displayed on the screen but, maybe, it would be "good enough" (tm).
> The "fancy" stuff would be in the actual attachment (this will happen
> often, anyways).

You can happily have markup in your text fields and when you include
that field in the template, pass it through the "safe" filter (or use
the "autoescape" block tag). For example,

{{ html_text|safe }}

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 upload

2008-06-29 Thread Julien

Hi,
There is a patch [1] which is almost ready and that should be merged
in Django very soon. You should give it a try and let the developers
know on the dev-list [2].

[1] http://code.djangoproject.com/ticket/2070
[2] 
http://groups.google.com/group/django-developers/browse_thread/thread/573a81affc5f09cc#

On Jun 30, 6:15 am, umrzyk <[EMAIL PROTECTED]> wrote:
> hi there,
> i would like to give my users ability to upload a huge (i.e. 10-20 MB)
> files, mostly images. standard uploading using django newforms and
> FileField is at the moment not an option. it kills my
> server immediately. recently i read about streaming upload, and.. wow,
> that's it! so i patched my django sources with 2070-r7728.patch (no
> conflicts) and gave it a try. here are the problems:
>
> - for small files (i didn't check what is a small file, i guess it's
> something < 2.5MB as mentioned in doc) i got a validation message:
> "the
> submitted file is empty"
>
> - for larger files (i tried 11MB) i got an error from server: "413
>   Request Entity Too Large"
>
> i'm sure i'm doing something wrong, actually i'm the beginner. could
> you
> suggest where should i start searching? Or could you help me with a
> sample snippet that would upload the file in a given directory?
>
> running server is nginx 0.7.1 with mod_wsgi
>
> thanks,
> jm.
--~--~-~--~~~---~--~~
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: Querying a User profile

2008-06-29 Thread Peter Rowell

> Any advice on how to query User for a particular team name?

Since the relationship is between Team and UserProfile, I believe
that's where you need to start. Something like this would work:

team = Team.objects.get(team=team_name)
ups = UserProfile.objects.filter(team=team)
users = [up.user for up in ups]

You now have a list of users on the team. There may be another way to
do this, but none leaps to mind.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Computed m2m relationships not being saved when in Admin

2008-06-29 Thread Peter Rowell

Short version: during a Save from the Admin interface, m2m
associations computed and applied as a side effect of calling save()
do not seem to be recorded (permanently?) in the database. The same
call from a view or a standalone script works.

Longer version:

I have the following class:

==
class Vineyard(models.Model):
  ...
varietals = models.ManyToManyField(Varietal, blank=True,
null=True)
  ...

def varietal_list(self):
return ', '.join([v.name for v in self.varietal.all()])

def set_default_varietals(self):
if self.varietal.count() == 0:
# add all default varietals
for v in Varietal.default():
self.varietal.add(v)
print self.varietal_list()  # check to see that it
happened

def save(self):
super(Vineyard, self).save() # make sure we have an ID before
we do m2m
self.set_default_varietals()


views.py:

def test(request):
# this one works just fine
v = Vineyard.objects.get(id=368)
v.save()
return HttpResponse(v.varietal_list())

==

When vineyard.save() is called on a new or existing object from a view
or a standalone script, it works just fine and the m2m table in the
database is updated correctly.

When I do a Save from the Admin page, I can see from the print
statement (running dev server) that set_default_varietal() is called
and that (apparently) the association was made, BUT(!) in the next
view of this Vineyard object the association is missing! (!!!)

There's no error message or any other indication that something wasn't
working, except that the new m2m relationships aren't there in the
database.

Is there something I'm missing here?

I tried adding another super().save() after set_default_vineyards()
and that didn't make any difference. I tried calling
transaction.commit_unless_managed(), no change. I tried calling
transaction.commit() and got a Transactional Error.

Help!

Ps. Although this one might be solvable by setting the defaults when a
new record is created (but where do you do that for an m2m?), there is
a *much* more complicated variation of this that keys off an analysis
of the object being save()'ed. That one must use something like this
code.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Querying a User profile

2008-06-29 Thread AdamC

I have two models, UserProfile and Team[2].

I want to create a Team page which lists all the users who belong to
that team. I'm not sure how to specify this in my view. [1] The
problem I run into is that team doesn't exist within User.

Any advice on how to query User for a particular team name?

TIA
Adam

[1]
def team_page(request, team_name):
try:
team = Team.objects.get(team=team_name)
except:
raise Http404 ('No team found')
u = User.objects.get(team=team_name)
users = u.get_profile().user
template = get_template('team_page.html')
variables = Context({
'team': team,
'users': users
})
output = template.render(variables)
return HttpResponse(output)

[2]
class Team(models.Model):
team = models.TextField(unique=True)
def __str__(self):
return str(self.team)
class Admin:
pass

class UserProfile(models.Model):
score = models.IntegerField()
team = models.ForeignKey(Team)
user = models.ForeignKey(User)
def __str__(self):
return str(self.user)
class Admin:
pass


--
You back your data up on the same planet?
http://www.monkeez.org
PGP key: 0x7111B833

--~--~-~--~~~---~--~~
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: html and TextField

2008-06-29 Thread greg

On Jun 28, 6:31 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2008-06-28 at 18:05 -0500, Greg Lindstrom wrote:
> > I would like to store text with html markup in a table to be displayed
> > to the screen.  When I created a TextField and placed html markup in
> > it, all of the tags were escaped automatically.  It there a setting to
> > turn this off (I didn't see it in the online documentation), or is
> > there another field to use so I can do this?
>
> No and no.
>
> You could create your own field subclass to do this, I guess. The reason
> for it not being there by default is that it mixes presentation facets
> with data storage and models are only data storage. It might happen one
> day, though, but it's not really high priority, since it's pretty easy
> to work with what's there now.
>
> Regards,
> Malcolm

Hey Malcolm,

Thanks for the reply.  I'd like to respond with some of the rarest
words on any mailing list:

I see your point and I agree with you.

I'd like to solicit advice from you -- and anyone else following along
-- about how to continue.   What I'd like is a way to post
announcements to my site.  It's a gymnastics site, so announcements
might be concerning an upcoming meet, fund raisers, the gym closing
for periodic maintenance, etc.  I have a standard announcement view
that shows the Title, Team, and Date in standard fields, then the
announcement text is posted to the "content" area.  Since there are so
many different announcements, there's really not a single look/feel
(some may contain tables, etc).  I really would like to drive these
with the database because the admin site makes them easy to enter and
I can control the display start and stop dates as well as the affected
teams (oh, yeah...I can flag an announcement as "critical" which
places an asterisk in front of the list).

I could use the fields defined above and just allow text in the actual
body, possible with a link to attachments (I have an "Attachments"
table that links to announcements).  This would limit what could be
displayed on the screen but, maybe, it would be "good enough" (tm).
The "fancy" stuff would be in the actual attachment (this will happen
often, anyways).

or

I could hard code announcements extending a base template.  It would
allow for any formatting I want, but one of my goals is to get this
working without me doing any day-to-day operational stuff.

Does anyone have any thoughts on either of these ideas, or another
idea that may work better?

Thanks for your time and help,

--greg
--~--~-~--~~~---~--~~
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: Inputting Date/Time in a Django Form

2008-06-29 Thread TiNo
add:





to your template, use SplitDateTimeField and pass the fields:

attrs={'class':'vDateField'}

That way you have the same date and time input as the admin interface.

TiNo

On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer <[EMAIL PROTECTED]>
wrote:

>
> Hi Folks,
>
> What's the simplest approach for me to have a form that makes it easy for
> the
> user to enter a Date/Time combination?
>
> I have my form class specified (the field in question is a
> forms.DateTimeField()), but I need to make it easy for users of the site to
> enter a date/time pair for the field.
>
> Is there a simple way to do this?  I'm using jQuery for javascript on the
> site
> if that's relevant.
>
> Thanks,
>
> Tim.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Inputting Date/Time in a Django Form

2008-06-29 Thread Tim Sawyer

Hi Folks,

What's the simplest approach for me to have a form that makes it easy for the 
user to enter a Date/Time combination?

I have my form class specified (the field in question is a 
forms.DateTimeField()), but I need to make it easy for users of the site to 
enter a date/time pair for the field.  

Is there a simple way to do this?  I'm using jQuery for javascript on the site 
if that's relevant.

Thanks,

Tim.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 upload

2008-06-29 Thread umrzyk

hi there,
i would like to give my users ability to upload a huge (i.e. 10-20 MB)
files, mostly images. standard uploading using django newforms and
FileField is at the moment not an option. it kills my
server immediately. recently i read about streaming upload, and.. wow,
that's it! so i patched my django sources with 2070-r7728.patch (no
conflicts) and gave it a try. here are the problems:

- for small files (i didn't check what is a small file, i guess it's
something < 2.5MB as mentioned in doc) i got a validation message:
"the
submitted file is empty"

- for larger files (i tried 11MB) i got an error from server: "413
  Request Entity Too Large"

i'm sure i'm doing something wrong, actually i'm the beginner. could
you
suggest where should i start searching? Or could you help me with a
sample snippet that would upload the file in a given directory?

running server is nginx 0.7.1 with mod_wsgi

thanks,
jm.

--~--~-~--~~~---~--~~
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: The Lost Fingers

2008-06-29 Thread Marcelo Barbero

2008/6/27 Juanjo Conti <[EMAIL PROTECTED]>:
>
> Could you recommend me some Django (the artist) hits?
>
> Juanjo

Nuages is my favourite:
http://www.youtube.com/watch?v=FpDiceqJItc
(but the guitarist in the video is not Django)

See also:
http://goear.com/search.php?q=django

Marcelo, from Rafaela

--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread spacetaxi

On 29 Jun., 18:44, "Alex Ezell" <[EMAIL PROTECTED]> wrote:
> It's pretty simple to get Django and PHP to share the same
> session information once a user has been logged in on the
> PHP side.

I'd like to do it the other way around: Login with django and share
the authentication with PHP and Zope2.

> I can provide more details on the session sharing if you wish.

Currently I'm just checking which options are reasonable. But I'll
happily get back on your offer when I start implementing this
functionality! So thank you very much!

-Stephan

--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread spacetaxi

On 29 Jun., 18:41, "Ariel Mauricio Nunez Gomez"
<[EMAIL PROTECTED]> wrote:
> I have 'integrated' django and moodle in the past. For authentication I
> would suggest using a single source (In my case is imap auth using google
> apps for your domain) and both moodle and django validate credentials
> against it.

Users are authenticated with ldap. So there are identical credentials
for django and moodle (and our other web apps).

> It is very easy to write django models to get access to moodle functions.

Up to now I don't havy any experience with moodle. I'm hoping I don't
have to become an expert on moodle internals just to "embed" it into
my django app, as I fear it to be a rather complex system - and
becoming an expert to be a very time consuming task... Hence my idea
of a rather generic approach to the problem. ;-)

> However I wouldn't recommend the django-app as proxy approach you suggest,
> better to write some matching  moodle themes and css for django apps and use
> something like nginx to do the routing.

I don't know nginx... Does it give us more options than Apache? Our
setup is as follows: We have Apache2 running as the only "visible"
server. It serves PHP and static files and it acts as proxy for Django
and Zope2 running on the same machine. But my suggested proxy approach
even would allow for "django-embedded" php/zope apps running on other
machines. It would give us rather flexible options... if it'd
work. ;-)

Thanks for your feedback!
-Stephan

--~--~-~--~~~---~--~~
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: python strings containing backslashes

2008-06-29 Thread Ned Batchelder

Actually, this doesn't work.  The string you show has two characters, 
both of them backslashes.  The r prefix means that backslashes aren't 
escapes, they're literal backslash characters.  Unfortunately, there's a 
flaw in the Python lexer which means you can't use a single backslash 
here either:

 >>> r'\\'
''
 >>> r'\'
  File "", line 1
r'\'
   ^
SyntaxError: EOL while scanning single-quoted string
 >>>

--Ned.

Leeland (The Code Janitor) wrote:
> I would use a raw string like this"
>
> string.rfind(r'\\')
>
> The raw string makes sure there is no additional escaped special
> characters. But you still need to escape the backslash.
>
> Here is a good read on all this: 
> http://www.python.org/doc/current/ref/strings.html
>
> + Leeland
> >
>
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: python strings containing backslashes

2008-06-29 Thread Leeland (The Code Janitor)

I would use a raw string like this"

string.rfind(r'\\')

The raw string makes sure there is no additional escaped special
characters. But you still need to escape the backslash.

Here is a good read on all this: 
http://www.python.org/doc/current/ref/strings.html

+ Leeland
--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread Alex Ezell

On Sun, Jun 29, 2008 at 11:31 AM, spacetaxi <[EMAIL PROTECTED]> wrote:

> Additionally I'd implement a "authentication bridge" between the
> different apps to share the login information with django.

This is the only part I've had any experience with. We have a legacy
PHP app that we are rewriting in Django, but which still does the vast
majority of the work across the application. It's pretty simple to get
Django and PHP to share the same session information once a user has
been logged in on the PHP side. That said, we do not have the ability
yet to create an authenticated Django "user" to be used in the Django
apps. We sort of have to crib in stuff from the session.

So, we've lost any of the auth and perm stuff that Django does. That
means custom login_required decorators and a custom perms system.

It's not ideal, but a transitional thing, it works. I can provide more
details on the session sharing if you wish.

/alex

--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread Ariel Mauricio Nunez Gomez
I have 'integrated' django and moodle in the past. For authentication I
would suggest using a single source (In my case is imap auth using google
apps for your domain) and both moodle and django validate credentials
against it.
It is very easy to write django models to get access to moodle functions.
However I wouldn't recommend the django-app as proxy approach you suggest,
better to write some matching  moodle themes and css for django apps and use
something like nginx to do the routing.

Best,
Ariel.

On Sun, Jun 29, 2008 at 11:31 AM, spacetaxi <[EMAIL PROTECTED]> wrote:

>
> Hello djangonauts,
>
> maybe someone of you has a good solution for the following scenario:
>
> We have several rather complex web applications (partly php-based,
> partly zope2-based) and I'd like to integrate them into one django-
> based front-end. New apps will be implemented with django, but we
> definitely need these "legacy" (php/zope2) apps to be available to the
> user within *one* front-end. Ideally the different apps should look
> like they actually were *one* app. (By the way, one of the php-based
> apps is Moodle (www.moodle.org).)
>
> This is my vision: After an user has logged into the (to-be-developed)
> django site, he get's some kind of "menu bar" (based on yahoo's yui)
> on the top of the screen. Every menu item selects a different web
> application, which may be django-based, php-based or zope2-based. The
> selected application will be shown below the menu bar, so the user can
> use the menu-bar to switch between the different web apps.
>
> Do you have an idea, how this could be implemented?
>
> Currently, I'm thinking about implementing some kind of http-proxy
> within my django-app, so django would forward the incoming requests
> (get/post) to the particular application. When receiving the response,
> django could modify the html source so the content gets embedded into
> my common page template (with the menu bar at the top of the page).
> Additionally I'd implement a "authentication bridge" between the
> different apps to share the login information with django.
>
> Is this a reasonable way to do it? Or do you have a better approach?
> Thank in advance for any hint!
>
> -Stephan
>
>
> >
>

--~--~-~--~~~---~--~~
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 as front-end for php- and zope2-based apps?

2008-06-29 Thread spacetaxi

Hello djangonauts,

maybe someone of you has a good solution for the following scenario:

We have several rather complex web applications (partly php-based,
partly zope2-based) and I'd like to integrate them into one django-
based front-end. New apps will be implemented with django, but we
definitely need these "legacy" (php/zope2) apps to be available to the
user within *one* front-end. Ideally the different apps should look
like they actually were *one* app. (By the way, one of the php-based
apps is Moodle (www.moodle.org).)

This is my vision: After an user has logged into the (to-be-developed)
django site, he get's some kind of "menu bar" (based on yahoo's yui)
on the top of the screen. Every menu item selects a different web
application, which may be django-based, php-based or zope2-based. The
selected application will be shown below the menu bar, so the user can
use the menu-bar to switch between the different web apps.

Do you have an idea, how this could be implemented?

Currently, I'm thinking about implementing some kind of http-proxy
within my django-app, so django would forward the incoming requests
(get/post) to the particular application. When receiving the response,
django could modify the html source so the content gets embedded into
my common page template (with the menu bar at the top of the page).
Additionally I'd implement a "authentication bridge" between the
different apps to share the login information with django.

Is this a reasonable way to do it? Or do you have a better approach?
Thank in advance for any hint!

-Stephan


--~--~-~--~~~---~--~~
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: Admin problem with user profile model.

2008-06-29 Thread AdamC

On Sun, Jun 29, 2008 at 5:17 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> On Sun, Jun 29, 2008 at 12:05 PM, AdamC <[EMAIL PROTECTED]> wrote:
>>
>> Thanks Karen. The user profile part works a treat now, until I
>> implement the team foreign key on the user profile.
>>
>> Then I get the error:
>>
>> OperationalError at /admin/tables/userprofile/
>> no such column: tables_userprofile.team_id
>>
>> on the admin part of the user profile. Now I understand the error, but
>> it doesn't make sense as it *should* exist.
>>
>> Again, any help is appreciated.
>
> You apparently ran syncdb for your models when the team ForeignKey in
> UserProfile was commented out.  Therefore the userprofile table in the
> database was created without the column to track this ForeignKey (team_id).
> You need to either manually add the column to your database so that it
> matches what you now have in your Django model, or do a manage.py reset of
> the application (which will delete any existing data in your tables).
>
> Karen
>

Works perfectly - many thanks again Karen.

Adam
--
You back your data up on the same planet?
http://www.monkeez.org
PGP key: 0x7111B833

--~--~-~--~~~---~--~~
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: Admin problem with user profile model.

2008-06-29 Thread Karen Tracey
On Sun, Jun 29, 2008 at 12:05 PM, AdamC <[EMAIL PROTECTED]> wrote:

>
> Thanks Karen. The user profile part works a treat now, until I
> implement the team foreign key on the user profile.
>
> Then I get the error:
>
> OperationalError at /admin/tables/userprofile/
> no such column: tables_userprofile.team_id
>
> on the admin part of the user profile. Now I understand the error, but
> it doesn't make sense as it *should* exist.
>
> Again, any help is appreciated.
>

You apparently ran syncdb for your models when the team ForeignKey in
UserProfile was commented out.  Therefore the userprofile table in the
database was created without the column to track this ForeignKey (team_id).
You need to either manually add the column to your database so that it
matches what you now have in your Django model, or do a manage.py reset of
the application (which will delete any existing data in your tables).

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: Admin problem with user profile model.

2008-06-29 Thread AdamC

On Sun, Jun 29, 2008 at 4:44 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
> On Sun, Jun 29, 2008 at 11:27 AM, AdamC <[EMAIL PROTECTED]> wrote:
>>
>> I have a couple of models whereby the admin interface is throwing up
>> some errors when I try add details to the user profile.
>>
>> Each user will have a points score and belong to a team, which will
>> aggregate all the scores of those users belonging to that team.
>>


> Your UserProfile __str__ function is returning a User object, not a string.
> It needs to return a string, since it is called to produce a string
> representation of your Model.  If you want to return the string
> representation of the associated user, return str(self.user).
>
>>
>> The score is an integer, but it seems that the template is expecting a
>> string, when I definitely don't want it to be a string.
>
> The error you have posted has nothing to do with score.
>

Thanks Karen. The user profile part works a treat now, until I
implement the team foreign key on the user profile.

Then I get the error:

OperationalError at /admin/tables/userprofile/
no such column: tables_userprofile.team_id

on the admin part of the user profile. Now I understand the error, but
it doesn't make sense as it *should* exist.

Again, any help is appreciated.

Adam
--
You back your data up on the same planet?
http://www.monkeez.org
PGP key: 0x7111B833

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



override label_tag?

2008-06-29 Thread TiNo

Hi,

Is there an easy way to override a form.field's label_tag method?
So I can have it add a class 'required' when form.field.required is
True, like it's done for the admin forms, but without the need of
creating fieldsets and fieldlines?

later,

TiNo
--~--~-~--~~~---~--~~
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: sessions in template (outside of views)

2008-06-29 Thread Arien

On Sun, Jun 29, 2008 at 9:08 AM, Bobby Roberts <[EMAIL PROTECTED]> wrote:
>
> So I have to explicitly pass the session variables to the template to
> use them?  That kind of defeats the purpose of session variables
> doesn't it?  If they are in session we should be able to access them
> easier than passing them from view to template throughout our
> application.

Variables that happen to hold session data are no different from other
variables.

If you want to have access to a variable in a template, you'll have to
make the variable available to the template somehow.  You can do this
by passing the variable to the template yourself, or (in some cases)
you can have a context processor do that for you.

This is one of those cases: you can have request.session added
implicitly if you do what Daniel Roseman wrote and active the
django.core.context_processors.request context processor, making sure
to always use a RequestContext when rendering the template.


Arien

--~--~-~--~~~---~--~~
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: Admin problem with user profile model.

2008-06-29 Thread Karen Tracey
On Sun, Jun 29, 2008 at 11:27 AM, AdamC <[EMAIL PROTECTED]> wrote:

>
> I have a couple of models whereby the admin interface is throwing up
> some errors when I try add details to the user profile.
>
> Each user will have a points score and belong to a team, which will
> aggregate all the scores of those users belonging to that team.
>
> My models look thus:
>
>  class Team(models.Model):
>team = models.TextField(unique=True)
>def __str__(self):
>return self.team
>class Admin:
>pass
>
> class UserProfile(models.Model):
>score = models.IntegerField()
>#team = models.ForeignKey(Team)
>user = models.ForeignKey(User)
>def __str__(self):
>return self.user
>class Admin:
>pass
>
> When I go to a user's profile in the admin interface I get the error:
>
> TypeError at /admin/tables/userprofile/1/
> __str__ returned non-string (type User)
> Request Method: GET
> Request URL:http://localhost:8000/admin/tables/userprofile/1/
> Exception Type: TypeError
> Exception Value:__str__ returned non-string (type User)
> Exception Location:
>/usr/lib/python2.5/site-packages/django/utils/encoding.py in
> force_unicode, line 53
>
> Template error
>
> In template
> /usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/change_form.html,
> error at line 14
> Caught an exception while rendering: __str__ returned non-string (type
> User)
>

Your UserProfile __str__ function is returning a User object, not a string.
It needs to return a string, since it is called to produce a string
representation of your Model.  If you want to return the string
representation of the associated user, return str(self.user).


> The score is an integer, but it seems that the template is expecting a
> string, when I definitely don't want it to be a string.
>

The error you have posted has nothing to do with score.

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
-~--~~~~--~~--~--~---



Admin problem with user profile model.

2008-06-29 Thread AdamC

I have a couple of models whereby the admin interface is throwing up
some errors when I try add details to the user profile.

Each user will have a points score and belong to a team, which will
aggregate all the scores of those users belonging to that team.

My models look thus:

 class Team(models.Model):
team = models.TextField(unique=True)
def __str__(self):
return self.team
class Admin:
pass

class UserProfile(models.Model):
score = models.IntegerField()
#team = models.ForeignKey(Team)
user = models.ForeignKey(User)
def __str__(self):
return self.user
class Admin:
pass

When I go to a user's profile in the admin interface I get the error:

TypeError at /admin/tables/userprofile/1/
__str__ returned non-string (type User)
Request Method: GET
Request URL:http://localhost:8000/admin/tables/userprofile/1/
Exception Type: TypeError
Exception Value:__str__ returned non-string (type User)
Exception Location:
/usr/lib/python2.5/site-packages/django/utils/encoding.py in
force_unicode, line 53

Template error

In template 
/usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/change_form.html,
error at line 14
Caught an exception while rendering: __str__ returned non-string (type User)

The score is an integer, but it seems that the template is expecting a
string, when I definitely don't want it to be a string.

I would be grateful on any advice about how to implement the above.
TIA
Adam
--
You back your data up on the same planet?
http://www.monkeez.org
PGP key: 0x7111B833

--~--~-~--~~~---~--~~
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: ModelInheritance : how to do isinstance() on a parent class object

2008-06-29 Thread felix


in Contact, the root class:

def save(self):
   """ on create, save the content type (leaf class) of
this object """
if(not self.content_type): # does this do a db lookup to
instantiate ?  should try to avoid that
self.content_type =
ContentType.objects.get_for_model(self.__class__)
self.save_base()

def as_leaf_class(self):
"""if this object is a subclass then refetch it with
the extra fields/table joins"""
content_type = self.content_type
model = content_type.model_class()
if(model == Contact):
#actually we could also check if self is not
Contact that throw a shit-out-of-wack error
return self
return model.objects.get(id=self.id)




On Jun 29, 4:09 pm, felix <[EMAIL PROTECTED]> wrote:
>
> > Or you can manually include a type_code attribute in your
> > parent model (since it's something you have created yourself).
>
> yes, I'll try this.
--~--~-~--~~~---~--~~
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: The Lost Fingers

2008-06-29 Thread Marcelo Barbero

2008/6/27 Juanjo Conti <[EMAIL PROTECTED]>:
>
> Could you recommend me some Django (the artist) hits?
>
> Juanjo
> --
> mi blog: http://www.juanjoconti.com.ar
>

Check here: http://goear.com/search.php?q=django

There's also a pretty song called "Nuages" here:
http://www.youtube.com/watch?v=FpDiceqJItc

Marcelo, from Rafaela

--~--~-~--~~~---~--~~
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 choices for views/newforms

2008-06-29 Thread John Aherne

Daniel Roseman wrote:
> On Jun 29, 2:24 pm, John Aherne <[EMAIL PROTECTED]> wrote:
>   
>> OK. I did some more experimenting with ModelChoiceField and my table.
>>
>> Surprise. It worked when I thought it would not. Why did it work. By
>> luck in my model I had the __unicode__ function return the right value.
>> So now I could see better what was happening.
>>
>> I also printed out the post values in the 'runserver' so I could see
>> better there what was being selected. There I was initially confused
>> because the cleaned_data was the return value from __unicode__ and not
>> what I wanted.
>>
>> But if I looked at the POST data direct I had the correct ID I wanted.
>>
>> The I saw what was happening. The post was rcmcli01:3, so the table was
>> being called with the code and giving me the name. But what I really
>> want at this point is the code so I can use it to look up another table
>> for a list of jobs. For the moment I can take that directly from the
>> POST data but I should really be getting it from cleaned_data. Not sure
>> how I can do that at the moment.
>>
>> Thanks
>>
>> John Aherne
>> 
>
>
> I think you're being confused by the display of what's being returned.
>
> In fact the value in cleaned_data should be the actual *model
> instance*. Since you have __unicode__ defined on that model, when you
> do
>   
 value = myform.cleaned_data['mychoicefield']
 print value
 
> you will see the value of the unicode method you defined. But the
> underlying value is the actual element - you can do
>   
 print value.id
 
> to get the id, and so on.
>
> By the way, I haven't addressed the second part of your OP, which was
> how to dynamically filter the values in the choicefield according to
> session data. Here's a good post that explains that:
> http://oebfare.com/blog/2008/feb/23/changing-modelchoicefield-queryset/
> --
> DR.
> >
>   
Thanks for the new info. I'll take a closer look.

Of course some of these things are documented, but you only see them 
when you have found out what is happening.

Thanks

John Aherne


--~--~-~--~~~---~--~~
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: ModelInheritance : how to do isinstance() on a parent class object

2008-06-29 Thread felix

On Jun 29, 1:28 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> > Actually it might be nice if the top parent class table had a
> > content_type field (or similar to avoid coupling to
> > contrib.contenttypes) so we could easily deduce the leaf class.
>
> ...The reason is that it
> breaks inheriting from third-party classes

yes, that makes total sense


> Or you can manually include a type_code attribute in your
> parent model (since it's something you have created yourself).

yes, I'll try this.  I guess override save() and if the content_type
isn't set then look it up and set it.
that should only happen on create at which point the leaf class type
is definitely known.


>  Relational
> databases and object-oriented inheritance have some mismatches (search
> for "Vietnam of computer science"

brilliant :)  let's not go to Iraq then.
but you've done a great job here.  with newforms-admin its all working
without problems for me.

yes, my Company class has 4 subclasses.

when you click through to view a Contact (generic parent class) I'm at
that point figuring out what the class is and simply relocating.

also : you could always do a left join across all tables and then just
check which ones' pointer fields came back not null.  that sounds
cheap.
but the parent class doesn't really know all of its subclasses.  you
would have to do this query by supplying a list of leaf classes that
it could then trace up the parents to the grandpappy and collect all
of those tables.

-cx

> 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: sessions in template (outside of views)

2008-06-29 Thread Bobby Roberts

So I have to explicitly pass the session variables to the template to
use them?  That kind of defeats the purpose of session variables
doesn't it?  If they are in session we should be able to access them
easier than passing them from view to template throughout our
application.


--~--~-~--~~~---~--~~
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 choices for views/newforms

2008-06-29 Thread Daniel Roseman

On Jun 29, 2:24 pm, John Aherne <[EMAIL PROTECTED]> wrote:
> OK. I did some more experimenting with ModelChoiceField and my table.
>
> Surprise. It worked when I thought it would not. Why did it work. By
> luck in my model I had the __unicode__ function return the right value.
> So now I could see better what was happening.
>
> I also printed out the post values in the 'runserver' so I could see
> better there what was being selected. There I was initially confused
> because the cleaned_data was the return value from __unicode__ and not
> what I wanted.
>
> But if I looked at the POST data direct I had the correct ID I wanted.
>
> The I saw what was happening. The post was rcmcli01:3, so the table was
> being called with the code and giving me the name. But what I really
> want at this point is the code so I can use it to look up another table
> for a list of jobs. For the moment I can take that directly from the
> POST data but I should really be getting it from cleaned_data. Not sure
> how I can do that at the moment.
>
> Thanks
>
> John Aherne


I think you're being confused by the display of what's being returned.

In fact the value in cleaned_data should be the actual *model
instance*. Since you have __unicode__ defined on that model, when you
do
>>> value = myform.cleaned_data['mychoicefield']
>>> print value
you will see the value of the unicode method you defined. But the
underlying value is the actual element - you can do
>>> print value.id
to get the id, and so on.

By the way, I haven't addressed the second part of your OP, which was
how to dynamically filter the values in the choicefield according to
session data. Here's a good post that explains that:
http://oebfare.com/blog/2008/feb/23/changing-modelchoicefield-queryset/
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 choices for views/newforms

2008-06-29 Thread John Aherne

John Aherne wrote:
> Daniel Roseman wrote:
>   
>> On Jun 29, 11:34 am, John Aherne <[EMAIL PROTECTED]> wrote:
>>   
>> 
>>> I've been looking at django for a while. Been through the tutorial a few
>>> times and read 2 books several times and am still trying to find out how
>>> some things work.
>>>
>>> Instead of an empty form on first loading, I would like to be able to
>>> fill out some selection lists with data pulled from a database table.
>>>
>>> There are 2 things I would like to achieve:--
>>>
>>> First, I have a model with 30 fields but I want to extract 2 columns for
>>> use with a selection list. I want to get all rows in the table but only
>>> 2 columns. I have looked at using .values() but that returns a different
>>> format than a queryset.
>>>
>>> So I then found Managers. But before I start going through that I
>>> thought I would check and see if I have gone blind and missed some
>>> obvious way of getting my select list filled based on my table selection.
>>>
>>> Second thing is I want to select certain columns from a table but filter
>>> the selection based on input from the session data. At the moment, I'm
>>> not using session data, I just want to hardcode the options so I can
>>> concentrate on how I get my selection list filled. Once again my model
>>> has 10 fields, but I only want to get 2 of those to use in my selection
>>> list.
>>>
>>> I thought about filling out a dictionary and passing that in as per the
>>> samples in forms.py. But I then read that I should not be doing this.
>>> Choices in forms is for mainly static selections. So I then start
>>> looking for a way to get my data set up for a selection list. But as I
>>> say, I've looked at .objects.values() and then started to look at managers.
>>>
>>> Also I have googled all over for some reference to this problem I have
>>> and not found any link to my problem. I have some found some links that
>>> relate to some edge cases, but nothing simple. So I think I must be
>>> being a bit stupid or blind, since noone else is having this problem.
>>>
>>> I would be very pleased if someone could point me in the way to go on this.
>>>
>>> John Aherne
>>> 
>>>   
>> What you want is a ModelChoiceField. For example:
>>
>> from django import newforms as forms
>> class MyForm(forms.Form):
>> mychoicefield =
>> forms.ModelChoiceField(queryset=MyModel.objects.all())
>>
>> or you could put your filter as the queryset -
>> MyModel.objects.filter(field=criteria)
>>
>> --
>> DR.
>> 
>>   
>> 
> Thanks for the reply.
>
> Yes I did look at this. But this pulls in all the fields from the model. 
> I only want to pull in 2 columns from the table.
>
> So I looked at .objects.values() and then managers. But before I take 
> that route I wanted to check I was going in the right direction.
>
> You seem to imply that I need to set up a model with just the fields I 
> need. Where I have found samples to look at that is the option chosen, 
> which makes it a lot simpler.
>
> Am I missing something.
>
> John Aherne
>
>
>
> >
>   
OK. I did some more experimenting with ModelChoiceField and my table.

Surprise. It worked when I thought it would not. Why did it work. By 
luck in my model I had the __unicode__ function return the right value. 
So now I could see better what was happening.

I also printed out the post values in the 'runserver' so I could see 
better there what was being selected. There I was initially confused 
because the cleaned_data was the return value from __unicode__ and not 
what I wanted.

But if I looked at the POST data direct I had the correct ID I wanted.

The I saw what was happening. The post was rcmcli01:3, so the table was 
being called with the code and giving me the name. But what I really 
want at this point is the code so I can use it to look up another table 
for a list of jobs. For the moment I can take that directly from the 
POST data but I should really be getting it from cleaned_data. Not sure 
how I can do that at the moment.

Thanks

John Aherne


--~--~-~--~~~---~--~~
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 choices for views/newforms

2008-06-29 Thread John Aherne

Daniel Roseman wrote:
> On Jun 29, 11:34 am, John Aherne <[EMAIL PROTECTED]> wrote:
>   
>> I've been looking at django for a while. Been through the tutorial a few
>> times and read 2 books several times and am still trying to find out how
>> some things work.
>>
>> Instead of an empty form on first loading, I would like to be able to
>> fill out some selection lists with data pulled from a database table.
>>
>> There are 2 things I would like to achieve:--
>>
>> First, I have a model with 30 fields but I want to extract 2 columns for
>> use with a selection list. I want to get all rows in the table but only
>> 2 columns. I have looked at using .values() but that returns a different
>> format than a queryset.
>>
>> So I then found Managers. But before I start going through that I
>> thought I would check and see if I have gone blind and missed some
>> obvious way of getting my select list filled based on my table selection.
>>
>> Second thing is I want to select certain columns from a table but filter
>> the selection based on input from the session data. At the moment, I'm
>> not using session data, I just want to hardcode the options so I can
>> concentrate on how I get my selection list filled. Once again my model
>> has 10 fields, but I only want to get 2 of those to use in my selection
>> list.
>>
>> I thought about filling out a dictionary and passing that in as per the
>> samples in forms.py. But I then read that I should not be doing this.
>> Choices in forms is for mainly static selections. So I then start
>> looking for a way to get my data set up for a selection list. But as I
>> say, I've looked at .objects.values() and then started to look at managers.
>>
>> Also I have googled all over for some reference to this problem I have
>> and not found any link to my problem. I have some found some links that
>> relate to some edge cases, but nothing simple. So I think I must be
>> being a bit stupid or blind, since noone else is having this problem.
>>
>> I would be very pleased if someone could point me in the way to go on this.
>>
>> John Aherne
>> 
>
>
> What you want is a ModelChoiceField. For example:
>
> from django import newforms as forms
> class MyForm(forms.Form):
> mychoicefield =
> forms.ModelChoiceField(queryset=MyModel.objects.all())
>
> or you could put your filter as the queryset -
> MyModel.objects.filter(field=criteria)
>
> --
> DR.
> >
>   
Thanks for the reply.

Yes I did look at this. But this pulls in all the fields from the model. 
I only want to pull in 2 columns from the table.

So I looked at .objects.values() and then managers. But before I take 
that route I wanted to check I was going in the right direction.

You seem to imply that I need to set up a model with just the fields I 
need. Where I have found samples to look at that is the option chosen, 
which makes it a lot simpler.

Am I missing something.

John Aherne



--~--~-~--~~~---~--~~
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: Multi-table inheritance with parent that can be null?

2008-06-29 Thread zenx

Ok. Everything clear then! Thank you!

On 29 jun, 12:36, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Sun, 2008-06-29 at 02:55 -0700, zenx wrote:
> > Can you make a model that inherits from another model with multi-table
> > inheritance and that can have a null parent? Or should do that always
> > with OneToOneFIeld(null=True) ?
>
> No. The assumption is that the parent link will always be non-null.
> After all, inheritance is saying you have an "is-a" relationship and it
> doesn't really make sense to say "foo is-a nothing". If the "parent" can
> be null, it's more of an attribute than an ancestor ("has-a", not
> "is-a").
>
> 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: dynamic choices for views/newforms

2008-06-29 Thread Daniel Roseman

On Jun 29, 11:34 am, John Aherne <[EMAIL PROTECTED]> wrote:
> I've been looking at django for a while. Been through the tutorial a few
> times and read 2 books several times and am still trying to find out how
> some things work.
>
> Instead of an empty form on first loading, I would like to be able to
> fill out some selection lists with data pulled from a database table.
>
> There are 2 things I would like to achieve:--
>
> First, I have a model with 30 fields but I want to extract 2 columns for
> use with a selection list. I want to get all rows in the table but only
> 2 columns. I have looked at using .values() but that returns a different
> format than a queryset.
>
> So I then found Managers. But before I start going through that I
> thought I would check and see if I have gone blind and missed some
> obvious way of getting my select list filled based on my table selection.
>
> Second thing is I want to select certain columns from a table but filter
> the selection based on input from the session data. At the moment, I'm
> not using session data, I just want to hardcode the options so I can
> concentrate on how I get my selection list filled. Once again my model
> has 10 fields, but I only want to get 2 of those to use in my selection
> list.
>
> I thought about filling out a dictionary and passing that in as per the
> samples in forms.py. But I then read that I should not be doing this.
> Choices in forms is for mainly static selections. So I then start
> looking for a way to get my data set up for a selection list. But as I
> say, I've looked at .objects.values() and then started to look at managers.
>
> Also I have googled all over for some reference to this problem I have
> and not found any link to my problem. I have some found some links that
> relate to some edge cases, but nothing simple. So I think I must be
> being a bit stupid or blind, since noone else is having this problem.
>
> I would be very pleased if someone could point me in the way to go on this.
>
> John Aherne


What you want is a ModelChoiceField. For example:

from django import newforms as forms
class MyForm(forms.Form):
mychoicefield =
forms.ModelChoiceField(queryset=MyModel.objects.all())

or you could put your filter as the queryset -
MyModel.objects.filter(field=criteria)

--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Multi-table inheritance with parent that can be null?

2008-06-29 Thread Malcolm Tredinnick


On Sun, 2008-06-29 at 02:55 -0700, zenx wrote:
> Can you make a model that inherits from another model with multi-table
> inheritance and that can have a null parent? Or should do that always
> with OneToOneFIeld(null=True) ?

No. The assumption is that the parent link will always be non-null.
After all, inheritance is saying you have an "is-a" relationship and it
doesn't really make sense to say "foo is-a nothing". If the "parent" can
be null, it's more of an attribute than an ancestor ("has-a", not
"is-a").

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
-~--~~~~--~~--~--~---



dynamic choices for views/newforms

2008-06-29 Thread John Aherne

I've been looking at django for a while. Been through the tutorial a few 
times and read 2 books several times and am still trying to find out how 
some things work.

Instead of an empty form on first loading, I would like to be able to 
fill out some selection lists with data pulled from a database table.

There are 2 things I would like to achieve:--

First, I have a model with 30 fields but I want to extract 2 columns for 
use with a selection list. I want to get all rows in the table but only 
2 columns. I have looked at using .values() but that returns a different 
format than a queryset.

So I then found Managers. But before I start going through that I 
thought I would check and see if I have gone blind and missed some 
obvious way of getting my select list filled based on my table selection.

Second thing is I want to select certain columns from a table but filter 
the selection based on input from the session data. At the moment, I'm 
not using session data, I just want to hardcode the options so I can 
concentrate on how I get my selection list filled. Once again my model 
has 10 fields, but I only want to get 2 of those to use in my selection 
list.

I thought about filling out a dictionary and passing that in as per the 
samples in forms.py. But I then read that I should not be doing this. 
Choices in forms is for mainly static selections. So I then start 
looking for a way to get my data set up for a selection list. But as I 
say, I've looked at .objects.values() and then started to look at managers.

Also I have googled all over for some reference to this problem I have 
and not found any link to my problem. I have some found some links that 
relate to some edge cases, but nothing simple. So I think I must be 
being a bit stupid or blind, since noone else is having this problem.

I would be very pleased if someone could point me in the way to go on this.


John Aherne


--~--~-~--~~~---~--~~
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: html and TextField

2008-06-29 Thread Daniel Roseman

On Jun 29, 12:05 am, "Greg Lindstrom" <[EMAIL PROTECTED]> wrote:
> I would like to store text with html markup in a table to be displayed
> to the screen.  When I created a TextField and placed html markup in
> it, all of the tags were escaped automatically.  It there a setting to
> turn this off (I didn't see it in the online documentation), or is
> there another field to use so I can do this?
>
> I'd like to do this so I can store "announcements" in my project.
>
> Thanks,
> --greg

Best thing to do is to unescape it in the template.

Either {{instance.field|safe}}
or
{% autoescape off %}
{{instance.field}}
{% autoescape on %}


Another way to do it might be to put a function in your model which
returns the data marked as safe (untested):

from django.utils.safestring import mark_safe
class MyModel(models.Model):
mytextfield = models.TextField()

def display_mytextfield(self):
return mark_safe(self.mytextfield)

then in the template just all {{instance.display_mytextfield}}

--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Bug with unique_together on mod_wsgi?

2008-06-29 Thread Julien

Ok, thanks.
I too found strange that it could be related. But the problem only
appeared on the production server just after we switched to mod_wsgi.
I'll investigate a bit further and post here if I can fix it.

On Jun 29, 6:23 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> `unique_together` is a database level feature so it cannot depend on
> web-server and its modules.
> When you don't give any code to see where you add new entry and
> retrieve.
>
> On Jun 29, 10:32 am, Julien <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Since I switched my site from mod_python to mod_wsgi, the meta
> > attribute 'unique_together' stopped working properly. When creating a
> > duplicate entry, instead of getting the error message "Entry with this
> > date already exists for the given slug." I get an exception:
>
> > "MultipleObjectsReturned: get() returned more than one Entry-- it
> > returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
> > 'slug__iexact': u'example-title'}"
>
> > (Full traceback given below.)
>
> > Also, some duplicates have slipped through when entries have been
> > added by the administrators of the site. So, apparently, that
> > exception is not always raised or at least it fails silently.
>
> > It works fine on the development server which runs with mod_python
>
> > Has someone got similar issues, and would you see what I'm missing
> > here?
>
> > Thanks a lot!
>
> > Julien
>
> > PS: Traceback:
>
> >  File "/MY_PATH/django/core/handlers/base.py", line 82, in
> > get_response
> >    response = callback(request, *callback_args, **callback_kwargs)
>
> >  File "/MY_PATH/django/contrib/admin/views/decorators.py", line 62, in
> > _checklogin
> >    return view_func(request, *args, **kwargs)
>
> >  File "/MY_PATH/django/views/decorators/cache.py", line 44, in
> > _wrapped_view_func
> >    response = view_func(request, *args, **kwargs)
>
> >  File "/MY_PATH/django/contrib/admin/views/main.py", line 334, in
> > change_stage
> >    errors = manipulator.get_validation_errors(new_data)
>
> >  File "/MY_PATH/django/oldforms/__init__.py", line 62, in
> > get_validation_errors
> >    errors.update(field.get_validation_errors(new_data))
>
> >  File "/MY_PATH/django/oldforms/__init__.py", line 379, in
> > get_validation_errors
> >    self.run_validator(new_data, validator)
>
> >  File "/MY_PATH/django/oldforms/__init__.py", line 369, in
> > run_validator
> >    validator(new_data.get(self.field_name, ''), new_data)
>
> >  File "/MY_PATH/django/utils/functional.py", line 55, in _curried
> >    return _curried_func(*(args+moreargs), **dict(kwargs,
> > **morekwargs))
>
> >  File "/MY_PATH/django/db/models/manipulators.py", line 302, in
> > manipulator_validator_unique_together
> >    old_obj = self.manager.get(**kwargs)
>
> >  File "/MY_PATH/django/db/models/manager.py", line 82, in get
> >    return self.get_query_set().get(*args, **kwargs)
>
> >  File "/MY_PATH/django/db/models/query.py", line 199, in get
> >    % (self.model._meta.object_name, num, kwargs))
>
> > MultipleObjectsReturned: get() returned more than one Entry-- it
> > returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
> > 'slug__iexact': u'example-title'}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Multi-table inheritance with parent that can be null?

2008-06-29 Thread zenx

Can you make a model that inherits from another model with multi-table
inheritance and that can have a null parent? Or should do that always
with OneToOneFIeld(null=True) ?
--~--~-~--~~~---~--~~
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: Bug with unique_together on mod_wsgi?

2008-06-29 Thread Alex Koshelev

`unique_together` is a database level feature so it cannot depend on
web-server and its modules.
When you don't give any code to see where you add new entry and
retrieve.

On Jun 29, 10:32 am, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Since I switched my site from mod_python to mod_wsgi, the meta
> attribute 'unique_together' stopped working properly. When creating a
> duplicate entry, instead of getting the error message "Entry with this
> date already exists for the given slug." I get an exception:
>
> "MultipleObjectsReturned: get() returned more than one Entry-- it
> returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
> 'slug__iexact': u'example-title'}"
>
> (Full traceback given below.)
>
> Also, some duplicates have slipped through when entries have been
> added by the administrators of the site. So, apparently, that
> exception is not always raised or at least it fails silently.
>
> It works fine on the development server which runs with mod_python
>
> Has someone got similar issues, and would you see what I'm missing
> here?
>
> Thanks a lot!
>
> Julien
>
> PS: Traceback:
>
>  File "/MY_PATH/django/core/handlers/base.py", line 82, in
> get_response
>    response = callback(request, *callback_args, **callback_kwargs)
>
>  File "/MY_PATH/django/contrib/admin/views/decorators.py", line 62, in
> _checklogin
>    return view_func(request, *args, **kwargs)
>
>  File "/MY_PATH/django/views/decorators/cache.py", line 44, in
> _wrapped_view_func
>    response = view_func(request, *args, **kwargs)
>
>  File "/MY_PATH/django/contrib/admin/views/main.py", line 334, in
> change_stage
>    errors = manipulator.get_validation_errors(new_data)
>
>  File "/MY_PATH/django/oldforms/__init__.py", line 62, in
> get_validation_errors
>    errors.update(field.get_validation_errors(new_data))
>
>  File "/MY_PATH/django/oldforms/__init__.py", line 379, in
> get_validation_errors
>    self.run_validator(new_data, validator)
>
>  File "/MY_PATH/django/oldforms/__init__.py", line 369, in
> run_validator
>    validator(new_data.get(self.field_name, ''), new_data)
>
>  File "/MY_PATH/django/utils/functional.py", line 55, in _curried
>    return _curried_func(*(args+moreargs), **dict(kwargs,
> **morekwargs))
>
>  File "/MY_PATH/django/db/models/manipulators.py", line 302, in
> manipulator_validator_unique_together
>    old_obj = self.manager.get(**kwargs)
>
>  File "/MY_PATH/django/db/models/manager.py", line 82, in get
>    return self.get_query_set().get(*args, **kwargs)
>
>  File "/MY_PATH/django/db/models/query.py", line 199, in get
>    % (self.model._meta.object_name, num, kwargs))
>
> MultipleObjectsReturned: get() returned more than one Entry-- it
> returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
> 'slug__iexact': u'example-title'}
--~--~-~--~~~---~--~~
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: html and TextField

2008-06-29 Thread Ross Dakin

Could you just un-escape the string before you pass it to your
template? I haven't tried this, just guessing.
--~--~-~--~~~---~--~~
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: Timeout for URLField?

2008-06-29 Thread Marcelo Ramos
2008/6/26 jabbercat <[EMAIL PROTECTED]>:

>
> Hello,
>
> does somebody know if there is a possibility to specify a timeout for
> the URLField? I'm just using a URLField, but if the URL is not correct
> the URLField needs a lot of time to response with an error.
>
>
No. Django's builtin validators has two results: validated or not. If you
put a timeout then you are not validating, you are "trying"  to validate
which is a completely different thing :-)

Why are you putting a validator if you allow it to be overriden. Just use a
CharField in that case.

Regards.

-- 
Marcelo Ramos

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Bug with unique_together on mod_wsgi?

2008-06-29 Thread Julien

Hi,

Since I switched my site from mod_python to mod_wsgi, the meta
attribute 'unique_together' stopped working properly. When creating a
duplicate entry, instead of getting the error message "Entry with this
date already exists for the given slug." I get an exception:

"MultipleObjectsReturned: get() returned more than one Entry-- it
returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
'slug__iexact': u'example-title'}"

(Full traceback given below.)

Also, some duplicates have slipped through when entries have been
added by the administrators of the site. So, apparently, that
exception is not always raised or at least it fails silently.

It works fine on the development server which runs with mod_python

Has someone got similar issues, and would you see what I'm missing
here?

Thanks a lot!

Julien



PS: Traceback:

 File "/MY_PATH/django/core/handlers/base.py", line 82, in
get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/MY_PATH/django/contrib/admin/views/decorators.py", line 62, in
_checklogin
   return view_func(request, *args, **kwargs)

 File "/MY_PATH/django/views/decorators/cache.py", line 44, in
_wrapped_view_func
   response = view_func(request, *args, **kwargs)

 File "/MY_PATH/django/contrib/admin/views/main.py", line 334, in
change_stage
   errors = manipulator.get_validation_errors(new_data)

 File "/MY_PATH/django/oldforms/__init__.py", line 62, in
get_validation_errors
   errors.update(field.get_validation_errors(new_data))

 File "/MY_PATH/django/oldforms/__init__.py", line 379, in
get_validation_errors
   self.run_validator(new_data, validator)

 File "/MY_PATH/django/oldforms/__init__.py", line 369, in
run_validator
   validator(new_data.get(self.field_name, ''), new_data)

 File "/MY_PATH/django/utils/functional.py", line 55, in _curried
   return _curried_func(*(args+moreargs), **dict(kwargs,
**morekwargs))

 File "/MY_PATH/django/db/models/manipulators.py", line 302, in
manipulator_validator_unique_together
   old_obj = self.manager.get(**kwargs)

 File "/MY_PATH/django/db/models/manager.py", line 82, in get
   return self.get_query_set().get(*args, **kwargs)

 File "/MY_PATH/django/db/models/query.py", line 199, in get
   % (self.model._meta.object_name, num, kwargs))

MultipleObjectsReturned: get() returned more than one Entry-- it
returned 2! Lookup parameters were {'date__iexact': u'2008-06-04',
'slug__iexact': u'example-title'}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---