Subclass AdminSite vs. custom admin views

2009-04-22 Thread MrJogo

Hi,

I'm creating a website for an organization that is going to need a
complicated web admin interface. The built in one is fine for the site
administrators, but there are different staff positions that need
access to different models, and sometimes individual fields in those
models should be hidden from certain staff members. On top of that,
for certain models, it makes more sense to present the information in
a non-standard way (such as, for the staff models, presenting each
year's staff as a group).  I just discovered the AdminSite stuff, and
was wondering whether it is worth it to try to create a custom one, or
if I should just create custom views. I'm leaning towards custom
views. 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
-~--~~~~--~~--~--~---



table display with AJAX

2009-02-06 Thread MrJogo

Hi,

One of my pages is going to have a table that I'd like to be sortable,
and I'm wondering the best way to do this. I looked into django-
tables, which seems good, but once the page is loaded, I'd also like
to be able to sort dynamically (using javascript). Before I go and
implement this myself, anyone have any suggestions on already made
solutions? 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: Authenticating static files against Django Auth with FastCGI

2008-11-04 Thread MrJogo

Awesome! This is INCREDIBLY helpful.

In terms of using it (I'm not too familiar with server stuff), I have
a few questions (which have to do with Apache, not lighttpd, so you
might not know). Basically, once I create that handler file and view,
how do I use them? Do I modify the .fcgi file (from
http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache)
to use the new wsgiserver? Do I create a .htaccess file in my media
directory with FastCgiAuthorizer set to the script (in which case, the
docs, 
http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiAuthorizer,
also say I need FastCgiAuthenticator)? If these questions are somewhat
nonsensical, it's because I don't completely understand what's going
on when a request is made. Thanks!

On Oct 23, 1:37 am, Chris Emerson <[EMAIL PROTECTED]> wrote:
> On Thu, Oct 23, 2008 at 12:05:45AM -0700,MrJogowrote:
>
> > I found a useful thread (http://groups.google.com/group/django-users/
> > browse_thread/thread/affb11a7692a29ef/
> > e1e2d569c1e9104d#016b2fe82fd80f36), so I think I can narrow my
> > question down a little: How do I use FastCgiAuthenticator to
> > authenticate against Django's auth module?
>
> I've done this (I'm using lighttpd).  I've put my code in some snippets:
>
> http://www.djangosnippets.org/snippets/1149/http://www.djangosnippets.org/snippets/1150/
>
> Hope this helps,
>
> Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authenticating static files against Django Auth with FastCGI

2008-10-23 Thread MrJogo

I found a useful thread (http://groups.google.com/group/django-users/
browse_thread/thread/affb11a7692a29ef/
e1e2d569c1e9104d#016b2fe82fd80f36), so I think I can narrow my
question down a little: How do I use FastCgiAuthenticator to
authenticate against Django's auth module?

On Oct 21, 12:40 am, MrJogo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using Django on my university webspace. I set it up by following
> (and slightly modifying) the instructions on this 
> page:http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#runnin...
>
> Now I would like to protect certain static files by authenticating
> against my Django user database; basically what's described 
> here:http://docs.djangoproject.com/en/dev/howto/apache-auth/.
> Unfortunately, I do not have access to the httpd.conf. I can
> put .htaccess files into the directories, but that's about it. How can
> I get the same functionality? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authenticating static files against Django Auth with FastCGI

2008-10-21 Thread MrJogo

Hi,

I am using Django on my university webspace. I set it up by following
(and slightly modifying) the instructions on this page:
http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache

Now I would like to protect certain static files by authenticating
against my Django user database; basically what's described here:
http://docs.djangoproject.com/en/dev/howto/apache-auth/.
Unfortunately, I do not have access to the httpd.conf. I can
put .htaccess files into the directories, but that's about it. How can
I get the same functionality? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



modelformset_factory or formset_factory for registration form that writes to two models?

2008-09-18 Thread MrJogo

Hi,

I want to make a registration form that writes to two models: User and
a custom Preferences. It seems that model formsets would be the best
way to do that, but all the documentation I can find seems to say that
modelformset_factory gets associated with a queryset. If I want to
create a new model, without an existing queryset, how do I do it with
modelformset_factory, or should I just use formset_factory with a form
that subclasses modelforms? Maybe some other way? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: specifying MEDIA_URL in CSS files

2008-09-18 Thread MrJogo

Erik: I can't use relative URLs because of how my hosting service (my
university) is set up. Each account is at something like
www.university.edu/~studentname/. I could hard code it if I were
leaving it on my space, but I'm making it for a group (which has space
at www.university.edu/group/groupname/), and when I move it over, I'd
like to have to go through and change as little as possible.

Tim: I'll look into those solutions.

Thanks to both of you.

On Sep 13, 4:12 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> > What's the best way to use MEDIA_URL in a CSS file. For example, right
> > now my CSS file has something like:
>
> > body {
> >   background: transparent url('/media/images/bg.gif') repeat;
> > }
>
> > I would like to use MEDIA_URL instead of /media/ (in a number of
> > places), but other than that the file is static. What's the best way
> > to do this? Should I templatize the whole thing? What type of a
> > performance change will I see (approximately)?
>
> This changes your CSS file from being static to being dynamic.
> As such, Django should serve the file.  However, as it's not
> something you'd expect to change often, Django's caching
> framework (making use of, say, memcached) may prove enormously
> helpful.  Alternatively, you might be able to hook into the
> post_syncdb signal, and use it to write/put the render the
> dynamic CSS file into a static CSS file on the static-media server.
>
> Just a few ideas,
>
> -tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



specifying MEDIA_URL in CSS files

2008-09-13 Thread MrJogo

What's the best way to use MEDIA_URL in a CSS file. For example, right
now my CSS file has something like:

body {
  background: transparent url('/media/images/bg.gif') repeat;
}

I would like to use MEDIA_URL instead of /media/ (in a number of
places), but other than that the file is static. What's the best way
to do this? Should I templatize the whole thing? What type of a
performance change will I see (approximately)?

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



Re: Custom manager for many-to-many traversal

2008-09-03 Thread MrJogo

H'ok, got this working. First off, I had a brain hiccup: my model was
one-to-many (the actual model is more complicated than my Book
example; I just used the Book to illustrate my point).

What I ended up doing was basically what you suggested to do using
Django's ORM: I ran two queries, one for Books and one for Authors.
Then I looped through and sewed them all together.

That was a fairly simple solution (which is the best kind), and I
thank you for pointing it out to me!

On Sep 1, 7:40 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On Sep 2, 2008, at 9:52 AM,MrJogowrote:
>
>
>
> > I read that post, and now have a general idea of what to do, but I'm
> > still confused on the specifics. It doesn't help that my SQL is VERY
> > rusty.
>
> I'm really not the one to be walking you through this, since my own  
> success was a bit of a fluke, but maybe I can nudge things in the  
> right direction.
>
>
>
> > Am I supposed to use cursor.execute() to do the INITIAL lookup? That
> > is, instead of calling a filter, or whatnot, on each book entry, I do
> > a cursor.execute that gets the books I want AND the related living
> > authors in one fell swoop? Do I set that up as a custom Manager?
>
> The way I did it was one query for the base queryset, and then one  
> cursor.execute() that pulled out the extra info I wanted to attach to  
> each queryset object. You certainly could do one cursor.execute() to  
> retrieve the entire query, but then you'd have to work with raw data,  
> not nice python objects.
>
> Come to think of it, you might not even want to use cursor.execute().  
> I did that because all I wanted was an extra list of pks, not full  
> model instances. If you want to use the living authors as full  
> instances (ie call methods on them), then you could do this all with  
> Django's ORM: one query of books with living authors, one query of  
> living authors, then python to attach the two.
>
> Whether you set it up as custom manager or not mostly depends on how  
> often you expect to be using this particular query. More than once or  
> twice, and you might as well make it a manager method.
>
> > What would be the SQL for that? My model does not create an in between
> > table (such as appname_book_authors).
> > How do I append my results to a queryset?
>
> It depends on your table set up, but the basic concept is looping over  
> books, and giving each book a new attribute 'living_authors' which is  
> a list of Author instances.
>
> The model definitions you posted earlier are a little odd, you say  
> you've got a M2M relationship between books and author, but actually  
> your Author has a foreign key to Book – ie, each Author can only have  
> written one book. If it were a M2M relationship, you'd probably put an  
> M2M 'authors' field on Book, and leave Author alone. That would create  
> the appname_book_authors table...
>
> Let me know if the model structure you posted is really the one you  
> want to use, and I might be able to help with the next step...
>
> Yours,
> Eric
>
> > I tried to figure these things out on my own, but I just couldn't wrap
> > my head around it.
>
> > On Aug 26, 2:32 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> >> On Aug 26, 2008, at 5:00 PM,MrJogowrote:
>
> >>> I guess I saw it as operating on a group of objects: filtering the
> >>> group of authors related to my_book by is_living. I also think I got
> >>> RelatedManager confused with Manager.
>
> >> Yaar, it can be a bit confusing. I guess what's important is to
> >> remember which model you've started your query with – all queries are
> >> relative to that table. I wonder if it's possibly to subclass
> >> RelatedManager and add custom methods, come to think of it...
>
> >>> I think I can handle two db hits, although it's not optimal. I wish
> >>> there was a way to get a set of data filtered on many levels (ie,  
> >>> only
> >>> books with living authors AND only the related living authors) with
> >>> one command/db hit.
>
> >> It will be more than two db hits if you've got to call
> >> living_authors() on every book in the set!
>
> >> Actually I needed to do something like this recently, here's a link  
> >> to
> >> the relevant 
> >> thread:http://groups.google.com/group/django-users/browse_thread/thread/9be1
> >> ...
>
> >> There's a lot of cruft in that thread, the basic idea is using
> >> cursor.execute() to do your subqueries (selecting all living authors
> >> per book), and then using pure python to attach those subqueries to
> >> your larger book queryset. It's not as painful as it sounds.
>
> >> Lastly, there are rumors of aggregation support coming soon/already
> >> here, but I'm not sure how that works (or even if it will solve these
> >> kinds of problems) so will say no more...
>
> >> E
>
> >>> On Aug 26, 2:10 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
>  On Aug 25, 2008, at 3:11 PM,MrJogowrote:
>
> > How do I create a custom manager for many-to-many traversal? An
> > 

