Setting up a MultiValueField + custom model field in admin

2009-11-29 Thread Justin
Hi guys,

Trying to teach myself a bit about creating custom fields (for both
forms and models) for Django.  Starting off with a somewhat contrived
storing a street address in one field.

I seem to have gotten the model field working, as I can run python
manage.py shell and successfully fill out the field in a model, save
the model, retrieve the model, and still have my custom field storing
the right data.

But when I try to create a corresponding form field to try and tie in
to the admin site, what I've currently got throws an error that the
"Address" class has no __getitem__

Code is at:
http://dpaste.com/126832/

Any pointers as to where I'm going wrong much 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread Nick Arnett
On Sun, Nov 29, 2009 at 8:30 PM, Gloria  wrote:

> Here's the line from my model:
> class UserProfile(models.Model):
>some other fields...
>privacy_options = models.ManyToManyField(PrivacyOption,
> blank=True, null=True, db_table = 'usr_privacy_selection')
>
> Here's the bit from my form:
>
> class ModifyProfileForm(forms.Form):
>some other fields...
>privacy = forms.ModelMultipleChoiceField(
>queryset=PrivacyOption.objects.all(),
>required=False,
>show_hidden_initial=True,
>widget=forms.CheckboxSelectMultiple,
>)
>

Hmmm... what are you trying to do by passing the queryset?  Doesn't that
send your form everybody's data, instead of just the active user?  If I
recall correctly, passing a queryset will initialize a form, so perhaps all
you need to do there is make it a "get" that returns only the current user's
data?



> When I initialize it like this:
>
>data = {some other fields...
>'privacy' : user_profile.privacy_options
>}
>
>form=ModifyProfileForm(data)
>

That doesn't look right.  I think should be:

 form=ModifyProfileForm(initial=data)

But I'm also not sure if your data dict is correct.  It should have an item
for each field that you want to initialize.

>
> Trying to set the initial value for this particular field also does
> not seem to help:
>
>initial_dict = {}
>for x in user_profile.privacy_options.all():
>initial_dict[x.name]=True
>
>form=ModifyProfileForm(data)
>form.fields['privacy'].initial = initial_dict
>
>
Again, I don't quite understand why your queryset is using "all" - seems
like you would just want one row ("get").  I'm not sure what the form object
would do with a queryset that has multiple rows.  Your dict should be passed
in the second to last line:

form=ModifyProfileForm(initial=initial_dict)

Something like your last line might work, but it is a lot more work than
just passing the form the initialization dict.

Others feel free to jump in here and set me straight as needed.  I'm still
fairly new to Django, so I'm no expert... but I've been struggling to learn
the same stuff lately.

Nick

--

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




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread Gloria
Here's the line from my model:
class UserProfile(models.Model):
some other fields...
privacy_options = models.ManyToManyField(PrivacyOption,
blank=True, null=True, db_table = 'usr_privacy_selection')

Here's the bit from my form:

class ModifyProfileForm(forms.Form):
some other fields...
privacy = forms.ModelMultipleChoiceField(
queryset=PrivacyOption.objects.all(),
required=False,
show_hidden_initial=True,
widget=forms.CheckboxSelectMultiple,
)

Here's whats happening in my view.

When I initialize it like this:

data = {some other fields...
'privacy' : user_profile.privacy_options
}

form=ModifyProfileForm(data)

Then I show it in the template:
{{ form.privacy.label_tag }}
{{ form.privacy }}
{{ form.privacy.errors }}

I get this error:
Caught an exception while rendering: 'ManyRelatedManager' object is
not iterable

So I change the template like so:
{% for privacy in form.privacy.all %}
{{privacy}}
{% endfor %}

and I get this in my browser:

 Privacy

* Enter a list of values.


as if it is not displaying any checkboxes because none have a value
set in them yet.

I want to display all checkboxes, and then check the ones which are
set.

I commented out this change in the view, no longer initializing the
form:

#'privacy' : user_profile.privacy_options,

and I still see nothing in my browser, unless I change the template to
this:

{{ form.privacy }}

Then, at least I see all checkboxes:

   Privacy
  o Show My Profile Page
  o Show Expertise
  o Show Affiliations
  o Show Organization
  o Show Contact Info
  o Allow Messages

Now, let me uncomment the init again, and try to initialize this form
to the db values:
'ManyRelatedManager' object is not iterable error again.

Trying to set the initial value for this particular field also does
not seem to help:

initial_dict = {}
for x in user_profile.privacy_options.all():
initial_dict[x.name]=True

form=ModifyProfileForm(data)
form.fields['privacy'].initial = initial_dict

The selected options never show up.

I know the selections are being passed to a user_profile instance and
stored in the database. So maybe this is a template rendering issue?

Thanks again,
Gloria



--

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




Re: Trouble Getting Past the Congratulations Page

2009-11-29 Thread Guze
Karen, restarting apache worked instantly.  I'm not used to having to
do that.  Normally it's the browser caching the old page that drives
you crazy.  Fortunately I have some aliases for starting, stopping,
restarting etc that make this really painless.

The idea of using the dev server has a lot of appeal, and I was upset
when I thought it wouldn't work remotely.  I can't have it "listen" to
all ip's cause the regular everyday apache server has some of these
it's working in the form of production websites.  But your syntax for
doing runserver with an ip might work for me to just listen for the
experimental site.

Thanks for your time.  I really appreciate it.

On Nov 29, 7:40 pm, Karen Tracey  wrote:
> On Sun, Nov 29, 2009 at 8:06 PM, Guze  wrote:
> >  I have spent time
> > looking at the django project tutorials, but they are pretty tied into
> > the development webserver which I cannot run since I have to browser
> > (or monitor or keyboard) connected to that hardware server.
>
> You do not need a monitor or keyboard attached to the machine to use the
> development server.  If you can ssh to the machine, you can run the
> development server.  You'll need to tell it to listen on all addresses
> instead of just loopback:
>
> python manage.py runserver 0.0.0.0:8000
>
> 0.0.0.0 is all, you could substitute a specific interface IP address if you
> prefer, but that is all you need to do to be able to reach the development
> server from a different client machine.
>
> When using Apache (unless you have set it up to use mod_wsgi and set things
> up to do  code monitoring to trigger a reload on source code changes) you
> will need to restart Apache each time you make a code change.  Otherwise the
> existing Apache processes will just keep using the code they've already
> loaded into memory.  My guess is that is what is blocking progress past the
> congratulations page.
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: django url and reverse

2009-11-29 Thread Karen Tracey
On Sun, Nov 29, 2009 at 6:45 AM, caliman  wrote:

> Hi!
>
> In my project most of my views requires the user to be logged in but
> in some i don't for example the login view wich only displays a login
> form. When I'm going to the login form as a non logged in user I get
> an error:
> "Error was: 'AnonymousUser' object has no attribute 'get_profile'" The
> error is thrown when I use django reverse or url (from template). It
> seems as when it checks for urls in my urls.py it parses not only that
> file to get the url it also tries to execute all views. Thats why I
> got the error when it executes a view that requires login and therefor
> uses my user.get_profile().
>
> Anyone know how to solve this? I do wnat to use url and reverse even
> for pages that doesn't require the user to be logged in.
>

It would help people help you if you would give specifics of your URLConf,
exactly what triggers the error, and the traceback that results.

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




Re: Trouble Getting Past the Congratulations Page

2009-11-29 Thread Karen Tracey
On Sun, Nov 29, 2009 at 8:06 PM, Guze  wrote:

>  I have spent time
> looking at the django project tutorials, but they are pretty tied into
> the development webserver which I cannot run since I have to browser
> (or monitor or keyboard) connected to that hardware server.


