Re: override save()

2009-08-09 Thread Léon Dignòn

That kind of surprises me. I thought that the whole code will be
parsed before actually doing something. Like C# :)

But save() is not overridden! If I comment out super() it still saves
the form.
-
class ProfileFormExtended(UserProfile):
def save(self, force_insert=False, force_update=False):
#super(ProfileFormExtended, self).save
(force_insert,force_update)
-

I have UserProfile(models.Model) defined. Then I inherit this class by
writing ProfileFormExtended(UserProfile) after that I create a
ModelForm class ProfileForm(models.ModelForm) which has a meta
attribute model=ProfileFormExtended which tells the ModelForm to use
the inherited ProfileFormExtended class to create a form. Up to here
it's working.

What it does NOT do is using ProfileFormExtended.save() instead of
UserProfile.save(). And that although it uses ProfileFormExtended.

What am I missing???






On Aug 10, 3:23 am, Malcolm Tredinnick 
wrote:
> On Sun, 2009-08-09 at 13:35 -0700, Léon Dignòn wrote:
> > Hi,
>
> > I have a ModelForm of my UserProfile model with two additional fields.
> > I need to override save(), to save the additional fields to the
> > django.contrib.auth.model.User model.
> > I tried to do that with a subclass of my UserProfile model class to
> > have the code separated. But I get a NameError: name
> > 'ProfileFormExtended' is not defined.
>
> > from django.contrib.auth.models import User
> > from django.db import models
> > from django.forms.models import ModelForm
> > from django import forms
> > from myproject.myapp.models import UserProfile
>
> > class ProfileForm(ModelForm):
> >     first_name = forms.CharField(max_length=30)
> >     last_name = forms.CharField(max_length=30)
>
> >     class Meta:
> >         model = ProfileFormExtended
>
> At the time this line of code is executed, this class doesn't exist yet
> (you don't define it until later in the file). The error message is
> telling you the right thing. Reorder the code in the file.
>
> Regards,
> Malcolm- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



how django admin display fetch data

2009-08-09 Thread Hellnar

Hello
I am trying to understand how django admin panel fetch and list the
data instaces of models. I need this because I will be implementing a
javascript graph to the listing view of a model (at the listing view
of these datas)

Cheers
--~--~-~--~~~---~--~~
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 save()

2009-08-09 Thread Karen Tracey
On Sun, Aug 9, 2009 at 10:23 PM, neridaj  wrote:

>
> It was suggested to me in an earlier post, to override save, and
> though I've read the documentation for upload_to before I guess I
> don't quite know how to implement it without an example. Due to my
> lack of experience I don't know how to address the 'instance' and
> 'filename' arguments required by the callable, is this even close?
>
> class Listing(models.Model):
>user = models.ForeignKey(User)
> name = models.CharField(max_length=50)
>order = models.ForeignKey('Order')
>
> def overwrite_upload_to(self, name):
> user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings',
> self.user.username)
> return user_dir_path
>

Don't add in MEDIA_ROOT yourself.  The return value from a callable
upload_to (just as if it were a simple string) is appended to your
MEDIA_ROOT setting.  So you don't need to add it in yourself.

>
>zipfile = models.FileField(upload_to=overwrite_upload_to(self,
> name))
>

Don't include the parens and parameters. Just pass the callable:

zipfile = models.FileField(upload_to=overwrite_upload_to)

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: select_related(field) doesn't use the default manager of the field

2009-08-09 Thread Gleber

Thanks for the reply,
This is much more complex than I thought..
I will stay with the way of two queries, better than one query per
object..

Gleber
--~--~-~--~~~---~--~~
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: Using email instead of username in extended "User" model?

2009-08-09 Thread Saikat Chakrabarti

Just some more info on this -
I use 
http://www.davidcramer.net/code/224/logging-in-with-email-addresses-in-django.html
for logging in using emails.  There is some discussion of this topic
on 
http://groups.google.com/group/django-users/browse_thread/thread/c943ede66e6807c/2fbf2afeade397eb?pli=1
.  And for registration, I generate a username for each user using the
code at http://www.djangosnippets.org/snippets/723/ .  This is mostly
a rehash of what's been already said, but it seems like a summation of
what I can find on the topic currently.

-Saikat

On Aug 4, 10:04 pm, Dana Woodman  wrote:
> Yeah that seems like the option Ill go with since it is probably the most
> clean and future compatible. My user's dont need to log into django admin
> anyways so that should suffice. Thanks everyone for the feedback!
>
> Cheers,
> Dana
>
> On Mon, Aug 3, 2009 at 4:23 PM, Malcolm Tredinnick 
>
>
> > wrote:
>
> > On Mon, 2009-08-03 at 13:13 -0700, Dana wrote:
> > > Ok, I understand the login part but what about registration? Wouldn't
> > > the user's need a username still? Or am I misunderstanding... And what
> > > about Django admin, it would still need a username correct?
>
> > Nothing stops you from creating a random string to populate the username
> > field with. It has to contain a unique identifier and it's often useful
> > if that is actually identifiable -- perhaps created from an amalgam of
> > the user's first and last names or something -- but it could be entirely
> > random, providing it is unique.
>
> > So when you are registering the user, just create a username string
> > however you like. The user themselves doesn't have to know or care what
> > it is. The thing is, their username won't change, their email address
> > might (one of the many small problems with email addresses as unique and
> > unchanging identifiers).
>
> > 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
-~--~~~~--~~--~--~---



Re: weirdist situation I have faced in 4 years of (ab)using django

2009-08-09 Thread Kenneth Gonsalves

On Sunday 09 Aug 2009 1:03:44 pm Kenneth Gonsalves wrote:
> addevent works fine and so does listing of events - and so does Meeting and
> Report. I have done this so many times in the last 4 years that I can do it
> in my sleep. But this time eventfull does not work. It does not throw
> errors. The template is displayed, but the data is from Meeting.

solved. I had used the same name for variable in my templatetag and in my 
template
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: select_related(field) doesn't use the default manager of the field

2009-08-09 Thread Malcolm Tredinnick

On Sat, 2009-08-08 at 22:00 -0700, Gleber wrote:
[...]
> When I override the get_query_set() adding extra fields, these fields
> aren't available if I execute:
> ModelB.objects.all().select_related('ref')

This is true.

> This is a bug? 

Not necessarily. It's intentional behaviour at the moment and it's
fairly tricky to make things work the way you want. *Particularly*
because you're using extra(). All bets are off once you start
introducing extra() into things, because that introduces opaque SQL
strings, so the necessary alias relabelling and the like that has to go
on to move query parts around isn't going to be able to work with that.

Worthwhile opening a ticket for this enhancement request. Don't be too
surprised if it's ultimately closed as wontfix, but I'd like to have a
think about it for a bit and see if the passing of a few months brings
up new ways to do this that I didn't think of the first couple of times
I worked on this problem.

> If not, how can I get the extra fields from ModelA
> through ModelB with only one query?

It might not be possible.

> I need this cause I have to display a list of 50+ ModelBs and i can't
> execute 50+ queries only for that..

Which you don't have to do. You can use normal select_related()
behaviour and then do an extra query to retrieve the necessary extra
fields and iterate through the queryset attaching the extra attributes
to the models. So it's one extra query.

You could even do this as a subclass of QuerySet as a specially named
method if you were doing it often enough that you wanted it wrapped up
neatly.

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



Re: override save()

2009-08-09 Thread Malcolm Tredinnick

On Sun, 2009-08-09 at 13:35 -0700, Léon Dignòn wrote:
> Hi,
> 
> I have a ModelForm of my UserProfile model with two additional fields.
> I need to override save(), to save the additional fields to the
> django.contrib.auth.model.User model.
> I tried to do that with a subclass of my UserProfile model class to
> have the code separated. But I get a NameError: name
> 'ProfileFormExtended' is not defined.
> 
> from django.contrib.auth.models import User
> from django.db import models
> from django.forms.models import ModelForm
> from django import forms
> from myproject.myapp.models import UserProfile
> 
> class ProfileForm(ModelForm):
> first_name = forms.CharField(max_length=30)
> last_name = forms.CharField(max_length=30)
> 
> class Meta:
> model = ProfileFormExtended

At the time this line of code is executed, this class doesn't exist yet
(you don't define it until later in the file). The error message is
telling you the right thing. Reorder the code in the file.

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



Re: overriding save()

2009-08-09 Thread Karen Tracey
On Sun, Aug 9, 2009 at 8:16 PM, neri...@gmail.com  wrote:

>
> Hello,
>
> I'm having trouble overriding save() to change the upload_to attribute
> of a FileField object. I would like the upload_to attribute to change
> depending on which user is selected from the select menu i.e., if user
> testuser24 is selected the upload_to would change to
> upload_to='listings/testuser24/'.
>
>
Why are you trying to do this by overriding save() instead of by specifying
a callable for upload_to?  Doc on this is here:

http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to

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



overriding save()

2009-08-09 Thread neri...@gmail.com

Hello,

I'm having trouble overriding save() to change the upload_to attribute
of a FileField object. I would like the upload_to attribute to change
depending on which user is selected from the select menu i.e., if user
testuser24 is selected the upload_to would change to
upload_to='listings/testuser24/'.



class Listing(models.Model):
user = models.ForeignKey(User)
zipfile = models.FileField(upload_to='listings')
name = models.CharField(max_length=50)
order = models.ForeignKey('Order')

def overwrite_upload_to(self):
user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings',
self.user.username)
self.zipfile.upload_to=user_dir_path

def save(self, force_insert=False, force_update=False):
Listing.overwrite_upload_to(self)
super(Listing, self).save(force_insert, force_update) # Call
the "real" save() method.

def __unicode__(self):
return self.name


Thanks for any help,

Jason
--~--~-~--~~~---~--~~
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 newbie, having problems with my first app. maybe in the urls.py?

2009-08-09 Thread ezulo...@gmail.com