Re: Custom manager for many-to-many traversal

2008-09-01 Thread MrJogo

I read that post, and now have a general idea of what to do, but I'm
still confused on the specifics. It doesn't help that my SQL is VERY
rusty.

Am I supposed to use cursor.execute() to do the INITIAL lookup? That
is, instead of calling a filter, or whatnot, on each book entry, I do
a cursor.execute that gets the books I want AND the related living
authors in one fell swoop? Do I set that up as a custom Manager?

What would be the SQL for that? My model does not create an in between
table (such as appname_book_authors).

How do I append my results to a queryset?

I tried to figure these things out on my own, but I just couldn't wrap
my head around it.

On Aug 26, 2:32 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On Aug 26, 2008, at 5:00 PM,MrJogowrote:
>
>
>
> > I guess I saw it as operating on a group of objects: filtering the
> > group of authors related to my_book by is_living. I also think I got
> > RelatedManager confused with Manager.
>
> Yaar, it can be a bit confusing. I guess what's important is to  
> remember which model you've started your query with – all queries are  
> relative to that table. I wonder if it's possibly to subclass  
> RelatedManager and add custom methods, come to think of it...
>
>
>
> > I think I can handle two db hits, although it's not optimal. I wish
> > there was a way to get a set of data filtered on many levels (ie, only
> > books with living authors AND only the related living authors) with
> > one command/db hit.
>
> It will be more than two db hits if you've got to call  
> living_authors() on every book in the set!
>
> Actually I needed to do something like this recently, here's a link to  
> the relevant 
> thread:http://groups.google.com/group/django-users/browse_thread/thread/9be1...
>
> There's a lot of cruft in that thread, the basic idea is using  
> cursor.execute() to do your subqueries (selecting all living authors  
> per book), and then using pure python to attach those subqueries to  
> your larger book queryset. It's not as painful as it sounds.
>
> Lastly, there are rumors of aggregation support coming soon/already  
> here, but I'm not sure how that works (or even if it will solve these  
> kinds of problems) so will say no more...
>
> E
>
>
>
> > On Aug 26, 2:10 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> >> On Aug 25, 2008, at 3:11 PM,MrJogowrote:
>
> >>> How do I create a custom manager for many-to-many traversal? An
> >>> example will illustrate what I want to do better. Suppose I have the
> >>> following models.py:
>
> >>> class Book(models.Model):
> >>>  title = models.CharField(max_length=100)
>
> >>> class Author(models.Model):
> >>>  books = models.ForeignKey(Book)
> >>>  name = models.CharField(max_length=100)
> >>>  is_alive = models.BooleanField()
>
> >>> This is a many-to-many relationship: a book can have multiple  
> >>> authors
> >>> and an author can have written multiple books.
>
> >>> If I have a book object my_book, and I want to get all the  
> >>> authors, I
> >>> do my_book.author_set.all(). How can I set up a custom manager to  
> >>> only
> >>> get living authors of that book, so I could do something like
> >>> my_book.livingauthor_set.all()?
>
> >> Custom managers are usually used for table-level functionality, ie
> >> you'd make a manager method that filters or acts on a *group* of
> >> books, not one single book. The usual thing to do when you want
> >> something from a single object is to put a custom method on Book,
> >> which returns living authors, like:
>
> >> def living_authors(self):
> >>      return self.author_set.filter(is_alive=True)
>
> >> What I don't know is if there's any way to keep this from making
> >> another db hit every time you call some_book.living_authors().
> >> QuerySets can't be further filtered once they've been evaluated, so
> >> using select_related() on the original Book QuerySet might not  
> >> help...
>
> >> Yours,
> >> Eric
>
> >>> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom manager for many-to-many traversal