You do not need a monitor or keyboard attached to the machine to use the
development server.  If you can ssh to the machine, you can run the
development server.  You'll need to tell it to listen on all addresses
instead of just loopback:

python manage.py runserver 0.0.0.0:8000

0.0.0.0 is all, you could substitute a specific interface IP address if you
prefer, but that is all you need to do to be able to reach the development
server from a different client machine.

When using Apache (unless you have set it up to use mod_wsgi and set things
up to do  code monitoring to trigger a reload on source code changes) you
will need to restart Apache each time you make a code change.  Otherwise the
existing Apache processes will just keep using the code they've already
loaded into memory.  My guess is that is what is blocking progress past the
congratulations page.

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




Re: django url and reverse

2009-11-29 Thread Skylar Saveland
You simply can't call request.user.get_profile() on an anonymous user.

caliman wrote:
> Hi!
>
> In my project most of my views requires the user to be logged in but
> in some i don't for example the login view wich only displays a login
> form. When I'm going to the login form as a non logged in user I get
> an error:
> "Error was: 'AnonymousUser' object has no attribute 'get_profile'" The
> error is thrown when I use django reverse or url (from template). It
> seems as when it checks for urls in my urls.py it parses not only that
> file to get the url it also tries to execute all views. Thats why I
> got the error when it executes a view that requires login and therefor
> uses my user.get_profile().
>
> Anyone know how to solve this? I do wnat to use url and reverse even
> for pages that doesn't require the user to be logged in.
>
> Stefan

--

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




Trouble Getting Past the Congratulations Page