So i am very new to django and have a little python experience. im
using webfraction to host my application and followed their
instructions on starting a django webapp. i have the server up and
running and im using the 1.0 documentation at djangobook.com, and
running django 1.0 for my webapp. I cannot seem to get my helloworld
URL at http://ezuloaga.webfactional.com/myproject/hello/ to display
anything other than the default django page. here are my views.py and
urls.py files. according to the documentation, it should display my
hello world page. Thanks for any help!

[ezulo...@web93 myproject]$ cat views.py
from django.http import HttpResponse

def hello(request):
return HttpResponse("Hello world")



[ezulo...@web93 myproject]$ cat urls.py
from django.conf.urls.defaults import *
from mysite.views import hello

urlpatterns = patterns('',
('^hello/$', hello),
)


http://ezuloaga.webfactional.com/myproject/hello/

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



newbies Deployment docs

2009-08-09 Thread justin jools

I hope this helps anyone starting, cos i learnt this the hard way!

---

get your python path working: (scroll down to environment variables)

http://www.voidspace.org.uk/python/articles/command_line.shtml#path

---

django deployment: Apache, Python, Django, PostgreSQl - the whole
shebang (helped me a lot)

http://wiki.thinkhole.org/howto:django_on_windows%E2%80%8F
---

p.s. !important when downloading mod_python make sure it matches your
Python and Apache versions:

e.g. mod_python-3.3.1.win32-py2.5-Apache2.2.exe

if they dont match your LoadModule python_module wont work!

hope this helps y'all ;)
--~--~-~--~~~---~--~~
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 do I minimize memory usage with WSGI and Apache?

2009-08-09 Thread Graham Dumpleton