2008-08-26 Thread MrJogo

I guess I saw it as operating on a group of objects: filtering the
group of authors related to my_book by is_living. I also think I got
RelatedManager confused with Manager.

I think I can handle two db hits, although it's not optimal. I wish
there was a way to get a set of data filtered on many levels (ie, only
books with living authors AND only the related living authors) with
one command/db hit.

On Aug 26, 2:10 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> On Aug 25, 2008, at 3:11 PM,MrJogowrote:
>
>
>
>
>
> > How do I create a custom manager for many-to-many traversal? An
> > example will illustrate what I want to do better. Suppose I have the
> > following models.py:
>
> > class Book(models.Model):
> >  title = models.CharField(max_length=100)
>
> > class Author(models.Model):
> >  books = models.ForeignKey(Book)
> >  name = models.CharField(max_length=100)
> >  is_alive = models.BooleanField()
>
> > This is a many-to-many relationship: a book can have multiple authors
> > and an author can have written multiple books.
>
> > If I have a book object my_book, and I want to get all the authors, I
> > do my_book.author_set.all(). How can I set up a custom manager to only
> > get living authors of that book, so I could do something like
> > my_book.livingauthor_set.all()?
>
> Custom managers are usually used for table-level functionality, ie  
> you'd make a manager method that filters or acts on a *group* of  
> books, not one single book. The usual thing to do when you want  
> something from a single object is to put a custom method on Book,  
> which returns living authors, like:
>
> def living_authors(self):
>      return self.author_set.filter(is_alive=True)
>
> What I don't know is if there's any way to keep this from making  
> another db hit every time you call some_book.living_authors().  
> QuerySets can't be further filtered once they've been evaluated, so  
> using select_related() on the original Book QuerySet might not help...
>
> Yours,
> Eric
>
>
>
> > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom manager for many-to-many traversal