2009-11-29 Thread Guze
I've been using the book "Python Web Development with Django" to get
up to speed on this amazing framework.  Although I'm new to python, I
have plenty of experience with other languages like C and lately PHP,
as well as running my own linux servers using apache2 for websites.
I've been flipping pages learning python (which I really like) and
using the example project, a blog app, as a way to focus the python/
django experience.  I've been able to use django-admin startproject to
create a project named mysite (as per the book).   manage.py  sartapp
blog works fine and manage.py  syncdb runs and builds lots of tables
in the mysql db (I've looked at them). The congrats page comes up just
fine.  But there it ends.  Trying to add the admin application does
not generate any errors, but also does not generate any admin pages...
all I see regardless of what I type in for an url, is that congrats
page.

The details.  I'm running debbian lenny as my webserver.  This is a
rack-mounted server sitting in my cold garage, and everything I do on
it is via remote login using ssh.  It's always worked great. It's
currently happily running several websites using xampp apache2, mysql
and php, originally on debbian sarge.  I decided to do some major
upgrades and wanted to migrate to django as well.  I upgraded to
debbian lenny and built from source new installations of apache2, php,
mysql, python 2.5 and django 1.1.  This took some time because I did
not want to turn off the existing websites, but with about six weeks
of careful work and tons of testing, working path issues, conf files,
etc I have it running the new stuff fine.  I can work directly in
python as a programming tool, the new (second) install of mysql does
not get confused with the old one in xampp, and even apache2 comes up
fine so I have both apache2 exceutables running.  I have spent time
looking at the django project tutorials, but they are pretty tied into
the development webserver which I cannot run since I have to browser
(or monitor or keyboard) connected to that hardware server.  I do have
a happy relationship with the server through ssh and have some spare
domains, one of which I hooked in via apache to the django example.
Again, it seems to work fine as shown by the congrats page when I type
in www.nleashed.com  (the domain I'm using).  But www.nleashed.com/admin
also shows the congrats page.  Bo.

My plan is to rebuild my websites, hopefully doing a LOT of
enhancements as I go, on the django framework and then kill/erase the
whole xampp tree.  But this has all ground to a halt when I try to get
the admin app going.  Here are the key files:

excerpt of settings.py


INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.blog',
)

entire urls.py

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
#(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)

and finally, the models.py file from the blog dir.

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

class BlogPost (models.Model):
title = models.CharField(max_length=150)
body = models.TextField()
timestamp = models.DateTimeField()

admin.site.register(BlogPost)

As you can see, this is pretty basic stuff, which really worries me --
means I'm failing in a really basic way :)

Any suggestions would be GREATLY 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




unsubscribe

2009-11-29 Thread turbogears




在2009-11-30 09:36:28,"Steve Holden"  写道:

On Sun, Nov 29, 2009 at 8:33 PM, Nick Arnett  wrote:

On Sun, Nov 29, 2009 at 4:01 PM, Steve Holden  wrote: 



Not at all. The client will typically use an "ephemeral"  port (one it obtains 
by saying to its local TCP layer "gimme a port number, I don't care what it 
is"). The connection (any connection) has *two* endpoints, and the port numbers 
each system uses are up to that system.

Obviously you want the server to listen on a "well-known" port most of the 
time, though as you have observed the Django administrator can configure the 
server to listen on any desired port. But the client really doesn't care - it 
just expects the server to reply to the same port number it sent its request 
from.

Of course, but I can't imagine why anybody would ever worry about that at the 
application level.


Me neither. The server just replies on the socket that the message comes in on. 
I'd like to know why the OP felt it was important to be able to identify the 
remote port.

regards
 Steve

-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

--

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




Re: WebFaction warning

2009-11-29 Thread David Zhou
On Sun, Nov 29, 2009 at 9:18 PM, digicase  wrote:

> I received a good email From Remi at WF which told me all I needed to
> know. The outage was unacceptable but hopefully lessons have been
> learned.

Do you mind sharing what he said? I'd be curious to know if any new
controls have been put into place to prevent this sort of sustained
outage from happening again.  And if new protocols on communication
during extended outages are being considered.

-- dz

--

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




Re: WebFaction warning

2009-11-29 Thread digicase
On Nov 29, 5:52 pm, Atamert Ölçgen  wrote:
> On Saturday 28 November 2009 07:28:27 digicase wrote:> I am sad to report 
> this, as up until now I had complete faith and
> > trust in them. That has been lost over the past few days. Support were
> > not transparent, status updates rare and vague.
>
> I have been following web44 issues from RSS and it sure has taken much longer
> than other instances. Sorry about what you've been through, I would gone mad
> if something like that had happened to me. I hope the issue gets resolved
> soon.
>
> I am all for customers disclosing their experiences with brands. So, please
> people; don't try to shut people up when they say something negative. I think
> open source communities should be open to such discussions.
>
> Having said that, I'm a webfactioner for some years and very happy with the
> service. Sure I had issues, but I have always found some real person to seek
> help on the other side. So my experience is actually the opposite of "not
> transparent". Big companies, small companies, they all make mistakes. Trouble
> begins when they start treating their customers like dirt. I bet we can find
> enough testimonials that WF is not (yet) one of them.

I received a good email From Remi at WF which told me all I needed to
know. The outage was unacceptable but hopefully lessons have been
learned.

>
> > Furthermore their daily backup of our home folder was corrupted, which
> > is probably as much as a lesson to me as a bad mark for Webfaction.
>
> This is a big issue. I hope they take appropriate action and fix this.

A subversion checkout become unusable, but that wasn't a huge deal.
Some photos are not there but overall the backup served it's purpose.

>
> Again, I hope you get your server up and running in no time.

Thanks, the site server is working again now :)
>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org

--

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




Re: how to get remote port number

2009-11-29 Thread Steve Holden
On Sun, Nov 29, 2009 at 8:33 PM, Nick Arnett  wrote:

> On Sun, Nov 29, 2009 at 4:01 PM, Steve Holden  wrote:
>
>
>>
>>> Not at all. The client will typically use an "ephemeral"  port (one it
>> obtains by saying to its local TCP layer "gimme a port number, I don't care
>> what it is"). The connection (any connection) has *two* endpoints, and the
>> port numbers each system uses are up to that system.
>>
>> Obviously you want the server to listen on a "well-known" port most of the
>> time, though as you have observed the Django administrator can configure the
>> server to listen on any desired port. But the client really doesn't care -
>> it just expects the server to reply to the same port number it sent its
>> request from.
>>
>
> Of course, but I can't imagine why anybody would ever worry about that at
> the application level.
>
> Me neither. The server just replies on the socket that the message comes in
on. I'd like to know why the OP felt it was important to be able to identify
the remote port.

regards
 Steve
-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: how to get remote port number

2009-11-29 Thread Nick Arnett
On Sun, Nov 29, 2009 at 4:01 PM, Steve Holden  wrote:

>
>
>> Not at all. The client will typically use an "ephemeral"  port (one it
> obtains by saying to its local TCP layer "gimme a port number, I don't care
> what it is"). The connection (any connection) has *two* endpoints, and the
> port numbers each system uses are up to that system.
>
> Obviously you want the server to listen on a "well-known" port most of the
> time, though as you have observed the Django administrator can configure the
> server to listen on any desired port. But the client really doesn't care -
> it just expects the server to reply to the same port number it sent its
> request from.
>

Of course, but I can't imagine why anybody would ever worry about that at
the application level.

Nick

--

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




What exactly does order_with_respect_to do?

2009-11-29 Thread Continuation
In the doc (http://docs.djangoproject.com/en/dev/ref/models/options/
#order-with-respect-to) it is mentioned that  order_with_respect_to
marks an object as "orderable" with respect to a given field.

What exactly does that mean? Can someone give me an example of how
this could  be used?

The doc's example is:
 order_with_respect_to = 'question'

How is that different from
ordering = ['question']


--

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




Re: Save as new and files

2009-11-29 Thread Pawel Pilitowski
Hi Tim,

Thanks for the response.

My Test model:

class Test(models.Model):
 text = models.CharField(max_length=50)
 image = models.ImageField(upload_to="upload/test_images/",  
blank=True, null=True)
 #also tried with FileField

 def __unicode__(self):
 return self.text

class TestAdmin(admin.ModelAdmin):
 save_as = True

admin.site.register(Test, TestAdmin)

On 28/11/2009, at 2:43 PM, Tim Valenta wrote:

> Does the newly created model lack a path entirely, or does it have a
> path that points to a false location? In other words, is the right
> path making it to the database, yet not to the filesystem to copy the
> file?  Also, since you didn't mention anything about it, I would
> remind you that a proper test would include trying to make a change to
> the FileField.  If you don't try to change it, yet push "Save as new",
> it won't be uploading the file again, so it won't be part of the list
> of fields that it's manipulating.  And that might be where the problem
> lies.  Could you confirm your suspicion from any playing around you
> can do?

> If you're sure that you really are setting it up for success yet it
> fails anyway,  you might consider overriding "save_model" on your
> ModelAdmin, so that you can play with the values and see what's going
> on:
>
># ... in your ModelAdmin subclass
>def save_model(self, request, obj, form, change):
>super( **YourClassName**, self).save_model(self, request,
> object, form, change)
>
># Check if a file upload is present on this save request
>if 'your_file_field_name' in request.FILES:
>
># FileField object, already saved and
># migrated to the supposedly correct "upload_to" location
>obj.your_file_field_name
>
> Hope that gets some cogs turning.. :)
>
> Tim

The path on the saved as new file does not get saved, it doesn't even  
appear in request.POST: image="", and request.FILES is empty. If I  
remove blank=True from the definition, admin ask for the field to be  
filled out.

If I submit a different file on the save as new, the new files gets  
saved no problems.

I hope thats clear :-)

Regard,

Pawel.





--

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




Re: how to get remote port number

2009-11-29 Thread Steve Holden
On Sun, Nov 29, 2009 at 6:56 PM, Nick Arnett  wrote:

>
>
> On Sun, Nov 29, 2009 at 2:24 PM, The New Hanoian wrote:
>
>> Hi,
>>
>> I'm learning Django. In the tutorial i find that the client IP address
>> can be retrieve through HttpRequest.META["REMOTE_ADDR"]. But I
>> couldn't find a way to retrieve the client port number. I think it
>> should be obvious. Am I missing something?
>
>
> Um, yes.  You're missing the fact that you already have it, since you are
> the one who configures Django's port.  The client can only contact you on
> the port it is running on, of course.
>
> In other words, the client port number always is the same as the server
> port number.  Gotta be so.
>
> Not at all. The client will typically use an "ephemeral"  port (one it
obtains by saying to its local TCP layer "gimme a port number, I don't care
what it is"). The connection (any connection) has *two* endpoints, and the
port numbers each system uses are up to that system.

Obviously you want the server to listen on a "well-known" port most of the
time, though as you have observed the Django administrator can configure the
server to listen on any desired port. But the client really doesn't care -
it just expects the server to reply to the same port number it sent its
request from.

regards
 Steve
-- 
Steve Holden+1 571 484 6266  +1 800 494 3119
Holden Web LLC http://www.holdenweb.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: how to get remote port number

2009-11-29 Thread Nick Arnett
On Sun, Nov 29, 2009 at 2:24 PM, The New Hanoian wrote:

> Hi,
>
> I'm learning Django. In the tutorial i find that the client IP address
> can be retrieve through HttpRequest.META["REMOTE_ADDR"]. But I
> couldn't find a way to retrieve the client port number. I think it
> should be obvious. Am I missing something?


Um, yes.  You're missing the fact that you already have it, since you are
the one who configures Django's port.  The client can only contact you on
the port it is running on, of course.

In other words, the client port number always is the same as the server port
number.  Gotta be so.

Nick

--

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




Re: Chart tool

2009-11-29 Thread Steve S.
For in-page charts, I use flot, as Javier suggested.  I plan to look
into pycha based on Skylar's suggestion, though.  There is no need for
client-side chart drawing with my use case.

On Nov 25, 3:31 pm, Javier Guerra  wrote:
> reportlab allows you to generate PDFs, which can be as high quality as
> you want; but if you want to display them on a webpage it's far from
> the best.
>
> matplotlib is nice, being python.  the biggest drawback is that being
> a server-side task, so you have to deal with the processing time
> and/or storage/deletion of (old) images.
>
> for in-page charts, you can use flot (http://code.google.com/p/flot/),
> or Google Charts (http://code.google.com/apis/chart/).  the first one
> is a jQuery plugin, the other is an API that basically lets you
> construct an URL for a PNG that's rendered on Google servers.  in both
> cases, you simply put (some of) your data on the page and let either
> the client (if using flot) or somebody else (if using Google charts)
> deal with the heavy tasks.
>
> --
> Javier

--

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




Re: A Design Question

2009-11-29 Thread Steve S.
This /is/ outside the scope of Django.

"Database normalization" and "Database design" are the google query
you're looking for to learn more about this, though. Here are some
links that may steer you in the right direction:

http://en.wikipedia.org/wiki/Database_normalization
http://databases.about.com/od/specificproducts/a/normalization.htm
http://devhood.com/tutorials/tutorial_details.aspx?tutorial_id=95
http://en.wikipedia.org/wiki/Database_design
http://databases.about.com/od/specificproducts/Database_Design.htm

--

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




Re: How do I tap into admin.py to generate data from models?

2009-11-29 Thread Russell Keith-Magee
On Mon, Nov 30, 2009 at 1:45 AM, Joshua Kramer  wrote:
> Hello,
>
> What document or example code should I consult to learn how to tap
> into admin.py to output specific data based on a model?  For example,
> if I have an application and a handful of models, if I do "admin.py
> sqlall" then I get output that consists of SQL statements used to
> generate the model in the database.  I would like to generate the
> models in another syntax, specifically Protocol Buffers.  This is
> related to a previous post:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...
>
> I am currently investigating the code that creates SQL tables, so I
> think I am on the right track to generate the data - but how do I hook
> this into manage.py?

You write a custom management command:

http://docs.djangoproject.com/en/dev/howto/custom-management-commands/

Yours
Russ Magee %-)

--

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




how to get remote port number

2009-11-29 Thread The New Hanoian
Hi,

I'm learning Django. In the tutorial i find that the client IP address
can be retrieve through HttpRequest.META["REMOTE_ADDR"]. But I
couldn't find a way to retrieve the client port number. I think it
should be obvious. Am I missing something?

--

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




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread levin11
Hi,

I tried to post this two hours ago, but it did not show up. So sorry
if this is the second copy.

I use "checkboxed" ModelMultipleChoiceField w/o any problems. Here is
a snippet:

class PictureForm(ModelForm):
tags = ModelMultipleChoiceField(queryset=Tag.objects.all(),
widget=CheckboxSelectMultiple, required=False)
class Meta:
model  = Picture
fields = ('title', ..., 'tags')

def edit_picture(request, pic_id):
pic = get_object_or_404(Picture, pk=pic_id)

if request.method == "POST":
pic_form= PictureForm(request.POST, instance=pic)
if pic_form.is_valid() and photo_forms.is_valid():
pic_form.save()
else:
pic_form= PictureForm(instance=pic)

return render_to_response("cat/edit_picture.html", dict(
pic_form  = pic_form
))

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




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread levin11
I have ModelMultipleChoiceField working for me OK, but I am not sure I
understand your question. Could you be a bit more specific?

This is a snippet from my code which may or may not help:

class PictureForm(ModelForm):
tags = ModelMultipleChoiceField(queryset=Tag.objects.all(),
widget=CheckboxSelectMultiple, required=False)
class Meta:
model  = Picture
fields = ('title',  , 'tags')

# the view:
def edit_picture(request, pic_id):
pic  = get_object_or_404(Picture, pk=pic_id)

if request.method == "POST":
pic_form = PictureForm(request.POST, instance=pic)
if pic_form.is_valid():
pic_form.save()
else:
pic_form= PictureForm(instance=pic)

return render_to_response("cat/edit_picture.html", dict(
pic_form= pic_form
))


On Nov 28, 3:05 pm, Gloria  wrote:
> Hi all,
> I've spent way too much time getting trying to get this widget to work
> the way I am envisioning.
> In the forms, I want to initialize it, but in the view I need to
> determine which boxes are checked.
> Has anyone done this without writing their own widget? It would be
> great to know how.
> Thank you in advance,
> Gloria

--

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




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread Nick Arnett
On Sun, Nov 29, 2009 at 9:52 AM, Gloria  wrote:

> Thanks for the response. I am trying to do this on the server side.
> Here is more detail.
> I am initializing it to all unchecked checkboxes in my forms.py.
> Then, in my view, I am trying to have HTML generate a "checked" value
> for certain checkboxes, based on some user data I received in that
> view.
> How do I generate "checked" HTML option using the builtin
> ModelMultipleChoiceField for certain checkboxes? Is there a builtin
> option that I  should set manually to cause the "checked" option to be
> generated? Or do I have to iterate over these fields, match them with
> data I have received, and generate the "checked" option myself, in the
> template?
>
>
You shouldn't have to do that if the data is available in your view.  It
should be as easy as passing a dict as "initial" to your form instance you
create in the view:

form = MyForm(initial = {"foo"=True, "bar"=True}

with the field names (instead of foo and bar) of the check boxes you want
checked.  Your form then should have them checked when it is rendered.

Nick

--

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




Re: streaming response, missing something simple

2009-11-29 Thread Preston Holmes


On Nov 28, 11:07 pm, Preston Holmes  wrote:
> My expectation was that it was possible to 'stream' a response back to
> a browser from a view, where that response is 'trickled' onto the
> browser page.  I had done this a while back in cherrypy and it worked
> as expected.
>
> a super simple view demonstrates the issue.  Instead of a series of
> numbers marching onto the page, there is a delay and then the whole
> response is written to the page.  I had disabled commonmiddleware to
> avoid any chance that I was hitting #7581
>
> Is this some limitation of runserver?
>
> from django.http import HttpResponse
> import time
>
> def streamer():
>     for x in range(50):
>         yield str(x)
>         time.sleep(.2)
>
> def writeback (request):
>     return HttpResponse(streamer(), mimetype="text/plain")
>
> insight welcome
>
> -Preston

Answering my own question in case anyone else runs into this.  It is
an issue with Safari buffering the first 1K

So all you need to do to fix it is add a line like:

yield ''.ljust(1024,'\0')

in the generator before your loop.

-Preston

--

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




A Design Question

2009-11-29 Thread Ramdas S
This is probably outside Django. But I am checking out since I am building
it with Django.

I am building a specialized closed group social networking web site for
special set of medical practitioners. Idea for my client is to be a mini-
LinkedIn of sorts for this small community.

We want to capture as many details as possible from some clinical practices,
to education, work experience, papers submitted etc. However at registration
time we want to limit it to just the basic details like name, email and may
be some license number.

However over a period of time we would like the user to add details.

Do I build one large UserProfile Table, with ForeignKey to colleges,
specializations etc or do I break it up into number of smaller profiles, and
link each profile to a User. What's the best practice?



-- 
Ramdas S

--

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




Re: Difficulty using anchor tags in templates

2009-11-29 Thread Andy
Fantastic!  I think I was overthinking my problem.  Thanks a lot!

On Nov 29, 10:36 am, rebus_  wrote:
> BTW here is an example:
>
> When you click this 
> link:http://en.wikipedia.org/wiki/Fragment_identifier#Processing
>
> your browser will open uphttp://en.wikipedia.org/wiki/Fragment_identifierpage 
> and then scroll
> down to the Processing title without wikipedia even knowing that you
> specifically want to see that part of the page, it will just send you
> the page and let your browser worry about scrolling.
>
> Also i apologize, since English is not my native language i might have
> trouble explaining some thing with it :)
>
> Davor

--

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




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread Gloria
Thanks for the response. I am trying to do this on the server side.
Here is more detail.
I am initializing it to all unchecked checkboxes in my forms.py.
Then, in my view, I am trying to have HTML generate a "checked" value
for certain checkboxes, based on some user data I received in that
view.
How do I generate "checked" HTML option using the builtin
ModelMultipleChoiceField for certain checkboxes? Is there a builtin
option that I  should set manually to cause the "checked" option to be
generated? Or do I have to iterate over these fields, match them with
data I have received, and generate the "checked" option myself, in the
template?

Thanks!

~G~

--

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




How do I tap into admin.py to generate data from models?

2009-11-29 Thread Joshua Kramer
Hello,

What document or example code should I consult to learn how to tap
into admin.py to output specific data based on a model?  For example,
if I have an application and a handful of models, if I do "admin.py
sqlall" then I get output that consists of SQL statements used to
generate the model in the database.  I would like to generate the
models in another syntax, specifically Protocol Buffers.  This is
related to a previous post:

http://groups.google.com/group/django-developers/browse_thread/thread...

I am currently investigating the code that creates SQL tables, so I
think I am on the right track to generate the data - but how do I hook
this into manage.py?

Thanks!
-J

--

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




App engine launcher on windows problem

2009-11-29 Thread knight
I'm trying to install app engine with django 1.1 on windows.

When launching the app engine I'm getting the following error:
http://slexy.org/view/s21oLrbkHh
The steps I do are:
1.) Create new app via launcher
2.) Copy my code (Which is empty django project)

My main.py code: http://slexy.org/view/s21oxoNqVv
I'm falling on line: "import django.db" which I can do successfully
from cmd. Do you have an idea what I'm doing wrong?

Regards, Arshavski Alexander.

--

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




Re: ModelMultipleChoiceField with checkboxes: How to generate the HTML "checked" option?

2009-11-29 Thread Nick Arnett
On Sat, Nov 28, 2009 at 3:05 PM, Gloria  wrote:

> Hi all,
> I've spent way too much time getting trying to get this widget to work
> the way I am envisioning.
> In the forms, I want to initialize it, but in the view I need to
> determine which boxes are checked.
> Has anyone done this without writing their own widget? It would be
> great to know how.
> Thank you in advance,
>

Rather than trying to do that on the client side (which is what I think
you're saying), have you considered just passing the required values to the
template as context variables?

Nick

--

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




Re: Difficulty using anchor tags in templates

2009-11-29 Thread rebus_
BTW here is an example:

When you click this link:
http://en.wikipedia.org/wiki/Fragment_identifier#Processing

your browser will open up
http://en.wikipedia.org/wiki/Fragment_identifier page and then scroll
down to the Processing title without wikipedia even knowing that you
specifically want to see that part of the page, it will just send you
the page and let your browser worry about scrolling.

Also i apologize, since English is not my native language i might have
trouble explaining some thing with it :)

Davor

--

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




Re: Difficulty using anchor tags in templates

2009-11-29 Thread rebus_
I have seem to overcomplicated and I hope i understand your question right :)

You just need to render the template with your titles and content (i
guess you call it resources).

If you have a link such as link anywhere
on your site, once you click on it you should return HttpResponse and
render your template with titles and content normally.

You don't need HttpResponseRedirect in resources view and you don't
need to do any special handling of fragment id in Django. It is done
by your client (browser).

so instead of

def resources(request):
   return HttpResponseRedirect('/resources/')

you would have something like:

def resources(request):
  articles = Context({'articles': Articles.objects.all()})
  return render_to_response('resources.html', articles)

If anywhere in your resources.html (once it's rendered) there is a
title or any other element which has id="title" your browser will
position that page on that element.

I suggest you read more on fragment identifiers.

http://en.wikipedia.org/wiki/Fragment_identifier

Davor

--

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




Re: Dynamicly preset forms in the admin interface

2009-11-29 Thread rebus_
2009/11/29 Kai Timmer :
> 2009/11/29 rebus_ :
>> Have you tried using fieldsets [1] in you ModelAdmin. Also you can
>> override save_model method on the ModelAdmin to set values for some
>> object attributes when the object is being saved [2].
>
> I don't see how I can use fieldsets to achieve this. I thought with
> the fieldsets I just tell django what forms to show in the interface,
> but not what to put in it.
> And when I overwrite the save_model method, there is no way to show
> the user what will end up in the database, right? So that is not the
> right way when I want to have the user to have the opportunity, to
> change the default data.
>
> Greets,
> --
> Kai Timmer | http://kaitimmer.de
> Email : em...@kaitimmer.de
> Jabber (Google Talk): k...@kait.de
>

Yes, fieldsets are used to decide what form fields to display and how
to lay them out on admin add/change views.
And yes, user would have no knowledge of what data is eventually
written in database at the time of object saving.

I must confess i haven't look into this up until now.

Seems that the add_view checks data passed through GET [1] (which is
of type QueryDict [2]) to see if any of the keys in GET correspond to
the attribute on Model, and if it finds any sets the value of that key
as initial value for the field in the admin form.

You can even set M2M fields this way by giving list of coma separated
PK's through GET for you M2M attribute.

So in your case, you can pass var though GET like so:

 /admin/app/article/add/?author=ante

and once it renders your author filed should contain word "ante".

But since you probably do not want to set your defaults directly
through URL you can wrap add_view in your ModelAdmin like this:

class ArticleAdmin(admin.ModelAdmin):
   def add_view(self, request, form_url='', extra_context=None):
  # GET is immutable QueryDict so we need to get a copy() as
explaind in docs
  request.GET = request.GET.copy()
  request.GET.update({'author':'ante'})
  return super(ArticleAdmin, self).add_view(request,
form_url=form_url, extra_context=extra_context)

When you refresh your article add view author field should contain
value of "ante".

Or if you want a full name of current user you could say:
request.GET.update({'author':request.user.get_full_name()})

I  imagine some of core devs or django gurus would maybe have better
ideas on how to do this (or can even tell you if this is documented
somewhere).

As far as readonly fields go i found snippet [3] but i haven't look at
it closely to tell you is it any good or not.
But if you set your fields read only how would you make them editable
if necessary? With JavaScript?

[1] 
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.GET
[2] 
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict
[3] http://www.djangosnippets.org/snippets/937/

Hope i helped this time :)

Davor

--

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




Re: Error: No module named polls

2009-11-29 Thread Vardhan Varma
did you named your project as 'mysite' and your app  as 'polls' ...
also make sure __init__.py exists inside directory polls (manage.py should
create that ).

hope that helps,

--Vardhan




On Sun, Nov 29, 2009 at 7:12 PM, Baba Samu wrote:

> Hi,
>
> Following the tutorial when i have "python manage.py sql polls" i get
> error message "No module named polls"
>
> I have modified settijng.py to.
>
> INSTALLED_APPS = (
>'django.contrib.auth',
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'mysite.polls'
> )
>
>
> any ideas?
>
> thanks,
> samu
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

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




Re: Dynamicly preset forms in the admin interface

2009-11-29 Thread Vardhan Varma
I do not know how to do this in admin,
 but in your own form do this
 peter = article( author = "Peter" )
 myform = TheFormClass ( instance =  peter )

hope that helps,


--Vardhan




On Sun, Nov 29, 2009 at 8:41 PM, Kai Timmer  wrote:

> 2009/11/29 rebus_ :
> > Have you tried using fieldsets [1] in you ModelAdmin. Also you can
> > override save_model method on the ModelAdmin to set values for some
> > object attributes when the object is being saved [2].
>
> I don't see how I can use fieldsets to achieve this. I thought with
> the fieldsets I just tell django what forms to show in the interface,
> but not what to put in it.
> And when I overwrite the save_model method, there is no way to show
> the user what will end up in the database, right? So that is not the
> right way when I want to have the user to have the opportunity, to
> change the default data.
>
> Greets,
> --
> Kai Timmer | http://kaitimmer.de
> Email : em...@kaitimmer.de
> Jabber (Google Talk): k...@kait.de
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

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




Re: Difficulty using anchor tags in templates

2009-11-29 Thread Andy
Hmm, still not clear.  My url is simply this:
(r'^resources/$', views.resources)

I have read that I need to use HttpResponseRedirect to make use of
#anchor tags.  Is this not the case?

Thanks for your help!


On Nov 29, 8:38 am, rebus_  wrote:
> 2009/11/29 Andy :
>
>
>
>
>
> > I have a model named Articles with title and content fields.  Each
> > page of my site should display a list of the titles, linked with
> > anchor tags to the corresponding area of the Resources page which
> > displays all the titles and content.  I am having trouble figuring out
> > how to pass the #title info.  I've read a previous post:http://
> > groups.google.com/group/django-users/browse_thread/thread/
> > bf5bae5b333aae/b8627d237d34fd69?lnk=gst&q=anchor+tag#b8627d237d34fd69,
> > but am still struggling.
>
> > Views(snippet):
> > articles = Context({'articles': Articles.objects.all()})
> > def index(request):
> >        return render_to_response('index.html', articles)
> > def resources(request):
> >        return HttpResponseRedirect('/resources/')
>
> > Base Template(snippet):
> >        
> >                Resources
> >                
> >                {% for articles in articles %}
> >                 > target="_blank">
> > {{ articles }}
> >        {% endfor %}
> >                
> >        
>
> > I am getting a 'too many redirect' error with this code.  Can anybody
> > help me with this?
>
> With assumption you have set your url like:
>
> url(r'^resources/$', 'resources',  name='resources')
>
> each time you open "resources" view you would get redirected to the
> "resources" view and you have endless loop, which browsers would
> terminate after certain number of repetitions.
>
> resources view should return html page with titles and content rather
> then redirect to it self.
>
> Basically, when you click on "/some/page/#fid", view which handles
> /some/page/ url should return HTML page, and if there is a fragment id
> ("#fid" in this case) in that page your browser should position your
> page on that fragment id (if possible).
>
> Hope i didn't overcomplicated this :)
>
> Davor

--

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




Re: Dynamicly preset forms in the admin interface

2009-11-29 Thread Kai Timmer
2009/11/29 rebus_ :
> Have you tried using fieldsets [1] in you ModelAdmin. Also you can
> override save_model method on the ModelAdmin to set values for some
> object attributes when the object is being saved [2].

I don't see how I can use fieldsets to achieve this. I thought with
the fieldsets I just tell django what forms to show in the interface,
but not what to put in it.
And when I overwrite the save_model method, there is no way to show
the user what will end up in the database, right? So that is not the
right way when I want to have the user to have the opportunity, to
change the default data.

Greets,
-- 
Kai Timmer | http://kaitimmer.de
Email : em...@kaitimmer.de
Jabber (Google Talk): k...@kait.de

--

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




Re: How to list all parents and their children if any?

2009-11-29 Thread Mario

Hi,

You mentioned that you could have used a m2m between Connector and
Cable, but it sounded that you opted out. I could be wrong, but to get
the desired report to display, I think you may need to revisit your
models.py and use the "_set" used in m2m relationships.


_mario


On Nov 28, 11:50 pm, adelaide_mike 
wrote:
> I have three models:
>
> class Connector(models.Model):
>     connectorname = models.CharField(max_length=32)
>
> class Cable(models.Model):
>     cablename = models.CharField(max_length=32)
>
> class Node(models.Model):
>     connector = models.ForeignKey(Connector)
>     cable = models.ForeignKey(Cable)
>     node_specific_data = models.CharField(max_length=32)
>
> I wish to make a report displaying all Connector names at least once,
> and the Cable name that the Node model relates them to.  If I did not
> need the nodespecificdata I could have used a many-to-many between
> Connector and Cable.  Sadly I do need it.
>
> A Connector may have any number of related nodes, including none.
>
> I need to obtain a report displaying all connectors at least once,
> with their related cablename(s), if any, shown (on additional rows if
> necessary).  Can I do this without resorting to raw SQL?
>
> Thanks (yet again)
>
> Mike

--

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




Re: Chart tool

2009-11-29 Thread Kevin Renskers
I am using the Google Visualization API myself, it's pretty nice. I
wrote a blog post with a little how to:
http://www.bolhoed.net/blog/using-the-google-visualization-api-in-django/
However, I also used FusionCharts in the past and that's got my vote
too :)