On Aug 10, 6:07 am, Jumpfroggy  wrote:
> I'm hosting a bunch of django apps on a shared host with 80MB of
> application memory (Webfaction in this case).  I've got a bunch of
> apps that are very infrequently used, but need to be online.  I've
> already changed the httpd.conf:
>     ServerLimit 1
> Instead of the default "ServerLimit 2".  With the default, each app
> spawns 3 apache processes; one manager, 2 worker processes.  With
> ServerLimit 1, there is only a manager and a single worker.  This cuts
> down on a lot for low-traffic sites.
>
> However, I'd like to see what the bare minimum memory usage can be.
> I've made sure DEBUG = False.  I also separated the static media to a
> separate server with MEDIA_ROOT and MEDIA_URL.  When I first start
> apache, the manager and worker processes use about 3MB (RSS) each.
> After the first access with a browser, the manager stays the same but
> the worker uses 16MB and stays there until apache is restarted.
>
> Ideally, I'd love it if the memory usage go back to the initial state
> (3MB) after a period of inactivity.  I'm curious; what is being stored
> in memory?  Are there other things I can do to reduce memory usage?
>
> The one thing I've seen is the "MaxRequestsPerChild" apache setting.
> As far as I can tell, it'll recreate the worker process after X
> requests.  But this seems like it might adversely affect performance,
> since I need something time-based, and not # requests based.  With
> MaxRequestsPerChild, I'm guessing if I set it to 10 but only had 9
> requests, it would sit there using up memory until the tenth request,
> which is not ideal.  With MaxRequestsPerChild set to 1, I'd be
> guaranteed low memory usage but would also recreate the worker process
> for each request, which seems like a bad idea.
>
> My goal is to have many apps running at bare-minimum memory usage, and
> only the frequently accessed sites taking up ~16MB memory each.  And
> when the active sites are dormant (late at night, etc), I'd like those
> to lower their memory use as well.  Is there any way to do this?
>
> Thanks! (and apologies if I've missed some obvious documentation...
> I've gone through a few guides, but nothing seems to have helped).

Replace use of mod_python with mod_wsgi. Ensure you use prefork MPM
for Apache and delegate Django instances to run in mod_wsgi daemon
mode process. Having done that, you can use inactivity-timeout option
for mod_wsgi daemon processes to have the process restarted and
returned to low memory footprint idle process after no use for a
while.

Note, just ensure you don't keep loading mod_python after having
switched to mod_wsgi as mod_python will still consume some extra
memory when not in use.

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



Re: Apache2 permission denied problem

2009-08-09 Thread Malcolm MacKinnon
Graham, thanks for taking the time to repond. I made the changes in my views
to use only absolute paths, and made the necessary changes to the file
permissions. All seems to work fine now.

On Sun, Aug 9, 2009 at 11:19 PM, Graham Dumpleton <
graham.dumple...@gmail.com> wrote:

>
>
>
> On Aug 9, 4:11 pm, Mac  wrote:
> > Hi,
> >
> > I'm new to Django, and am trying to write a csv file and attach it to
> > an email that is sent upon completion of a sales order. All works fine
> > in the developement server, but when I switch to Apache2 I get an
> > error message that either says' No such file or directory, ../orders1/
> > csv_files/ or Permissions denied etc. All works fine when I use the
> > developement server. Here's my Apache2 sites-available script:
> > 
> > ServerAdmin malc...@sporthill.com
> > ServerName localhost
> > ServerAlias localhost/media/
> > DocumentRoot /home/malcolm/data1/orders1/media
> > WSGIScriptAlias / /home/malcolm/data1/orders1/apache/django.wsgi
> > 
> > Order allow,deny
> > Allow from all
> > 
> > 
> > Order allow,deny
> > Allow from all
> > 
> > 
> >
> > Apache2 is located in /etc/apache2/
> >
> > My app is in /home/malcolm/data1/orders1/
> >
> > Here's some of the relevant code in my views:
> > for n in new_m:
> > so_order=n.so_number
> > so_order=str(so_order)
> > custo=n.custno/csv_files/"+custo+so_order+".csv", "wb"))
> >
> > Any ideas about what might fix this problem. Any thoughts are
> > appreciated.
>
> Two things.
>
> The first is that you must use absolute path names when referring to
> directories/files as the current working directory of Apache when run
> isn't going to be the same as when you used development server.
>
> Second, the user that Apache runs as will not likely have permissions
> to write to same directories as user you ran development server. You
> need to somehow give Apache permission to write to the directories, or
> use daemon mode of Apache/mod_wsgi and configure the daemon process to
> run as sam user as you used to run development server.
>
> Graham
> >
>

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



Re: Apache2 permission denied problem

2009-08-09 Thread Graham Dumpleton



On Aug 9, 4:11 pm, Mac  wrote:
> Hi,
>
> I'm new to Django, and am trying to write a csv file and attach it to
> an email that is sent upon completion of a sales order. All works fine
> in the developement server, but when I switch to Apache2 I get an
> error message that either says' No such file or directory, ../orders1/
> csv_files/ or Permissions denied etc. All works fine when I use the
> developement server. Here's my Apache2 sites-available script:
> 
>         ServerAdmin malc...@sporthill.com
>         ServerName localhost
>         ServerAlias localhost/media/
>         DocumentRoot /home/malcolm/data1/orders1/media
>         WSGIScriptAlias / /home/malcolm/data1/orders1/apache/django.wsgi
>         
>         Order allow,deny
>         Allow from all
>         
>         
>         Order allow,deny
>         Allow from all
>         
> 
>
> Apache2 is located in /etc/apache2/
>
> My app is in /home/malcolm/data1/orders1/
>
> Here's some of the relevant code in my views:
> for n in new_m:
>             so_order=n.so_number
>             so_order=str(so_order)
>             custo=n.custno/csv_files/"+custo+so_order+".csv", "wb"))
>
> Any ideas about what might fix this problem. Any thoughts are
> appreciated.

Two things.

The first is that you must use absolute path names when referring to
directories/files as the current working directory of Apache when run
isn't going to be the same as when you used development server.

Second, the user that Apache runs as will not likely have permissions
to write to same directories as user you ran development server. You
need to somehow give Apache permission to write to the directories, or
use daemon mode of Apache/mod_wsgi and configure the daemon process to
run as sam user as you used to run development server.

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



Re: user online

2009-08-09 Thread Daniel Roseman

On Aug 9, 10:07 pm, "Rob B (uk)"  wrote:
> Im using this middleware to try and display a list of online user on
> my site.http://dpaste.com/77464/
>
> Im just not sure how to pass it to my view and template.  Any ideas?
>
> Middleware found 
> @http://groups.google.com/group/django-users/browse_thread/thread/6f5f...
>
> Thanks

Jeremy explains how to do it in the message you link to:
"You'll want to use OnlineUsers.get_online_user_ids() wherever you
need
the list of IDs. "

ie import the OnlineUsers module in your view and pass
OnlineUsers.get_online_user_ids() into the context.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



user online

2009-08-09 Thread Rob B (uk)

Im using this middleware to try and display a list of online user on
my site.
http://dpaste.com/77464/

Im just not sure how to pass it to my view and template.  Any ideas?

Middleware found @
http://groups.google.com/group/django-users/browse_thread/thread/6f5f759d3fd4318a/

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: 2 Questions about feeds

2009-08-09 Thread Léon Dignòn

Please try to change the Sitename in the backend at /admin/sites/site/
Per default its example.com

On Aug 8, 8:46 pm, When ideas fail  wrote:
> Hi, i'm developing a feed but i still have a couple of questionss.
>
> 1. I have this in my models:
>
> def get_absolute_url(self):
>         return "/blog/%s/" % self.post_slug
>
> but the rss has the links down as:http://example.com/blog/post_3/,
> the blog/post_3/ is correct, how can i make sure its linked to right
> domain name? for example have it go to andrew.com/blog/post_3?
>
> 2. What does the  element do?
> I've changed it a few times and i can't see what difference it makes?
>
> 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: My ModelAdmin customizations don't work

2009-08-09 Thread Chao Xu

Oh, I am so careless. Thank you very much!

On Aug 8, 9:41 pm, Alex Gaynor  wrote:
> On Sat, Aug 8, 2009 at 8:37 PM,ChaoXu wrote:
>
> > I want't to add search in admin site and followed the instructions of
> > official guide of The Django admin site. But nothing on admin site
> > changed, nor errors appeared after I changed my code.
>
> > following is my code, please help me. Thank you in advance!
>
> > entity.models.py code ===
> > from django.db import models
> > from django.contrib.auth.models import User
> > import datetime
>
> > class University(models.Model):
> >    name = models.CharField(max_length=100)
> >    abbreviation = models.CharField(unique=True, max_length=50)
>
> > entity.admin.py code 
> > from entity.models import *
> > from django.contrib import admin
>
> > class UniversityAdmin(admin.ModelAdmin):
> >    list_display = ('name', 'abbreviation')
> >    search_fields = ['name']
>
> > admin.site.register(University)
>
> Your problem is you registered your Model with the admin without
> telling it about your custom ModelAdmin class, so it used the default
> one.  The last line should be.
>
> admin.site.register(University, UniversityAdmin)
>
> 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
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MySQL server has gone away

2009-08-09 Thread akramquraishi

Hi,

I'm getting a lot of "MySQL server has gone away" errors on my site.

I tried increasing the connection timeout but the site is in a private
beta and has very less activity. At times there aren't any requests
for hours together.

And when there are requests .. these errors comes up multiple times
and after that it starts running smoothly.

I'm sure this issue will vanish once the site build up traffic.. But
during site demos errors like these are embarrassing.

Please suggest a workaround.

Thanks.
Akram



#
Traceback (most recent call last):
#

#
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py",
line 86, in get_response
#
response = callback(request, *callback_args, **callback_kwargs)
#

#
File "/root/main/mosambe/../mosambe/jobs/views/auth.py", line 5, in
login
#
if request.user.is_authenticated():
#

#
File "/usr/lib/python2.5/site-packages/django/contrib/auth/
middleware.py", line 5, in __get__
#
request._cached_user = get_user(request)
#

#
File "/usr/lib/python2.5/site-packages/django/contrib/auth/
__init__.py", line 83, in get_user
#
user_id = request.session[SESSION_KEY]
#

#
File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
backends/base.py", line 46, in __getitem__
#
return self._session[key]
#

#
File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
backends/base.py", line 172, in _get_session
#
self._session_cache = self.load()
#

#
File "/usr/lib/python2.5/site-packages/django/contrib/sessions/
backends/db.py", line 16, in load
#
expire_date__gt=datetime.datetime.now()
#

#
File "/usr/lib/python2.5/site-packages/django/db/models/manager.py",
line 93, in get
#
return self.get_query_set().get(*args, **kwargs)
#

#
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 304, in get
#
num = len(clone)
#

#
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 160, in __len__
#
self._result_cache = list(self.iterator())
#

#
File "/usr/lib/python2.5/site-packages/django/db/models/query.py",
line 275, in iterator
#
for row in self.query.results_iter():
#

#
File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 206, in results_iter
#
for rows in self.execute_sql(MULTI):
#

#
File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py",
line 1734, in execute_sql
#
cursor.execute(sql, params)
#

#
File "/usr/lib/python2.5/site-packages/django/db/backends/mysql/
base.py", line 93, in execute
#
return self.cursor.execute(query, args)
#

#
File "/usr/lib/python2.5/site-packages/MySQL_python-1.2.3c1-py2.5-
linux-x86_64.egg/MySQLdb/cursors.py", line 173, in execute
#
self.errorhandler(self, exc, value)
#

#
File "/usr/lib/python2.5/site-packages/MySQL_python-1.2.3c1-py2.5-
linux-x86_64.egg/MySQLdb/connections.py", line 36, in
defaulterrorhandler
#
raise errorclass, errorvalue
#

#
OperationalError: (2006, 'MySQL server has gone away')

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



override save()

2009-08-09 Thread Léon Dignòn

Hi,

I have a ModelForm of my UserProfile model with two additional fields.
I need to override save(), to save the additional fields to the
django.contrib.auth.model.User model.
I tried to do that with a subclass of my UserProfile model class to
have the code separated. But I get a NameError: name
'ProfileFormExtended' is not defined.

from django.contrib.auth.models import User
from django.db import models
from django.forms.models import ModelForm
from django import forms
from myproject.myapp.models import UserProfile

class ProfileForm(ModelForm):
first_name = forms.CharField(max_length=30)
last_name = forms.CharField(max_length=30)

class Meta:
model = ProfileFormExtended
exclude = ('user', 'avatar',) # User will be filled in by the
view.

class ProfileFormExtended(UserProfile):
def save(self, force_insert=False, force_update=False):
if self.name == "Yoko Ono's blog":
else:
super(ProfileFormExtended, self).save(force_insert,
force_update) # Call the "real" save() method.
--~--~-~--~~~---~--~~
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: Custom manager and delete()

2009-08-09 Thread Adi Andreias

Hello,

Anyone can give us a hint with this?
I have the same problem: with a custom manager (for a 2nd database)
SELETs and INSERTs are working, but not the DELETE operation.
Seems like DELETE references a global connection variable (to the main
database).

Thanks


michael wrote:
> Hi,
>
> [Sorry, if this has been asked before]
> I defined a model using a custom manager. However, this custom manager
> is not used when I call "delete()" method on an instance object. The
> reason
> I use a custom manager is because the model represents objects in
> another
> legacy database (different from the normal database used by django).
> So
> I'm basically trying to emulate multi-db support.
>
> Obviously, as delete() uses the default manager, it fails as the
> corresponding
> table is not in that database.
>
> Is there a workaround for this, or do I have to overload delete() in
> my model
> and use raw SQL?
>
> Thanks,
> Michael.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How do I minimize memory usage with WSGI and Apache?

2009-08-09 Thread Jumpfroggy

I'm hosting a bunch of django apps on a shared host with 80MB of
application memory (Webfaction in this case).  I've got a bunch of
apps that are very infrequently used, but need to be online.  I've
already changed the httpd.conf:
ServerLimit 1
Instead of the default "ServerLimit 2".  With the default, each app
spawns 3 apache processes; one manager, 2 worker processes.  With
ServerLimit 1, there is only a manager and a single worker.  This cuts
down on a lot for low-traffic sites.

However, I'd like to see what the bare minimum memory usage can be.
I've made sure DEBUG = False.  I also separated the static media to a
separate server with MEDIA_ROOT and MEDIA_URL.  When I first start
apache, the manager and worker processes use about 3MB (RSS) each.
After the first access with a browser, the manager stays the same but
the worker uses 16MB and stays there until apache is restarted.

Ideally, I'd love it if the memory usage go back to the initial state
(3MB) after a period of inactivity.  I'm curious; what is being stored
in memory?  Are there other things I can do to reduce memory usage?

The one thing I've seen is the "MaxRequestsPerChild" apache setting.
As far as I can tell, it'll recreate the worker process after X
requests.  But this seems like it might adversely affect performance,
since I need something time-based, and not # requests based.  With
MaxRequestsPerChild, I'm guessing if I set it to 10 but only had 9
requests, it would sit there using up memory until the tenth request,
which is not ideal.  With MaxRequestsPerChild set to 1, I'd be
guaranteed low memory usage but would also recreate the worker process
for each request, which seems like a bad idea.

My goal is to have many apps running at bare-minimum memory usage, and
only the frequently accessed sites taking up ~16MB memory each.  And
when the active sites are dormant (late at night, etc), I'd like those
to lower their memory use as well.  Is there any way to do this?

Thanks! (and apologies if I've missed some obvious documentation...
I've gone through a few guides, but nothing seems to have helped).
--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread Léon Dignòn

Thank you all! :)

On Aug 9, 9:35 pm, "J. Cliff Dyer"  wrote:
> On Sun, 2009-08-09 at 11:59 -0700, Léon Dignòn wrote:
> > In my myproject/urls.py I want to pass the class to a function.
> > Because my urls.py is full of imports, I do not want another import
> > line for this class I only use at one line, because it's easier to
> > read.
>
> > I wonder that I have to import myproject when I reference a model
> > class in an app which _is_ in the project I am currently using. For
> > that I have to ask this:
>
> > Do I really need 'import myproject' in myproject/urls.py when I'd like
> > to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
>
> In fact, you need to import more than myproject.  You need to import
> myproject.myapp.models.  Imports happen at the module level, which is to
> say, one file at a time.  You don't need to import each class
> individually, but you do need to import each module.  
>
> If you are worried about having too many imports in your urls.py
> configuration file, see if you can break it up somewhat by giving each
> app its own urlconf with only the urls relevant to that particular app.
>
> Cheers,
> Cliff
--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread J. Cliff Dyer

On Sun, 2009-08-09 at 11:59 -0700, Léon Dignòn wrote:
> In my myproject/urls.py I want to pass the class to a function.
> Because my urls.py is full of imports, I do not want another import
> line for this class I only use at one line, because it's easier to
> read.
> 
> I wonder that I have to import myproject when I reference a model
> class in an app which _is_ in the project I am currently using. For
> that I have to ask this:
> 
> Do I really need 'import myproject' in myproject/urls.py when I'd like
> to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
> 
> 

In fact, you need to import more than myproject.  You need to import
myproject.myapp.models.  Imports happen at the module level, which is to
say, one file at a time.  You don't need to import each class
individually, but you do need to import each module.  

If you are worried about having too many imports in your urls.py
configuration file, see if you can break it up somewhat by giving each
app its own urlconf with only the urls relevant to that particular app.

Cheers,
Cliff




--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread Daniel Roseman

On Aug 9, 7:59 pm, Léon Dignòn  wrote:
> In my myproject/urls.py I want to pass the class to a function.
> Because my urls.py is full of imports, I do not want another import
> line for this class I only use at one line, because it's easier to
> read.
>
> I wonder that I have to import myproject when I reference a model
> class in an app which _is_ in the project I am currently using. For
> that I have to ask this:
>
> Do I really need 'import myproject' in myproject/urls.py when I'd like
> to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???
>

Yes, if you want to write 'myproject.whatever' you need to import
myproject. Python doesn't magically know about namespaces unless you
tell it.

You're right that since you're in myproject you don't need to import
that - you can just import myapp and do 'myapp.models'. But you still
need to import myapp.

However, I do wonder why you have so many imports in your urls.py. I
presume you know that you can just use strings to reference the view
functions?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: import problem

2009-08-09 Thread Léon Dignòn

In my myproject/urls.py I want to pass the class to a function.
Because my urls.py is full of imports, I do not want another import
line for this class I only use at one line, because it's easier to
read.

I wonder that I have to import myproject when I reference a model
class in an app which _is_ in the project I am currently using. For
that I have to ask this:

Do I really need 'import myproject' in myproject/urls.py when I'd like
to write somewhere in the urls.py 'myproject.myapp.models.MyModel'???



On Aug 9, 8:50 pm, Daniel Roseman  wrote:
> On Aug 9, 7:34 pm, Léon Dignòn  wrote:
>
>
>
>
>
> > Hello,
>
> > some times I'd like not to import a class but just write it down.
>
> > Instead of
> > from myproject.myapp.models import MyModel
>
> > I'd like to use
> > myproject.myapp.models.MyModel
>
> > But I get a NameError: name 'myproject' is not defined
>
> > Also
> > myapp.models.MyModel
> > raises a NameError: name 'myapp' is not defined
>
> > Any ideas?
>
> What are you trying to do - what do you mean by 'write it down'?
>
> If you just want to use 'myproject.myapp.models.MyModel', instead of
> just 'MyModel', when referencing a model class, that's fine - but you
> still need to import myproject.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: import problem

2009-08-09 Thread Daniel Roseman

On Aug 9, 7:34 pm, Léon Dignòn  wrote:
> Hello,
>
> some times I'd like not to import a class but just write it down.
>
> Instead of
> from myproject.myapp.models import MyModel
>
> I'd like to use
> myproject.myapp.models.MyModel
>
> But I get a NameError: name 'myproject' is not defined
>
> Also
> myapp.models.MyModel
> raises a NameError: name 'myapp' is not defined
>
> Any ideas?

What are you trying to do - what do you mean by 'write it down'?

If you just want to use 'myproject.myapp.models.MyModel', instead of
just 'MyModel', when referencing a model class, that's fine - but you
still need to import myproject.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



import problem

2009-08-09 Thread Léon Dignòn

Hello,

some times I'd like not to import a class but just write it down.

Instead of
from myproject.myapp.models import MyModel

I'd like to use
myproject.myapp.models.MyModel

But I get a NameError: name 'myproject' is not defined

Also
myapp.models.MyModel
raises a NameError: name 'myapp' is not defined

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



Re: javascript variable in url resolver template tag

2009-08-09 Thread Daniel Roseman

On Aug 9, 4:59 pm, Sven Richter  wrote:
> I am looking for a rating function AJAX style.
> So what i am trying to do is the following:
>
> Click on a link  register a Jquery function to call on that click with:
> $('a#vote_pos').click(rate_it);
> and then in rate_it call the url rate with two paramaters int entry and
> string pos_neg
> like
> $.ajax( {type:"POST", url:/entry/rate/pos_neg, ...
> and i wanted to build the url with the url tag like:
> url:{% url rate entry pos_neg %}
>
> Sven
>

Rather than having a dynamic URL with parameters, you'll just have to
make the parameters part of the POST. So you can still use the url tag
at render time to output the URL, but instead of it being /entry/5/
rate/positive/ it should just be eg /entry/rate/, and the values for
rate and pos_neg are keys in the POST.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using create_object generic view excluding

2009-08-09 Thread Darek

On Aug 9, 7:54 pm, Lacrima  wrote:
> Hello!
>
> I want to use django.views.generic.create_update.create_object to
> create and save object.
> But I need one field to be excluded from the form displayed.
> I can do it by setting exclude = ('somefield',) in the Meta class of
> my ModelForm subclass.
> If so I can't submit this form without an error, because this excluded
> field is required in my Model.
>
> I need to supply value for the excluded field programmatically to the
> create_object.
> How should I do this?
>
> My form:
> --
> from myapp.models import Question
> class QuestionForm(forms.ModelForm):
>     class Meta:
>         model = Question
>         exclude = ('quiz',)
> --
>
> My view:
> --
> from django.views.generic.create_update import create_object
> from myapp.forms import QuestionForm
> def add_question(request):
>     return create_object(request, form_class=QuestionForm)
> --
>
> My model doesn't allow 'quiz' field to be empty and I need to supply
> this value omitting the form.
> How should I do this?
>
> Any help will be really appreciated.
>
> If my question isn't clear I'll try to explain it more precisely, but
> my English is quite poor.
>
> With regards,
> Max.

Add to "quiz" field in Question model keyword blank=True (for varchar
type or "blank=True, null=True" for foreign key or datetime)

--~--~-~--~~~---~--~~
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: Using create_object generic view excluding

2009-08-09 Thread Darek

Add to "quiz" field in Question model keyword blank=True (for varchar
type or "blank=True, null=True" for foreign key or datetime)

On Aug 9, 7:54 pm, Lacrima  wrote:
> Hello!
>
> I want to use django.views.generic.create_update.create_object to
> create and save object.
> But I need one field to be excluded from the form displayed.
> I can do it by setting exclude = ('somefield',) in the Meta class of
> my ModelForm subclass.
> If so I can't submit this form without an error, because this excluded
> field is required in my Model.
>
> I need to supply value for the excluded field programmatically to the
> create_object.
> How should I do this?
>
> My form:
> --
> from myapp.models import Question
> class QuestionForm(forms.ModelForm):
>     class Meta:
>         model = Question
>         exclude = ('quiz',)
> --
>
> My view:
> --
> from django.views.generic.create_update import create_object
> from myapp.forms import QuestionForm
> def add_question(request):
>     return create_object(request, form_class=QuestionForm)
> --
>
> My model doesn't allow 'quiz' field to be empty and I need to supply
> this value omitting the form.
> How should I do this?
>
> Any help will be really appreciated.
>
> If my question isn't clear I'll try to explain it more precisely, but
> my English is quite poor.
>
> With regards,
> Max.
--~--~-~--~~~---~--~~
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: Using create_object generic view excluding

2009-08-09 Thread Lacrima

Sorry, I have missed some words in the topic name, but I can't change
it now. (

On Aug 9, 8:54 pm, Lacrima  wrote:
> Hello!
>
> I want to use django.views.generic.create_update.create_object to
> create and save object.
> But I need one field to be excluded from the form displayed.
> I can do it by setting exclude = ('somefield',) in the Meta class of
> my ModelForm subclass.
> If so I can't submit this form without an error, because this excluded
> field is required in my Model.
>
> I need to supply value for the excluded field programmatically to the
> create_object.
> How should I do this?
>
> My form:
> --
> from myapp.models import Question
> class QuestionForm(forms.ModelForm):
>     class Meta:
>         model = Question
>         exclude = ('quiz',)
> --
>
> My view:
> --
> from django.views.generic.create_update import create_object
> from myapp.forms import QuestionForm
> def add_question(request):
>     return create_object(request, form_class=QuestionForm)
> --
>
> My model doesn't allow 'quiz' field to be empty and I need to supply
> this value omitting the form.
> How should I do this?
>
> Any help will be really appreciated.
>
> If my question isn't clear I'll try to explain it more precisely, but
> my English is quite poor.
>
> With regards,
> Max.
--~--~-~--~~~---~--~~
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 create_object generic view excluding

2009-08-09 Thread Lacrima

Hello!

I want to use django.views.generic.create_update.create_object to
create and save object.
But I need one field to be excluded from the form displayed.
I can do it by setting exclude = ('somefield',) in the Meta class of
my ModelForm subclass.
If so I can't submit this form without an error, because this excluded
field is required in my Model.

I need to supply value for the excluded field programmatically to the
create_object.
How should I do this?

My form:
--
from myapp.models import Question
class QuestionForm(forms.ModelForm):
class Meta:
model = Question
exclude = ('quiz',)
--

My view:
--
from django.views.generic.create_update import create_object
from myapp.forms import QuestionForm
def add_question(request):
return create_object(request, form_class=QuestionForm)
--

My model doesn't allow 'quiz' field to be empty and I need to supply
this value omitting the form.
How should I do this?

Any help will be really appreciated.

If my question isn't clear I'll try to explain it more precisely, but
my English is quite poor.

With regards,
Max.
--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-09 Thread justin jools
o thanks for that :)
as soon as my administrator finally sorts out Python script executing for me
- omg! ,I'll try that

On Sat, Aug 8, 2009 at 6:43 PM, Larrik Jaerico  wrote:

>
> I'll bet a lot of the mailing list will faint when they see this, but
> I've gotten it to work pretty easily by just dropping the django
> directory directly into my project directory.
>
> On Aug 8, 8:24 am, justin jools  wrote:
> > ok well thanks for your reply:
> >
> > first I have free access and they have told me python is installed but
> it's
> > not working as I ran a hello world test script which doesbt execute. That
> is
> > the first of my problems.
> >
> > My second problem is installing Django...
> >
> > and third configuring the django scripts to run as outlined in the django
> > book, but I am stuck and the first and second hurdles...
> >
> > I have been looking for a web host server that does support but seems
> there
> > isnt any.. python support is a paid for service.
> >
> > 
> >
> > If you can offer any advice here its would be great. I guess the first
> thing
> > i need to do is bug the administrator to get a Python test script
> running.
> >
> > On Fri, Aug 7, 2009 at 10:45 PM, Daniel Roseman  >wrote:
>  >
> >
> >
> > > On Aug 7, 9:56 pm, justin jools  wrote:
> > > > thanks for the reply but I have access to a server for free so I
> wanted
> > > to
> > > > set it up myself, how can it be so difficult? Django is renowned as
> an
> > > easy
> > > > rapid development framework so why is it so difficult to deploy?
> >
> > > You haven't said why you think it's difficult. The documentation is
> > > clear, and most people here have found it fairly easy to deploy. What
> > > has been your problem? Why has the Django book not told you want you
> > > want?
> > > --
> > > DR.
> >
>

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



Re: django-registration and RegistrationFormUniqueEmail subclass

2009-08-09 Thread Léon Dignòn

Thank you

On Jul 22, 7:42 pm, Dan Harris  wrote:
> The stuff in the brackets are the optional arguments passed to the
> "register" view.
>
> You can read the documentation about the view at:
>
> http://bitbucket.org/ubernostrum/django-registration/src/b360801eae96...
>
> Alternatively you can check out the code as well.
>
> Cheers,
>
> Dan
--~--~-~--~~~---~--~~
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 change the option text in a form's select-tag?

2009-08-09 Thread Léon Dignòn

I solved it with __unicode__ in the model class.

On Aug 7, 1:38 pm, Léon Dignòn  wrote:
> Hello,
>
> I installed django-profiles and added an extended UserProfile. One
> template displays all fields which are necessary to edit a users
> profile. Every user can choose a favorite aeroplane. Every aeroplane
> is built by one manufacturer.
>
> I print the edit form in the template with {{ form }}. The form
> dispays a select tag to chose a favorite aeroplane. Everything works
> fine.
>
> I want to make a little change on how the selectfielddisplays the
> options. I would like toaddthe manufacturer to the option string. Is
> there an easy way to insert the manufacturer to the option? I want to
> avoid as much code as possible since the django-profiles app provides
> views and forms. I hope not to write any own. Maybe I can change the
> model so that it alwas displays Manufacturer+Aeroplane when called?
>
> I just tried to insert the following code in the Aeroplane class:
> def __unicode__(self):
>         return self.name + manufacturer.name
>
> 
> Here some detailed explanation and code:
>
> My selectfieldlooks like this:
> 
>   Plane1
>   Plane2
>   Plane3
> 
>
> My selectfield*should* looks like this:
> 
>   Manufacturer1 Plane1
>   Manufacturer2 Plane2
>   Manufacturer3 Plane3
> 
>
> Here is the models.py
>
> class Aeroplane(models.Model):
>     name = models.CharField(max_length=32, unique=True)
>     year_of_construction = models.PositiveSmallIntegerField()
>     manufacturer = models.ForeignKey(Manufacturer)
>
>     def __unicode__(self):
>         return self.name
>
> class UserProfile(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     favorite_aeroplane = models.ForeignKey(Aeroplane, blank=True)
>
>     def get_absolute_url(self):
>         return ('profiles_profile_detail', (), { 'username':
> self.user.username })
>     get_absolute_url = models.permalink(get_absolute_url)
>
> Here is the template:
>
> {% extends "base.html" %}
> {% block content %}
>     
>       {{ form.as_p }}
>       
>     
> {% endblock content %}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Generic view 'archive_year' not working

2009-08-09 Thread Matthew

I am using Django's generic views to create a blog site.  The
templates I created, entry_archive_day, entry_archive_month,
entry_archive, and entry_detail all work perfectly, but
entry_archive_year does not.

Instead, it is simply a blank page.  It looks like it sees no objects
in 'object_list'.

Details are included below:


urls.py


entry_info_dict = {
   'queryset': Entry.objects.all(),
   'date_field': 'pub_date',
   }

...

(r'^weblog/$',
 'django.views.generic.date_based.archive_index', # works with
'latest', not 'object_list'
 entry_info_dict),
# Weblog by year
(r'^weblog/(?P\d{4})/$',
 'django.views.generic.date_based.archive_year', # doesn't work
 entry_info_dict),
# Weblog by month
(r'^weblog/(?P\d{4})/(?P\w{3})/$',
 'django.views.generic.date_based.archive_month',
 entry_info_dict),
# Weblog by day
(r'^weblog/(?P\d{4})/(?P\w{3})/(?P\d{2})/$',
 'django.views.generic.date_based.archive_day',
...


entry_archive_year:





Entry Archive {{ year }}


{% for object in object_list %}
{{ object.title }}

Published on {{ object.pub_date|date:"F j, Y" }}

{% if object.excerpt_html %}
   {{ object.excerpt_html|safe }}
{% else %}
   {{ object.body_html|truncatewords_html:"50"|safe }}
{% endif %}

Read full
entry

{% endfor %}



==
Output for http://localhost:8000/weblog/2009/aug/ (notice 3 entries
for August):
==

Latest!

Published on August 9, 2009

Specific areas for enhancement:

* Adding related objects should be easier. Now you have to "save and
continue" to get an extra set of fields to add a new related object.
You should be able to click "add new object" to add another set of
blank fields inline on the page ...

Read full Entry
Practical Django Projects

Published on August 9, 2009

It also will keep track of open tags and close them if it cuts off the
text before a closing tag. (A sep- arate filter, truncatewords, simply
cuts off at the specified number of words and pays no attention to
HTML.)

Read full Entry
Star Wars

Published on August 6, 2009

Star Wars used to be a great movie series.

Read full Entry

===
Output for http://localhost:8000/weblog/2009/ is a blank page (no
errors).  There should be at least 3 entries, demonstrated by
August.
===

Thanks,
Matthew
--~--~-~--~~~---~--~~
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: Bug with model get_*_display() methods?

2009-08-09 Thread Margie

Thanks for the pointers, that all make sense now.

Margie

On Aug 8, 6:47 pm, Malcolm Tredinnick 
wrote:
> On Sat, 2009-08-08 at 12:09 -0700, Margie wrote:
>
> [...]
>
> > Question: If want to use a special widget for a ChoiceField, is it
> > true that I need to instantiate the ChoiceField (or TypedChoiceField),
> > rather than just setting the .widget attribute on the one that is by
> > default created for me (due to it being a modelForm)?
>
> > I find that if I just do this:
>
> >             self.fields["status"].widget = StatusWidget(task=instance)
>
> Grep'ing for "choices" in django/forms/*.py would reveal the answer to
> this. Have a look at how the Select widget handles choices, since that
> is what you're subclassing.
>
> The "choices" attribute of all the classes in widgets.py is set in the
> __init__() method of each widget. In fields.py, have a look at
> ChoiceField and you'll see that when you set choices on a field, they
> are also set on the associated widget (there's a _set_choices() method
> that is part of the "choices" property on ChoiceField).
>
> What you're doing in your above code is not setting any choices at all.
> You need to tell the widget which choices it can use.
>
> [...]
>
> > However, I see when debugging that IntegerField.to_python is an
> > unbound method:
>
> > (Pdb) self.coerce
> > 
>
> > What is the right thing to set coerce to if I just want it to do
> > whatever it would "normally" do for the corresponding model field if I
> > wasn't trying to override the widget?  In my case I have verified that
> > if I set coerce=int that does work, but that doesn't seem very
> > general.  I'd much rather use whatever the standard coerce method
> > would have been if I hadn't overridden the widget.
>
> I'm not completely convinced this is a great plan, since if you are only
> overriding the widget in __init__, then the coerce function will already
> have been set up when the TypedChoiceField was created (it's a feature
> of the forms.Field subclass, not the widget). If you are overriding the
> form field entirely then you know better than Django what the correct
> type to use is, so it's actually easier and arguably clearer to just put
> in the right thing.
>
> However, you also have access to the model, so just use the
> model._meta.fields[...] entry for the field and use the to_python()
> method on that instance. Look at things like
> django.db.models.options.Options.get_field_by_name().
>
> 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
-~--~~~~--~~--~--~---



Re: Bug with model get_*_display() methods?

2009-08-09 Thread Margie

Right - of course.  Don't ask me why didn't realize to use IntegerField
().to_python myself ...

Margie

On Aug 8, 12:32 pm, Alex Gaynor  wrote:
> On Sat, Aug 8, 2009 at 2:09 PM, Margie wrote:
>
> > Ok, still slightly confused.  First - a high level description.  I
> > have a field that contains choices, but when I display the select, I
> > want to display some extra html below the select box, so I am creating
> > a custom widget that displays the standard select followed by my html.
>
> > Question: If want to use a special widget for a ChoiceField, is it
> > true that I need to instantiate the ChoiceField (or TypedChoiceField),
> > rather than just setting the .widget attribute on the one that is by
> > default created for me (due to it being a modelForm)?
>
> > I find that if I just do this:
>
> >            self.fields["status"].widget = StatusWidget(task=instance)
>
> > then my widget's select does not contain any choices.  My widget
> > doesn't do anything special to the select, it looks like this:
>
> > class StatusWidget(widgets.Select):
> >    def __init__(self, task, attrs={}):
> >        self.task = task
> >        super(StatusWidget, self).__init__(attrs)
>
> >    def render(self, name, value, attrs=None):
> >        rendered = super(StatusWidget, self).render(name, value,
> > attrs)
> >        rendered = rendered +  add a bunch of stuff to the end
> >        return rendered
>
> > Because I seem unable to display the choices correctly in the select
> > box when I just set the field's widget attribute to my StatusWidget, I
> > am instantiating the field itself.  That now looks like this:
>
> >            self.fields["status"] = forms.TypedChoiceField
> > (choices=Task.STATUS_CHOICES, widget=StatusWidget(task=instance),
> > required=False, coerce=IntegerField.to_python)
>
> > However, I see when debugging that IntegerField.to_python is an
> > unbound method:
>
> > (Pdb) self.coerce
> > 
>
> > What is the right thing to set coerce to if I just want it to do
> > whatever it would "normally" do for the corresponding model field if I
> > wasn't trying to override the widget?  In my case I have verified that
> > if I set coerce=int that does work, but that doesn't seem very
> > general.  I'd much rather use whatever the standard coerce method
> > would have been if I hadn't overridden the widget.
>
> > Margie
>
> > On Aug 8, 12:11 am, Malcolm Tredinnick 
> > wrote:
> >> Hi Margie,
>
> >> On Fri, 2009-08-07 at 23:17 -0700, Margie wrote:
>
> >> > Hmmm, ok, after digging around I realize that full_clean was not
> >> > setting cleaned_data for the status field to an integer value;
> >> > cleaned_data['status'] was just getting set to something like u'1'.
>
> >> > I am in fact using sqllite, and yes, my status fields are just
> >> > integers:
>
> >> > OPEN_STATUS = 1
> >> > CLOSED_STATUS = 2
> >> > STALLED_STATUS = 3
>
> >> > I think the problem has to do with the way I created the status field,
> >> > which is like this:
>
> >> >             self.fields["status"] = forms.ChoiceField
> >> > (choices=Task.STATUS_CHOICES, widget=StatusWidget(task=instance),
> >> > required=False)
>
> >> Right, that won't do what you want. ChoiceField normalizes to a unicode
> >> object.
>
> >> > I tried moving to TypedChoiceField(), but that didn't help.  I
> >> > debugged into it in the case where I used TypedChoiceField() and I can
> >> > see that when coerce is called it isn't doing anything, it is just
> >> > returning the unicode value.
>
> >> > I find that if I do this instead, that it does do the coerce
> >> > correctly:
>
> >> >             self.fields["status"].widget = StatusWidget(task=instance)
>
> >> > In looking at the doc it looks like the purpose of TypedChoiceField()
> >> > is to allow me to create my own coerce function, is that right?
>
> >> Correct.
>
> >> >   And
> >> > of course I wasn't doing that so it was behaving the same as
> >> > ChoiceField, and it looks like the default there is to just return the
> >> > unicode.
>
> >> Also correct. The documentation says "Defaults to an identity function"
> >> and all the data coming from a form submission are strings (Python
> >> unicode objects), so if you don't supply the coerce parameter, it does
> >> nothing.
>
> >> It's probably a slight API wart that TypedChoiceField doesn't just raise
> >> an exception if you don't supply coerce(). The default is slightly
> >> dangerous, as it almost always means you're misusing the field. Not a
> >> fatal flaw in the design, however.
>
> >> > When I don't declare the status field at all (ie, just let django do
> >> > it's default thing), my guess is that it is choosing a coerce function
> >> > based on the integer type of my choices, is that true?
>
> >> Yes. The django.db.models.fields.Field.formfield() method detects if you
> >> have specified "choices" in the field and uses the Field subclass's
> >> to_python() function as the coerce 

Re: javascript variable in url resolver template tag

2009-08-09 Thread Sven Richter
Ok, i think i understand the problem now.
So i have to hardcode the url in my javascript function?
That was what i wanted to circumvent.

Sven

On Sun, Aug 9, 2009 at 5:57 PM, Daniel Roseman wrote:

>
> On Aug 9, 4:43 pm, Sven Richter  wrote:
> > Hi all,
> >
> > i wanted to know if it is possible to pass a Javascript variable to
> > the url template tag?
> >
> > Like:
> > 
> > ...
> > 

Re: javascript variable in url resolver template tag

2009-08-09 Thread Sven Richter
I am looking for a rating function AJAX style.
So what i am trying to do is the following:

Click on a link  wrote:

>
> On Sun, Aug 9, 2009 at 5:43 PM, Sven Richter
> wrote:
> > Hi all,
> >
> > i wanted to know if it is possible to pass a Javascript variable to
> > the url template tag?
> >
> > Like:
> > 
> > ...
> > 

Re: javascript variable in url resolver template tag

2009-08-09 Thread Daniel Roseman

On Aug 9, 4:43 pm, Sven Richter  wrote:
> Hi all,
>
> i wanted to know if it is possible to pass a Javascript variable to
> the url template tag?
>
> Like:
> 
> ...
> 

Re: javascript variable in url resolver template tag

2009-08-09 Thread Matthias Kestenholz

On Sun, Aug 9, 2009 at 5:43 PM, Sven Richter wrote:
> Hi all,
>
> i wanted to know if it is possible to pass a Javascript variable to
> the url template tag?
>
> Like:
> 
> ...
> 

javascript variable in url resolver template tag

2009-08-09 Thread Sven Richter
Hi all,

i wanted to know if it is possible to pass a Javascript variable to
the url template tag?

Like:

...

Re: Model Methods and displaying in template?

2009-08-09 Thread rmschne

Daniel,

Now we're cooking. You were quite right.  A red herring that I had the
wrong syntax.  The function list2text was not correct. It had been
correct but for whatever reason I didn't notice that I messed up a tab
key (in Python) and it was not computing correctly (whereas at one
point it was). I fixed the missing tab and I put a few more bits of
defensive coding.  Thanks!

On Aug 9, 12:55 pm, Daniel Roseman  wrote:
> On Aug 9, 12:42 pm, rmschne  wrote:
>
>
>
>
>
> > I'm looking for the right syntax for inside a template to display a
> > model variable that is actually not a field in the database (defined
> > by the mode), but a Model method.
>
> > Class Member(model.Models):
> >     id = models.IntegerField(primary_key=True, db_column='ID')
> >     lname = models.CharField(max_length=150, db_column='LName',
> > blank=True)
> >     fname = models.CharField(max_length=150, db_column='FName',
> > blank=True)
> >      (plus other fields)
>
> >     def contactslistindirectory(self):
> >         """Returns a comma deliminted list of all member contacts
> > (with last contact prefixed by and)"""
> >         s1=self.contacts.all().filter(indirectory=True)
> >         s=list2text(s1)
> >         return s
>
> > The model method "contactslistindirectory() returns a string of the
> > name of the contacts for that member.  It's getting that information
> > from another model called Contact which has a ForeignKey connection
> > back to Member.
>
> > I have a template working that can display {{ member.lname }},
> > {{member.fname }} and others.  The template loops through all
> > members.
>
> > I want to display in the template for each member the value of what is
> > in contactslistindirectory.  I've tried
> > {{ member.contactslistindirectory }} and that doesn't work.  I don't
> > know the syntax for displaying the value of a Model Method in a
> > template.  I'm sure the answer is right in front of me, but despite
> > searching the documentation for examples, I can't spot it.  I can see
> > how the model methods are defined, but as yet have not seen how to use
> > that in a  template.
>
> > Any pointers?
>
> {{ member.contactslistindirectory }} is the correct syntax. There must
> be something wrong with the method - perhaps the filter is not
> returning any results, or perhaps list2text is incorrect.
>
> You might try debugging by putting a 'print s' before the return
> statement in your method, and seeing what that prints in the console.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Javascript with built-in templates tags

2009-08-09 Thread esatterwh...@wi.rr.com



On Aug 7, 9:31 pm, WilsonOfCanada  wrote:
> Hellos,
>
> I was wondering how to use {{ }} variables in javascript functions.
>
> ex. onchange = "changeArea({{ mooman |safe|escapejs}});"
>
> Thanks

I had this problem too, it was pretty frustrating. I can to 2
different solutions.


1. new template in youapps directory calls whatever_js.html so you
know that is actually javascript.
* just write the 
 ...Code {{ Here }}
  
* and use the {% include  whatever_js.html %} tag where needed.

2. Probably not always the best option, but is useful for testing. put
the
 
  ... Code {{ Here }}
 
   in the template it self. This way django renders out all of the
code before the JavaScript is interpreted and runs as expected.

I'm pretty sure the Admin area does something pretty similar to the
whatever_js.html templates idea. If all else fails you could copy and
paste all of the js into your template the obtrusive way and see if it
works properly, then work backward by pulling bits out.

Maybe that helps?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



implementing a javascript graph application to the existing admin panel listing view

2009-08-09 Thread Hellnar

Greetings
I want to implement a javascript graph plot application (ie
http://people.iola.dk/olau/flot/examples/turning-series.html) to the
existing admin view, where the instances of a model at the listing
view also showing charts of these items and can be filtered through by
using the already  implemented list_filter option which I added at the
admin.py of my application.

I would be greatful for any direction, example or already existing
tutorial

Cheers.
--~--~-~--~~~---~--~~
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: Code generation

2009-08-09 Thread sjtirtha
Hi Joshua,

thank you for your response.
It means the statement:

"With that, you've got a free, and rich, *Python
API*to
access your data. The API is created on the fly, no code generation"

in http://docs.djangoproject.com/en/dev/intro/overview/, does not mean that
django generate the code on the fly, but it has a generic API
implementation.

However, I'm more interessted, how manage.py generate the SQL, setting.py,
etc.
Does django ever able to generate code skeleton like Rails does?

Regards,

Steve
On Sun, Aug 9, 2009 at 3:09 PM, Joshua Partogi wrote:

> Python Metaclass is the keyword.
>
>
> On Sun, Aug 9, 2009 at 10:59 PM, sjtirtha  wrote:
>
>> And it is also mentioned in
>> http://docs.djangoproject.com/en/dev/intro/overview/
>> That Django generates the Model API on the fly. How can we generate code
>> on the fly in python?
>>
>> steve
>>
>>
>> On Sun, Aug 9, 2009 at 2:56 PM, sjtirtha  wrote:
>>
>>> Hi,
>>>
>>> does anybody now, how django generates the code?
>>> Is it documented some where? I read somewhere that Django uses Cheetah to
>>> generate code. But in other website, Guido compares Django template and
>>> cheetah.
>>>
>>> Regards,
>>> Steve
>>>
>>
>
> --
> http://blog.scrum8.com
> http://twitter.com/scrum8
>
> >
>

--~--~-~--~~~---~--~~
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: Code generation

2009-08-09 Thread Joshua Partogi
Python Metaclass is the keyword.

On Sun, Aug 9, 2009 at 10:59 PM, sjtirtha  wrote:

> And it is also mentioned in
> http://docs.djangoproject.com/en/dev/intro/overview/
> That Django generates the Model API on the fly. How can we generate code on
> the fly in python?
>
> steve
>
>
> On Sun, Aug 9, 2009 at 2:56 PM, sjtirtha  wrote:
>
>> Hi,
>>
>> does anybody now, how django generates the code?
>> Is it documented some where? I read somewhere that Django uses Cheetah to
>> generate code. But in other website, Guido compares Django template and
>> cheetah.
>>
>> Regards,
>> Steve
>>
>

-- 
http://blog.scrum8.com
http://twitter.com/scrum8

--~--~-~--~~~---~--~~
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: Code generation

2009-08-09 Thread sjtirtha
And it is also mentioned in
http://docs.djangoproject.com/en/dev/intro/overview/
That Django generates the Model API on the fly. How can we generate code on
the fly in python?

steve

On Sun, Aug 9, 2009 at 2:56 PM, sjtirtha  wrote:

> Hi,
>
> does anybody now, how django generates the code?
> Is it documented some where? I read somewhere that Django uses Cheetah to
> generate code. But in other website, Guido compares Django template and
> cheetah.
>
> Regards,
> Steve
>

--~--~-~--~~~---~--~~
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: My first Django project

2009-08-09 Thread Ronghui Yu
Hi, Kannan,

I am very happy that you like this project. I knew nothing about Django 
before starting this project. I learnt a lot during this process. But 
for some reasons, there are still a few problems, I am doing my best to 
fix them. I would like to publish the code if there are many guys has 
interest in this project. But now, not the time. Thank you for your 
understanding.


Kannan ??:
> >The first project I do by using Django, http://www.cvcenter.cn 
> , please take a >look, and enjoy.
> >Any feedback will be appreciated.
>
> Hi friend...
>   I saw ur site.It is good. Congratulations for ur job.
> Just i am started learning the Django.If u don't mind will u send the 
> project's souce code for my reference.
>
>
>
> With regards,
>
> Kannan. R. P,
>
>
>
>
> >

-- 
Ronghui Yu 

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



Code generation

2009-08-09 Thread sjtirtha
Hi,

does anybody now, how django generates the code?
Is it documented some where? I read somewhere that Django uses Cheetah to
generate code. But in other website, Guido compares Django template and
cheetah.

Regards,
Steve

--~--~-~--~~~---~--~~
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: My first Django project

2009-08-09 Thread Ronghui Yu
Thanks for your advice
I'll think about it. :-)

Mirat Bayrak ??:
> Hi, i liked you project look slike simple cv center. May be you can 
> think about usability. For example creating items has too much steps. 
> May be you can put all that forms into one page. Or may be forms can 
> by dynamicaly shown above */create another foo item/*  with jquery. In 
> other sides i liked it..
>
> >

-- 
Ronghui Yu 

--~--~-~--~~~---~--~~
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 Methods and displaying in template?

2009-08-09 Thread Daniel Roseman

On Aug 9, 12:42 pm, rmschne  wrote:
> I'm looking for the right syntax for inside a template to display a
> model variable that is actually not a field in the database (defined
> by the mode), but a Model method.
>
> Class Member(model.Models):
>     id = models.IntegerField(primary_key=True, db_column='ID')
>     lname = models.CharField(max_length=150, db_column='LName',
> blank=True)
>     fname = models.CharField(max_length=150, db_column='FName',
> blank=True)
>      (plus other fields)
>
>     def contactslistindirectory(self):
>         """Returns a comma deliminted list of all member contacts
> (with last contact prefixed by and)"""
>         s1=self.contacts.all().filter(indirectory=True)
>         s=list2text(s1)
>         return s
>
> The model method "contactslistindirectory() returns a string of the
> name of the contacts for that member.  It's getting that information
> from another model called Contact which has a ForeignKey connection
> back to Member.
>
> I have a template working that can display {{ member.lname }},
> {{member.fname }} and others.  The template loops through all
> members.
>
> I want to display in the template for each member the value of what is
> in contactslistindirectory.  I've tried
> {{ member.contactslistindirectory }} and that doesn't work.  I don't
> know the syntax for displaying the value of a Model Method in a
> template.  I'm sure the answer is right in front of me, but despite
> searching the documentation for examples, I can't spot it.  I can see
> how the model methods are defined, but as yet have not seen how to use
> that in a  template.
>
> Any pointers?

{{ member.contactslistindirectory }} is the correct syntax. There must
be something wrong with the method - perhaps the filter is not
returning any results, or perhaps list2text is incorrect.

You might try debugging by putting a 'print s' before the return
statement in your method, and seeing what that prints in the console.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model Methods and displaying in template?

2009-08-09 Thread rmschne

I'm looking for the right syntax for inside a template to display a
model variable that is actually not a field in the database (defined
by the mode), but a Model method.

Class Member(model.Models):
id = models.IntegerField(primary_key=True, db_column='ID')
lname = models.CharField(max_length=150, db_column='LName',
blank=True)
fname = models.CharField(max_length=150, db_column='FName',
blank=True)
 (plus other fields)

def contactslistindirectory(self):
"""Returns a comma deliminted list of all member contacts
(with last contact prefixed by and)"""
s1=self.contacts.all().filter(indirectory=True)
s=list2text(s1)
return s

The model method "contactslistindirectory() returns a string of the
name of the contacts for that member.  It's getting that information
from another model called Contact which has a ForeignKey connection
back to Member.

I have a template working that can display {{ member.lname }},
{{member.fname }} and others.  The template loops through all
members.

I want to display in the template for each member the value of what is
in contactslistindirectory.  I've tried
{{ member.contactslistindirectory }} and that doesn't work.  I don't
know the syntax for displaying the value of a Model Method in a
template.  I'm sure the answer is right in front of me, but despite
searching the documentation for examples, I can't spot it.  I can see
how the model methods are defined, but as yet have not seen how to use
that in a  template.

Any pointers?


--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-09 Thread Denis Cheremisov

I thinkg it's firefox issue - with google chromium, midori or opera
it's felt much faster.

On Aug 7, 3:46 pm, Jo  wrote:
> Surely can't only be me that finds the main Django site painfully
> slow? There is some javascript in there or something that just kills
> my browser.
>
> I'm using Firefox on Linux, on 1.5gig P4, OK not state of the art but
> it's fine for pretty much any other website, but when I try to look
> something up on the Django website, firefox jumps to 80% CPU and takes
> 10s of seconds to render each page, and even when the page is rendered
> the browser is so sluggish as to be almost unusable.
>
> Django might speed up development, but what it gives it takes away in
> time sitting waiting for the damn docs to load!
--~--~-~--~~~---~--~~
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: weirdist situation I have faced in 4 years of (ab)using django

2009-08-09 Thread prabhu S

Hi KG,

Nice to meet you! How are you confirming if the data is from Meeting?
Are you looking at the final rendered html? What does a print after
the statement

p = Event.objects.get(pk=id)

tell you? Also check if you have just one view for the particular url
mapping.

Regards,
Prabhu

On Aug 9, 8:33 am, Kenneth Gonsalves  wrote:
> hi
> latest svn, apache and mod_python on fedora 11 (same problem with runserver)
>
> I have three models: Event, Report and Meeting.
> Outside admin I have addevent which adds and event, event, which gives a list
> of events and eventfull which details one event.. And the same for Report and
> Meeting.
>
> addevent works fine and so does listing of events - and so does Meeting and
> Report. I have done this so many times in the last 4 years that I can do it in
> my sleep. But this time eventfull does not work. It does not throw errors. The
> template is displayed, but the data is from Meeting. The same thing happens
> with reportfull. What django is doing is calling eventfull, getting data from
> meetingfull and displaying that in eventfull.html. I have another app with the
> same three models which works perfectly on the same machine with the same
> configuration. Obviously I am doing something stupid. But what? Here is my
> urls.py (relevant extracts):
>
> urlpatterns = patterns('ilugc.web.views',
>     url(r'^$', 'report', name='report'),
>     #meeting
>     url(r'^meeting/$', 'meeting', name='meeting'),
>     url(r'^meetingfull/(?P\d+)/$', 'meetingfull', name='meeting_by_id'),
>     #report
>     url(r'^report/$', 'report', name='report'),
>     url(r'^report/(?P\d+)/$', 'report', name='report_by_tag'),
>     url(r'^addreport/$', 'addreport', name='addreport'),
>     url(r'^addreport/(?P\d+)/$', 'addreport', name='add_report'),
>     url(r'^reportfull/(?P\d+)/$', 'reportfull', name='report_by_id'),
>     #event
>     url(r'^event/$', 'event', name='event'),
>     url(r'^addevent/$', 'addevent', name='addevent'),
>     url(r'^addevent/(?P\d+)/$', 'addevent', name='add_event'),
>     url(r'^eventfull/(?P\d+)/$', 'eventfull', name='event_by_id'),
>
> and the relevant extract from views.py:
>
> def event(request):
>     """
>     list of events by topic
>     """
>
>     lst=Event.objects.all()
>     t = loader.get_template('web/event.html')
>     c = RequestContext(request,
>                 {'lst':lst,
>                  })
>     return HttpResponse(t.render(c))
>
> def eventfull(request,id):
>     """
>     Details of specific Events
>     """
>     canedit = False
>     p = Event.objects.get(pk=id)
>     if p.author_id == request.user.id:
>         canedit=True
>     t = loader.get_template('web/eventfull.html')
>     c = RequestContext(request,
>                 {'p':p,
>                 'canedit': canedit,
>                  })
>     return HttpResponse(t.render(c))
>
> --
> regards
> kghttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Recursive request and page layout

2009-08-09 Thread prabhu S

It will be awesome if you can make and open source such a tag.
Shouldn't be hard since templates can be evaluated independent of
http. If you want something simpler, use iframe and point it to the
correct url.

Regards,
Prabhu

On Aug 8, 12:11 pm, SardarNL  wrote:
> I've checked the custom tags and the middleware that automatically
> registers request object inside the template context, this is all I
> need to get the recursive call working. However I wonder why such
> functionality isn't there. Probably there is another way to put
> content from totally independent components/apps on the same page.
> Could someone point me in the right direction?
>
> The overhead of recursive requests is negligible and I will make
> custom render tag for it Monday if no other "django way" solution
> bubbles up here.
>
> On Aug 7, 8:11 pm, Daniel Roseman  wrote:
>
>
>
> > On Aug 7, 5:24 pm, SardarNL  wrote:
>
> > > Hi Folks
>
> > > Here is the problem, we have some pages that don't contain any
> > > content, but rather layout the blocks which are served by other views.
> > > Extending the template and overriding some blocks is not a solution,
> > > because there are many unrelated blocks, that can not be rendered by a
> > > single view.
>
> > > Naturally I would expect some {% dispatch "/some/path/here" %} tag,
> > > such that when template is being processed, the tag will issue
> > > recursive request and will be replaced by obtained content. The tag
> > > should be able to replace the base template of called view, so the
> > > header/footer and other markup will not be rendered if view is called
> > > as a block.
>
> > > Unfortunately there is no such tag. So my question is: how to give the
> > > control to independent blocks. The idea is:
>
> > >   - current request is being processed by some view, which knows how
> > > to fetch only its own content
> > >   - the designer may want to add other content/block, totally
> > > unrelated to current request, for example a poll/banner/menu etc.
> > >   - the block needs to be served by some view because there database
> > > fetch is needed along other processing. So simple include of a
> > > template is not a solution. Fetching all the content within the top-
> > > most view isn't a solution because the block can be used on many
> > > places.
>
> > > That is the reason why this should be implemented as recursive call,
> > > such that the block-view will not even know it is being called as a
> > > block and will simply render the content. Of course in real situation
> > > the view still needs to know it is being called as a block, such that
> > > more simplistic templates may be used.
>
> > > Please explain what is the django way and how would you solve this,
> > > maybe I'm digging in totally wrong direction.
>
> > Including blocks on a page is what custom template tags are for. See
> > here:http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
> > particularly the section on 'inclusion tags'.
>
> > That's not exactly what you asked for in terms of recursive views, but
> > is probably better as it has less overhead - calling a view
> > recursively would involve instantiating an HttpResponse object each
> > time, then extracting the content and throwing the object away.
> > --
> > DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: My first Django project

2009-08-09 Thread Kannan
>The first project I do by using Django, http://www.cvcenter.cn, please take
a >look, and enjoy.
>Any feedback will be appreciated.

Hi friend...
  I saw ur site.It is good. Congratulations for ur job.
Just i am started learning the Django.If u don't mind will u send the
project's souce code for my reference.



With regards,

Kannan. R. P,

--~--~-~--~~~---~--~~
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 get rid of the 'u'? Seems to be everyhere :)

2009-08-09 Thread Dave

Hey all, thanks for your replies.

I have been only using python for a little over a month and django
only for a little over a week.

Thanks again for your help.

On Aug 9, 4:32 am, David Zhou  wrote:
> See:
>
> http://diveintopython.org/xml_processing/unicode.html
>
> -- dz
>
> On Sat, Aug 8, 2009 at 11:27 PM, Joshua Partogi 
> wrote:
> > u' stands for Python unicode.
>
> > On Sun, Aug 9, 2009 at 12:03 PM, strotos  wrote:
>
> >> Hey all,
>
> >> I am very new to Django and am having a bit of trouble with something
> >> and I'm hoping I can get some help from you all.
>
> >> I was just wondering how do I share say a list or dictionary between
> >> views?
>
> >> What I have at the moment is.
>
> >> from django.shortcuts import render_to_response
> >> from django.http import HttpResponse
>
> >> myList = ["http://localhost:1;, "http://localhost:2;]
>
> >> def index(request):
> >>        head = "Viewer"
>
> >>        thelist = ""
>
> >>        for i in myList:
> >>                thelist = ('%s  Test ') % (thelist,
> >> i)
>
> >>        body ="%s" % thelist
> >>        tail = ""
> >>        print thelist
> >>        html = head,body,tail
>
> >>        return HttpResponse(html)
>
> >> def update(request):
>
> >>        query = request.GET.get('t', '')
> >>        print query
> >>        myList.append(query)
> >>        html ="UploadUpload OK %s >> body
> >>        return HttpResponse(html)
>
> >> In my update the "query" variable is added to the list myList, but a u
> >> is appended which seams to be the url of the app, is there a way to
> >> remove this u, or is there a better way to share data like a dict or
> >> list between views?
>
> > --
> >http://blog.scrum8.com
> >http://twitter.com/scrum8
--~--~-~--~~~---~--~~
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: Javascript with built-in templates tags

2009-08-09 Thread Daniel Roseman

On Aug 9, 6:19 am, WilsonOfCanada  wrote:
> I tried that before, but it only seems to work when it is used on
> the .html file.
>
> onchange="changeArea('{{ list_areas.BC|safe|escapejs}}')
>
> I need it to be onchange="changeArea('{{ list_areas|safe|escapejs}}')
> so the function can use list_areas (My javascript and html are on
> separate files).
>
> On .js file,
>
> If I use:
> function changeArea(selectedAreas)
> {
>         alert({{list_areas.BC}});
>
> }
>
> with or without the |escapejs would cause the entire javascript not to
> work.
>
> If I use:
> function changeArea(selectedAreas)
> {
>         alert(selectedAreas.BC);
>
> }
>
> or
>
> function changeArea(selectedAreas)
> {
>         alert(selectedAreas["BC"]);}
>
> would be undefined.
>
> However, if it is:
>
> function changeArea(selectedAreas)
> {
>         alert(selectedAreas[0]);
>
> }
>
> I will get "{"
>
> Thanks again.  (If I missed the answer in the docs, sorry :) )


You are simply not thinking about this logically.

The 'html file' is a Django template. It is processed by Django's
templating engine, so template variables and tags are replaced
correctly, even within inline javascript.

The 'js file' is not a Django template. It is a static file -
presumably you are serving it via Apache or the development server's
static.serve view. Because it's not being processed by Django's
templating engine, template variables and tags are not replaced but
included as-is.

If you want to include Django variables in javascript, the way to do
it is as you did at first - have a small 

weirdist situation I have faced in 4 years of (ab)using django

2009-08-09 Thread Kenneth Gonsalves

hi
latest svn, apache and mod_python on fedora 11 (same problem with runserver)

I have three models: Event, Report and Meeting.
Outside admin I have addevent which adds and event, event, which gives a list 
of events and eventfull which details one event.. And the same for Report and 
Meeting.

addevent works fine and so does listing of events - and so does Meeting and 
Report. I have done this so many times in the last 4 years that I can do it in 
my sleep. But this time eventfull does not work. It does not throw errors. The 
template is displayed, but the data is from Meeting. The same thing happens 
with reportfull. What django is doing is calling eventfull, getting data from 
meetingfull and displaying that in eventfull.html. I have another app with the 
same three models which works perfectly on the same machine with the same 
configuration. Obviously I am doing something stupid. But what? Here is my 
urls.py (relevant extracts):

urlpatterns = patterns('ilugc.web.views',
url(r'^$', 'report', name='report'),
#meeting
url(r'^meeting/$', 'meeting', name='meeting'),
url(r'^meetingfull/(?P\d+)/$', 'meetingfull', name='meeting_by_id'),
#report
url(r'^report/$', 'report', name='report'),
url(r'^report/(?P\d+)/$', 'report', name='report_by_tag'),
url(r'^addreport/$', 'addreport', name='addreport'),
url(r'^addreport/(?P\d+)/$', 'addreport', name='add_report'),
url(r'^reportfull/(?P\d+)/$', 'reportfull', name='report_by_id'),
#event
url(r'^event/$', 'event', name='event'),
url(r'^addevent/$', 'addevent', name='addevent'),
url(r'^addevent/(?P\d+)/$', 'addevent', name='add_event'),
url(r'^eventfull/(?P\d+)/$', 'eventfull', name='event_by_id'),

and the relevant extract from views.py:

def event(request):
"""
list of events by topic
"""

lst=Event.objects.all()
t = loader.get_template('web/event.html')
c = RequestContext(request,
{'lst':lst,
 })
return HttpResponse(t.render(c))

def eventfull(request,id):
"""
Details of specific Events
"""
canedit = False
p = Event.objects.get(pk=id)
if p.author_id == request.user.id:
canedit=True
t = loader.get_template('web/eventfull.html')
c = RequestContext(request,
{'p':p,
'canedit': canedit,
 })
return HttpResponse(t.render(c))

-- 
regards
kg
http://lawgon.livejournal.com

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



Re: Continuing problems running Django when not site Root.

2009-08-09 Thread Streamweaver

Okay I am finnally getting my brain around this.

Thanks so much. I tried the code out and it works great, even on the
login.

I appreciate everyone's help and patience.

On Aug 8, 9:49 pm, Malcolm Tredinnick 
wrote:
> On Sat, 2009-08-08 at 13:41 -0700, Streamweaver wrote:
> > Let me clarify. This method handles the RequestContext obviously since
> > it's a login but what I mean is the SCRIPT_NAME variable isn't set for
> > the template and can't be read as far as I can tell.
>
> Nothing is automatically set for a template. If you want access to a
> particular quantity in a template, pass it in. You could even create a
> context processor if you want it every time. Typically, SCRIPT_NAME is
> *not* required in templates, since things like the url template tag
> already handle it automatically and constructing the correct URL for
> many things is more complex than just crashing together a few strings,
> so it tends to be done via template tags or in views. Thus, SCRIPT_NAME
> isn't a likely candidate for something that would be passed in all the
> time.
>
> 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
-~--~~~~--~~--~--~---



Apache2 permission denied problem

2009-08-09 Thread Mac

Hi,

I'm new to Django, and am trying to write a csv file and attach it to
an email that is sent upon completion of a sales order. All works fine
in the developement server, but when I switch to Apache2 I get an
error message that either says' No such file or directory, ../orders1/
csv_files/ or Permissions denied etc. All works fine when I use the
developement server. Here's my Apache2 sites-available script:

ServerAdmin malc...@sporthill.com
ServerName localhost
ServerAlias localhost/media/
DocumentRoot /home/malcolm/data1/orders1/media
WSGIScriptAlias / /home/malcolm/data1/orders1/apache/django.wsgi

Order allow,deny
Allow from all


Order allow,deny
Allow from all



Apache2 is located in /etc/apache2/

My app is in /home/malcolm/data1/orders1/

Here's some of the relevant code in my views:
for n in new_m:
so_order=n.so_number
so_order=str(so_order)
custo=n.custno/csv_files/"+custo+so_order+".csv", "wb"))

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