ManytoMany using intermediary table and custom db_table

2008-10-31 Thread Mark

I'm having a little trouble tracking a down a small problem. My models
(which are working) look like this (with some of the boilerplate cut
out):

class Image(models.Model):
id = models.AutoField(primary_key=True)
pub_date = models.DateTimeField(blank=True)
caption = models.TextField(blank=True)
location = models.CharField(blank=True, max_length=150)
portfolios = models.ManyToManyField(Portfolio, db_table='set_image',
blank=True)

def __unicode__(self):
return u"%s | %s" % (self.caption, self.location)
class Meta:
db_table = 'image'
ordering = ('-pub_date',)

class Portfolio(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(blank=True, max_length=150)
description = models.CharField(blank=True, max_length=300)

class Meta:
db_table = 'sets'
def __unicode__(self):
return self.name

class ImagePort(models.Model):
# Merge table to add data (Rank for ordering) to many-to-many
relationship between Image and Portfolio
portfolio = models.ForeignKey(Portfolio, blank=False, default=None)
image = models.ForeignKey(Image, blank=False, default=None)
rank = models.IntegerField(null=True, blank=True)

class Meta:
db_table = 'set_image'
ordering = ('rank',)


and in an admin.py file I have:

class ImageAdmin(admin.ModelAdmin):
ordering = ['id']
filter_horizontal = ('portfolios',)

admin.site.register(Image, ImageAdmin)

This works fine even after upgrading to 1.0. But when I follow the new
docs and change my Image model's many-to-many definition to:

portfolios = models.ManyToManyField(Portfolio, through="ImagePort",
blank=True)

I lose the many-to-many portfolios with the nifty filter_horizontal in
the Image admin. I can get the admin.TabularInline interface by
following the docs, but like most people I really prefer the nifty
javascript version. If I try to add the portfolio with something like
fields=('portfolios',) in the ImageAdmin I get a template syntax error
complaining that the key 'portfolio' is not found.

Am I doing something obviously wrong?

--~--~-~--~~~---~--~~
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 Content Types With Test Databases

2008-12-14 Thread Mark

Hello,

Are there any comments on the issue I describe below?
Aside from issue 7052 in the tracker:

http://code.djangoproject.com/ticket/7052

I'm a new user of Django so I may be doing something
wrong.

I hope line wrapping doesn't ruin any code...

Thanks
Mark



Using Content Types With Test Databases

Related issue: http://code.djangoproject.com/ticket/7052

Dumping an app's database tables using the 'manage.py dumpdata'
command produces some problems when the ContentTypes app
is used.

The content types application is a contribution to the
Django product.  It is described in:

http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#ref-contr
ib-contenttypes

Content types are mostly automatic and an entry
for each model is made when a model is added to the
database.  This happens normally and during the creation
of the test database when tests are run using manage.py test.

Unfortunately, the content types in a development database
seem to almost always differ from those created in the test
database.  This makes any dumpdata output containing content_type
fields mostly useless.

A workaround for this is to have any data model which uses
a content_type ForeignKey to implement a save method that
autosets the content_type field:

# We need a special save method to set the content_type.
def save(self, force_insert=False, force_update=False):
self.content_type =
ContentType.objects.get(app_label=os.path.basename(os.path.dirname
(__fil
e__)), model=self.__class__.__name__.lower())
super(Party, self).save(force_insert, force_update) # Call the
"real" save() method.


This workaround requires a script to remove any content_type
fields listed in a JSON dumpdata fixture file.

Fixtures must be dumped with the --indent=2 option
on the dumpdata command.  The default JSON format will
be used.

manage.py dumpdata --indent=2 [appname] > initial_data.json

This python script will strip the content_type entries
from the fixture file.

strip_contenttypes.py
=====

#!/usr/bin/env python
#
# Mark V. Giovannetti 2008-12-14
# $Id$
# $URL$

# This script removes content_type fields from a django
# fixture file.

# Usage: strip_contenttypes.py json_file [, json_file]
#
# A backup file with an extension of '.with_content_types'
# is created for any input files.

import fileinput
import re, string

# This pattern matches a content_type line.
ct_pattern = re.compile('^\s+"content_type":')

# This pattern matches a content_type line that
# has a comma so that case can be handled by not
# removing the preceding comma.
ct_pattern_with_comma = re.compile('^\s+"content_type":\s+\d+\s*,\s*
$')

# This pattern is to match and replace a trailing
# comma before the content_type field.
trailing_comma_pattern = re.compile(',\s*$')

# This pattern is to match the last bracket in
# the json file and print it.
last_line_pattern = re.compile('^\s*]\s*$')

# We have to cope with the trailing comma on the
# line preceding the content_type line, so we must
# buffer two lines.
line1 = u''
line2 = u''

json_file = fileinput.input(inplace=1, backup='.with_content_types')

for line in json_file:

# remove the newline from the end of the line
line = string.rstrip(line)

# Check if we are at the first line, if so, set the
# line2 to be this line and depend on the initial blank
# value set for line1.
if json_file.isfirstline():
line2 = line
# We continue since the first line will never have a
# content_type marker.
continue
else:
# Move line1 to line2 and set the new line2 to the
# line just read.
line1 = line2
line2 = line

# Look for the content_type pattern in line2
if ct_pattern.match(line2):

# Don't alter line1 if the content_type line has a comma.
if ct_pattern_with_comma.match(line2):
line2 = u''
else:
line2 = u''
line1 = trailing_comma_pattern.sub('', line1, count=1)

# We don't bother printing a blank line.
if line1: print line1

# We have to output the last line within this loop
# since once the json_file is closed the inplace edit
# stops.  Let's hope the last line is always the closing
# bracket ].
if last_line_pattern.match(line):
print line2




Further, in order to have the model's actual save method
called, the base.py file in django\core\serializers must
have its DeserializedObject class' save method modified:

C:\Python25\Lib\site-packages\django\core\serializers\base.py

class DeserializedObject(object):
"""
A deserialized model.

Basically a container for holding the pre-saved deserialized data
along
with the many-to-many data saved with the object.

  

Django project idea (postfix+proftpd integration)

2008-08-22 Thread mark

Greetings from a new django user.

Now that I'm done with the configuration of my server, it's time to
setup a admin webpage so that certain local and 'virtual' (mysql)
users can configure postfix and proftp databases. Both daemons, as
well as courier-imap could be used together with a table structure
created by django.

The idea is that there would be server administrators, domain owners,
ftp users and mail users. Server administrators ofcourse have full
control, domain owners can manage their users and quota for their
users, ftp/mail users can change their password and view quota
settings.

It sounds like a project that's worth some time. It could be made in
such a way that it would be available for many users. However, I'm not
familiar with setting up a project in a collaborating fashion. I'm not
really familiar with mercurial/svn and am fairly new to Django. But
because it sounds like fun I hoping to find people that are interested
in teaming up or at least to hear me out on further details.

Mark

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

2008-08-24 Thread Mark

I played for a while and this is my result:

StaffSeq = tuple((str(i),)*2 for i in \ 
auth.models.User.objects.filter(is_staff=True))

(..)
models.CharField(max_length=30,choices=StaffSeq)

Are there better ways to do this?

Mark

On Sunday 24 August 2008 13:18:42 Mark wrote:
> This class is only for the admin page. In the following model I'd like to
> make owned_by a dropdown box showing staff users.
>
>
> from django.db import models
> from django.contrib import admin
> from django.contrib import auth
>
> class Car(models.Model):
>   brand = models.CharField(max_length=20)
>   color = models.CharField(max_length=10)
>   owned_by = models.ForeignKey(something)
>
> How can I achieve 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
-~--~~~~--~~--~--~---



Showing staff users from another model

2008-08-24 Thread Mark

This class is only for the admin page. In the following model I'd like to make 
owned_by a dropdown box showing staff users.


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

class Car(models.Model):
brand = models.CharField(max_length=20)
color = models.CharField(max_length=10)
owned_by = models.ForeignKey(something)

How can I achieve 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: Showing staff users from another model

2008-08-24 Thread Mark

> > Are there better ways to do this?
> Yes.
> owned_by = models.ForeignKey(User, limit_choices_to={ 'is_staff': True
> })
> The model documentation covers the 'limit_choices_to' argument, as
> well as the proper syntax for setting up foreign keys.

I agree, there is plenty of documentation, I'll get into it better as I 
progress. Thanks for the help on this one 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: Django new comments framework error

2008-08-28 Thread Mark

Hi,

Updated to 8613 with the release of Django 1.0 Beta 2 and saw the
addition of commenting framework - tried to add it and am getting a
similar error to above.

On Aug 27, 3:54 pm, Slavus <[EMAIL PROTECTED]> wrote:
> Here is the solution:
> You'll get this if you still have stale pyc files left over from the
> old comment system. Delete 'em and your code will work.

I tried this (even though I did not use the old commenting system).

Here is the exception information...

Environment:

Request Method: GET
Request URL: http://localhost/apps/buildboard/builddetails/80/
Django Version: 1.0-beta_1-SVN-unknown
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django_apps.buildboard',
 'django_xmlrpc',
 'django.contrib.comments']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Template error:
In template c:\_tools\python251\lib\site-packages\django\contrib
\comments\templates\comments\form.html, error at line 2
   Caught an exception while rendering: Reverse for '' not found.
   1 : {% load comments %}


   2 : 


   3 :   {% for field in form %}


   4 : {% if field.is_hidden %}


   5 :   {{ field }}


   6 : {% else %}


   7 :   


   10 : {% if field.errors %}{{ field.errors }}{% endif %}


   11 : {{ field.label_tag }} {{ field }}


   12 :   


Traceback:
File "c:\_tools\python251\lib\site-packages\django\core\handlers
\base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "c:\_tools\python251\lib\site-packages\django\contrib\auth
\decorators.py" in __call__
  67. return self.view_func(request, *args, **kwargs)
File "c:\_projects\django_apps\..\django_apps\buildboard\views.py" in
build_details
  309. print t.render(c)
File "c:\_tools\python251\lib\site-packages\django\template
\__init__.py" in render
  176. return self.nodelist.render(context)
File "c:\_tools\python251\lib\site-packages\django\template
\__init__.py" in render
  756. bits.append(self.render_node(node, context))
File "c:\_tools\python251\lib\site-packages\django\template\debug.py"
in render_node
  71. result = node.render(context)
File "c:\_tools\python251\lib\site-packages\django\contrib\comments
\templatetags\comments.py" in render
  158. formstr = render_to_string(template_search_list,
{"form" : self.get_form(context)}, context)
File "c:\_tools\python251\lib\site-packages\django\template\loader.py"
in render_to_string
  107. return t.render(context_instance)
File "c:\_tools\python251\lib\site-packages\django\template
\__init__.py" in render
  176. return self.nodelist.render(context)
File "c:\_tools\python251\lib\site-packages\django\template
\__init__.py" in render
  756. bits.append(self.render_node(node, context))
File "c:\_tools\python251\lib\site-packages\django\template\debug.py"
in render_node
  81. raise wrapped

Exception Type: TemplateSyntaxError at /apps/buildboard/builddetails/
80/
Exception Value: Caught an exception while rendering: Reverse for
'' not found.

Original Traceback (most recent call last):
  File "c:\_tools\python251\lib\site-packages\django\template
\debug.py", line 71, in render_node
result = node.render(context)
  File "c:\_tools\python251\lib\site-packages\django\template
\__init__.py", line 876, in render
return func(*resolved_vars)
  File "c:\_tools\python251\lib\site-packages\django\contrib\comments
\templatetags\comments.py", line 245, in comment_form_target
return comments.get_form_target()
  File "c:\_tools\python251\lib\site-packages\django\contrib\comments
\__init__.py", line 50, in get_form_target
return
urlresolvers.reverse("django.contrib.comments.views.comments.post_comment")
  File "c:\_tools\python251\lib\site-packages\django\core
\urlresolvers.py", line 307, in reverse
*args, **kwargs)))
  File "c:\_tools\python251\lib\site-packages\django\core
\urlresolvers.py", line 291, in reverse
raise NoReverseMatch("Reverse for '%s' not found." % lookup_view)
NoReverseMatch: Reverse for ''
not found.

---

basic http authentication in API

2008-09-15 Thread mark

Hi All,

i'am writing API for a service and i want to use basic http
authentication  for my service users.

is there is something built in django.

Please advice


--~--~-~--~~~---~--~~
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 new comments framework error

2008-09-16 Thread Mark

Hi,

Finally - I got comments to work - but not correctly :-(

Django version - svn:9003

Urls conf ..
(r'^comments/', include('django.contrib.comments.urls')),

I tried everything:
 - Deleted django/contrib/comments*.pyc files (a number of times)
 - updated to svn latest (a number of times :) )

I finally got an idea from another thread in this group - where
someone said if they manually added the django.contrib.comments.urls
directly to their app url conf then it worked. I did that - and I got
it working too.

But that leaves my wondering why I can't it working the way it's
documented.

One thing that I noticed is that the django/contrib/comments/urls.py
is not getting imported (no pyc file is being created).

So the problem I am having must be due to URL confs, and more than
likely to this urlconf not being included correctly :-(

The following doesn' t work in my app urls.py...
urlpatterns += patterns('',
(r'^comments/', include('django.contrib.comments.urls')),
)

But in the same app urls.py the following DOES work...
urlpatterns += patterns('django.contrib.comments.views',
url(r'^comments/post/$',  'comments.post_comment',
name='comments-post-comment'),
url(r'^comments/posted/$','comments.comment_done',
name='comments-comment-done'),
url(r'^comments/flag/(\d+)/$','moderation.flag',
name='comments-flag'),
url(r'^comments/flagged/$',   'moderation.flag_done',
name='comments-flag-done'),
url(r'^comments/delete/(\d+)/$',  'moderation.delete',
name='comments-delete'),
url(r'^comments/deleted/$',   'moderation.delete_done',
name='comments-delete-done'),
url(r'^comments/moderate/$',  'moderation.moderation_queue',
name='comments-moderation-queue'),
url(r'^comments/approve/(\d+)/$', 'moderation.approve',
name='comments-approve'),
url(r'^comments/approved/$',  'moderation.approve_done',
name='comments-approve-done'),
)

urlpatterns += patterns('',
url(r'^comments/cr/(\d+)/(\w+)/$',
'django.views.defaults.shortcut', name='comments-url-redirect'),
)

Any ideas?

Thanks
  Mark

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

2008-09-17 Thread Mark



On Sep 17, 7:01 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Wiadomość napisana w dniu 2008-09-16, o godz. 19:31, przez Mark:
>
> > I tried everything:
> > - Deleted django/contrib/comments*.pyc files (a number of times)
> > - updated to svn latest (a number of times :) )
>
> That's not "everything" ;). Doing rm -rf django/contrib/comments was  
> the thing I did. And it worked too.
>

Before every svn update I do rm -rf django!!  (or the equiv on windows
rd /s django)

> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R&D, Redefine
> [EMAIL PROTECTED]

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



model filed with default type set in database

2009-03-24 Thread mark

im a newbie to django. i have an existing database with default values
for field set in the database:
for example:

  created timestamp without time zone DEFAULT now(),
  number_polls integer DEFAULT 0,


i want to use django admin interface to manage tables. how do i set up
these fields in models.py, so that i can let the database set the
default values and not in django.
i tried setting null=True, and blank=True, it did not work
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Simple Pagination Problem

2009-07-29 Thread Mark

Thanks, but I have been. Its still not clear - To date I have always
been displaying

"Page 1 of 23. Showing 10 results per page"

I am just lost on how to do this.

On Jul 29, 3:44 pm, krylatij  wrote:
> Read 
> documentationhttp://www.djangoproject.com/documentation/models/pagination/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Simple Pagination Problem

2009-07-29 Thread Mark

These seem to be what I am looking for - but they are not available in
the template from what I see.
page2.start_index()
page2.end_index()


On Jul 29, 3:51 pm, Mark  wrote:
> Thanks, but I have been. Its still not clear - To date I have always
> beendisplaying
>
> "Page 1 of 23. Showing 10resultsper page"
>
> I am just lost on how to do this.
>
> On Jul 29, 3:44 pm, krylatij  wrote:
>
> > Read 
> > documentationhttp://www.djangoproject.com/documentation/models/pagination/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Simple Pagination Problem

2009-07-29 Thread Mark

Ye thats what I was afraid of - i was hoping there was something in
the Pagination object that would help me out.
But I cant see anything.

Maybe someone will point it out after I have implemented the above.

Thanks.

On Jul 29, 3:58 pm, cootetom  wrote:
> You may have to do a bit of computation back on the server in python
> code to get the data you're after. From thepaginationobject you know
> what page you are currently on, you also know how many items are on a
> page so:
>
> last_item = page_num * items_per_page
> first_item = last_item - items_per_page + 1
>
> Then in your template you can say:
>
> Displayingresults{{ first_item }} - {{ last_item }} of {{ p.count }}
> found.
>
> On Jul 29, 3:51 pm, Mark  wrote:
>
> > Thanks, but I have been. Its still not clear - To date I have always
> > beendisplaying
>
> > "Page 1 of 23. Showing 10resultsper page"
>
> > I am just lost on how to do this.
>
> > On Jul 29, 3:44 pm, krylatij  wrote:
>
> > > Read 
> > > documentationhttp://www.djangoproject.com/documentation/models/pagination/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model filed with default type set in database

2009-03-25 Thread mark

so its not possible to model this in django?

>  created timestamp without time zone DEFAULT now(),
>  number_polls integer DEFAULT 0,


thanks!

On Tue, Mar 24, 2009 at 8:22 AM, mark  wrote:
> im a newbie to django. i have an existing database with default values
> for field set in the database:
> for example:
>
>  created timestamp without time zone DEFAULT now(),
>  number_polls integer DEFAULT 0,
>
>
> i want to use django admin interface to manage tables. how do i set up
> these fields in models.py, so that i can let the database set the
> default values and not in django.
> i tried setting null=True, and blank=True, it did not work
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Timer in Django

2009-12-03 Thread Mark
Hi,

I'm using Django to create registration/payment application for a
limited number of products.I want to create a timer so that when a
user chooses to purchase a product, that product will then displayed
as "already taken".  But, if the user the user does not go through
with the purchase and the timer runs out, the product goes back to
status "available".  If the user completes the purchase, the timer
should cancel, leaving the product's status permanently as "already
taken".

I've tried using python's dictionary to instantiate python Timer
objects of the fly, but about 30% of the time, I get a "key error"
when it's time to cancel the Timer.

Please.  Could someone give me an idea on the proper way to do this in
Django?

Thanks very much!
Mark

--

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




Re: DKIM Email

2010-05-19 Thread Mark
On Apr 22, 4:16 am, Simon Meers  wrote:
> For anyone else who learned about DKIM recently [1], I've uploaded a
> snippet for a DKIM-signing email backend [2].

Brilliant. I'm just developing a Django app, had read the CH article
and was just about to figure out how to apply it to my project - but
you saved me the trouble. Thanks!

--
m.

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



Custom Feeds

2010-02-09 Thread Mark
There are a couple threads about creating custom syndication feeds,
but none ever seem to arrive at an answer.

Has anyone figured out how to add custom item elements to a feed? The
example in the django docs shows very clearly how to add hard-coded
attributes to the root, but avoids offering an example of using
SyndicationFeed.add_item_elements().

It seems to do this in anything other than a trivial way you will want
access to the item object, but it get passed  an item which is "a
dictionary of all the data passed to SyndicationFeed.add_item()"
That's where they lost me.

Does anyone have an example?

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



import csv

2010-03-19 Thread Mark
Hello,
I'm having some trouble putting together a form for batch import of
csv files.

I found django-batchimport at http://code.google.com/p/django-batchimport/
and that seemed to be the answer.  It looks like it was integrated
into Django a year ago (http://code.djangoproject.com/changeset/
10121).

It's looking batchadmin and I can't figure out how the importing of
that goes.

There is an open issue on this (http://code.google.com/p/django-
batchimport/issues/detail?id=4).  I really think that this would be a
great functionality to have.

If anyone else has a good idea how to get csv import working (as easy
as possible) for a newbie, I'd really appreciate it.

Thanks!
Mark

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



Re: import csv

2010-03-20 Thread Mark
I got it to work by just using the (already) imported
django.contrib.admin
BatchModelAdmin now becomes admin.ModelAdmin

http://code.google.com/p/django-batchimport/issues/detail?id=4


On Mar 19, 1:22 pm, Mark  wrote:
> Hello,
> I'm having some trouble putting together a form for batch import of
> csv files.
>
> I found django-batchimport athttp://code.google.com/p/django-batchimport/
> and that seemed to be the answer.  It looks like it was integrated
> into Django a year ago (http://code.djangoproject.com/changeset/
> 10121).
>
> It's looking batchadmin and I can't figure out how the importing of
> that goes.
>
> There is an open issue on this (http://code.google.com/p/django-
> batchimport/issues/detail?id=4).  I really think that this would be a
> great functionality to have.
>
> If anyone else has a good idea how to get csv import working (as easy
> as possible) for a newbie, I'd really appreciate it.
>
> Thanks!
> Mark

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



soliciting interest in a medical open source project to save the world

2010-03-29 Thread Mark
OK, maybe it won't save the world.

My name is Mark Morgan and I'm working on a project which might be of
interest to some of you.  I'm a family doctor in Minnesota and I'm
associated with a really, really big clinic in Minnesota as well as
the US Indian Health Service.  Neither institution is associated with
the project I describe below.

http://bitbucket.org/mmorgan71/soapnote

The project involves clinical (medical) documentation and using
templates (not in the Django sense) for some of the more routine
visits.  I believe that an application that inserts blurbs into free
text fields would augment medical care and could work with nearly any
Electronic Medical Record (EMR).

I'm not a programmer.  I thought I was smart because I had done a lot
with MS Access before medical school.  Working on this has been a
lesson in humility.

So much clinical software is proprietary.  Over the last year and a
half learning about Django, I've learned that the narrow focus of a
proprietary project ignores the abundance of benefits of an open
source effort.

A year ago, I approached the Indian Health Service about my project
and they encouraged me to pursue open-source.  I'm currently in
residency and have kids, so I haven't had a whole lot of time to work
on this, except in the middle of the night when I'm not on call.

But I still believe in this project.  I was afraid to put it out there
until I had something like a "proof of concept".  Over the last few
weeks, I've basically cloned Ayman Hourieh's application in his
awesome book:  "Django 1.0 Web Site Development".

Instead of sharing bookmarks, though, this is sharing pieces of text
which would be rough clinical note text.  I plugged in django-tagging
and a csv importer.

His project includes voting, commenting, and social networking
features  and those are all important to me.

For my project, I'm hoping to refine the interface, add a bookmarking
feature, and put together something of a note builder.

What I envision for the note builder is: a mechanism for saving a few
blurbs of text to build the different "SOAP" sections of a medical
note (the S is subjective (patient's complaint), the O is objective
(doctor's examination), the A is assessment (diagnosis) and the P is
plan (treatment).  So the user clicks on an S, O, A, and P (or any
combination) and builds their note.  Then that can be dumped into a
temporary text file on their computer or they can just copy it to the
clipboard.

I have some other thoughts on what would happen to that text file, but
this is already becoming a long post.  The basic functionality of just
getting your note put together and copying and pasting it into the EMR
would be a great improvement.

And OH HOW would I love for this to be on App Engine (and I do keep
trying) but I can't figure out how to do this with Django Nonrel (or
helper or patch).

I believe that this would make medical care better.  The content would
be open-source as well.  Medical providers collaborating to improve
the questions we ask, the exams we do, and treatments we provide.  At
the point of care.

There's also a place for this in medical training.  A student is given
the assignment of creating a clinical note for a common visit:  upper
respiratory infection.  They submit their note to their precepting
physician who gives feedback via this website.  And the information
persists for all to benefit.

I've been looking periodically over the last year and a half and there
isn't a project like this (open source or otherwise).  There are lots
and lots of EMRs out there, but the EMRs are proprietary and that
works against collaboration.

One note, you may see "evidence" is one of my models.  This is
important.  It is the piece that providers use to decide if treatments
actually work.  Linking these "SOAP notes" to evidence will help
select out the clinical notes that are "best practices".  To a certain
extent, every doctor is reinventing the wheel with every single
patient visit.  It's really amazing to me how similar programming is
to providing medical care.  And here we could apply DRY to both!

So, I've been living with this "ideal app" in my head for a long time
now, and even though the code is going to make you throw up and a lot
of the urls are messed up, I thought maybe at least one person might
be interested in helping with this.

Let me know and we can get to work.

Mark

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



little problem with the django template language

2008-06-19 Thread mark

Hi,

I am stuck, please help.

This is what I am trying to do:

{% ifequal item1 item2 %}
...do what I want

item1 = '/test/something/'
item2 = '/test/somethingelse/'

or

item1 = '/test/'
tem2 = '/test/simething'

both should evaluate to true and execute the if block.

I experimented with 'item|slice[:]' but I could not find out how to
determin the position (index) of the second '/'.

Please note I am a beginner in Django and I should probably know how
to solve this but obviously I do not :-((


Best Regards,
Mark


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

2008-06-20 Thread mark

I guess it was a little confusing how I formulated my problem. I just
try again. Sorry for that.

In Python what I want to do would look like the following:

item1 = '/test/something/'
item2 = '/test/somethingelse/'

if item2.startswith(item1):
do_the_trick()


Now since Django has this nice template language I need to do
something like that:
{% ifstartswith item2 item1 %}
...do the trick
{% endifstartswith %}

is that possible?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Mako templates with flatpages

2008-06-20 Thread mark

Hi there,

I am new to Django. My current website is in Typo3 (PHP) and I want to
redo most of it because I like Python better. Since I do not like the
Django template language I want to use Mako templates.

I found a way on how to use the Mako templates in Django. To get this
working I have to change the views. Most of the website is flatpages.
Is there a way to use Mako templates with flatpages without changing
the Django source (flatpage views). I want to have the Django
framework untouched and all the configurations, code etc. within my
project folder.

Is this possible?

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



flatpage for 404

2008-06-21 Thread mark

Hi there,

I do not like the django default behaviour for 404 pages since I do
not want to create a 404.html template. I like my flatpages a lot
especially the default.html template I created earlier. Therefore I
would like django to use my default.html template to display the 404
and use the '/404/' flatpage which I created. Unfortunately I did not
find out how to configure this behaviour.
I would like the configuration within my project folder and not patch
my Django installation.

Best Regards,
Mark


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

2008-06-21 Thread mark

> Lookup django.conf.urls.defaults module how handler404 is defined and
> override it by assigning  your view function in your application

hmm, here is what the documentation says:
>>>A string representing the full Python import path to the view that should be 
>>>called if none of the URL patterns match.

By default, this is 'django.views.defaults.page_not_found'. That
default value should suffice.
<<<

here is what I tried to do based on your remarks:
In my project folder I created a default.py file with the following
content:
# handler404 = 'django.views.defaults.page_not_found'
handler404 = 'django.contrib.flatpages.flatpage:404'

Unfortunately django does not even notice this configuration.

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

2008-06-21 Thread mark

I think I found an acceptable solution now.

I added the following to the files in my project directory...
urls.py:
...
handler404 = 'mysite.views.page_not_found'
handler500 = 'mysite.views.server_error'

views.py:
from django.contrib.flatpages.views import flatpage
...
def page_not_found(request):
return flatpage(request, '/404/')

def server_error(request):
return flatpage(request, '/500/')

I also created two flatpages '/404/' and '/500/'.

The only thing I do not like about the solution is that when I open a
page e.g. http://localhost:8080/crap/ Django comes up with the /404/
page but the browser shows the 'http://localhost:8080/crap/' url.

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



partial table query

2007-12-21 Thread mark

Hi,

I'am new to django framework.

as i was looking on the data model each data model is a class that is
table in the database.

my qestion is if i have a table that want to retrive partial data from
the table

Example: (media object)

table [id, name , description, url , thumbnail ]

and i also want to cerate an object MediaHeader that containe only
[id, name , description]
and MediaData [id, name , description, url , thumbnail ]

some my view need to show only the data of MediaHeader and some of
them need only MediaData.

so is there is away to tell the data model to be able to read from a
specific table and a specific filed.

Thanks

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



Debugging automatic related database fetches

2011-02-17 Thread Mark
I have a large application where I make significant use of
select_related() to bring in related model data during each original
query.

As the application has grown, the select_related calls haven't
completely kept up, leaving a number of scenarios where Django happily
and kindly goes running off to the database to fetch related model
rows.  This significantly increases the number of database hits, which
I obviously don't want.

I've had some success in tracking these down by checking the queries
generated using the django.db.connection.queries collection, but some
remain unsolved.

I've tried to find a suitable location in the django code to raise an
exception in this scenario, making the tracking much easier, but tend
to get lost in the code.

Is anyone able to point me in the right direction for a suitable
location for this?

Thanks,

Mark.

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



Re: wsgi configuration

2011-04-05 Thread Mark
Not sure if this will help, but worth a stab. Check this page:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango I had a
similar error and it fixed it for me.

After it tells you how to set up the django.wsgi it says this may not
work if you used the Django server to set up your site. Django puts
some paths in it that Python doesn't yet have using WSGI. Your
situation is a little complicated as I am just getting into Django,
but I figured I'd share this document if it may help.

Good luck,

Mark

On Apr 5, 12:46 pm, yongzhen zhang <4...@live.cn> wrote:
> Hi, thanks for reply, i have tried this. Now in order to make it
> clear, i move the iStore under home, like this: "/home/yongzhen/
> iStore". django.wsgi is inside apache file and the apache file is
> under iStore: "/home/yongzhen/iStore/django.wsgi". The content of
> django.wsgi:
>  import os, sys
> wsgi_dir = os.path.abspath(os.path.dirname(__file__))
> project_dir = os.path.dirname(wsgi_dir)
> sys.path.append(project_dir)
> project_settings = os.path.join(project_dir,'settings')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'iStore.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> and in /etc/apache2/sites-available, there is istore file, i have $
> sudo a2ensite istore. the content of istore:
> NameVirtualHost *:80
>
> 
>         ServerAdmin webmaster@localhost
>         ServerNamewww.imaboy.cn
>         ServerAlias shop.imaboy.cn
>         Alias /static /home/yongzhen/iStore/static
>         Alias /php /var/www
>         DocumentRoot /home/yongzhen/iStore
>         WSGIScriptAlias / /home/yongzhen/iStore/apache/django.wsgi
>         ErrorLog /var/log/apache2/error.log
>         LogLevel warn
>         CustomLog /var/log/apache2/access.log combined
> 
>
> When i try to openwww.imaboy.cn, here is the error in apache2
> error.log:
> [Tue Apr 05 22:43:03 2011] [error] Exception KeyError:
> KeyError(-1218787584,) in  threading.pyc'> ignored
> [Tue Apr 05 22:43:03 2011] [error] Exception KeyError:
> KeyError(-1218787584,) in  threading.pyc'> ignored
> [Tue Apr 05 22:43:03 2011] [error] Exception KeyError:
> KeyError(-1218787584,) in  threading.pyc'> ignored
> [Tue Apr 05 22:43:03 2011] [error] Exception KeyError:
> KeyError(-1218787584,) in  threading.pyc'> ignored
> [Tue Apr 05 22:43:03 2011] [error] Exception KeyError:
> KeyError(-1218787584,) in  threading.pyc'> ignored
> [Tue Apr 05 22:43:03 2011] [notice] caught SIGTERM, shutting down
> PHP Deprecated:  Comments starting with '#' are deprecated in /etc/
> php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
> [Tue Apr 05 22:43:04 2011] [notice] Apache/2.2.14 (Ubuntu) PHP/
> 5.3.2-1ubuntu4.7 with Suhosin-Patch mod_wsgi/2.8 Python/2.6.5
> configured -- resuming normal operations
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44] mod_wsgi
> (pid=8570): Exception occurred processing WSGI script '/home/yongzhen/
> iStore/apache/django.wsgi'.
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44] Traceback
> (most recent call last):
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]   File "/usr/
> local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line
> 230, in __call__
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]
> self.load_middleware()
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]   File "/usr/
> local/lib/python2.6/dist-packages/django/core/handlers/base.py", line
> 33, in load_middleware
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]     for
> middleware_path in settings.MIDDLEWARE_CLASSES:
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]   File "/usr/
> local/lib/python2.6/dist-packages/django/utils/functional.py", line
> 276, in __getattr__
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]
> self._setup()
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]   File "/usr/
> local/lib/python2.6/dist-packages/django/conf/__init__.py", line 40,
> in _setup
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]
> self._wrapped = Settings(settings_module)
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]   File "/usr/
> local/lib/python2.6/dist-packages/django/conf/__init__.py", line 75,
> in __init__
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44]     raise
> ImportError("Could not import settings '%s' (Is it on sys.path? Does
> it have syntax errors?): %s" % (self.SETTINGS_MODULE, e))
> [Tue Apr 05 22:43:11 2011] [error] [client 82.130.18.44] ImportError:
> Could not impor

Storing data before committing to data base, wait for approval of admin

2016-05-04 Thread Mark


I'm building a mobile app using Ionic framework, so the front end is 
essentially a single page AngularJS app. I'm using Django Rest framework as 
the backend.

In the application, an employee should be able to suggest updates, deletes, 
or additions to database models. In my schema, there is a "Contact person" 
model (which has fields like first_name, last_name, phone_number, etc.), a 
"GPS Address model" (which has fields like street_name, street_num, city, 
etc.) and an overarching "Delivery stop" model to which virtually all of 
the other models relate.


What I need to implement is a system whereby an employee can suggest an 
edit to an existing object, say a Contact (id: 45, first_name: 'John', 
phone_number: "435-") which has a FK relationship to a Delivery Stop 
(id: 20, title: "Stop and Shop", notes: "closes at 0600"). The employee 
wants to update the phone number to "435-0001". But the update shouldn't be 
committed to the database until a manager has reviewed the update and 
approved, or edited the update then approved.


I have a few ideas about how I might do this, but none of them seem as easy 
as I think it could be. Does anyone have any suggestions about best 
practices in this situation?

The application will also include a special manager interface where they 
can few all suggested updates/edits and approve/reject them. The client 
side essentially functions with the Delivery Stop as the primary object, 
which shows all related items in a tabbed interface (Contacts, Gps 
addresses, etc.) And each time an edit is suggested by an employee, the 
appropriate manager will receive an email notification.


Any suggestions are much appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/99fecded-f6f7-4d3a-8876-44e83a3ce007%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Modify image before it's handled by stdimage

2015-09-25 Thread Mark


I'm using django-stdimage for creating variations of the image.


class Photo(models.Model):
photo = StdImageField(upload_to='photos', verbose_name=_("photo"),
  variations={'large': (600, 600), 'thumbnail': (100, 100)}


StdImageField does it's own operations on the image, subclassing ImageField and 
having attr_class = StdImageFieldFile

StdImageFieldFile does the actual save operation


class StdImageFieldFile(ImageFieldFile):
"""
Like ImageFieldFile but handles variations.
"""

def save(self, name, content, save=True):
super(StdImageFieldFile, self).save(name, content, save)
render_variations = self.field.render_variations
if callable(render_variations):
render_variations = render_variations(
file_name=self.name,
variations=self.field.variations,
storage=self.storage,
)
if not isinstance(render_variations, bool):
msg = (
'"render_variations" callable expects a boolean return value,'
' but got %s'
) % type(render_variations)
raise TypeError(msg)
if render_variations:
self.render_variations()


However, I want to do some manipulation of the image before 
StdImageFieldFile does it (rotating).

So I created my custom field, to catch the image before it's passed to 
stdimage


class Rotate(ImageFieldFile):
def save(self, name, content, save=True):
save = False

return super(Rotate, self).save(name, content, save)
class StdImageFieldFileRotateMixin(Rotate, StdImageFieldFile):
pass
class StdImageFieldRotate(StdImageField):
attr_class = StdImageFieldFileRotateMixin


I have the image in the content property of the Rotate class and I can 
manipulate the image using PIL, but after it's done, I don't know how to 
assign this image back to the content property. It seems that it's 
generated on the lower level. Is there a method to generate this content 
property 
and then MRO will handle the rest (i.e. pass it to StdImageFieldFile and it 
will do the rest)?



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3d492953-d5c5-4f7d-a318-cdbe3929ee74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Conditional annotation super slow

2016-01-06 Thread Mark


I'm using django's (1.8.5) conditional annotation in order to add filtered 
data to each object dynamically. But the issue is that it's very slow on 
all machines I've tested it.

What it does is basically adds data to each user. How many messages they 
sent from provided date, how many messages have failed and how many 
messages they sent from yesterday. There is not much data. Just about 100 
users and each of them may have about 50 messages daily.


objects = self.get_queryset().annotate(sent_count=
Sum(
Case(When(messages__date_sent__gte=date_from, then=1)),
output_field=IntegerField()
),
error_count=
Sum(
Case(When(messages__status__iexact='error', then=1)),
output_field=IntegerField()
),
sent_yesterday=
Sum(
Case(When(messages__date_sent__gte=yesterday, then=1)),
output_field=IntegerField()
)
)


When checking a query, it takes up to 15 seconds to execute it. Am I doing 
something wrong or is conditional annotation not designed for things like 
this?


After looking at the generated query, it seems that Django is trying to 
GROUP BY by every available field in both models and their related models.. 
After adding prefetch_related to some related models, issue was fixed on 
one machine, but still persists on the second one. 


Is this a bug?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75d15495-9c66-4e3c-a153-912b220d9e35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Conditional annotation super slow

2016-01-06 Thread Mark
I've run query manually removing all fields from GROUP BY that are not 
related to aggregation and query runs fast. But how to do the same in 
Django? How to remove unrelated fields to the aggregation from GROUP BY 
clause?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/036c16a6-d088-40f9-9ed2-67a28280bd7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


inspect a model's field's option's values

2008-10-30 Thread Mark Wolgemuth

It seems like I'm missing something, but here's what I'm trying to do:

In creating a Form object, I'm setting size limit validation
(max_length). I'd like to recover the value for that from the
corresponding Model's Field's max_length. So basically I want a symbol
lookup that will inspect in the options of a field I have defined for
a model, without having an instance of the model, just it's type.

This is to avoid the 2 having to share a common separately defined
constant, or just using an integer that I have to coordinate in both
places, or in place of always using auto forms.

eg

class MyModel(Model):
 myfield = CharField(max_length=128)

--

class MyForm(Form):
 myfield = CharField(max_length=**GET.FROM.MODEL**)

I assume that by using the Meta:  model = logic in Form for auto form,
that this is being done, but it wasn't obvious to me how.

--~--~-~--~~~---~--~~
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: inspect a model's field's option's values

2008-10-31 Thread Mark Wolgemuth

That's exactly what I'm looking for.
I'll probably try adding that feature to the model base class or as a
mixin.

@classmethod
def get_field_option_by_name(self, fieldname, optionname):
field = self._meta.get_field_by_name(fieldname)[0]
return getattr(fieldname, optionname)

possibly with the default thing also.

On Oct 30, 12:18 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
> On 30 oct, 14:26, Mark Wolgemuth <[EMAIL PROTECTED]> wrote:
>
>
>
> > It seems like I'm missing something, but here's what I'm trying to do:
>
> > In creating a Form object, I'm setting size limit validation
> > (max_length). I'd like to recover the value for that from the
> > corresponding Model's Field's max_length. So basically I want a symbol
> > lookup that will inspect in the options of a field I have defined for
> > a model, without having an instance of the model, just it's type.
>
> > This is to avoid the 2 having to share a common separately defined
> > constant, or just using an integer that I have to coordinate in both
> > places, or in place of always using auto forms.
>
> > eg
>
> > class MyModel(Model):
> >      myfield = CharField(max_length=128)
>
> > --
>
> > class MyForm(Form):
> >      myfield = CharField(max_length=**GET.FROM.MODEL**)
>
> def get_model_field_option(model, field, option, default=None):
>     field = model._meta.get_field_by_name(field)[0]
>     return getattr(field, option, default)
>
> class MyForm(Form):
>      myfield = CharField(
>          max_length=get_model_field_option(MyModel, 'myfield',
> 'max_length', 100)
>          )
>
> Caveat : Not sure it works on all possible options for all possible
> fields - testing left as an exercise to to OP !-)
>
> HTH
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HBase and Django

2008-12-28 Thread Mark Jarecki

Hi,

I was wondering whether anyone has made any headway into getting  
HBase working with Django? I think the existence of such an option  
would be definite boon to the framework.

Cheers

Mark

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



Could someone help me understand the finer points of import

2009-01-04 Thread Mark Jones

For the discussion below, ALL the code is in .../intomec/tenq

I wrote some code in tests.py like so:

   from tenq.models import *
self.expectedValue = Answers((1,2,3,4))

within the to_python() method of AnswersField in models.py:
def to_python(self, _value):
print "_value.__class__ =",_value.__class__
if isinstance(_value, Answers):
return _value

isinstance(_value, Answers) fails for the object created in tests.py
because the
>>>_value.__class__ = 
>>>_value.__class__ = 


when I change tests.py to
from intomec.tenq.models import *
self.expectedValue = Answers((1,2,3,4))

I get
>>>_value.__class__ = 
>>>_value.__class__ = 
and isinstance doesn't fail.

What I can't figure out is, why do both imports work, and why do they
generate different results.  It seems to me the name of the class is
the name of the class, and either the import should fail or they
should both yield the same name.

Anyone have any ideas on why this is?  I'm not even sure why the
second from statement works, since I'm already in the intomec folder
when I run

python manage.py test

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



Re: Redirect parent from within iframe without losing session

2009-01-04 Thread Mark Jones

are you redirecting to the same port?  I think redirection to a
different domain OR port would keep the cookie from getting back to
the server, thus killing your session.

On Jan 3, 10:33 am, Berco Beute  wrote:
> My page shows a (logged in) user an iFrame but when the iframe
> redirects the browser after it's done, the session is lost. The
> redirecting of the parent (by the iframe) is done as follows:
>
> =
> 
>     
>         function load() {
>             parent.location.href='http://localhost:8000/somewhere';
>         }
>     
> 
> ==
>
> Is there a way to keep the session alive (e.g. keep the user logged
> in)?
>
> Thanks,
> 2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Do sth on time ?

2009-01-04 Thread Mark Jones

You need a process running outside the bounds of the webserver that
reads the database every so often, and then sleeps with a wakeup every
so often, and a list of when things "expire".  It updates the
database, the webpage reflects the update.

You could of course do this via a wget driven by crontab, so that all
the logic is on the webserver.

On Jan 4, 4:50 am, makka...@gmail.com wrote:
> Hi list,
>
> I have a web app which is a kind of arbitration application. Users bid on some
> products or projects and the one who gives the biggest price gets the
> project. Every project has some bidding expiration time. What i need is how
> can i handle the situation to change the status of the project on a specific
> time? For example , i submit a project and it should expire after 2 hours.
>
> Some solutions i can think are :
>         - Cronjobs , which checks the db every minute , but that will be very
> expensive i think
>         - Twisted , but if server gets restarted i may loose the track of the
> deferreds
>
> Does anyone solved a problem like that before ? Any suggestions ...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File Download

2009-01-04 Thread Mark Jones

Are you trying to get your source code off a server, and instead find
it being executed by the webserver?

If you have shell access, tar the files up and download that, create a
folder where the files aren't executable and download them that
way.

If it is your source, I would assume you have some sort of source code
repository that should have the source..

The question is a tad vague.

On Jan 3, 10:21 pm, Sparky  wrote:
> Hello. This is probably a silly question but I have files being stored
> onto a server and strangely getting them there was very easy but how
> can I get them back down?
>
> Thank you for your patience in advance,
> Sam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: I would like to report a bug but I can't log in

2009-01-04 Thread Mark Jones

Well, I think we can all see where you get your nickname.


On Jan 4, 12:03 am, Friendless  wrote:
> On Jan 4, 2:42 pm, "Karen Tracey"  wrote:
>
> > I'll admit your tone here is starting to make me lose interest in your
> > problem report.
>
> Admit it, you weren't very interested in the first place. You've given
> me all sorts of reasons as to why the bug shouldn't be fixed, despite
> (a) evidence that it is a bug, and (b) at least a clue as to how to
> fix it. The simple fact of the matter is that Django failed on the
> very first thing I did with it, your website doesn't work (yes, I did
> try logging in using the link as Ramiro suggested), and my first
> encounter with the community has been hostile. Django's doing nothing
> for me, and I refuse to get involved with a community that won't even
> believe me, let alone help. I've given you a good bug report, but now
> I'm out of here. Do whatever you like.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: to understand MEDIA_URL

2009-01-05 Thread Mark Jones

Are you closing the file after you write to it and before you try to
send it?  Why do you have to write it to a file to deliver it as a
static file, why not just render it to a response directly?

On Jan 5, 4:13 am, Alan  wrote:
> Hi List,
> Because I couldn't find any idea better I am using "MEDIA_URL = '/static/'"
> as a repository for the output of my application so I can see the results in
> the web interface and download them.
>
> However, I noticed for a particular case where I open and read a file
> content to be viewed in a web page that I get this error:
>
> -
> IOError at /ccpngrid/call_status_func
>
> [Errno 2] No such file or directory:
> '/Users/alan/workspace/webapps/static/grid/alan_20090105T094321/static/grid/alan_20090105T093444/Results_1brv_ccpngrid/DOCS/last_it/report'
>
> Request Method: POST
> Request URL:http://localhost:8000/ccpngrid/call_status_func
> Exception Type: IOError
> Exception Value:
>
> [Errno 2] No such file or directory:
> '/Users/alan/workspace/webapps/static/grid/alan_20090105T094321/static/grid/alan_20090105T093444/Results_1brv_ccpngrid/DOCS/last_it/report'
>
> Exception Location: /Users/alan/workspace/webapps/src/webAppsRoutines.py in
> callStatusFunc, line 518
> -
>
> If I stop and restart the sever (manager.py runserver) it seems that my
> static folder gets refreshed and then the server is now aware of this
> 'report' file and then I can see it. If during this runserver session, I
> submit another job, the new report will failed as show above.
>
> So, is it possible to "refresh" my "MEDIA_URL = '/static/'" in runserver
> session without needing to restart it, or better rethink all the way I did
> for presenting results (not using "MEDIA_URL = '/static/'" basically)?
> Suggestions are welcome.
>
> Many thanks in advance.
>
> Alan
>
> --
> Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> Department of Biochemistry, University of Cambridge.
> 80 Tennis Court Road, Cambridge CB2 1GA, UK.
>
> >>http://www.bio.cam.ac.uk/~awd28<<
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



NewBie Question about ForeignKey relationships

2009-01-07 Thread Mark Jones

Ok, here is some simple code:

class Maker(models.Model):
name = CharField(max_length=20)

class Auto(models.Model):
name = CharField(max_length)
maker = ForeignKey(Maker)


maker = Maker.objects.get(pk=1)

How do I get all the Autos made by this maker

I don't see a maker.autos (railsish)
All I have been able to figure out for this is:

Auto.objects.filter(maker=maker.id)# this works
Auto.objects.filter(maker=maker)# this works too

Is that all there is, or is there some maker.autos abstraction that I
just don't see.  The last method 2 methods both work, but it seems
awkward to use them given the fact that I have a Maker, and the
relationship between Maker and Auto is known in the models but via the
Manager interface requires restatement in (maker=maker.id) or
alternately (maker=maker)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NewBie Question about ForeignKey relationships

2009-01-07 Thread Mark Jones

Thanks for the pointer, I had read all around that.

The short version is:

maker.auto_set.all()


There was was Dry(er) more elegant method to be found.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Putting pieces back together again

2009-01-11 Thread Mark Jones

I have some fields on my page that have more than one attribute for
simplification, lets say two attributes

answer = {'txt':'something', 'allowblank':0}

laid out on the page as:
{% for answer in quiz_question.answers %}
  
  
{% endfor %}

the first is pulled from an input field, and if !allowblank, needs to
have some text.

I write some OnSubmit() javascript on my page to check this field, and
if it is blank, check the allowblank attribute in the following hidden
field to see if this is OK.  If is isn't ok, I ask the user "you sure
you wanna leave this field blank?"  If the user says "YES, I want to
leave it blank, the JS changes allowblank to 1 and we submit the form.

If the backend gets the form and the field is blank, but the
allowblank is true, then I know the user said OK, no problem, I let it
be blank, otherwise I validate it on the server side (in case they use
noscript like I do) and if allowblank=0 and the field is blank, I send
the form back to them with a checkbox like this

{% for answer in question.answers %}
  
   I
really want to leave this field blank
{% endfor %}

My problem comes about because a nice list of dict objects has been
broken apart by the html form and needs to be reassembled.  While I
can do this like so:

  for i in range(len(qqanswers)-1,0, -1):
  qqanswers[i] = {'txt':answers[i], 'allowblank':int
(allowblank[i])}
  if answers[i] == '' and allowblank[i]:
  del qqanswers[i]

I don't like how ugly this looks.  I tried changing the names of the
input objects to:

answers.txt and answers.allowblank, but that didn't work, I got POST
lists back that were names answers.txt and answers.allowblank that
looked like:



of course all of this ignores the fact that checkboxes that aren't
checked aren't sent back to the server anyway which is where the need
for a more elegant solution comes from in the first place..

Is there a nice elegant way to solve this, or does it just have to be
done the way I've done it..
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Putting pieces back together again

2009-01-13 Thread Mark Jones

Thanks, formsets was the answers, and smartly enough, they didn't name
all the fields the exact same name, but reassemble them afterwards.

On Jan 12, 9:04 am, Jeff FW  wrote:
> Mark,
>
> You should really use Forms and FormSets--they'll make this problem
> essentially go away.
>
> http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-indexhttp://docs.djangoproject.com/en/dev/topics/forms/formsets/
>
> -Jeff
>
> On Jan 12, 12:46 am, Mark Jones  wrote:
>
> > I have some fields on my page that have more than one attribute for
> > simplification, lets say two attributes
>
> > answer = {'txt':'something', 'allowblank':0}
>
> > laid out on the page as:
> > {% for answer in quiz_question.answers %}
> >   
> >    > value="{{ answer.allowblank }}" />
> > {% endfor %}
>
> > the first is pulled from an input field, and if !allowblank, needs to
> > have some text.
>
> > I write some OnSubmit() javascript on my page to check this field, and
> > if it is blank, check the allowblank attribute in the following hidden
> > field to see if this is OK.  If is isn't ok, I ask the user "you sure
> > you wanna leave this field blank?"  If the user says "YES, I want to
> > leave it blank, the JS changes allowblank to 1 and we submit the form.
>
> > If the backend gets the form and the field is blank, but the
> > allowblank is true, then I know the user said OK, no problem, I let it
> > be blank, otherwise I validate it on the server side (in case they use
> > noscript like I do) and if allowblank=0 and the field is blank, I send
> > the form back to them with a checkbox like this
>
> > {% for answer in question.answers %}
> >   
> >    > value="{{ answer.allowblank }}" /> I
> > really want to leave this field blank
> > {% endfor %}
>
> > My problem comes about because a nice list of dict objects has been
> > broken apart by the html form and needs to be reassembled.  While I
> > can do this like so:
>
> >           for i in range(len(qqanswers)-1,0, -1):
> >               qqanswers[i] = {'txt':answers[i], 'allowblank':int
> > (allowblank[i])}
> >               if answers[i] == '' and allowblank[i]:
> >                   del qqanswers[i]
>
> > I don't like how ugly this looks.  I tried changing the names of the
> > input objects to:
>
> > answers.txt and answers.allowblank, but that didn't work, I got POST
> > lists back that were names answers.txt and answers.allowblank that
> > looked like:
>
> >  > u'answers.answer': [u'1', u'2', u'3', u'4']}>
>
> > of course all of this ignores the fact that checkboxes that aren't
> > checked aren't sent back to the server anyway which is where the need
> > for a more elegant solution comes from in the first place..
>
> > Is there a nice elegant way to solve this, or does it just have to be
> > done the way I've done it..
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Forcing content_types.json to be loaded before any other fixtures

2009-01-13 Thread Giovannetti, Mark

Is there a way to force a fixture to be loaded first
when running manage.py test?

I'd like to load a content_types.json fixture immediately
before any other fixtures are loaded.  

This might fix some of the vexing problems with using
content_types and tests.

Anyone know if this is possible?

Thanks
Mark

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



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: <http://www.mophilly.com/wiki/How_to_install_Django_on_SME_Server 
 >

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: Recommendations for local web dev on Mac OS X 10.5 vs. developing against WebFaction Linux box

2008-09-15 Thread Mark Phillips


On Sep 15, 2008, at 4:58 PM, DougI wrote:

> Should I develop locally on my Mac, i.e. install Django/PostgreSQL
> locally and then upload to WebFaction, or create/open files directly
> on my WebFaction server via SSH or FTP?
>
> Also, recommendations for an IDE would be appreciated - TextMate,
> Komodo, IDLE, etc?

I agree with David Zhou that it is easiest to develop using the  
localhost, especially when you are learning. That way you control  
everything on your own system. However, setting up Django is easier on  
linux systems, IMHO; Mac OS X is my preferred OS but I gotta call it  
like I see it...

I use BBEdit and old fashion debugging techniques with python. I liked  
the demos of Wing and Komodo but in the end I fall back on what I  
know, which is BBEdit.

On *nux I use pico/nano/vi, depending on what I need to do. pico and  
nano are very simple and you can pick them up quickly.

For postsgres, which is a new addition for me, I am looking at DB  
Visualizer and Oracle's SQL Developer.


hth,

  - Mark Phillips

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

2009-01-25 Thread Mark Jones

Sample.py includes the following:
==
from django.db import models

class Good(models.Model):
code = models.CharField(max_length=64)
quizid = models.IntegerField(null=False, blank=False)
published_on = models.DateTimeField(auto_now_add=True)

class Fails(models.Model):
code = models.CharField(max_length=64)
quizid = models.IntegerField(null=False, blank=False)
published_on = models.DateTimeField(auto_now_add=True)

def __init__(self, *args, **kwargs):
super(Fails, self).__init__(args, kwargs)
===

python manage.py shell
>>> from Sample import Good,Fails
>>> g = Good()
>>> f = Fails()
>>> type(g.id)

>>> type(f.id)



Why-O-Why does the type(f.id) != type(g.id)

The reason this matters is because when I call Fails.save(), I get
this message:

Exception Type: TypeError
Exception Value:int() argument must be a string or a number, not
'tuple'

What I can't understand is why overriding __init__() causes this
behavior.  My code needs to do something in __init__(), but even when
I remove all that it is doing, the model underneath changes the type
of the id column.

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



Re: Strange Model behavior

2009-01-26 Thread Mark Jones

I guess I was just too tired when I wrote it, I just forgot the * and
** on the 2 arguments.

I have some initialization that I'm doing in __init__ but had removed
that to make the example shorter and was still seeing the problem.

Thanks for the help, those 3 *'s fixed the whole problem


On Jan 26, 5:50 am, Steve Holden  wrote:
> Dj Gilcrease wrote:
> > What do you need to do in __init__
>
> You don't actually need to fo anything at all! As you have the code now
> you're calling the superclass's __init__ with two arguments: the newly
> created instance, a tuple of the other positional args (if any) and a
> dict of the keyword arguments (if any).
>
> Change the method to
>
>     def __init__(self, *args, **kwargs):
>         super(Fails, self).__init__(*args, **kwargs)
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changing form field rendering dependent on field type

2009-01-26 Thread Mark Jones

That almost sounds like you will have to write the renderer for that
class.  I don't think this will be easy to do in the template, but if
you override django.forms.widgets.Select.render. you can probably make
it work.

On Jan 26, 11:51 am, mattsouth  wrote:
> I wish to customise a form template so that I produce forms like:
>
> 
> my text field : 
> 
> my select field : ...
> my multiline text field : 
> 
> 
>
> i.e. forms in a single column of paragraph tabs where usually the
> field label and input field are in separate blocks, except when the
> field is a select box (i.e. it's widget is a
> django.forms.widgets.Select object). I'd like to iterate through the
> form fields to draw the template, following the documentation,
> using something like this:
>
> 
> {% for field in form %}
>         {{ field.label_tag }} : {% if field.is_select %} {{ field }} {%
> endif %}
>         {% if not field.is_select %}{{ field }}{% endif %}
> {% endfor %}
> 
>
> but I'm having difficulty detecting the selection field.  Does anyone
> have any suggestions for doing 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Changing database fields

2009-01-28 Thread Mark Jones

This is where Rails rocks and DJango doesn't.  I haven't been able to
find any kind of DB Migrations in Django like those in Rails.  Sad
too, because other than that, Python is a lot nicer than Ruby (Syntax
wise for an old C++ programmer)

On Jan 28, 3:29 pm, Oleg Oltar  wrote:
> Hi!
> I am creating my first application. Which is to be a small publishing
> system.
>
> I defined a model, which represent a single article, and also added about 15
> articles to my database (which is sqlite3).
>
> Now I understand that I should extend my models with few more fields (e.g.
> need to add categories and date_published). I thought that can simply
> add those to my models, but then realized that I need to modify already
> created fields...
>
> Is there a common practice to do it? Maybe some recipe?
>
> Thanks,
> Oleg
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



can't clear form data in runserver (works in shell)

2009-02-02 Thread Mark Jones

I have a form that is working well.  However I want to allow them to
reuse the form multiple times.  Each time they submit the form, I will
send up to 6 emails.  Then, if an email is sent successfully, I want
to remove that email address from the form that I present to them.  If
the email isn't successfully sent, I want to move that field up the
list.

The problem comes when I get to

self.data[friend] = ''

inside clearsent

When I work thru this in the shell, it works as expected, but when
runserver is going, it generates the error: This QueryDict instance is
immutable

I don't want to clear all the fields, I want to leave the email
subject and body alone and clear the 'To' fields and present the form
for another round of emails to be sent.  How do you do this?

class AnnounceForm(forms.Form):
friend1 = forms.EmailField(label='1st Friend', required=True,
help_text='Enter the first friend you want to tell about this')
friend2 = forms.EmailField(label='2nd Friend', required=False)
friend3 = forms.EmailField(label='3rd Friend', required=False)
friend4 = forms.EmailField(label='4th Friend', required=False)
friend5 = forms.EmailField(label='5th Friend', required=False)
friend6 = forms.EmailField(label='6th Friend', required=False)
cc_myself = forms.BooleanField(label='cc myself', required=False)
emailsubject = forms.CharField(label='Email Subject')
emailbody = forms.CharField(widget=forms.Textarea, label='The
email will say:')

friends =
('friend1','friend2','friend3','friend4','friend5','friend6')
def recipients(self):
data = super(AnnounceQuizForm, self).clean()
recipients = []
for friend in self.friends:
if data[friend]:
recipients.append(data[friend])
return recipients

def clearsent(self, sentto):
"""
Clear the form of all the emails that are contained in sentto
and repopulate the fields from the top down with the ones that did not
send successfully
"""
again = []
for friend in self.friends:
if self.cleaned_data[friend] not in sentto:
again.append(self.cleaned_data[friend])
self.data[friend] = ''
if len(again):
fields = list(self.friends)
fields.reverse()
for email in again:
self.data[fields.pop()] = email


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



Re: can't clear form data in runserver (works in shell)

2009-02-03 Thread Mark Jones

I guess I wasn't thinking completely clearly in regards to that, I'm
guessing the only failures that could happen might be failure to
connect to the server guess I'll need to dig into what failures could
be returned and what they might mean.

I did solve the problem with this one line added to clearsent:

self.data._mutable=True # this doesn't seem right, but what
the heck its 1am


On Feb 3, 1:21 am, Malcolm Tredinnick 
wrote:
> On Mon, 2009-02-02 at 23:05 -0800, Mark Jones wrote:
> > I have a form that is working well.  However I want to allow them to
> > reuse the form multiple times.  Each time they submit the form, I will
> > send up to 6 emails.  Then, if an email is sent successfully,
>
> Right there you have your first problem. Emails aren't necessarily sent
> immediately. What does "sent" mean? Accepted by your server? Received at
> the target end and not bounced? There are lots of way an email can fail.
> Further, it can take some time to send email (connection times and so
> on), even just to a local system. So blocking the web response based on
> some "success or fail" measure in the email system is a bit fragile.
>
> Maybe you've carefully evaluated all the steps in the pipeline and have
> your risks worked out. I'd consider whether you're really solving the
> right problem, however.
>
>
>
> > I want
> > to remove that email address from the form that I present to them.  If
> > the email isn't successfully sent, I want to move that field up the
> > list.
>
> > The problem comes when I get to
>
> >             self.data[friend] = ''
>
> > inside clearsent
>
> > When I work thru this in the shell, it works as expected, but when
> > runserver is going, it generates the error: This QueryDict instance is
> > immutable
>
> > I don't want to clear all the fields, I want to leave the email
> > subject and body alone and clear the 'To' fields and present the form
> > for another round of emails to be sent.  How do you do this?
>
> Copy the data dictionary: request.POST.copy() is the usual idiom when
> you want to change something like that. You can't change Django's copy
> of the data, but you can certainly make your own copy and change that.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



creating links from inline within admin

2009-02-16 Thread Mark (Nosrednakram)

Hello,

models
  person
  organization

fk relationship between person and organization, i.e. an organization
consists of people.

I would like to list the people using an inline form in admin with a
like back to the person and have the person added to the organization
in the person form.  The main reason the the overhead for drop down
boxes with thousands of people and hundreds of members.

I have created a template and assigned it using the inline.
Changed to using raw_id_fields to limit the amount of information to
process

I would like to do something like this in the inner loop in the
template by can't find a way to do it:

{{ person.first_name}}

Any help appreciated, I have searched the archives an am not finding
anything with the terms I am using.  I am no afraid to extend classes
is someone can advise me on where I might start on this.

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



Re: checkboxInput values

2009-02-18 Thread Mark Jones

and you do that like so:

answer0 = forms.IntegerField(label='', widget=forms.CheckboxInput
(attrs={'value':0}))

for the next bloke that doesn't want to have to figure it out.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



CheckboxInput widget has a flaw when used with an IntegerField

2009-02-19 Thread Mark Jones

forms.IntegerField(widget=forms.CheckboxInput(attrs={'value':1}),
required=False)

won't work because

def value_from_datadict(self, data, files, name):
if name not in data:
# A missing value means False because HTML form submission
does not
# send results for unselected checkboxes.
return False
return super(CheckboxInput, self).value_from_datadict(data,
files, name)

returns False when the box is unchecked, and False is not one of the
EMPTY_FIELDS so you end up with required=True even when you specify
required=False

Not sure how to fix this for real, I've created a CheckboxInteger that
returns None instead of False

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



Re: CheckboxInput widget has a flaw when used with an IntegerField

2009-02-19 Thread Mark Jones

Maybe because I have a list of values that I want the user to be able
to select between.  A list of 4 or so things that I want the user to
be able to choose one or more of.  Is there some better way to get
this accomplished?

On Feb 19, 11:43 am, Karen Tracey  wrote:
> On Thu, Feb 19, 2009 at 11:56 AM, Mark Jones  wrote:
>
> > forms.IntegerField(widget=forms.CheckboxInput(attrs={'value':1}),
> > required=False)
>
> > won't work because
>
> >    def value_from_datadict(self, data, files, name):
> >        if name not in data:
> >            # A missing value means False because HTML form submission
> > does not
> >            # send results for unselected checkboxes.
> >            return False
> >        return super(CheckboxInput, self).value_from_datadict(data,
> > files, name)
>
> > returns False when the box is unchecked, and False is not one of the
> > EMPTY_FIELDS so you end up with required=True even when you specify
> > required=False
>
> Huh?  The field doesn't become required.  Rather the IntegerField is unable
> to validate the value returned in the case where the check box is unchecked:
>
> Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)>>> from django import forms
> >>> class OBF(forms.Form):
>
> ...    x = forms.IntegerField(widget=forms.CheckboxInput(attrs={'value':1}),
> required=False)
> ...>>> f = OBF({})
> >>> f.is_valid()
> False
> >>> f.errors
>
> {'x': [u'Enter a whole number.']}
>
> The error is not that the field is required, but that the value returned by
> the widget cannot be interpreted by the IntegerField.
>
> > Not sure how to fix this for real, I've created a CheckboxInteger that
> > returns None instead of False
>
> > Any better ideas?
>
> Don't try to marry a widget that returns one sort of data to a field that is
> expecting something else?  Seriously, why are you trying to hammer in your
> nail with this screwdriver?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is safe unsafe?

2009-02-23 Thread Mark Jones

Kind of sucks that you are worried about your server, but not worried
about the people that might use your site.

I'd answer your question regarding JS except for the fact I think the
server and the clients should be safe for the general public, and I
don't want to make it that easy on you.  Allowing some script kiddie
to load JS into a field that will play back on someone else's machine
is reprehensible, even if those users aren't smart enough to install
noscript.

On Feb 23, 1:32 pm, Michael Repucci  wrote:
> Hi Django'ers, this will probably sound like a silly question, but
> normally I haven't had to think about server security (that's been
> someone else's job). However, on my current project I do need to
> consider this, and I just wanted to double-check that I understand the
> risks of using the "safe" tag in HTML templates.
>
> I've got users that I shouldn't entirely trust, who have access to a
> TextField in a model, and that field is displayed in the resultant
> HTML with the safe filter. Now, I understand that that means the user
> could put JavaScript (or similar) in this field, and it will be
> triggered when the page loads. But this doesn't present a threat to
> the server security does it? PHP includes won't be interpreted, so
> that's not a problem, and JavaScript doesn't have access to the server
> file system, right? I'm just not sure whether there is potential HTML
> code that could be used to actually damage the server, access its
> files, or cause a DoS attack.
>
> Any help would be greatly appreciated! 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Not understand help_text

2009-02-23 Thread Mark Jones

When a model field has help_text, that text will be show in the form.
I'm a little bothered by this because effectively the model is doing
something that really belongs in the view, but I understand the point
is to make it easy to create forms based on a model and I can just
live with it.

What bothers me about this is that it seems pointless to have this
shortcut if the help_text isn't identified in some way when it is
output using as_p()  so that I end up with:

Username:  Required. 30 characters
or fewer. Alphanumeric characters only (letters, digits and
underscores).

If I have an error I get:

This field is required.
Username:  Required. 30 characters or
fewer. Alphanumeric characters only (letters, digits and
underscores).

where the error is styled in such away that I can draw attention to
it.

I could just go in and hand code my forms in the template so I have
TOTAL control over rendering, it just seems strange I have to go from
drop dead easy as_p() to WET (opposite of DRY) to get my forms out, or
I have to go and overload as_p() in all my forms

Here is to hoping I'm just stupid and don't see the method behind the
madness


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



Re: Not understand help_text

2009-02-23 Thread Mark Jones

That is exactly the kind of WET I was talking about.  as_p() with
appropriate CSS styling will render really nice forms as is, with the
exception of the help_text.  I even think that could be fixed without
any major rework, just a change in the as_p() string

from

def as_p(self):
"Returns this form rendered as HTML s."
return self._html_output(u'%(label)s %(field)s%(help_text)
s', u'%s', '', u' %s', True)

to

def as_p(self):
"Returns this form rendered as HTML s."
return self._html_output(u'%(label)s %(field)s%(help_text)s', u'%s', '', u' %s',
True)

similar changes would be needed for as_ul() and as_table()
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Not understand help_text

2009-02-24 Thread Mark Jones

I occurred to me last night right before sleep that I can patch this
in my code by deriving all my forms from my MyForm, fixing it in one
place and remaining DRY.

Nice to see I'm not the only one that found this to be a bit strange.


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



Re: Django App build - the right process?

2009-02-24 Thread Mark Jones

The first 2 saves are overly complex:

def save(self):
if self.unit_price and not self.price_discount == '0':
  adjust = float(self.price_discount / 100.0)
  val_result = str(adjust)
  discount = Decimal(self.unit_price - (Decimal(val_result) *
self.unit_price))
  self.product_id.product_selling_price = discount
  self.product_id.save()
  super(ProductSellingPrice, self).save()
else:
  self.product_id.product_selling_price = self.unit_price
  self.product_id.save()
  super(ProductSellingPrice, self).save()

There is no need for an if here, the math works out, so you just lose
the if and do the computations every time.  I would still move the
code to something like:

self.product_id.product_selling_price = adjust_price(self.unit_price)
which of course would just be written as self.adjust_selling_price()

The last one looks like a complicated business rule in the first
place, not sure how you fix it, other than to refactor that code out
of save into an adjust_pricing() so that the save logic is
reasonable.  This does just move the glob that is the discounting to
somewhere else, but it makes it easier to follow the save logic while
it is happening.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Securely storing passwords

2009-02-24 Thread Mark Jones

How about integrating with something like OpenID?  Not sure if it
would do the trick, but it might be a step in the right direction,
assuming the sites you are interoperating with are 'friendly'

On Feb 24, 5:49 am, LaundroMat  wrote:
> Hi -
>
> I'm working on a small django app that allows users to interact with
> other websites where they have an account. Ofcourse, using this app
> means providing your username and password for the other website.
>
> What are the most secure ways of handling this information? I suppose
> encrypting the passwords is one option, but are there any ways to
> prevent people who have access to the app's source code and database
> of retrieving user's names and passwords?
>
> Thanks in advance,
>
> Mathieu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can one template extend multiple templates?

2009-02-24 Thread Mark Jones

It seems like maybe I don't understand the question but it will extend
an infinite number of templates

Just add {% extends "base.html" %} into every template you want to
extend.

You can even do {% extends "derived.html" %} which extends base.html

On Feb 24, 8:41 am, lzhshen  wrote:
> Suppose I have base template called "base.html", can it extend more
> then two other template, such as "a01.html" and "a02.html"?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Permission model's CharField fields, name and codename, too short

2009-03-19 Thread Giovannetti, Mark
;, line 317, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
  File
"/usr/local/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 2020, in execute_sql
cursor.execute(sql, params)
psycopg2.DataError: value too long for type character varying(50)

}}}

Thanks for any pointers.
Mark

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



RE: Permission model's CharField fields, name and codename, too short

2009-03-20 Thread Giovannetti, Mark

 

> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:django-us...@googlegroups.com] On Behalf Of Malcolm Tredinnick
> Sent: March 19, 2009 22:18
> To: django-users@googlegroups.com
> Subject: Re: Permission model's CharField fields, name and 
> codename, too short
> 
> 
> On Thu, 2009-03-19 at 21:58 -0400, Giovannetti, Mark wrote:
> > Hi Everyone,
> > 
> > Has anyone else run across this?  I tried to enter it as
> > a ticket at: 
> > 
> >  http://code.djangoproject.com/simpleticket
> > 
> > but was mistaken for a spammer.  ;-)
> 
> You need to register then, as it says in the big coloured box on that
> page.

I saw that, thank you.  I declined registration for reasons of
my own.

> 
> I was hoping your mail would finish with "so I decided to check if the
> ticket was already in Trac and realised it was #8632".

I saw a few other related tickets as well.

> 
> I found that by typing "Django long permission names" into 
> Google and it
> was the first link. Please, please, please search before opening
> tickets. There's a good chance it's been discovered before.

Yes, the search I performed turned up a few others, too.
One was two years old, the other is 7 months old.

My point in posting is to raise this seemingly simple
issue and have it fixed once and for all.  It is vexing
having to modify the django/contrib/auth/models.py file
on all upgrades to handle this.  

Now, if you have any helpful comments on my original 
questions (below), please provide them.  Thanks.

Original questions:
> I can easily fix this by changing the max_length 
> values both to 255 (in the installed source code and the database) 
> to overcome this.   Should I be doing this?  

I asked the above "should I?" in case the law of unintended consequences
decides to express itself.

and

> If so, can these values be bumped up in the official release?

I asked that question to add it to the request queue to fix this
problem.  

Regards,
Mark


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



Trying to understand Django and Python from a C++ perspective

2009-06-29 Thread Mark Jones

I can't seem to reason out why/how this works.

I have a class Named Stuff

I can say Stuff.objects.filter(.) and that will return valid set
of data.

What I can't understand is what exactly is objects, and why is it I
can call it with Stuff.objects, but I can't call it with stuff.objects
(an instance of Stuff).

>>> dir(Stuff) shows me 'objects'
>>> dir(stuff) shows me 'objects'

>>> type(Stuff.objects)

>>> type(stuff.objects)
Traceback (most recent call last):
  File "", line 1, in 
  File "...manager.py", line 151, in __get__
AttributeError: Manager isn't accessible via Stuff instances

What is the python Magic going on here to make this possible?

I'm asking because I want to make something like 'objects' in that it
doesn't need an instance, but it is scoped within the model of Stuff.

My background is C++ and these look like methods/objects that are
static to the class, not part of the instances.  I just can't figure
out how to declare and instantiate them in python.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trying to understand Django and Python from a C++ perspective

2009-06-29 Thread Mark Jones

Yea, I'm not wanting to use stuff.objects, but I'm wanting to pull
some of the same voodoo, probably not safe for a python novice like
myself :-)

On Jun 29, 5:24 pm, Alex Gaynor  wrote:
> On Mon, Jun 29, 2009 at 5:19 PM, Mark Jones  wrote:
>
> > I can't seem to reason out why/how this works.
>
> > I have a class Named Stuff
>
> > I can say Stuff.objects.filter(.) and that will return valid set
> > of data.
>
> > What I can't understand is what exactly is objects, and why is it I
> > can call it with Stuff.objects, but I can't call it with stuff.objects
> > (an instance of Stuff).
>
> > >>> dir(Stuff) shows me 'objects'
> > >>> dir(stuff) shows me 'objects'
>
> > >>> type(Stuff.objects)
> > 
> > >>> type(stuff.objects)
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "...manager.py", line 151, in __get__
> > AttributeError: Manager isn't accessible via Stuff instances
>
> > What is the python Magic going on here to make this possible?
>
> > I'm asking because I want to make something like 'objects' in that it
> > doesn't need an instance, but it is scoped within the model of Stuff.
>
> > My background is C++ and these look like methods/objects that are
> > static to the class, not part of the instances.  I just can't figure
> > out how to declare and instantiate them in python.
>
> Django uses an advanced python feature called descriptors in order to
> prevent you from accessing a manager (which is what "objects" is) from an
> instance.  My understanding of the reason for this is somewhat conceptual:
> asking for all the objects that are "Stuff"s makes sense, but asking for all
> the objects that are "some object" doesn't make as much sense.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django Filter parser slightly less than intuitive

2009-08-12 Thread Mark Jones

{{ datevar|date: dateformat}}

won't parse.

You get the error:
Could not parse the remainder: ': dateformat' from 'datevar|date:
dateformat'

Turns out that unlike most other places, spaces ARE significant here.
It could be fixed by changing the filter_raw_string on line 448 of
django/template/__init__.py to eat the whitespace before and after the
variable or constant or i18n string with something like

\s* added to this portion of the regex for parsing

 (?:%(arg_sep)s\s*# Added here
 (?:
  %(i18n_open)s"(?P%(str)s)"%(i18n_close)s|
  "(?P%(str)s)"|
  (?P[%(var_chars)s]+)
 )\s*  # and here

It should probably either be fixed or at least documented.

I'm posting this here so that others can find it quickly and
understand the cause of the error message.  I wasted over an hour
because the error message wasn't clear enough to say, hey stupid,
white space all of a sudden matters with filter arguments.

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



Admin Panel: Restrict ForeignKey selections via permissions

2009-08-12 Thread Mark Stahler

Can someone point me in the direction to best solve this problem. It
would easier to show you:

class Profile(models.Model):
status = models.ForeignKey(Status)
...



class Status(models.Model):
status_name = models.CharField(max_length=50)
...

I need to be able to restrict the select box in Add/Change of the
Profile model in the Admin panel to the first 3 entries (with proper
id)  from the Status table. Basically I have 5 values in Status and I
need to have 2 kinds of users, a submitter and a reviewer. Submitter
can only add a 1-3 level status but the reviewer can add/change from 1-
whatever.

What would be the best way to do this? Can I extend the ForeignKey
class? Would it be easier to change my model some how? Any suggestions
would be appreciated, this is my first Django app and I am really
enjoying it.

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



Single Django Project, Multiple Apache Subdomains

2009-08-24 Thread Mark Stahler

I am using Nginx as a front end web server redirecting Python requests
to Apache + mod_wsgi. Everything with that is working fine. I have one
Django project running and I want to setup subdomains for a few of my
project apps.

Proposed structure:

/www/project/ -

-->/admin/ - admin.domain.com

-->/www/ - www.domain.com

-->/common_data/ - no subdomain

--> etc

Where is this setup done? Apache or is it done within Django? Is an
Apache rewrite rule the best way to do this? I would prefer to
maintain urls in the browser window. ie 
http://domain.com/admin/filebrowser/browse/
-> http://admin.domain.com/filebrowser/browse/.

Any advice would be appreciated. Thanks

PS: I have seen the following links: 
http://www.djangosnippets.org/snippets/1119/,
http://sharjeel.2scomplement.com/2008/07/24/django-subdomains/,
http://www.rossp.org/blog/2007/apr/28/using-subdomains-django/ but
they dont appear to be doing the same thing.

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



Advice on Subclassing a TextField

2009-08-29 Thread Mark Anderson
Hello,

I wanted a field that would render in a rich text editor and store the data
in a TextField so I created a field type of HtmlField and custom HtmlWidge.
It works but I was wondering is anyone would be willing to give me feedback
on best practices etc, This is my first attempt at subclassing and any
points on would be great.  I would like modelform to set the class to rte
and adjust rows/cols without me having to specify a widget.

Thank you,
Mark

class HtmlWidget(Textarea):
def __init__(self, attrs=None):
super(HtmlWidget, self).__init__(attrs)

def render(self, name, value, attrs=None):
if value is None: value = ''
value = smart_unicode(value)

return mark_safe(\
u'%s'
% \
  (name, escape(value)))

class HtmlField(models.TextField):

def get_internal_type(self):
return "HtmlField"

def formfield(self, **kwargs):
kwargs['widget'] = HtmlWidget
return super(HtmlField, self).formfield(**kwargs)

def __init__(self, *args, **kwargs):
super(HtmlField, self).__init__(*args, **kwargs)

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



Re: Advice on Subclassing a TextField

2009-08-30 Thread Mark (Nosrednakram)

I had at one time included the following and ended up putting it back
so that syncdb would actually create the columns.  Without it the
table is created with the column being made.  I am assuming this is
correct but am not sure.

def db_type(self):
return TextField().db_type()

Thanks for pointing out passing attrs because I did that originally.
This is more because i am auto generating forms for all loaded models
using a generic add object application I wrote.  I chose this route
because I didn't want to have to manually create forms for each.

Thanks again for your input.

Mark
On Aug 30, 8:03 am, Alex Robbins 
wrote:
> Also, maybe you aren't submitting all the code, but you could do the
> same thing by just passing an attrs dictionary to the text area
> widget.http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms
> Not sure that this requires two more classes.
>
> Hope that helps,
> Alex (Robbins)
>
> On Aug 30, 12:53 am, Mark Anderson  wrote:
>
> > Hello,
>
> > I wanted a field that would render in a rich text editor and store the data
> > in a TextField so I created a field type of HtmlField and custom HtmlWidge.
> > It works but I was wondering is anyone would be willing to give me feedback
> > on best practices etc, This is my first attempt at subclassing and any
> > points on would be great.  I would like modelform to set the class to rte
> > and adjust rows/cols without me having to specify a widget.
>
> > Thank you,
> > Mark
>
> > class HtmlWidget(Textarea):
> >     def __init__(self, attrs=None):
> >         super(HtmlWidget, self).__init__(attrs)
>
> >     def render(self, name, value, attrs=None):
> >         if value is None: value = ''
> >         value = smart_unicode(value)
>
> >         return mark_safe(\
> >         u'%s'
> > % \
> >               (name, escape(value)))
>
> > class HtmlField(models.TextField):
>
> >     def get_internal_type(self):
> >         return "HtmlField"
>
> >     def formfield(self, **kwargs):
> >         kwargs['widget'] = HtmlWidget
> >         return super(HtmlField, self).formfield(**kwargs)
>
> >     def __init__(self, *args, **kwargs):
> >         super(HtmlField, self).__init__(*args, **kwargs)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using cmemcache - not a good idea?

2009-09-01 Thread Ryan Mark

Hey Folks - I did load testing on my amazon ec2
ubuntu+django+postgresql+memcached setup. I discovered that under
load, cmemcache seems to fail on get cache requests. It causes django
to make a bunch of set cache calls, even though the key exists in
memcached. switching to python-memcache fixed this problem

The django docs seem to recommend using cmemcache - even though it has
not been updated in a long time. It is supposedly faster than the pure
python library (it uses the c libmemcache). It looks to me like there
are serious problems with it that would have caused a big headache had
I not also been monitoring memcached while load testing.

Anybody have anything to add to this?

Ryan Mark

-- 
Ryan Mark
http://ryan-mark.com
847 691 8271

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



Re: [Solved] Re: Make dev server respond on multiple IPs?

2009-09-01 Thread Ryan Mark

python manage.py runserver 0.0.0.0:8000

should bind the dev server to every IP on the machine

On Tue, Sep 1, 2009 at 3:27 PM, ringemup wrote:
>
> Never mind, I figured it out.  Just need to start a separate instance
> for each IP.
>
> On Sep 1, 4:26 pm, ringemup  wrote:
>> I've got some screwy DNS stuff going on on my local machine and need
>> the development server to respond to requests on two IP addresses at
>> once (127.0.0.1 and 192.168.1.7).  Is there any way to wrangle that?
>>
>> Thanks!
> >
>



-- 
Ryan Mark
http://ryan-mark.com
847 691 8271

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



Re: Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?

2009-03-31 Thread Mark Shewfelt

Hi Karl,

I just came across your post and am having the same issue (Ubuntu 8.04
Server). I managed to build the latest versions of unixODBC and
FreeTDS and install them to /usr/local/lib. When I run python and try
to import pyodbc I get the following error:

administra...@maverick:~/pyodbc-2.1.4$ python -c "import pyodbc"
Traceback (most recent call last):
  File "", line 1, in 
ImportError: libodbc.so.1: cannot open shared object file: No such
file or directory
administra...@maverick:~/pyodbc-2.1.4$

So obviously pyodbc cannot find the libs I just built - but I cannot
figure out how to specify their location when building pyodbc. Did you
have this issue? Any help is welcome!

Thanks,

Mark

On Feb 25, 5:19 pm, kgingeri  wrote:
> Ok, I figured this out myself...
>
> I had to un-install all pre-installed odbc stuff - unixODBC (possibly
> iODBC as well, except it didn't seem to actually uninstall completely)
> andFreeTDS.
>
> I then got source and did configure/make/make installs of unixODBC
> first, thenFreeTDS.
> This order is important so that the ./configure command can find all
> the right stuff.
> An important note is the params for theFreeTDS./configure command.
> I used the following:
>
> $ ./configure --with-unixodbc=/usr/local  --enable-msdblib --disable-
> libiconv --with-tdsver=8.0
>
> Anyway, it's working now without complaint!
>
> :v)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?

2009-04-01 Thread Mark Shewfelt

Thanks Karl - Actually, this morning I gave up and upgraded Ubuntu to
8.10, which uses a newer version of FreeTDS and unixODBC. It seems to
work OK, though there are some funky Unicode issues using Django's
TextField, but I can get around those for now.

Cheers,

Mark

On Mar 31, 8:41 pm, "Karl Gingerich"  wrote:
> Mark, I'll up to my eye balls in alligators right now, I'll get back to you 
> soon. - Karl
>
> -----Original Message-
> From: Mark Shewfelt 
>
> Date: Tue, 31 Mar 2009 08:25:55
> To: Django users
> Subject: Re: Incompatibility with FreeTDS/ODBC and Unicode on a MSSQL server?
>
> Hi Karl,
>
> I just came across your post and am having the same issue (Ubuntu 8.04
> Server). I managed to build the latest versions of unixODBC and
> FreeTDS and install them to /usr/local/lib. When I run python and try
> to import pyodbc I get the following error:
>
> administra...@maverick:~/pyodbc-2.1.4$ python -c "import pyodbc"
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: libodbc.so.1: cannot open shared object file: No such
> file or directory
> administra...@maverick:~/pyodbc-2.1.4$
>
> So obviously pyodbc cannot find the libs I just built - but I cannot
> figure out how to specify their location when building pyodbc. Did you
> have this issue? Any help is welcome!
>
> Thanks,
>
> Mark
>
> On Feb 25, 5:19 pm, kgingeri  wrote:
> > Ok, I figured this out myself...
>
> > I had to un-install all pre-installed odbc stuff - unixODBC (possibly
> > iODBC as well, except it didn't seem to actually uninstall completely)
> > andFreeTDS.
>
> > I then got source and did configure/make/make installs of unixODBC
> > first, thenFreeTDS.
> > This order is important so that the ./configure command can find all
> > the right stuff.
> > An important note is the params for theFreeTDS./configure command.
> > I used the following:
>
> > $ ./configure --with-unixodbc=/usr/local  --enable-msdblib --disable-
> > libiconv --with-tdsver=8.0
>
> > Anyway, it's working now without complaint!
>
> > :v)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overwrite send_mail

2009-05-10 Thread mark hellewell
Hi,

The django-mailer app I've been using simply defines a send_mail function
with the same signature as the one from django.core.mail.  With the 'mailer'
app in your INSTALLED_APPS you can then just do something like this at the
top of your views.py etc:


# use django-mailer app if it's available
if 'mailer' in settings.INSTALLED_APPS:
from mailer import send_mail
else:
from django.core.mail import send_mail


django-mailer recently moved to GitHub:

http://github.com/jtauber/django-mailer/tree/master

Should be all there is to it!
mark

2009/5/10 Dougal 

>
> Hi,
>
> is there a hook to help me replace the django send_mail function?
>
> I know I can just create my own but I want a nice easy way to handle
> emails my own way for a bunch of apps and it seems almost all re-
> usable apps tend to use send_mail.
>
> I've hunted but can't find anything in the docs
>
> Cheers,
> Dougal
> >
>

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



Multiple decorator and maybe caching, not sure

2009-05-21 Thread mark hellewell
Hello,

I've written a few decorators for my views. Each of the decorators operate
on the same object obtained from the db backend using ORM and each checks
different things.  I'll chain them together sometimes,  but not always.  In
the decorated view I'll usually be doing yet another
MyObjectClass.objects.get(...) (as I've done in each of the decorators
already) to carry out some operation or other on the object.

My question is,  is there some way to either avoid having to make repeated
ORM queries in each of the decorators or to cache the result of the first
ORM query (no matter which decorator it's obtained from)? All I'm usually
doing it a .get(id=123) to get an object to work on and it feels wasteful.

Is some form of middleware to cache db queries the "done thing" here?  Not
sure where to start.

Thanks for any help!
Mark

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



Re: Multiple decorator and maybe caching, not sure

2009-05-21 Thread mark hellewell
2009/5/21 Jarek Zgoda 

> Use low-level Django cache framework to cache retrieved object but
> don't forget to invalidate the cache upon each change to this object.
> Like:
>
> obj = cache.get(obj_key)
> if not obj:
> obj = ObjClass.objects.get(pk=obj_pk)
> cache.set(obj_key, obj)
> return obj
>

It's really that straight-forward,  what a nice surprise!

Thanks,
Mark


> --
> Artificial intelligence stands no chance against natural stupidity
>
> Jarek Zgoda, R&D, Redefine
> jarek.zg...@redefine.pl
>
>
> >
>

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



Re: Couple of basic Django questions

2009-09-12 Thread Mark Freeman

Dan, this link helped me a lot for using my stylesheet and images on
the test server.

http://docs.djangoproject.com/en/dev/howto/static-files/

Mark


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



Re: Editors of choice

2009-09-12 Thread Mark Freeman

Mostly Netbeans for me, however I do tend to use VIM quite a bit.

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



Subclassing Field to Define Default Widgets

2009-09-14 Thread Mark (Nosrednakram)

Hello Django Community,

Let me explain what I'm doing:

When using ModelForm to generate forms I frequently added the same
widget/parameters to fields.  I love the flexability to be able to do
this but find it very repetitive if I'm adding the same widget and/or
options to a field on several forms.  To avoid this situation I have
subclassed fields and assigned them widgets with standard options.

The question:

Other than requiring my custom fields/widgets be available to my
applications what are the other reasons this is a good/bad practice?
The simplest example is for a password field.  By default its a
CharField and I want to assign the PasswordInput widget and  set
render_value=False).  So rather than assign the widget at the form
level I'd prefer to set it at the model level with something like.

class PasswordField(models.CharField):
"""
PasswordField

This allows be to subclass a CharField and sets it up to use the
password
widget.
"""

def formfield(self, *args, **kwargs):
kwargs['widget'] = PasswordInput(render_value=False)
return super(PasswordField, self).formfield(**kwargs)

I prefer this to setting the widget in the form because I use auto
generated forms with a simple management tool.  Checking to see if a
custom form exists is easy enough to do but for almost all cases this
seems to be more DRY to me.  Another example is for HTMLField with a
custom widget that subclasses TextField.  I use a RTEditor for
HTMLField and use them in a lot of places but in reality it's a
TextField with a custom widget.  Should I be doing this in the forms
instead of the models?  Is this a poor way to design things?  Is
creating default presentation behaviors for fields bad and does it
violate MTV?

Thanks for Feedback,
Mark

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



Re: urls.py

2009-09-14 Thread Mark (Nosrednakram)



On Sep 14, 8:52 am, Ramanathan  wrote:
> I tried it.. but still it is not working.
>
> I am using django version 1.1.

If your view takes a parameter you need to give it a name and I
generally prepend a distinct identifier to my url so that django knows
what's going on.

(r'^activate/(?P.+)/$','proj.register.views.activate')

Which assumes your view has defined  something like

def activate(request, my_string):

I'm not sure what your true desired result is but i would try
something like the following.

(r'^media/(?P.*)$', 'django.views.static.serve',
  {'document_root': '/home/ramanathan/media'}),

This will require you to prepend media to your URL for media
requests.   This way django know the /media/path passed as to the
static server where path can be anything.

Hope this helps,
Mark

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



Re: Deploying with Apache: confused by odd PythonPath requirement

2009-09-14 Thread Mark (Nosrednakram)

Hello Dan,

CAUTION: I don't think the is the standard way of doing this but I
have found it to make my code portable and easy to implement.  Your
mileage may very but I have started removing the project name from all
of my code and for this configuration to work you would need to also.

I use the following on apache2 server where /opt/django/bancgi-prod is
the project directory and then I remove the project name from
ROOT_URLCONF in setting so it's equal = 'urls'.  Then in all
applications I import from the app and don't use project name ever.
This is important because my code is now portable.  Project name
doesn't matter except to the starting web server and the applications
can simple be used in any project without having to modify the project
name in any of the code.  I believe that by including project name in
your code you're making it hard to port and it isn't required by the
built in server or by Apache and probably not by anything else but I
don't know.  Again this works for me anyway :) but your mileage may
very.


  ServerName bancgi-prod.western.edu
  ServerAlias bancgi-prod

  
PythonPath "['/opt/django/bancgi-prod'] + sys.path"
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
SetEnv PYTHON_EGG_CACHE "/tmp"
PythonOption django.root /bancgi-prod
PythonDebug Off
Options FollowSymLinks
  


Hope this helps,
Mark


On Sep 13, 4:39 pm, Graham Dumpleton 
wrote:
> On Sep 14, 7:31 am, Dan06  wrote:
>
> > I've 'successfully' deployed django in a development environment on
> > Apache2. While, I've got it to work, I'm
> > thoroughly confused by the PythonPath setting needed for it to work.
>
> > I don't understand why I need to give the directory that contains the
> > django 'project' AND the directory that contains the django
> > 'application' (see PythonPath below), since the directory that
> > contains the django 'project' also contains the django
> > 'application' (see directory structure below).
>
> > Anyone know why I need to specify both 'project' and 'application'
> > directories?
>
> Because you haven't prefixed all your imports or module path
> references in urls.py with the name of the site.
>
> Graham
>
> > PythonPath "['/var/django_projects/', '/var/django_projects/test/'] +
> > sys.path"
>
> > Directory structure:
>
> > var/
> > | django_projects/ <--- General directory for all django work/projects
> > | | test/ <--- Django project directory created by: django-admin.py
> > startproject test
> > | | | test_app1/ <--- Django app directory created by: python
> > manage.py startapp test_app1
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to organize django projects on a productive server?

2009-09-16 Thread Mark (Nosrednakram)

Hello Orschiro,

If you are the sole developer working in your home directory is OK but
if you grow you'll have to grant access to your home directory to
someone else.  If you are building applications on a *nix type server
I'd recommend storing your base project(S) in /opt/django.  Any
production code that isn't maintained by the systems patching system I
try to put in either /usr/local or in /opt and in the case of django I
have always used /opt.  Additionally I make sure the directories all
belong to the django group and so do the developers.  By doing this
and setting change group id by chmod 2775 files are created all
belonging to the same group and can be worked on by more than one
person.  Assuming an appropriate umask is also being set.

I run one Apache server with virtual hosts for each of the django
projects that I serve with a separate directory link serving the
static files.  The static files are in /var/www/html/
project_site_media and I create symbolic link to them in my project
base directory for site_media while developing and servery with
runserver but in production I don't have django server any static
files. Each project has a templates directory as does each
application.  The base templates directory has a few templates and is
listed first in the templates path listing in settings.  It typically
contains login.html, logout.html, base.html, branded.html and
genericform.html.  I also have a minimal base.html and branded.html in
each applications templates directory so I can work with applications
standalone but override them all with the project specific base and
branded templates.  All images, css, js etc. are in the static
directory.  With each applications templates directory I stick all
templates in a sub directory named exactly the same as the
applications.  This is so applications don't run into each others
report.html upload.html etc.

I do all development on the development server using the built in
server and in a separate directory from the production sever.  I use
subversion and check all applications in but not the project.  Once I
get the applications working correctly I check it into subversion and
then go to the production server and check it out or run an update.
If database changes are required that syncdb won't handle like adding
columns etc.  I will create a sql script that will handle the changes
and run it at that time.  Typically it will add a column or something
along those lines.  I prefer to make these changes manually and have a
script ready to go.  Don't forget to take a full backup prior to
making changes just in case ;)

One other point I'd like to bring up is that I don't believe in using
the project name in references.  Don't import from project.app.models
but from app.models which will work fine and allow you to copy,
checkout etc your application and add it to setting etc. without
having to modify any of you code.

Include a separate urls.py file in each application and include it
from your projects urls.py.  Typically to add an application to a
configured project I so a svn chechout of the applicaiton.  Add it to
applicatoins and template path sections in settings and then add a
line in urls.py to include the application urls.py this is all that it
generally take to get an application up and running with a branded
look and feel :).

Sorry for the long answer, hope it's helpful.

Mark
On Sep 15, 1:28 pm, orschiro  wrote:
> Hello guys,
>
> first, I know it is not that important how to do this but as I'm
> pretty knew and callow I'd like to know how some experienced users do
> that.
>
> At the moment I have just a normal user account besides my root that
> stores all my django projects. Also my django trunk lives in there.
>
> Another point what interests me. Are you using a central directory for
> static files and templates etc. that are available for all your
> projects or does every project have its own directories in there?
>
> And final, are you developing on your local machine with the
> development server or immedeatly at the server via ssh?
>
> If yes, how do you deploy your project and about what points do you
> have to concern while doing that?
>
> Anyway, is there any good documentation how good deployment on a
> server might look like?
>
> I know, a bunch of questions but answers would be very helpful for
> me.
>
> Thank you guys. :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reading text files into mysql database

2009-10-01 Thread Mark (Nosrednakram)

Hello,

If your data is in a CSV format I have a tool I wrote to do this a
while ago that has served me well several times:
http://projects.django-development.info/trac/dd_csvloader   To
download if you want as a CSV check for a snippet at
djangosnippets.org.  http://www.djangosnippets.org/snippets/1697/ is
one such snippet.  You can also use the manager to import/export data
is several formats see 
http://docs.djangoproject.com/en/dev/ref/django-admin/#loaddata-fixture-fixture.
Just a few links to get you started.

Good Luck,
Mark

On Oct 1, 7:25 am, Carlos Gustavo  wrote:
> Hi All,
>
> I am a django newbie and so far it has been great.
>
> How do I populate a mysql database table with data from a text file?
>
> Also How do I dump results of a database query into a text file.
>
> I have already created my django model for the mysql table.
>
> Thanks in advance.
>
> -Carlos
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ORM

2009-10-08 Thread Mark (Nosrednakram)

Hello Isoscale,

>  I intend to write ORM code that will create views and triggers in the
> database? Which parts of the source code should I alter?

I use django to access views commonly, primarily for reporting I'll
create views taking care of the complex joins from our ERP so
developers can easily use the ORM.  There are a few things to keep in
mind if you want to use the ORM to access views especially if they are
based on external tables.

  1. ORM expects tables with a single PK
  2. Don't add views into your models.py use another file to define
them

The first one is very important you'll need to come up with a single
unique identifier for each row which can be a concatenated string etc.
If you are using oracle you can use rownum see notes at . Can you explain the your purpose
that requires you to create views and triggers.

Hope this helps,
Mark


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



Re: Overriding the default field types

2009-10-08 Thread Mark (Nosrednakram)

 Hello Luca,

> my models is this:
> class Per(models.Model):
>     dip = models.CharField(max_length=100)
>     di = models.CharField(max_length=100)
>     df = models.CharField(max_length=100)
>     m = models.CharField(max_length=500)
>     dri = models.CharField(max_length=100)
>
> the form is this:
>
> class PerForm(ModelForm):
>     class Meta:
>         model = Per
>
> i need that the field dri is hidden in the render of the form, can you
> tell me how i can do this?

You can and exclude to your Meta:

class PerForm(ModelForm):
class Meta:
model = Per
excluse = ('dri')

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



lighttpd and admin

2009-10-14 Thread Mark (Nosrednakram)

Hello All,

I setup lighttpd and fastcgi the other day and everything seemed good
until I tried to log into admin.  It posts to "//admin" which in the
browser is http:///admin without a host.  I believe this is due to
adding FORCE_SCRIPT_NAME="/" in my setting file which was required to
make {% url %} and reverse work I believe.  Is there a fix I haven't
found?  my lighttpd.conf with [CAPS] placeholders.  Any thoughts on
where to look?

server.modules  = ( "mod_rewrite",
"mod_redirect",
"mod_fastcgi",
"mod_alias",
"mod_access",
"mod_accesslog" )

server.errorlog = "/opt/django/fastcgi/error.log"
accesslog.filename  = "/opt/django/fastcgi/access.log"

server.document-root   = "/opt/django/html/"
server.port= 8080

mimetype.assign = (
  ".pdf"  =>  "application/pdf",
  ".jpg"  =>  "image/jpeg",
  ".jpeg" =>  "image/jpeg",
  ".png"  =>  "image/png",
  ".js"   =>  "text/javascript",
  ".css"  =>  "text/css",
  ".html" =>  "text/html",
  ".htm"  =>  "text/html",
  ".gif"  =>  "image/gif",
  ""  =>  "application/octet-stream",
 )

$HTTP["url"] =~ "^/media($|/)" {
 dir-listing.activate = "enable"
   }

$HTTP["host"] == "[HOSTNAME]" {
  url.redirect = ( "^/(.*)" => "http://[SERVER]/$1"; )
}
$HTTP["host"] == "[SERVER]" {

fastcgi.server = (
"/mysite.fcgi" => (
"main" => (
"socket" => "/opt/django/fastcgi/[SERVER].socket",
"check-local" => "disable",
)
)
)
alias.url = (
"/media" => "/opt/django/[PROJECT]/site_media/",
)

url.rewrite-once = (
"^(/media.*)$" => "$1",
"^(/.*)$" => "/mysite.fcgi$1"
)
}

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



Re: lighttpd and admin

2009-10-14 Thread Mark (Nosrednakram)

Thanks That fixed it :)

On Oct 14, 9:52 am, justquick  wrote:
> I have lighty setup for several of my projects using fastcgi and to
> make them work, i had to set
>
> FORCE_SCRIPT_NAME = ''
>
> instead of
>
> FORCE_SCRIPT_NAME = '/'
>
> give that a try and see if {% url %} et al are still working
>
> On Oct 14, 11:22 am, "Mark (Nosrednakram)" 
> wrote:
>
> > Hello All,
>
> > I setup lighttpd and fastcgi the other day and everything seemed good
> > until I tried to log into admin.  It posts to "//admin" which in the
> > browser is http:///admin without a host.  I believe this is due to
> > adding FORCE_SCRIPT_NAME="/" in my setting file which was required to
> > make {% url %} and reverse work I believe.  Is there a fix I haven't
> > found?  my lighttpd.conf with [CAPS] placeholders.  Any thoughts on
> > where to look?
>
> > server.modules              = ( "mod_rewrite",
> >                                 "mod_redirect",
> >                                 "mod_fastcgi",
> >                                 "mod_alias",
> >                                 "mod_access",
> >                                 "mod_accesslog" )
>
> > server.errorlog             = "/opt/django/fastcgi/error.log"
> > accesslog.filename          = "/opt/django/fastcgi/access.log"
>
> > server.document-root       = "/opt/django/html/"
> > server.port                = 8080
>
> > mimetype.assign             = (
> >   ".pdf"          =>      "application/pdf",
> >   ".jpg"          =>      "image/jpeg",
> >   ".jpeg"         =>      "image/jpeg",
> >   ".png"          =>      "image/png",
> >   ".js"           =>      "text/javascript",
> >   ".css"          =>      "text/css",
> >   ".html"         =>      "text/html",
> >   ".htm"          =>      "text/html",
> >   ".gif"          =>      "image/gif",
> >   ""              =>      "application/octet-stream",
> >  )
>
> > $HTTP["url"] =~ "^/media($|/)" {
> >      dir-listing.activate = "enable"
> >    }
>
> > $HTTP["host"] == "[HOSTNAME]" {
> >   url.redirect = ( "^/(.*)" => "http://[SERVER]/$1"; )}
>
> > $HTTP["host"] == "[SERVER]" {
>
> >     fastcgi.server = (
> >         "/mysite.fcgi" => (
> >             "main" => (
> >                 "socket" => "/opt/django/fastcgi/[SERVER].socket",
> >                 "check-local" => "disable",
> >             )
> >         )
> >     )
> >     alias.url = (
> >         "/media" => "/opt/django/[PROJECT]/site_media/",
> >     )
>
> >     url.rewrite-once = (
> >         "^(/media.*)$" => "$1",
> >         "^(/.*)$" => "/mysite.fcgi$1"
> >     )
>
> > }
>
> > Thank you,
> > Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Advice on checking optionally installed applications/features

2009-10-23 Thread Mark (Nosrednakram)

Hello Django Users,

I sometimes have reversion installed and sometimes have a
CACHE_BACKEND defined and came up with the following solution for
determining if I should register a model or use cache specific
functionality.  Since I'm not a Python Guru I'm asking an evaluation
of this method before I start using it in all my code.  The length
check on CACHE_BACKEND is in the even someone sets it to ''.
Currently I started adding this to each file where it's relevant.

try:
import reversion
_USE_REVERSION=True
except:
_USE_REVERSION=False

try:
if len(settings.CACHE_BACKEND) > 0:
_USE_CACHE=True
except:
_USE_CACHE=False

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



Re: Advice on checking optionally installed applications/features

2009-10-24 Thread Mark (Nosrednakram)

Thank you!

I made the changes an believe I understand the reasoning for all of
your advice. I now have the following in my_stteing.py:

from django.conf import settings

def using_reversion():
try:
import reversion
return True
except ImportError:
return False
except:
pass

def using_cache():
if len(getattr(settings,'CACHE_BACKEND',0)) > 0:
return True
else:
return False

This really helped clean up my code!

Thank Again,
Mark
On Oct 23, 9:43 pm, Ethan Jucovy  wrote:
> On Fri, Oct 23, 2009 at 1:09 PM, Mark (Nosrednakram) 
> > wrote:
>
> > Hello Django Users,
>
> > I sometimes have reversion installed and sometimes have a
> > CACHE_BACKEND defined and came up with the following solution for
> > determining if I should register a model or use cache specific
> > functionality.  Since I'm not a Python Guru I'm asking an evaluation
> > of this method before I start using it in all my code.
>
> It seems sensible to me.  I put a few implementation-level comments inline,
> but I agree that checking for imports and the existence of settings is the
> best way to do this.
>
> The length
>
> > check on CACHE_BACKEND is in the even someone sets it to ''.
> > Currently I started adding this to each file where it's relevant.
>
> You might want to encapsulate these in their own module somewhere, so you
> can later change or add ways of determining the answers.  From the outside
> it could then look like `from my_configuration import using_reversion; if
> using_reversion(): [etc]`
>
> > try:
> >    import reversion
> >    _USE_REVERSION=True
> > except:
> >    _USE_REVERSION=False
>
> Don't use a blanket `except`, just to be on the safe side.  You want `except
> ImportError`.
>
> try:
>
> >    if len(settings.CACHE_BACKEND) > 0:
> >        _USE_CACHE=True
> > except:
> >    _USE_CACHE=False
>
> Again, avoid catching all exceptions.  (If e.g. the settings module threw a
> RuntimeError on attribute access, you'd probably want to know about that,
> not disable the cache.)  Instead, `except AttributeError`, or just `if
> len(getattr(settings, "CACHE_BACKEND", '')) > 0`.
>
> Regards,
> egj
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inspectdb Oracle

2009-10-26 Thread Mark (Nosrednakram)

On Oct 26, 4:43 am, gillengam  wrote:
> Hi, I must develop an application that use Oracle database. The Oracle
> connection user is the owner of some tables, but he can only read two
> views (he is not the owner). I used command "python manage.py
> inspectdb > models.py", but I got only user's tables and  I need
> also the two views. How can I do? Is it possible?
>
> Thanks

I usually create a table using something similar to:

create table temp_member_view as select * from member_view where
rownum < 2;

Where member_view would be the original view name.  I then use the
inspectdb to create the model for the new table and then drop the
table it should create a better model than I do usually when I try to
do it manually.If your view doesn't have an obvious single column
primary key you may want to look at my notes on this subject:

http://projects.django-development.info/trac/dd_dd/wiki/Creating_Django_Views_of_Tables

Great call on overriding save/delete I'll add to my notes and start
doing that as well since I wasn't.

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



Re: If your on Dreamhost, vote for Django support

2009-10-28 Thread Mark Stahler

Good Luck. I have a Dreamhost account for my blog (Tried a dreamhost
vps for a week and a half) and now I have a Linode slice for my Django/
Rails stuff. Quasi-democratic system as in you have the illusion of
some kind of voice.

On Oct 28, 1:17 am, Richard Jeong  wrote:
> Thanks to Daniels help, I'm likely going to get my Dreamhost VPS server
> installed inspite of the problems I had during my attempt at installation.
> I would like to adovcate that for anyone else who is still on Dreamhost and
> on this list, vote for Full Django
> supporton
> the suggestion panel.  It's about time they really supported, and as
> they
> are quasi-democratic about how they improve then we should leverage it.
>
> Also worth voting for is
> mod_pythonand
> mod_wsgias
> they are obviously useful in Django support.
>
> Thanks again to the list and Daniel for making Django work for me.
> Rich
> 
> rje...@spamcop.net
> skype: rjeong
> blog: blog.wonderfullyrich.nethttp://imgs.xkcd.com/comics/beliefs.jpg
>
> Sent from Kampala, Uganda
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form that updates a list of items?

2009-11-02 Thread Mark (Nosrednakram)

Hello,

I'm not sure if I understand your problem but if I do you could name
your fields the same in both tables, which I believe you may have
done.  Then your view could generate your input form using form =
RoleUpDataFrom() and if you have POST data you could use form =
RealDataForm(reques.POST).  This is just a thought and I haven't done
it but is what I'd try before making it complex with loops etc..

Mark

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



model-validation: Excessive (and weird) queries during validation

2009-11-02 Thread Mark L.

As the subject states, I am using the model-validation branch at the
moment, which allows me to do, well, validation in the models.

I've however, noticed a very strange behaviour of the validation
logic, - any time  the clean() method is fired on the
"materialized" (saved or retrieved from the database) model, that
contains unique fields, the following query is fired (let me just give
you an example):

from django.db import models

class A(models.Model):
pass

a = A.objects.create()
a.clean()

a.clean() results, among everything, in this: 'SELECT (1) AS "a" FROM
"val_a" WHERE ("val_a"."id" = 1 AND NOT ("val_a"."id" = 1 ))'

I might be missing something vital, but what is that "where" clause
there for? What is it supposed to check? The stacktrace for the query
is the following:
787  clean django/db/models/base.py
619   validate django/db/models/base.py
624   validate_unique django/db/models/base.py
683   _perform_unique_checks django/db/models/base.py
112   __nonzero__ django/db/models/query.py
106   _result_iter django/db/models/query.py
692   _fill_cache django/db/models/query.py
756   iterator django/db/models/query.py
287   results_iter django/db/models/sql/query.py
2369 execute_sql django/db/models/sql/query.py

Apparently, it is happening inside the uniqueness check. Anyway, the
most strange thing, is that calling clean() results in a query. I've
noticed it when I was displaying a set of a few hundred objects (each
of them has to be cleaned before sending the data to template), which
resulted in a few hundred of queries (for a single request), which
brought my dev-machine to the knees. It becomes worse if the cleaned
model is a part of a table-inheritance hierarchy, - clean() is called
sequentially for every model "up" the hierarchy, which results in a
tremendous number of queries executed per single request.

I must say, however, that I, at this moment, have no idea how to check
for uniqueness *without* issuing a query and, from what I see, django
doesn't like to assume things, so the db hits *will* be made.

Obviously, I can swindle Django into not checking uniqueness on clean
(by rolling my own clean method in models.Model subclasses), however,
that doesn't sound like a very good idea (if alternatives exist).

Sorry if this is an inappropriate list/group for this question. Maybe
I should instead address it to the django-developers or the issue
tracker.

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



  1   2   3   4   5   6   >