On Nov 25, 9:07 pm, "S.Selvam"  wrote:
> Hi all,
>
> This is my first post here andi  am new to django.
>
> I need to show some data as a chart.
>
> I would like to achieve a high quality rendering.
>
> Is reportlab or matplotlib enough ?
>
> I hope you can direct me on track.
>
> --
> Yours,
> S.Selvam
> Sent from Bangalore, KA, India

--

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




Re: Difficulty using anchor tags in templates

2009-11-29 Thread rebus_
2009/11/29 Andy :
> I have a model named Articles with title and content fields.  Each
> page of my site should display a list of the titles, linked with
> anchor tags to the corresponding area of the Resources page which
> displays all the titles and content.  I am having trouble figuring out
> how to pass the #title info.  I've read a previous post:http://
> groups.google.com/group/django-users/browse_thread/thread/
> bf5bae5b333aae/b8627d237d34fd69?lnk=gst&q=anchor+tag#b8627d237d34fd69,
> but am still struggling.
>
> Views(snippet):
> articles = Context({'articles': Articles.objects.all()})
> def index(request):
>        return render_to_response('index.html', articles)
> def resources(request):
>        return HttpResponseRedirect('/resources/')
>
> Base Template(snippet):
>        
>                Resources
>                
>                {% for articles in articles %}
>                
> {{ articles }}
>        {% endfor %}
>                
>        
>
> I am getting a 'too many redirect' error with this code.  Can anybody
> help me with this?
>