2008-08-25 Thread MrJogo

I could, but I need to do it in a template, and from what I
understand, passing variables to method calls in the template language
is a pain, or at least ugly. I think a custom manager is the elegant,
"proper" way to so it (someone can correct me if I'm wrong.

On Aug 25, 10:31 am, John M <[EMAIL PROTECTED]> wrote:
> Since my_book.auther_set.all() returns a QS, can't you just say
> something like ...all().filter(author__isalive=True) or something like
> that?  I've never tried, but I thought that django would figure it
> out?
>
> J
>
> On Aug 25, 12:11 am,MrJogo<[EMAIL PROTECTED]> wrote:
>
> > How do I create a custom manager for many-to-many traversal? An
> > example will illustrate what I want to do better. Suppose I have the
> > following models.py:
>
> > class Book(models.Model):
> >   title = models.CharField(max_length=100)
>
> > class Author(models.Model):
> >   books = models.ForeignKey(Book)
> >   name = models.CharField(max_length=100)
> >   is_alive = models.BooleanField()
>
> > This is a many-to-many relationship: a book can have multiple authors
> > and an author can have written multiple books.
>
> > If I have a book object my_book, and I want to get all the authors, I
> > do my_book.author_set.all(). How can I set up a custom manager to only
> > get living authors of that book, so I could do something like
> > my_book.livingauthor_set.all()?
>
> > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom manager for many-to-many traversal

2008-08-25 Thread MrJogo

How do I create a custom manager for many-to-many traversal? An
example will illustrate what I want to do better. Suppose I have the
following models.py:

class Book(models.Model):
  title = models.CharField(max_length=100)

class Author(models.Model):
  books = models.ForeignKey(Book)
  name = models.CharField(max_length=100)
  is_alive = models.BooleanField()

This is a many-to-many relationship: a book can have multiple authors
and an author can have written multiple books.

If I have a book object my_book, and I want to get all the authors, I
do my_book.author_set.all(). How can I set up a custom manager to only
get living authors of that book, so I could do something like
my_book.livingauthor_set.all()?

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



EmailMultiAlternatives send error

2008-06-22 Thread MrJogo

I'm sending a user-submitted form using EmailMultiAlternatives. From
my view, I'm calling a helper function in a different file (but in the
same directory) to actually compose and send the email. When I send
the message from this helper function (using msg.send()), I get a
Server Error page. When, however, I return the message, and send it
from views.py, it sends fine. Anyone know why?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: sending email without "from" specified