With assumption you have set your url like:

url(r'^resources/$', 'resources',  name='resources')

each time you open "resources" view you would get redirected to the
"resources" view and you have endless loop, which browsers would
terminate after certain number of repetitions.

resources view should return html page with titles and content rather
then redirect to it self.

Basically, when you click on "/some/page/#fid", view which handles
/some/page/ url should return HTML page, and if there is a fragment id
("#fid" in this case) in that page your browser should position your
page on that fragment id (if possible).

Hope i didn't overcomplicated this :)

Davor

--

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




Re: Dynamicly preset forms in the admin interface

2009-11-29 Thread rebus_
2009/11/29 Kai Timmer :
> Hello,
> I'm new to django, so this question may look a bit stupid, but I
> couldn't find the information in the documentation.
>
> I have a pretty simple model which looks like this:
> class article(models.Model):
>  headline = models.CharField(max_length=140)
>  newsentry = models.TextField()
>  pub_date = models.DateTimeField('date published', null=True,
> blank=True)
>  write_date = models.DateTimeField('started writing')
>  published = models.BooleanField()
>  author = models.CharField(max_length=20)
>
> What i want to do now, is that some of these fields are preset when a
> new article is written. Lets say a user named Peter is going to write
> a new article, then the author field should be preset to "Peter" and
> shouldn't be editable. Same thing for write_date, which should be set
> to the time Peter started to write this article. How do I do this?
>
> Greets,
> Kai
>
> --

Have you tried using fieldsets [1] in you ModelAdmin. Also you can
override save_model method on the ModelAdmin to set values for some
object attributes when the object is being saved [2].

[1] 
http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-form
[2] 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

Davor

--

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




Re: How to list all parents and their children if any?

2009-11-29 Thread adelaide_mike
Thanks Karen yet again.

Am I right in thinking that this cannot be a symetrical arrangement
ie:

connector can access values from cable(s)
and
cable can access values from connector(s)

It does not appear to be possible to put a ManyToManyField in both the
"parent' models, because one must be declared before the other, and
the other is therefore invalid at that time

Perhaps there is a work around?

Mike

On Nov 29, 2:56 pm, Karen Tracey  wrote:
> On Sat, Nov 28, 2009 at 11:50 PM, adelaide_mike 
>
>
> > wrote:
> > I have three models:
>
> > class Connector(models.Model):
> >    connectorname = models.CharField(max_length=32)
>
> > class Cable(models.Model):
> >    cablename = models.CharField(max_length=32)
>
> > class Node(models.Model):
> >    connector = models.ForeignKey(Connector)
> >    cable = models.ForeignKey(Cable)
> >    node_specific_data = models.CharField(max_length=32)
>
> > I wish to make a report displaying all Connector names at least once,
> > and the Cable name that the Node model relates them to.  If I did not
> > need the nodespecificdata I could have used a many-to-many between
> > Connector and Cable.  Sadly I do need it.
>
> The extra information doesn't prohibit use of ManyToMany, see:
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o...
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Error: No module named polls

2009-11-29 Thread Baba Samu
Hi,