2008-06-10 Thread MrJogo

Never mind, it was an EMAIL_HOST problem.

On Jun 10, 7:25 pm, MrJogo <[EMAIL PROTECTED]> wrote:
> I use a university webservice, and they do not allow scripts to set
> the "from" address when sending mail (for example, php's mail function
> works fine). How should I send mail from Django?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



sending email without "from" specified

2008-06-10 Thread MrJogo

I use a university webservice, and they do not allow scripts to set
the "from" address when sending mail (for example, php's mail function
works fine). How should I send mail from Django?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



APPEND_SLASH and fastcgi

2008-06-06 Thread MrJogo

I am using Django with fastcgi and I cannot get the append slashes
middleware to work (I have CommonMiddleware installed in my settings
folder, and APPEND_SLASH is true). I have come across a number of
posts where append slashes breaks their installating, but for mine it
just does not append the slash. For example, when I go to
http://www.hostingsite.com/mydir/home, I get a 404 with the request
URL http://www.hostingsite.com/mydir/script.fcgi/home (http://
www.hostingsite.com/mydir/home/ works fine). How can I get append
slashes to work?

The .htaccess in mydir is below, along with my fastcgi file.


.htaccess

AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /mydir/cgi-bin/script.fcgi/$1 [QSA,L]



script.fcgi

#!/usr/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/path/to/mydir/django")
sys.path.insert(1, "/path/to/mydir/cgi-bin/djangoprojects/")

# Switch to the directory of your project.
os.chdir("/path/to/mydir/cgi-bin/djangoprojects/lsjumb")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



getting form data in a template - using form labels

2008-06-01 Thread MrJogo

I'm trying to create a simple plain text email template that displays
user-submitted, clean form data. Right now, the template is:

email_template.txt
{% for field, value in data.items %}
{{ field }}: {{ value }}
{% endfor %}