Following the tutorial when i have "python manage.py sql polls" i get
error message "No module named polls"

I have modified settijng.py to.

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.polls'
)


any ideas?

thanks,
samu

--

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




Dynamicly preset forms in the admin interface

2009-11-29 Thread Kai Timmer
Hello,
I'm new to django, so this question may look a bit stupid, but I
couldn't find the information in the documentation.

I have a pretty simple model which looks like this:
class article(models.Model):
  headline = models.CharField(max_length=140)
  newsentry = models.TextField()
  pub_date = models.DateTimeField('date published', null=True,
blank=True)
  write_date = models.DateTimeField('started writing')
  published = models.BooleanField()
  author = models.CharField(max_length=20)

What i want to do now, is that some of these fields are preset when a
new article is written. Lets say a user named Peter is going to write
a new article, then the author field should be preset to "Peter" and
shouldn't be editable. Same thing for write_date, which should be set
to the time Peter started to write this article. How do I do this?

Greets,
Kai

--

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




Re: WebFaction warning

2009-11-29 Thread Atamert Ölçgen
On Saturday 28 November 2009 07:28:27 digicase wrote:
> I am sad to report this, as up until now I had complete faith and
> trust in them. That has been lost over the past few days. Support were
> not transparent, status updates rare and vague.
I have been following web44 issues from RSS and it sure has taken much longer 
than other instances. Sorry about what you've been through, I would gone mad 
if something like that had happened to me. I hope the issue gets resolved 
soon.

I am all for customers disclosing their experiences with brands. So, please 
people; don't try to shut people up when they say something negative. I think 
open source communities should be open to such discussions.

Having said that, I'm a webfactioner for some years and very happy with the 
service. Sure I had issues, but I have always found some real person to seek 
help on the other side. So my experience is actually the opposite of "not 
transparent". Big companies, small companies, they all make mistakes. Trouble 
begins when they start treating their customers like dirt. I bet we can find 
enough testimonials that WF is not (yet) one of them.


> Furthermore their daily backup of our home folder was corrupted, which
> is probably as much as a lesson to me as a bad mark for Webfaction.
This is a big issue. I hope they take appropriate action and fix this.

Again, I hope you get your server up and running in no time.


-- 
Saygılarımla,
Atamert Ölçgen

 -+-
 --+
 +++

www.muhuk.com
mu...@jabber.org

--

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




Difficulty using anchor tags in templates

2009-11-29 Thread Andy
I have a model named Articles with title and content fields.  Each
page of my site should display a list of the titles, linked with
anchor tags to the corresponding area of the Resources page which
displays all the titles and content.  I am having trouble figuring out
how to pass the #title info.  I've read a previous post:http://
groups.google.com/group/django-users/browse_thread/thread/
bf5bae5b333aae/b8627d237d34fd69?lnk=gst&q=anchor+tag#b8627d237d34fd69,
but am still struggling.

Views(snippet):
articles = Context({'articles': Articles.objects.all()})
def index(request):
return render_to_response('index.html', articles)
def resources(request):
return HttpResponseRedirect('/resources/')

Base Template(snippet):

Resources

{% for articles in articles %}

{{ articles }}
{% endfor %}



I am getting a 'too many redirect' error with this code.  Can anybody
help me with this?

--

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




Re: Chart tool

2009-11-29 Thread Tim Langeman
We're using AnyChart.  It is similar to Fusion Charts in that it is an
XML data source that is rendered on the client side with a Flash SWF.
   http://www.anychart.com

I don't think AnyChart has a free version, so you'll have to look into
the licensing arrangements to see if it is worth it for you.

We're using the scatter chart with my company to display microfinance
interest rate data.
   http://www.mftransparency.org/data/countries/ba/data/

-Tim Langeman
Akron, PA (USA)

On Nov 29, 4:31 am, John M  wrote:
> We started playing with FusionCharts, they have a free version which
> is pretty slick.  It's flash based, and not sure about the printing
> aspect yet.  It's generated with some XML and an SWF file.
>
> J
>
> On Nov 25, 12:07 pm, "S.Selvam"  wrote:
>
>
>
> > Hi all,
>
> > This is my first post here andi  am new to django.
>
> > I need to show some data as a chart.
>
> > I would like to achieve a high quality rendering.
>
> > Is reportlab or matplotlib enough ?
>
> > I hope you can direct me on track.
>
> > --
> > Yours,
> > S.Selvam
> > Sent from Bangalore, KA, India

--

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




Re: german umlaute on search querys

2009-11-29 Thread Hinnack
Hi Karen,

thanks for investigating...
I solved the problem.
There were 2 reasons:
- php code non passing correct encoded POST
- urllib.unquote_plus not working as expected

and not for last that the raw_post_data is not decoded and a POST var is...
(my blindness)

Thanks again for your help.

-- Hinnack

2009/11/26 Karen Tracey 

> On Thu, Nov 26, 2009 at 7:03 AM, Hinnack wrote:
>
>> Hi Karen,
>>
>> thanks again for your reply.
>> I use Aptana with pydev extension.
>> Debugging the app shows the following for search:
>> dict: {u'caption': u'f\\xfcr', u'showold': False}
>>
>>
> That's confusing to me, because other than having an extra \ (which could
> be an artifact of how it's being displayed), that looks like a
> correctly-built unicode object für.
>
> and for qs:
>> str: für
>> although it seems to be � instead of ASCII 252 - but this could be,
>> because I am sitting on a MAC
>> while debugging.
>>
>
> Using python manage.py shell might shed more light, I fear the tool here is
> assuming an incorrect bytestring encoding and getting in the way.
>
> I cannot recreate anything like what you are seeing.  I have a model Thing
> stored in a MySQL DB (using a utf-8 encoded table) with CharField name.
> There are two instances of this Thing in the DB that contain für in the
> name.  From a python manage.py shell, using Django 1.1.1:
>
> >>> from ttt.models import Thing
> >>> import django
> >>> django.get_version()
> '1.1.1'
> >>> ufur = u'f\u00fcr'
> >>> print ufur
> für
> >>> ufur
> u'f\xfcr'
> >>> ufur.encode('utf-8')
> 'f\xc3\xbcr'
> >>> ufur.encode('iso-8859-1')
> 'f\xfcr'
>
> small-u with umlaut is U+00FC, encoded in utf-8 that takes 2 bytes C3BC,
> encoded in iso-8859-1 it is the 1 byte FC.
>
> Filtering with icontains, using either the Unicode object or the utf-8
> encode bytestring version, works properly:
>
> >>> Thing.objects.filter(name__icontains=ufur)
> [,  bytestring>]
> >>> Thing.objects.filter(name__icontains=ufur.encode('utf-8'))
> [,  bytestring>]
>
> Attempting to filter with an iso-8859-1 encoded bytestring raises an error:
>
> >>> Thing.objects.filter(name__icontains=ufur.encode('iso-8859-1'))
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.5/site-packages/django/db/models/manager.py", line
> 129, in filter
> return self.get_query_set().filter(*args, **kwargs)
>   File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
> 498, in filter
> return self._filter_or_exclude(False, *args, **kwargs)
>   File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line
> 516, in _filter_or_exclude
> clone.query.add_q(Q(*args, **kwargs))
>   File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py",
> line 1675, in add_q
> can_reuse=used_aliases)
>   File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py",
> line 1614, in add_filter
> connector)
>   File "/usr/lib/python2.5/site-packages/django/db/models/sql/where.py",
> line 56, in add
> obj, params = obj.process(lookup_type, value)
>   File "/usr/lib/python2.5/site-packages/django/db/models/sql/where.py",
> line 269, in process
> params = self.field.get_db_prep_lookup(lookup_type, value)
>   File
> "/usr/lib/python2.5/site-packages/django/db/models/fields/__init__.py", line
> 214, in get_db_prep_lookup
> return ["%%%s%%" % connection.ops.prep_for_like_query(value)]
>   File "/usr/lib/python2.5/site-packages/django/db/backends/__init__.py",
> line 364, in prep_for_like_query
> return smart_unicode(x).replace("\\", "").replace("%",
> "\%").replace("_", "\_")
>   File "/usr/lib/python2.5/site-packages/django/utils/encoding.py", line
> 44, in smart_unicode
> return force_unicode(s, encoding, strings_only, errors)
>   File "/usr/lib/python2.5/site-packages/django/utils/encoding.py", line
> 92, in force_unicode
> raise DjangoUnicodeDecodeError(s, *e.args)
> DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position 1-2:
> unexpected end of data. You passed in 'f\xfcr' ()
>
> This is because Django assumes the bytestring is utf-8 encoded, and runs
> into trouble attempting to convert to unicode specifying utf-8 as the
> string's encoding, since it is not valid utf-8 data.
>
> The only way I have been able to recreate anything like what you are
> describing is to incorrectly construct the original unicode object from a
> utf-8 bytestring assuming a iso-8859-1 encoding:
>
> >>> badufur = ufur.encode('utf-8').decode('iso-8859-1')
> >>> badufur
> u'f\xc3\xbcr'
> >>> print badufur
> für
> >>> print badufur.encode('utf-8')
> für
> >>> print badufur.encode('iso-8859-1')
> für
>
> Using that unicode object doesn't produce any hits in the DB:
>
> >>> Thing.objects.filter(name__icontains=badufur)
> []
>
> But encoding it to iso-8859-1 does, because that has the effect of
> restoring the original utf-8 bytestring:
>
> >>> Thing.objects.filter(name__icontains=badufur.encode('iso-8859-1'))
> [,  bytestring>]
>
> Howev