The view passes the template {'data': form.cleaned_data}.
Unfortunately, making the template like this displays ugly field names
(ie, "other_comments"), not the label field names (ie, "Other
Comments"), which can be accessed from form["some_field"].label.

How can I modify the template to display the field's label with the
cleaned data?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Creating a form class based on fields stored in the database

2008-05-20 Thread MrJogo

I want to create a web interface where users can create a form (ie,
define the number of fields and what types of fields they are and the
name to display), which will be stored in the Django database, and
then displayed elsewhere on the site as an actual form. Any ideas how
best to do this, specifically how to turn data stored in a database
(probably as a charfield) into a form object? Any examples of this
already being done? Is there a Python method to turn strings (ie,
"forms.CharField()") into the objects they represent?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



using templates for javascript files

2008-05-12 Thread MrJogo

I'd like my javascripts to know MEDIA_URL so they can pull pictures
from there (for a slideshow) and I was wondering the best way of doing
this.

I figure the best way would be to create one javascript file that goes
through the Django templating and makes a variable available for the
other scripts. Something like:

//site.js
var site = {
  medai_url = '{{ MEDIA_URL }}'
};

Then other scripts could access it through site.media_url. My question
is how best to templatize a javascript file. I could just put it in my
base.html file between , but that way's kind of poo.

If I were to templatize the entire file, it would have to go through
urls.py, but for consistency's sake I'd like the url to be within my
media/javascript folder, ie a urls.py entry something like:

urlpatterns = patterns('',
  (r'^' + settings.MEDIA_URL + r'javascript/site.js$', media_js),
)

But then I run into the problem that MEDIA_URL is an absolute URL, so
I'd probably have to do some string manipulation to get the relative
URL out.

Am I missing an easier way of doing it? Thoughts on these approaches?
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: relative link problem with admin login

2008-04-05 Thread MrJogo

My urls.py file is (I only used the non-testing part):

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  ('', url(r'^~mysite/', include('mysite.mysiteurls'))),
)

And my mysiteurls.py file:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
  url(r'^admin/', include('django.contrib.admin.urls')),
  url(r'^', include('lsjumb.main.urls')),
)