django url and reverse

2009-11-29 Thread caliman
Hi!

In my project most of my views requires the user to be logged in but
in some i don't for example the login view wich only displays a login
form. When I'm going to the login form as a non logged in user I get
an error:
"Error was: 'AnonymousUser' object has no attribute 'get_profile'" The
error is thrown when I use django reverse or url (from template). It
seems as when it checks for urls in my urls.py it parses not only that
file to get the url it also tries to execute all views. Thats why I
got the error when it executes a view that requires login and therefor
uses my user.get_profile().

Anyone know how to solve this? I do wnat to use url and reverse even
for pages that doesn't require the user to be logged in.

Stefan

--

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




Re: View returns no queryset

2009-11-29 Thread Daniel Roseman
On Nov 28, 11:15 pm, "R. Gorman"  wrote:
> I've got a real stumper. Well, a stumper for me; I'm hoping someone
> has some insight. Here's the view I'm calling:
>

>
>     games = Game.objects.all()
>     return render_to_response('season_schedule.html',
> {games:"object_list"},context_instance = RequestContext(request))

If this is a direct cut and paste from your code, the problem is in
this bit: {games: "object_list"}
This creates a dictionary with a single entry, whose **name** is the
value of 'games', and the **value** is 'object_list'. I don't think
that's what you want. Put these the other way round.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: CSRF Flatpages

2009-11-29 Thread rebus_
2009/11/28 John Leith :
> I have a problem with the CSRF framework, and i'm just checking here
> to see if anyone else ran into this problem and hopefully found a
> solution. Here is my problem:
>
> I have a login form on the base template of my site. The home page is
> just a flatpage. My login processor is csrf protected. I have the
> middleware and the {% csrf_token %} is set in the template.
>
> The problem is that there is no output from the template tag, it
> dosen't contribute anything at all to the rendered HTML. So naturally,
> I can't login from the homepage.
>
> I poked around in the code, and i planning on digging some more.
> However, if someone else has encountered this, i sure would appreciate
> some guidance.
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

Flat pages are used to store plain HTML [1], you can't use filter nor
templatetags in them (perhaps you could with some weird middleware or
something but it would not be good solution).

Create custom HTML template for you login view, pass the template name
to your login url pattern (if you don't need custom view) and
everything should work out fine i think.

 url(r'^login/$', 'login',
{'template_name': 'registration/login.html'},
name='login'),

[1] 
http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#module-django.contrib.flatpages

--

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




Re: Chart tool

2009-11-29 Thread John M
We started playing with FusionCharts, they have a free version which
is pretty slick.  It's flash based, and not sure about the printing
aspect yet.  It's generated with some XML and an SWF file.

J

On Nov 25, 12:07 pm, "S.Selvam"  wrote:
> Hi all,
>
> This is my first post here andi  am new to django.
>
> I need to show some data as a chart.
>
> I would like to achieve a high quality rendering.
>
> Is reportlab or matplotlib enough ?
>
> I hope you can direct me on track.
>
> --
> Yours,
> S.Selvam
> Sent from Bangalore, KA, India

--

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




Re: Installation Problem on Mac OS Leopard

2009-11-29 Thread John M
Me too, I'm not having any issues.  I just installed on 10.6 by
downloading 1.1.1 and running the install command sudo python setup.py
install and no issues.  After install I run django-admin.py --version
and it shows 1.1.1

You'll need to give us more info to help.

Are you using sudo?  What version of OSX?  I wonder what version of
Python you have?  Maybe that's the issue?

HTH

John

On Nov 27, 1:15 pm, Christophe Pettus  wrote:
> On Nov 27, 2009, at 1:01 PM, Eric wrote:
>
> > Why doesn't
> > Mac have an easy way to install stuff.
>
> I think we'll need a bit more information about the problem you're  
> having; installing Django 1.1 on my Leopard MacBook Pro was entirely  
> painless.  What errors are you getting at which steps?
>
> --
> -- Christophe Pettus
>     x...@thebuild.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: View returns no queryset

2009-11-29 Thread John M
I suspect that the query isn't being executed, cause you're not
accessing any elements?

have you tried to print games and see what comes out?

passing {games:"object_list"} seems like it should make sense, but
since I'm not an expert on Python or django, I'd imagine that the
"object_list" isn't being hit, hence the no query.

Try the print, and then you'll know if it's a variable in your
template error or something.

Do you have the code that you used when you used a generic view?

HTH

J

On Nov 28, 3:15 pm, "R. Gorman"  wrote:
> I've got a real stumper. Well, a stumper for me; I'm hoping someone
> has some insight. Here's the view I'm calling:
>
> def season_schedule_month(request, league_slug, year, month):
>     """Given a league slug, retrieve the season's schedule
>     month by month.
>     return date_based.archive_month(
>         request,
>         year = year,
>         #month_format = "%m"
>         month = month,
>         date_field = 'date',
>         queryset = Game.season.schedule(league_slug),
>         template_name ='season_schedule.html')"""
>     #games = Game.season.schedule(league_slug).filter
> (date__month=month)
>     games = Game.objects.all()
>     return render_to_response('season_schedule.html',
> {games:"object_list"},context_instance = RequestContext(request))
>
> It was originally a generic view, but I've reduced it down to a simple
> all objects request because of the bug in my code I'm trying to figure
> out. So the generic view does not work either. The same query run in
> the Django shell produces something like 30 objects. This page is
> returned without any errors but also without any queryset. It doesn't
> even give an empty set of brackets, denoting an empty queryset. I've
> looked at the django debug-toolbar and it does not show the SQL query
> in the queries list, so it appears the query is not even run. Rest of
> the site, which often accesses the same model, runs fine. I have no
> idea why this simple query will not run correctly. It is code related
> because I've moved the code to a different server with a different
> setup and the problem follows.
>
> Anyone run into this before?

--

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