>Django strips the domain part (and the GET parameters), leaving
>'~mysite/index/' as what to match (unless somebody else on this list
>corrects me, but I didn't found this documented). So you'll need to
>take out the ~mysite yourself, which is what urls.py does

I'm not sure my setup works exactly like this. Using my old urls.py, I
would navigate to http://www.university.edu/~mysite/admin/ with the
regex ^admin/. When I changed the regex to ~mysite/admin/, it no
longer finds the page. A curious thing is that on the Django 404 page,
the request URL is listed as http://www.university.edu/admin/ instead
of http://www.university.edu/~mysite/admin/ (I don't know if this is
relevant, but I have no idea what is causing the problem). It could be
because my setup uses fastcgi to redirect nonexisting pages (ie, not
media pages) in the /~mysite/ folder to Django to deal with (I used
the directions here:
http://www.djangoproject.com/documentation/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache).

On Apr 3, 2:47 am, Evert Rol <[EMAIL PROTECTED]> wrote:
> > I tried doing what you suggested, but now it gives me the error
> > 'RegexURLResolver' object has no attribute 'rindex' when I try to go
> > to the admin page (or any page that exists, for that matter. Pages
> > that don't exist get an unhandled exception).
>
> Can you show us your url setup as you have it now? It may be something
> else.
>
>  From a quick Google, it may also be a problem depending on the Django
> version; which version are you using?
>
> > Also, I'm not sure if your solution will fix my problem. Django should
> > never receive the /~mysite/ part of the url becuase its root is that
> > folder (ie,http://www.university.edu/~mysite/index/is seen in Django
> > as /index/).
>
> Django strips the domain part (and the GET parameters), leaving
> '~mysite/index/' as what to match (unless somebody else on this list
> corrects me, but I didn't found this documented). So you'll need to
> take out the ~mysite yourself, which is what urls.py does (though the
> media url setting would need to be adjusted for that).
> I'm doing exactly the same thing as you, other than that my 'prefix'
> isn't precisely ~mysite, but I'm still stripping it out before
> matching for views. Works for me.
>
> >>> I'm trying to set up my site on a university webspace, so the root
> >>> is
> >>> a subdirectory, iewww.university.edu/~mysite/. Because of this, I'm
> >>> having trouble logging into the admin pages. I go
> >>> towww.university.edu/~mysite/admin/
> >>> and get the login page, but when I try to login, it goes to
> >>>www.university.edu/admin/becausethe form posts to the relatvie
> >>> url /
> >>> admin/. Any ideas how to fix this? Anyone else have this problem?
>
> >> Not a problem to me really, as here's how I fixed it:
>
> >> urls.py:
>
> >> from django.conf.urls.defaults import *
> >> from django.conf import settings
> >> import sys
>
> >> if 'runserver' in sys.argv:
> >> urlpatterns = patterns('',
> >> # special URLs
> >> (r'^mysitemedia/(?P.*)$', 'django.views.static.serve',
> >>  {'document_root': settings.MEDIA_ROOT}),  # This may have to
> >> be different, eg '^~mysite/media/' or so (but be careful the admin
> >> and
> >> your own media don't clash).
>
> >> # normal URLs
> >> url(r'^~mysite/', include('mysite.mysiteurls')),   # Here, I
> >> pick out the base url
> >>)
> >> else:
> >> urlpatterns = patterns('', url(r'^~mysite/',
> >> include('mysite.mysiteurls')),)
>
> >> and mysiteurls.py:
>
> >> from django.conf.urls.defaults import *
>
> >> urlpatterns = patterns('',
> >> # special URLs
> >> (r'^admin/', include('django.contrib.admin.urls')),
>
> >> # normal URLs
> >> url(r'^users/', include('mysite.users.urls')),
> >> .
> >> .
> >> .
> >> url(r'^', include('mysite.main.urls')),
> >> )
>
> >> Lastly, in settings.py, I have defined a ROOT_URL and some
> >> redefinitions for the user stuff:
> >> ROOT_URL = '/~mysite/'
> >> LOGIN_URL = ROOT_URL + 'users/login/'
> >> LOGOUT_URL = ROOT_URL + 'users/logout/'
> >> LOGIN_REDIRECT_URL = ROOT_URL + 'users/profile/'
>
> >> Note: I have put '~mysite' in various places, but since I actually
> >> simply use 'mysite', I may have done some incorrect substitutions. So
> >> do doublecheck.
> >> But in principal this should work, and with the proper setup for the
> >> media, you can use the same url configuration for a development and
> >> production server.
--~--~-~--~~~---~--~~
You received this message 

Re: relative link problem with admin login

2008-04-02 Thread MrJogo

I tried doing what you suggested, but now it gives me the error
'RegexURLResolver' object has no attribute 'rindex' when I try to go
to the admin page (or any page that exists, for that matter. Pages
that don't exist get an unhandled exception).

Also, I'm not sure if your solution will fix my problem. Django should
never receive the /~mysite/ part of the url becuase its root is that
folder (ie, http://www.university.edu/~mysite/index/ is seen in Django
as /index/).

On Apr 2, 2:52 pm, Evert Rol <[EMAIL PROTECTED]> wrote:
> > I'm trying to set up my site on a university webspace, so the root is
> > a subdirectory, iewww.university.edu/~mysite/. Because of this, I'm
> > having trouble logging into the admin pages. I go 
> > towww.university.edu/~mysite/admin/
> > and get the login page, but when I try to login, it goes to
> >www.university.edu/admin/because the form posts to the relatvie url /
> > admin/. Any ideas how to fix this? Anyone else have this problem?
>
> Not a problem to me really, as here's how I fixed it:
>
> urls.py:
>
> from django.conf.urls.defaults import *
> from django.conf import settings
> import sys
>
> if 'runserver' in sys.argv:
>  urlpatterns = patterns('',
>  # special URLs
>  (r'^mysitemedia/(?P.*)$', 'django.views.static.serve',
>   {'document_root': settings.MEDIA_ROOT}),  # This may have to
> be different, eg '^~mysite/media/' or so (but be careful the admin and
> your own media don't clash).
>
>  # normal URLs
>  url(r'^~mysite/', include('mysite.mysiteurls')),   # Here, I
> pick out the base url
> )
> else:
>  urlpatterns = patterns('', url(r'^~mysite/',
> include('mysite.mysiteurls')),)
>
> and mysiteurls.py:
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> # special URLs
>  (r'^admin/', include('django.contrib.admin.urls')),
>
> # normal URLs
>  url(r'^users/', include('mysite.users.urls')),
>  .
>  .
>  .
>  url(r'^', include('mysite.main.urls')),
> )
>
> Lastly, in settings.py, I have defined a ROOT_URL and some
> redefinitions for the user stuff:
> ROOT_URL = '/~mysite/'
> LOGIN_URL = ROOT_URL + 'users/login/'
> LOGOUT_URL = ROOT_URL + 'users/logout/'
> LOGIN_REDIRECT_URL = ROOT_URL + 'users/profile/'
>
> Note: I have put '~mysite' in various places, but since I actually
> simply use 'mysite', I may have done some incorrect substitutions. So
> do doublecheck.
> But in principal this should work, and with the proper setup for the
> media, you can use the same url configuration for a development and
> production server.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



relative link problem with admin login

2008-04-02 Thread MrJogo

I'm trying to set up my site on a university webspace, so the root is
a subdirectory, ie www.university.edu/~mysite/. Because of this, I'm
having trouble logging into the admin pages. I go to 
www.university.edu/~mysite/admin/
and get the login page, but when I try to login, it goes to
www.university.edu/admin/ because the form posts to the relatvie url /
admin/. Any ideas how to fix this? Anyone else have this problem?
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



adding data to the forms.Form class and rendering it

2007-12-24 Thread MrJogo

I'm working on a photo tagging app where the admin specifies
categories (such as people, places, etc) and the users can input tags
for different pictures. On the page, each category is rendered as an
input (with some pretty titles and divs) on a single tagging form. For
text inputs, I'd like to have already existing tags displayed above
the input field (it'll be different for select boxes, but I'll figure
that out later). To make it easier to display, I'd like to store the
data as an attribute of the field, and have the output of that field
be the formatted html, so that I can do something like:

{% for field in form %}
{{ field.tags }}
{% endfor %}

and for each field, an unordered list of tags will be displayed (or
something like that).

My question is: what do I do to my Form subclass (called TagForm) to
store data and rendering data in each field? Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



determining newforms field type in a template

2007-12-17 Thread MrJogo

If I pass a form into my template as a variable, is there a way to
tell what input type a field is in the template? My template creates
pretty boxes for the form fields, but I don't want them around hidden
inputs. I was hoping for something like {% ifequal field.type "hidden"
%} but I can't seem to find an equivalent of field.type.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: database API filter() vs get()

2007-12-17 Thread MrJogo

I understand now. Thanks.

On Dec 17, 9:11 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 18-Dec-07, at 10:33 AM, MrJogo wrote:
>
> > What's the practical difference between calling
> > DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
> > **kwargs can be whichever paramenters)? I understand that filter
> > returns a QuerySet, but I don't really get how that affects me or my
> > code.
>
> get will return precisely one object. whereas filter will return a
> list of objects (list may contain only one object or be empty. So the
> difference is that if you do
>
> a = ...get()
> you can write a.id
> a= ...filter()
> you would have to write a[0].id (if you are expecting only one object
> to be returned)
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/
> Foss Conference for the common man:http://registration.fossconf.in/web/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



database API filter() vs get()

2007-12-17 Thread MrJogo

What's the practical difference between calling
DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
**kwargs can be whichever paramenters)? I understand that filter
returns a QuerySet, but I don't really get how that affects me or my
code.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



design for static/dynamic website

2007-12-15 Thread MrJogo

I'd like to migrate a currently static website to Django to add some
dynamic features to it and I have some questions about how best to do
that.

The public site has mainly informational pages that can be static, but
a few, like a members list, work better dynamic. The Django docs say
that Django leaves serving static pages to the web server, but that
seems to have some drawbacks. 1) the django pages don't have file
extensions and the static pages do. 2) The static pages can't use
Django's templating system.

I started looking at flatpages for the static pages, but won't that
add the unecessary overhead of a db lookup? Thoughts or suggestions?
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---