Re: filtering out entries that are already made

2010-01-27 Thread Kenneth Gonsalves
On Thursday 28 Jan 2010 12:47:39 pm Kenneth Gonsalves wrote:
> I have a model called Matchentry which has foreign keys to the Match model
>  and  the Player model. When making a new Matchentry, obviously the choices
>  have to be limited to the players who have not already been entered. I
>  used to do this manually using plain python, but do we have a queryset
>  that can do this?
> 
> to make it clear: select all players who are not entered in a specific
>  match.  Manually I would do:
> 
> get all the matchentries for a specfic tournament and use player_set.all()
>  to  get a list of already entered players. Then build the CHOICES list by
>  excluding all the already entered players.
> 
> a query like: Player.objects.exclude(all players in 
> matchentry.player_set.all())
> 

please ignore this mail - it is rubbish
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.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-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.



Support for MS SQL Databases

2010-01-27 Thread sridharpandu
By any chance does Django support MSSQL DB's. I have a query from a
prospective customer who would like to protect his current IT
investments.

Best regards

Sridhar

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



filtering out entries that are already made

2010-01-27 Thread Kenneth Gonsalves
hi,

I have a model called Matchentry which has foreign keys to the Match model and 
the Player model. When making a new Matchentry, obviously the choices have to 
be limited to the players who have not already been entered. I used to do this 
manually using plain python, but do we have a queryset that can do this? 

to make it clear: select all players who are not entered in a specific match. 
Manually I would do:

get all the matchentries for a specfic tournament and use player_set.all() to 
get a list of already entered players. Then build the CHOICES list by 
excluding all the already entered players.

a query like: Player.objects.exclude(all players in 
matchentry.player_set.all())


-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.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-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.



False negatives on model validation of CharField with choices

2010-01-27 Thread Thomas B. Higgins
I am writing to see if anyone thinks this is not a bug before creating
a new ticket. I have an app that runs as expected on Django 1.1.1. It
used to work on the development version, but a problem arose no later
than 1.2 alpha 1 SVN-12271, and perhaps much earlier.

Basically, the errors dictionary is wrong for every CharField with
choices in the model. My custom validation continues to work, except
when overridden by default validation. When my custom validation is
commented out, the picture becomes clearer:

1)  An error "Value u"A325" is not a valid choice" is reported for a
select field with no possibility of selecting a blank when any of the
four available choices is selected. Elimination of the "blank" line is
handled as described on 11/07/07 by semenov at 
http://code.djangoproject.com/ticket/4653
using a combination of an explicit blank=False and a declared default
value. This is baffling. I cannot conceive of a reason for an error in
this case.

2) An error of "This field cannot be blank" is reported for fields
with a default named in the model, such as:

stiff_pl_grade= models.CharField(max_length=8, choices=PL_grades,
blank=False, default="A36",
help_text="Stiffener PL grade")

It is my understanding that if a default is supplied, it should not be
necessary to fill the field, even if blank=False.

FloatFields with choices and IntegerFields with choices continue to
behave as expected.

It seems clear that when the is_valid() method is run on the form,
something bad is happening to CharFields with choices, and this type
of field only, and perfectly valid string selections or string
defaults are being reported as invalid, probably by automatic model
validation.

My code works fine under version 1.1.1 and I see nothing in the
development documentation to explain this odd new behavior.

Any thoughts?

-- 
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: URL design - why the trailing slash?

2010-01-27 Thread Graham Dumpleton


On Jan 28, 11:54 am, Brett Thomas  wrote:
> Most of the URLConf examples I run across use a trailing slash on all 
> URLs:www.example.com/profile/
>
> I'm not sure why, but I don't like this. I think it looks nicer 
> without:www.example.com/profile
>
> Are there any performance or security reasons to use the trailing slash in
> Django? Seems like there could be some quirk with regular expressions that
> I'm not thinking of...

If you don't have a trailing slash for something which is an internal
node, ie., can have child pages, and you use a relative URL rather
than absolute URL, then the relative URL will be resolved incorrectly
by the browser.

For example, if at '/some/path/' and returned HTML uses 'child.html',
then browser will resolve it as:

  /some/path/child.html

if accessed as '/some/path' and returned HTML uses 'child,html', then
browser will resolve it as:

  /some/child.html

which isn't want you want.

So, you use trailing slash if you want relative URLs in responses.

Either way, you should use one of the other and not allow both at the
same time. That is '/some/path/' and '/some/path' should not both
work. If you do allow both, then search engines will have multiple
entries for same resource. Also may stuff up caching systems or at
least reduce their efficiency as will keep multiple copies.

Graham

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

2010-01-27 Thread chiranjeevi muttoju
Hi daniel,
Thanks for ur reply. I am viewing that page through the facebook only. but i
cont able to work with the FBML tags. Is there an initial setup to use the
FBML tags. Please help me if u know.
Thank you.

On Thu, Jan 28, 2010 at 3:08 AM, Daniel Roseman wrote:

> On Jan 27, 9:15 pm, "chiranjeevi.muttoju" 
> wrote:
> > Hi
> >   in my application the FBML tags are not working properly.. could any
> > one of you please help me if you know what the problem might be..
> >
> > thank you.
> > --chiranjeevi.
>
> Yes, your problem is on line 5.
>
> OK, I'll get my crystal ball out. Since you mention FBML, I'll assume
> you're doing a Facebook app. FBML is only processed when the
> application is viewed through Facebook itself. If you're viewing it
> locally, it won't work.
> --
> 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.
>
>


-- 
▒▒�...@g@d...@◄▒▒

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



Session Management

2010-01-27 Thread Bhaskar Gara
Hi,

Right now I am tracking my subcriber session,  I have a new
requirement.  From our website, the subcriber can go to different
website and take the exam. Once he finish that exam, I need to send a
request to their database to get the result of that exam.

How can I track the second website activities (start and end). Do I
need to create one more session to track that ?  Is it possible
Session inside Session.


Thank you
Bhaskar

-- 
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: URL design - why the trailing slash?

2010-01-27 Thread Eugene Wee
Hi,

On Thu, Jan 28, 2010 at 8:54 AM, Brett Thomas  wrote:
> Most of the URLConf examples I run across use a trailing slash on all URLs:
> www.example.com/profile/
>
> I'm not sure why, but I don't like this. I think it looks nicer without:
> www.example.com/profile

I believe that it is just a matter of personal preference: some people
like to always have a slash appended (or never appended) for
consistency. I prefer to append a slash when the page is some kind of
category, but leave it out when it is a "leaf node". (I noticed that
this is what the W3C website does.)

> Are there any performance or security reasons to use the trailing slash in
> Django? Seems like there could be some quirk with regular expressions that
> I'm not thinking of...

I do not know about performance, but I doubt there is a security
issue, otherwise it would not have made sense to make the APPEND_SLASH
setting behave the way it does, i.e., a slash is not appended if the
initial URL (without a trailing slash) can be found in the URLconf.

Regards,
Eugene Wee

-- 
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: 1.2 alpha, multiple databases, and raw SQL

2010-01-27 Thread Russell Keith-Magee
On Thu, Jan 28, 2010 at 10:41 AM, Chris Curvey  wrote:
> Is there a way to use raw SQL with multiple databases?  I thought it
> might be something like:
>
> from django.db import connection
> cursor = connection.cursor(using="mydb")
>
> but that complains about an unexpected keyword arg.

It is possible, but not like that.

There are a couple of ways to handle raw SQL over multiple databases,
depending on exactly what you want to do.

If you want to do a SELECT on a specific model, but with some
eccentric FROM/WHERE/HAVING clause that Django doesn't support, you
can use the new raw query method:

Author.objects.raw('SELECT id, name FROM library_authors WHERE ')

To make this a query on a different database:

Author.objects.db_manager('mydb').raw('SELECT id, name FROM
library_authors WHERE ')

The db_manager() clause gives you a version of the objects manager
that has been forced to use the 'mydb' database. Every manager
provides a raw() method that allows you to call raw sql, and return
model objects. So - this query will run your raw SQL on the mydb
database.

If you have a database router installed, you may not need the
db_manager() query. The raw() query will interrogate the master router
to find the appropriate read database; if your router is set up to
direct 'Author' read queries to 'mydb', the original
Author.objects.raw() query will operate on the mydb database
automagically.

If you want to do an UPDATE, INSERT, or some other SQL query, you need
to fall back to using a cursor as before. To access a multi-db cursor,
we haven't changed the connection interface - we've changed the way
you get a connection.

from django.db import connections

cursor = connections['mydb'].cursor()
cursor.execute('INSERT ')

That is, the 'db.connection' object has been replaced with an index
called 'db.connections', keyed by database alias. Each of those
connections behaves as the single connection did in 1.1.

The old 'db.connection' object has been retained for backwards
compatibility, but it is assumed to be no more than an alias for:

connections['default']

I hope that clarifies things.

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.



1.2 alpha, multiple databases, and raw SQL

2010-01-27 Thread Chris Curvey
Is there a way to use raw SQL with multiple databases?  I thought it
might be something like:

from django.db import connection
cursor = connection.cursor(using="mydb")

but that complains about an unexpected keyword arg.

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



URL design - why the trailing slash?

2010-01-27 Thread Brett Thomas
Most of the URLConf examples I run across use a trailing slash on all URLs:
www.example.com/profile/

I'm not sure why, but I don't like this. I think it looks nicer without:
www.example.com/profile

Are there any performance or security reasons to use the trailing slash in
Django? Seems like there could be some quirk with regular expressions that
I'm not thinking of...

Thanks --
Brett

-- 
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: Reasons why syncdb ignores an application?

2010-01-27 Thread mtnpaul
In manage.py you could add

sys.path.insert(0, "/path/to/web")

Just before the  if __name__="__main__":   line

You will also need to handle this in your wsgi file for deployment.

Are you using "South"? If so, new tables for something you have
migrated will not be built by syncdb.



On Jan 27, 11:54 am, phoebebright  wrote:
> I cannot find the reason why syncdb will not create tables from a
> models.py.
>
> It is quite happy to create the auth tables and ones from an external
> app that is included in INSTALLED_APPS but it won't build the tables
> from my 'web' folder.
>
> I can put a print statement in the web.models.py and it appears.  It
> is clearly parsing all the models, because if I put a foreignkey to a
> model which doesn't exist, it complains until I fix the error, but it
> won't build the tables.  I do a syncdb and nothing happens and nothing
> is displayed.
>
> Have tried running it with verbosity 2 and this folder is never
> referred to.
>
> Have included 'from web.models import *' in urls.py and admin.py for
> luck.
>
> Have tried copying the web folder to another name and putting that
> name in the INSTALLED_APPS.
>
> The only other symptom is that if I do  'python manage.py sql web'  I
> get the error
> Error: App with label web could not be found. Are you sure your
> INSTALLED_APPS setting is correct?
>
> Here is my INSTALLED_APPS:
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.admin',
>     'web',
>     'lifestream',
> )
>
> I have no idea what to try next!!

-- 
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: ANN - django-test-extensions now provides assert_xml(xml, xpath)

2010-01-27 Thread Phlip
> The second line uses XPath notation to assert that the report's first
>  contains a  which contains exactly 30  rows.

Forgot to mention: We are doing this because wkhtmltopdf apparently
cannot respect  tags when it paginates tables for us, so we
must do it the old fashioned way.

Below my sig is a link to a book on view testing w/o screen scraping,
for anyone who wants to follow up on these theories. Lots of wicked
HTML (and XPath) in it, but no Django! C-:

--
  Phlip
  http://zeroplayer.com/tfui/TestFirstUserInterfaces.pdf

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



ANN - django-test-extensions now provides assert_xml(xml, xpath)

2010-01-27 Thread Phlip
Djangoists:

For every system I use, I invent a version of assert_xml(). (Sometimes
I call it assert_html(), or assert_xpath(), or assert_xhtml(),
depending on the context.)

For Django, it's assert_xml(), available in the current django-test-
extensions. Get it with this malarkey:

sudo pip install -e git+git://github.com/garethr/django-test-
extensions.git#egg=test_extensions

The following is an exemplary example using it to test an HTML report,
without testing the raw  mechanics, and without accidentally
testing the report's structure. You might change unrelated details in
the report, and this test should not break. A test case that used
assert_regex_contains() might trip over incidental details, because
only insanely complex regices can parse XML accurately. And developer
tests should not be insanely complex.

html = _produce_report(data, 30)
self.assert_xml(html, '//table[ position() = 1 and count(tbody/
tr) = 30 ]')
self.assert_xml(html, '//table[ 2 ]')

The first line builds a report, and paginates it into pages of 30
lines each.

The second line uses XPath notation to assert that the report's first
 contains a  which contains exactly 30  rows.

The third line asserts that there is a second   in the report -
the paginated one. Asserting that it is not simply an empty 
element is left as an exercise for the reader.

assert_xml() returns an lxml etree node, and can optionally accept one
for its first argument. If we upgrade my test to follow the guideline
"neither test cases nor assertions should say /and/", we can also run
the assertions like this:

table = self.assert_xml(html, '//table[ 1 ]')
self.assert_xml(table, 'tbody[ count(tr) = 30 ]')

The library also contains deny_xml(), to trivially detect that a given
HTML string or element does not contain a given XPath. Tip: This XPath
should be very wide, because a narrow one might pass similar HTML that
does not trigger its threshold. In developer testing, assertions
should be narrow and denials should be wide.

Django cultists should test their web pages with client.get(), then
drop their response.content strings into assert_xml(), to spot check
that their templates populated the correct data values. These "view
tests" are orders of magnitude faster and more convenient than, say,
Selenium tests.

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand

-- 
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: "Pro Django" book still up to date

2010-01-27 Thread Russell Keith-Magee
On Thu, Jan 28, 2010 at 1:07 AM, thanos  wrote:
> It's useless. The "The definitive guide to Django" by Holovaty and
> Kaplan-moss is okay, but the Pro version is really just a waste of
> paper and time.

Everyone is entitled to an opinion, but I must say my opinion is the
exact opposite. Yes, Pro Django is written for Django 1.0. Yes, this
means that the book doesn't cover some of the more recent features of
Django 1.1 and 1.2. That doesn't mean the book is useless IMHO -
Django's backwards compatibility guarantees mean that old features
still work - there is just a better way sometimes.

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.



Re: "Pro Django" book still up to date

2010-01-27 Thread Russell Keith-Magee
On Thu, Jan 28, 2010 at 6:23 AM, FxFocus  wrote:
> On Jan 27, 4:55 pm, Achim Domma  wrote:
>> Hi,
>>
>> I'm interested in buying the "Pro Django" book. I could not find any
>> hint about what version it's written for. As it covers mostly
>> internals and the ideas behind Django, it should not be outdated as
>> quickly as other books. Has anybody read that book and can give some
>> feedback about how useful it is for the current version of Django?
>>
>> cheers,
>> Achim
>
> You can download a free pdf version for evaluation here...
>
> http://www.freebookspot.in/Books-Pro%20Django.htm
>
> I don't know why it's free but I assume the site is legal as I got the
> link from a respectable paper magazine article.

I won't speak for Marty or APress, but I *severely* doubt that this is
a legitimate site. A site with really bad page layout, sharing files
on RapidShare, that passes PDFs through a link removal service doesn't
say "legitimate" to me.

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.



Re: Is it possible to 'order' the left side of a filter_horizontal?

2010-01-27 Thread SeanSF
I just had the same question, and the meta 'ordering' did the trick.
Thanks Reed and Tim!

On Nov 30 2009, 8:22 am, rc  wrote:
> Tim,
>
> The ordering meta option on my model did the trick. Thanks for the
> solution.
>
> Reed
>
> On Nov 25, 1:50 pm, Tim Valenta  wrote:
>
>
>
> > Well, you've got a couple of options.  One is easiest and most
> > straightforward, but could impact performance.  The second is a little
> > bit more work, but would limit the ordering to only taking effect on
> > that one form.
>
> > The first way is to use the Meta option `ordering = ('fieldname',)`,
> > as described 
> > here:http://docs.djangoproject.com/en/dev/ref/models/options/#ordering
>
> > Bare in mind that this will passively affect ALL queries you do to
> > that model's objects, unless you specifically tell it not to order
> > during the query.  If you think that you'll *always* want that sort
> > order to take effect, then this is the preferred method of
> > accomplishing that.
>
> > The second way is to intercept the form's queryset powering the
> > widget.  If you're not using Form objects with your admin (ie, you're
> > just specifying 'fields' or 'fieldsets' on your ModelAdmin), then
> > you'll have to take a quick sidequest:
>
> > Create a class somewhere (preferably in your app's directory, in a
> > "forms.py" file or something obvious) like so:
>
> >     from django import forms
> >     from models import MyModel
> >     class MyModelForm(forms.ModelForm):
> >         class Meta:
> >             model = MyModel
> >         def __init__(self, *args, **kwargs):
> >             forms.ModelForm.__init__(self, *args, **kwargs)
> >             self.fields['myfieldname'].queryset =
> > MyModel.objects.order_by('custom_sort_field_name')
>
> > And then back in your ModelAdmin, add this attribute to the class:
>
> >     # ...
> >     from forms import MyModelForm
> >     form = MyModelForm
>
> > This will cause the admin to use *your* form instead of the default.
> > What I've done is created a form which simply hijacks the queryset on
> > 'myfieldname' (the field you're trying to sort), and alters it before
> > the widget has a chance to render itself.
>
> > Both methods are effective, but be sure to consider my initial
> > statement, about performance impact.  Pick the method that strikes the
> > balance in your mind between performance and practicality.
>
> > Hope that helps!
>
> > On Nov 25, 1:06 pm, rc  wrote:
>
> > > I have configured a modeladmin which uses thefilter_horizontal
> > > feature. I would like to be able to order left side of this feature by
> > > name instead of the default (which I believe is by id). Is this
> > > possible? I see how to use "ordering" in the display for change lists,
> > > but not sure how to apply that to the 'left' side data of the
> > >filter_horizontal.

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



Kinterbasd error

2010-01-27 Thread Etratch
Hello everybody, I have a huge problem and Google has not helped me
solution : (
Come to my problem:
I have a web server configured with ModPython for 2 websites
those that connect to a firebird database - "2 is
connect the same database "
The problem is that sometimes I get the following error

"(0L, 'The concurrency level cannot be changed once it has been set.
Use kinterbasdb.init(concurrency_level=?) to set the concurrency level
legally.')"

Ja researched a lot on the Internet and the solution would be to use
the following
command:
kinterbasdb.init (type_conv = 200, concurrency_level = 2)
But the problem continues and I have no more idea how to solve.

If someone has gone through something similar or have some experience
with
the kinterbasdb and can help me ...

thanks for help


-- 
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: "Pro Django" book still up to date

2010-01-27 Thread FxFocus
On Jan 27, 4:55 pm, Achim Domma  wrote:
> Hi,
>
> I'm interested in buying the "Pro Django" book. I could not find any
> hint about what version it's written for. As it covers mostly
> internals and the ideas behind Django, it should not be outdated as
> quickly as other books. Has anybody read that book and can give some
> feedback about how useful it is for the current version of Django?
>
> cheers,
> Achim

You can download a free pdf version for evaluation here...

http://www.freebookspot.in/Books-Pro%20Django.htm

I don't know why it's free but I assume the site is legal as I got the
link from a respectable paper magazine article.

-- 
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: Python app Installers

2010-01-27 Thread Atamert Ölçgen
On Wednesday 27 January 2010 22:34:19 Kenny Meyer wrote:
> Have a look at python-setuptools.
> 
> May fit your needs.
> 

http://packages.python.org/distribute/

-- 
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: Reasons why syncdb ignores an application?

2010-01-27 Thread Kenneth Gonsalves
On Thursday 28 Jan 2010 3:10:32 am phoebebright wrote:
> What is going on?!
> 

in shell try from yourapp.web.views import *
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.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-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.



Dealing with polyhierarchical data

2010-01-27 Thread Olivier Guilyardi
Hi,

I'm working with a polyhierarchical thesaurus, and trying to handle that in
Django. By polyhierarchical, I mean : nodes can have both multiple parents and
children.

Actually, this is a geographical thesaurus, and yes a location can have multiple
parents (being across countries, etc..).

I have read about the Nested set paradigm [1], and would love to use that, maybe
through django-mptt or django-treebeard. But unless someone shows me how, nested
sets aren't suitable for polyhierarchical data.

Currently I have a simple recursive many-to-many mapping. This allows to
establish the poly-relations, but is completely unusable for real use cases.

For instance, I have a table of "items", with a "location" field which points to
a location in the thesaurus.

Now I need to list all items which are located in a given country.

I just can't filter by country, there's no such field in the items table. And a
location can be of any level of precision, such as country, region, city,
village, etc..

The nested set would be perfect for this, but apparently can't handle multiple
parents.

Do you see a fast and elegant way to handle this ?

[1] http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

-- 
  Olivier

-- 
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: Why does admin fail on one project and not another?

2010-01-27 Thread grahamu
Two additional notes for this issue:
1. Clicking on _any_ model in the admin causes the same TypeError.
2. Clicking on "+Add" in admin for the User model yields a blank form!
Clicking on "+Add" for any other model shows a valid form.

On Jan 27, 3:08 pm, grahamu  wrote:
> I'm having a problem with django admin working for one local project
> and not another. Both use the same version of Django (SVN-12311). Both
> have very similar settings.py files.
>
> The issue appears when I click on an app model class name in the root
> admin list (at "/admin/"). In this case I was trying to view "Cam"
> instances from the "cam" application. I believe admin is trying to
> show a list of "Cam" instances, but instead I get an error:
>
>   "Exception Value: changelist_view() takes at least 2 arguments (1
> given)"
>
> Now I'm pretty sure there isn't a problem with Django here, but there
> is also precious little to guide me in my search for where my code
> goes wrong. Can anyone with similar experience provide some advice?
> Thanks!
>
> Graham
>
> From the traceback:
>
> Environment:
>
> Request Method: GET
> Request URL:http://localhost:8000/admin/cam/cam/
> Django Version: 1.2 alpha 1 SVN-12311
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'django.contrib.admindocs',
>  'django.contrib.markup',
>  'django.contrib.humanize',
>  'django.contrib.comments',
>  'django_extensions',
>  'django.contrib.flatpages',
>  'mobileadmin',
>  'registration',
>  'serviceclient',
>  'scoresys',
>  'south',
>  'home',
>  'weatherstation',
>  'weather',
>  'food',
>  'blog',
>  'cam',
>  'miniblog',
>  'grill',
>  'fantasy']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.middleware.doc.XViewMiddleware',
>  'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
>
> Traceback:
> File "c:\django\trunk\django\core\handlers\base.py" in get_response
>   101.                     response = callback(request,
> *callback_args, **callback_kwargs)
> File "c:\django\trunk\django\contrib\admin\options.py" in wrapper
>   238.                 return self.admin_site.admin_view(view)(*args,
> **kwargs)
> File "c:\django\trunk\django\utils\decorators.py" in __call__
>   36.         return self.decorator(self.func)(*args, **kwargs)
> File "c:\django\trunk\django\utils\decorators.py" in _wrapped_view
>   86.                     response = view_func(request, *args,
> **kwargs)
>
> Exception Type: TypeError at /admin/cam/cam/
> Exception Value: changelist_view() takes at least 2 arguments (1
> given)

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



Why does admin fail on one project and not another?

2010-01-27 Thread grahamu
I'm having a problem with django admin working for one local project
and not another. Both use the same version of Django (SVN-12311). Both
have very similar settings.py files.

The issue appears when I click on an app model class name in the root
admin list (at "/admin/"). In this case I was trying to view "Cam"
instances from the "cam" application. I believe admin is trying to
show a list of "Cam" instances, but instead I get an error:

  "Exception Value: changelist_view() takes at least 2 arguments (1
given)"

Now I'm pretty sure there isn't a problem with Django here, but there
is also precious little to guide me in my search for where my code
goes wrong. Can anyone with similar experience provide some advice?
Thanks!

Graham


>From the traceback:

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/cam/cam/
Django Version: 1.2 alpha 1 SVN-12311
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.markup',
 'django.contrib.humanize',
 'django.contrib.comments',
 'django_extensions',
 'django.contrib.flatpages',
 'mobileadmin',
 'registration',
 'serviceclient',
 'scoresys',
 'south',
 'home',
 'weatherstation',
 'weather',
 'food',
 'blog',
 'cam',
 'miniblog',
 'grill',
 'fantasy']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')


Traceback:
File "c:\django\trunk\django\core\handlers\base.py" in get_response
  101. response = callback(request,
*callback_args, **callback_kwargs)
File "c:\django\trunk\django\contrib\admin\options.py" in wrapper
  238. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "c:\django\trunk\django\utils\decorators.py" in __call__
  36. return self.decorator(self.func)(*args, **kwargs)
File "c:\django\trunk\django\utils\decorators.py" in _wrapped_view
  86. response = view_func(request, *args,
**kwargs)

Exception Type: TypeError at /admin/cam/cam/
Exception Value: changelist_view() takes at least 2 arguments (1
given)

-- 
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: Reasons why syncdb ignores an application?

2010-01-27 Thread Daniel Roseman
On Jan 27, 6:54 pm, phoebebright  wrote:
> I cannot find the reason why syncdb will not create tables from a
> models.py.
>
> It is quite happy to create the auth tables and ones from an external
> app that is included in INSTALLED_APPS but it won't build the tables
> from my 'web' folder.
>
> I can put a print statement in the web.models.py and it appears.  It
> is clearly parsing all the models, because if I put a foreignkey to a
> model which doesn't exist, it complains until I fix the error, but it
> won't build the tables.  I do a syncdb and nothing happens and nothing
> is displayed.
>
> Have tried running it with verbosity 2 and this folder is never
> referred to.
>
> Have included 'from web.models import *' in urls.py and admin.py for
> luck.
>
> Have tried copying the web folder to another name and putting that
> name in the INSTALLED_APPS.
>
> The only other symptom is that if I do  'python manage.py sql web'  I
> get the error
> Error: App with label web could not be found. Are you sure your
> INSTALLED_APPS setting is correct?
>
> Here is my INSTALLED_APPS:
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.admin',
>     'web',
>     'lifestream',
> )
>
> I have no idea what to try next!!

The only thing I can think of it that there is no __init__.py in the
'web' directory.
--
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: Reasons why syncdb ignores an application?

2010-01-27 Thread phoebebright
Malcolm,

Thanks for your reply. Path does not include web:

 '/Users/phoebebr/Development/tinyhq',
 '/Users/phoebebr/Development/tinyhq/libs',
 '/Users/phoebebr/Development/tinyhq',
 '/Users/phoebebr/Development/tinyhq/libs',
 '/Users/phoebebr/Development/tinyhq',


but if I do import web I don't get any error.
Tried adding a path directly at the top of settings so I get

 '/Users/phoebebr/Development/tinyhq',
 '/Users/phoebebr/Development/tinyhq/web',
 '/Users/phoebebr/Development/tinyhq/libs',
 '/Users/phoebebr/Development/tinyhq',
 '/Users/phoebebr/Development/tinyhq/web',
 '/Users/phoebebr/Development/tinyhq/libs',
 '/Users/phoebebr/Development/tinyhq',

but symptoms remain the same.

What is going on?!


On Jan 27, 7:23 pm, Malcolm Box  wrote:
> On Wed, Jan 27, 2010 at 6:54 PM, phoebebright 
> wrote:
>
>
>
>
>
> > I cannot find the reason why syncdb will not create tables from a
> > models.py.
>
> > It is quite happy to create the auth tables and ones from an external
> > app that is included in INSTALLED_APPS but it won't build the tables
> > from my 'web' folder.
>
> > I can put a print statement in the web.models.py and it appears.  It
> > is clearly parsing all the models, because if I put a foreignkey to a
> > model which doesn't exist, it complains until I fix the error, but it
> > won't build the tables.  I do a syncdb and nothing happens and nothing
> > is displayed.
>
> > Have included 'from web.models import *' in urls.py and admin.py for
> > luck.
>
> > This would explain the print statement appearing.
> > Have tried copying the web folder to another name and putting that
> > name in the INSTALLED_APPS.
>
> > The only other symptom is that if I do  'python manage.py sql web'  I
> > get the error
> > Error: App with label web could not be found. Are you sure your
> > INSTALLED_APPS setting is correct?
>
> What is your python path?  Do manage.py shell
>
> >>> import sys
> >>> sys.path
>
> Then try
>
> >>> import web
>
> My guess is that for some reason your python path doesn't include the web
> directory.
>
> The only other thing I can think of is some import error in your app that's
> silently failing on syncdb - the "import web" test above should spot that.
>
> Cheers,
>
> Malcolm

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

2010-01-27 Thread Daniel Roseman
On Jan 27, 9:15 pm, "chiranjeevi.muttoju" 
wrote:
> Hi
>   in my application the FBML tags are not working properly.. could any
> one of you please help me if you know what the problem might be..
>
> thank you.
> --chiranjeevi.

Yes, your problem is on line 5.

OK, I'll get my crystal ball out. Since you mention FBML, I'll assume
you're doing a Facebook app. FBML is only processed when the
application is viewed through Facebook itself. If you're viewing it
locally, it won't work.
--
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: Updating a user/profile model object

2010-01-27 Thread Daniel Roseman
On Jan 27, 7:42 pm, JonRob  wrote:
> Hi,
>
> I'm just starting out learning Django, trying to cut my teeth by
> working on a simple website that involves a user profile.
>
> I've created a ModelForm of the profile model, that instances the
> profile of the logged in user, which I then want the user to be able
> to update so that they can update their profile information. When I
> hit the update button, however, I get a validation error pointing at
> the ForeignKey field which links the profile to the User model.
>
> I think the problem is that form.save() is trying to insert another
> record, rather than update the current, probably related to the
> primary key being automatically incremented, but I can't figure out
> how to fix it. I was hoping somebody here might be able to point me in
> the right direction.
>
> Relevant code snippets are below:
>
> 
>
> #models.py
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.forms import ModelForm
>
> class Organisation(models.Model):
>     first_name = models.CharField(max_length=50)
>     last_name = models.CharField(max_length=50)
>     email = models.EmailField(max_length=50)
>     organisation_name = models.CharField(max_length=50)
>     club_name = models.CharField(max_length=50)
>     paypal_address = models.EmailField(max_length=50)
>     phone_number = models.IntegerField()
>     coach_company = models.CharField(max_length=50)
>     user = models.ForeignKey(User, unique=True, primary_key=True)
>
> class OrganisationForm(ModelForm):
>     class Meta:
>         model = Organisation
>
> #views.py
>
> from django.http import HttpResponse, HttpResponseRedirect
> from django.contrib.auth.models import User
> from django.template import Context, loader
> from FanTran.organisations.models import OrganisationForm
>
> def profile(request):
>     if request.user.is_authenticated():
>
>         organisation = request.user.get_profile()
>         profile_form = OrganisationForm(instance=organisation)
>
>         profile = request.user.get_profile()
>         t = loader.get_template('organisations/profile.html')
>         c = Context ({
>             'profile_form':profile_form,
>             'profile':profile,
>         })
>         return HttpResponse(t.render(c))
>     else:
>         return HttpResponse('Error: Not a valid user')
>
> def profile_update(request):
>     if request.user.is_authenticated():
>         if request.method == 'POST':
>             form = OrganisationForm(request.POST)
>             if form.is_valid():
>                 form.save()
>                 return HttpResponseRedirect('accounts/profile/')
>             else:
>                 return HttpResponse(form.errors)
>     else:
>         return HttpResponseRedirect('/login/')
>
> ---
>
> Thanks in advance,
>
> Jon

You're posting your update to a different view from the one that
initially displays the form. The usual way to do this is to have the
form post back to the same view, but have an 'if request.POST' to
branch the execution. The main forms documentation explains the
standard flow.

The main problem, though, is that you're not passing the instance into
the form when you instantiate on post, so as you say the form creates
a new instance. You just need to get the profile (that's where it
makes sense to use the same view for display and post) and pass it in
just as you do in the other view:
form = OrganisationForm(request.POST, instance=organisation)

Also, no doubt you recognise this, but if the form produces errors,
your view will display them, but not re-display the form to allow the
user to correct and resubmit. Once again, that's where using the same
view for display and post makes sense.
--
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.



FBML not working

2010-01-27 Thread chiranjeevi.muttoju
Hi
  in my application the FBML tags are not working properly.. could any
one of you please help me if you know what the problem might be..

thank you.
--chiranjeevi.

-- 
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: Python app Installers

2010-01-27 Thread Kenny Meyer
zweb (traderash...@gmail.com) wrote:
> What is the best way to build installer for python/django based
> software product ?
> Like in Microsoft world you can have .exe and installshield?
> 
> I need to way which can guide user to setup database, run DB script,
> set up parameters and guide him through installation. Also want to
> give the option to do full install or apply only a patch/upgrade.

Have a look at python-setuptools.

May fit your needs.

-- 


signature.asc
Description: Digital signature


Re: Models, forms and inlineformset

2010-01-27 Thread Stefan Nitsche
On Wed, Jan 27, 2010 at 14:04, andreas schmid  wrote:

> is this an add or an edit form? or both?
>
> i have a similar inlineformset and i need to loop over the inline
> objects to set the foreignkey to the parent object like:
>
>if form.is_valid() and formset.is_valid(): # All validation rules pass
>new_idea = form.save(commit=False)
>new_idea.author = request.user
>new_idea = form.save()
>formset_models = formset.save(commit=False)
>for f in formset_models:
>f.idea = new_idea
>f.save()
>return HttpResponseRedirect(new_idea.get_absolute_url())
>
>
> im actually experiencing problems with the edit form where i can get the
> values displayed in the form if i want to edit but i get a
>
>Exception Type: MultiValueDictKeyError
>Exception Value:
>
>Key 'activity_set-0-id' not found in  {u'activity_set-0-name': [u'a\xf6lskjdf\xf6sa'], u'activity_set-0-type':
> [u'research']
>
> on save... any hints?
>
>
> Stefan Nitsche wrote:
> > On Mon, Jan 4, 2010 at 23:27, Stefan Nitsche  > > wrote:
> >
> > Hi,
> >
> > to begin with I would like to declare that I'm still on the
> > beginner end of the scale when it comes to Python and Django.
> >
> > I have an app which has two models:
> >
> > class Item(models.Model):
> > title = models.CharField()
> > description_markdown = models.TextField()
> >
> > class ItemImage(models.Model):
> > item = models.ForeignKey(Item)
> > image = models.ImageField(upload_to='tmp')
> >
> > What I want to do now is to create a page where users can submit
> > an item and upload an image (or images) at the same time. I can
> > create a form using ModelForm for the Item-model and I can create
> > a form for the ItemImage-model using inlineformset_factory, if I
> > do this the submit page looks like it should. However it doesn't
> > behave the way I want it to when saving, but to be honest I have
> > no real idea of what I'm doing when it comes to the related
> > model/form.
> >
> > If I understand it correctly when using inlineformset_factory I
> > must give it an instance so that it can map the foreignkey,
> > correct? So how do one go about and create a form where people can
> > add "item" and "itemimages" at the same time? I'm feeling totaly
> > lost any pointers would be greatly appreciated.
> >
> > --
> > Stefan Nitsche
> > ste...@nitsche.se 
> >
> >
> >
> > Ok I'm totally lost here. I've created an edit function which works
> > splendidly except for the inline-part, it displays alright but it
> > isn't saved at all.
> >
> > My models look like this:
> > ==
> >
> > class Recipe(models.Model):
> > author = models.ForeignKey(User)
> > name = models.CharField(max_length=255, verbose_name='Namn på
> rätten')
> > category = models.ForeignKey('Category', verbose_name='Kategori')
> > create_date = models.DateTimeField(auto_now_add=True)
> > servings = models.CharField(max_length=10, verbose_name='Portioner')
> > cooking_time = models.CharField(max_length=10,
> > verbose_name='Tillagningstid')
> > ingredients = models.TextField(verbose_name='Ingridienser')
> > instructions = models.TextField(verbose_name='Instruktioner')
> > oven_heat = models.CharField(max_length=10, null=True, blank=True,
> > verbose_name='Ugnsvärme')
> > serving_tips = models.TextField(null=True, blank=True,
> > verbose_name='Serveringsförslag')
> > tags = TagField(verbose_name='Taggar')
> > slug = models.SlugField()
> > published = models.NullBooleanField(default=1)
> >
> > class Image(models.Model):
> > recipe = models.ForeignKey(Recipe)
> > file = models.ImageField(upload_to=get_file_path)
> >
> > My view looks like this:
> > =
> > from django.shortcuts import render_to_response, get_object_or_404
> > from django.template import RequestContext
> > from django.http import HttpResponseRedirect
> > from nitsche.recipes.models import Category, Recipe, Image
> > from nitsche.recipes.forms import RecipeForm
> > from django.contrib.auth.decorators import login_required
> > from django.forms.models import inlineformset_factory
> >
> > @login_required
> > def edit(request, slug):
> > ImageFormSet = inlineformset_factory(Recipe, Image)
> > recipe = Recipe.objects.filter(published=True).get(slug=slug)
> > form = RecipeForm(instance=recipe)
> > formset = ImageFormSet(instance=recipe)
> > if request.method == 'POST':
> > form = RecipeForm(request.POST, instance=recipe)
> > formset = ImageFormSet(request.POST, request.FILES,
> > instance=recipe)
> > if form.is_valid(): # All validation rules pass
> > form.save()
> > if 

Making a model field have a default value

2010-01-27 Thread Malcolm Box
Hi,

A question that's probably obvious but I can't quite see the best way to do
it.

I've got a model, call it Template, with some fields colour1, colour2 etc.
What I want is that if there's a no value for the colourN field then a
default value is returned when the field is read.

Aha I hear you say, just use

class Template(models.Model):
  colour1 = models.CharField(default = "red")

However, as far as I can tell this only fills in a default value when the
object is first created.  I've got two problems with that:

1) these are new fields on the model, and I've got a whole pile of existing
records where these are going to be blank.  Setting default="red" in the
model doesn't seem to fix that.
2) I do want people to be able to set a colour in the admin, change their
minds, set it to blank and have the original colour restored.

Boiling it down, I want a way to make the colour1 field work like this:

def _get_colour1(self):
if self.value == '':
 return self.default_value
else:
 return self.value

I can't spot an obvious way to do this  - what have I missed?

Thanks,

Malcolm

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



Updating a user/profile model object

2010-01-27 Thread JonRob
Hi,

I'm just starting out learning Django, trying to cut my teeth by
working on a simple website that involves a user profile.

I've created a ModelForm of the profile model, that instances the
profile of the logged in user, which I then want the user to be able
to update so that they can update their profile information. When I
hit the update button, however, I get a validation error pointing at
the ForeignKey field which links the profile to the User model.

I think the problem is that form.save() is trying to insert another
record, rather than update the current, probably related to the
primary key being automatically incremented, but I can't figure out
how to fix it. I was hoping somebody here might be able to point me in
the right direction.

Relevant code snippets are below:



#models.py

from django.db import models
from django.contrib.auth.models import User
from django.forms import ModelForm

class Organisation(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
email = models.EmailField(max_length=50)
organisation_name = models.CharField(max_length=50)
club_name = models.CharField(max_length=50)
paypal_address = models.EmailField(max_length=50)
phone_number = models.IntegerField()
coach_company = models.CharField(max_length=50)
user = models.ForeignKey(User, unique=True, primary_key=True)

class OrganisationForm(ModelForm):
class Meta:
model = Organisation

#views.py

from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.models import User
from django.template import Context, loader
from FanTran.organisations.models import OrganisationForm

def profile(request):
if request.user.is_authenticated():

organisation = request.user.get_profile()
profile_form = OrganisationForm(instance=organisation)

profile = request.user.get_profile()
t = loader.get_template('organisations/profile.html')
c = Context ({
'profile_form':profile_form,
'profile':profile,
})
return HttpResponse(t.render(c))
else:
return HttpResponse('Error: Not a valid user')

def profile_update(request):
if request.user.is_authenticated():
if request.method == 'POST':
form = OrganisationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('accounts/profile/')
else:
return HttpResponse(form.errors)
else:
return HttpResponseRedirect('/login/')

---

Thanks in advance,

Jon

-- 
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: "Pro Django" book still up to date

2010-01-27 Thread Reinout van Rees

On 01/27/2010 05:55 PM, Achim Domma wrote:

Hi,

I'm interested in buying the "Pro Django" book. I could not find any
hint about what version it's written for. As it covers mostly
internals and the ideas behind Django, it should not be outdated as
quickly as other books. Has anybody read that book and can give some
feedback about how useful it is for the current version of Django?


Written for 1.0, at least the version I bought 2 weeks ago :-)

I haven't read it in full yet, but I've got the same impression as you 
have: it won't be outdated so quickly.


For me, the core value is that the book explains all the various django 
details (forms, templates, views, models) in depth and explains how they 
really work (so: with background information) and how they're supposed 
to be used.


Reading it is giving me a good clue on what is possible with django. If 
I later need to apply it, I can look it up again in the book or, perhaps 
more likely, I can google for it in the django documentation.



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer/advisor at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

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



Python app Installers

2010-01-27 Thread zweb
What is the best way to build installer for python/django based
software product ?
Like in Microsoft world you can have .exe and installshield?

I need to way which can guide user to setup database, run DB script,
set up parameters and guide him through installation. Also want to
give the option to do full install or apply only a patch/upgrade.

-- 
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: Reasons why syncdb ignores an application?

2010-01-27 Thread Malcolm Box
On Wed, Jan 27, 2010 at 6:54 PM, phoebebright wrote:

> I cannot find the reason why syncdb will not create tables from a
> models.py.
>
> It is quite happy to create the auth tables and ones from an external
> app that is included in INSTALLED_APPS but it won't build the tables
> from my 'web' folder.
>
> I can put a print statement in the web.models.py and it appears.  It
> is clearly parsing all the models, because if I put a foreignkey to a
> model which doesn't exist, it complains until I fix the error, but it
> won't build the tables.  I do a syncdb and nothing happens and nothing
> is displayed.
>



> Have included 'from web.models import *' in urls.py and admin.py for
> luck.
>
> This would explain the print statement appearing.


> Have tried copying the web folder to another name and putting that
> name in the INSTALLED_APPS.
>
> The only other symptom is that if I do  'python manage.py sql web'  I
> get the error
> Error: App with label web could not be found. Are you sure your
> INSTALLED_APPS setting is correct?
>
>
What is your python path?  Do manage.py shell
>>> import sys
>>> sys.path

Then try
>>> import web

My guess is that for some reason your python path doesn't include the web
directory.

The only other thing I can think of is some import error in your app that's
silently failing on syncdb - the "import web" test above should spot that.

Cheers,

Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Number of total items in the database

2010-01-27 Thread Zeynel
Thanks. That works.

On Jan 27, 1:26 pm, Malcolm Box  wrote:
> On Wed, Jan 27, 2010 at 6:10 PM, Zeynel  wrote:
> > Hello,
>
> > How do I query the the total number of items in the database to put in
> > a template?
>
> > I want to add to this pagehttp://swimswith.com/search/that "There
> > are currently [X] lawyers in the database."
>
> Have a look at the count() method on Querysets.
>
> So something like:  Lawyers.objects.count() will be the answer.
>
> Cheers,
>
> Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Multilingual project with applications in different default-languages

2010-01-27 Thread Andreas Pfrengle
Hello Matthias,


> It is possible, but you _will_ get a chaos (or have already gotten one
> in case you've already gone down that road).
thanks for pointing me onto the painful truth. We _have_ the chaos...
but it's not that big yet ;-)

> If you need to fix
> the english version later, the gettext tools will help you match up
> the translations again (through fuzzy matching).
I think you mean this:
http://www.gnu.org/software/gettext/manual/gettext.html#Fuzzy-Entries

As I understand it, this only works if I change the original string
'slightly'. I'll come back to this if we'll need it...

Are there any thoughts of implementing an application-wide language
setting instead of a project-wide in django one day? An application
could define it in its __init__, or you'd have to pass the default
language in the INSTALLED_APPS setting, e.g. as tuples of (app-string,
default-lang-code-string). Well, would make multilingual projects out
of multilingual apps much easier :-)

-- 
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: ExtendableModel

2010-01-27 Thread phoebebright
Maybe you should consider an alternative backend to SQL - which is
after all a relational database!  CouchDB?
I could see queries being very expensive with your model.



On Jan 26, 10:08 am, Igor Rubinovich 
wrote:
> Hi,
>
> I need an educated opinion on the following idea. It's supposed to
> provide a (very-)weakly coupled architecture where any object that
> inherits from ExtendableModel can be said to relate to one or many
> objects that also inherit from it. This way I want to achieve at least
> two things:
>
>   (1) No need to hard-code relationships
>   (2) As a consequence of (1) no need to reconstruct the tables every
> time I want to add a new relationship
>
> I think this is not a very bad idea, but maybe technically there are
> better ways to implement this. Or, maybe, it IS a bad idea
> altogether? :)
> Also - how is it (if at all) possible to still use the admin interface
> with this kind of architecture?
>
> The code is below - thanks for any comments!
>
> Thanks,
> Igor
> 
>
> from django.db import models
> from django.contrib.contenttypes import generic
> from django.contrib.contenttypes.models import ContentType
>
> class ExtendableModel(models.Model):
>         id = models.AutoField(primary_key=True)
>         extendable_content_type = models.ForeignKey(ContentType)
>         extendable_object_id = models.PositiveIntegerField()
>         extendable_content_object = generic.GenericForeignKey
> ('extension_content_type', 'extension_object_id')
>
>         def __init__(self, *args, **kwargs):
>                 super(ExtendableModel, self).__init__(self, args, kwargs)
>                 self.extendable_content_type_id = int
> (ContentType.objects.get_for_model(self).id)
>                 print type(self.extendable_content_type_id)
>
>         def get_related(self, model_class): # Returns objects of type
> model_class that extend self
>                 ContentType.objects.get_for_model(b)
>
>                 return model_class.objects.filter(
>                                 
> extendable_content_type__pk=ContentType.objects.get_for_model
> (self).id,
>                                 extendable_object_id=self.id)
>
> 
>
> Sample usage:
>
> class Entry(ExtendableModel):
>         title = models.TextField(editable=False, blank=True)
>         ...
>
> class Event(ExtendableModel):
>     start_datetime = models.DateTimeField
> (default=datetime.datetime.now)
>     end_datetime = models.DateTimeField(default=datetime.datetime.now)
>
> 
>
> entry = Entry(title="A blog post")
> event = Event(start_datetime=somestime1, end_datetime_sometime2)
>
> entry.associate(event) # suppose this is how actual object-to-object
> relationships
>                                  # are added - haven't thought this
> thru

-- 
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: I am new to the Django community

2010-01-27 Thread phoebebright
Not reading but after a year using Django I have just got myself setup
with Aptana + Pydev which includes an interactive debugger.  I found
this very useful for understanding what is going on in Django behind
the scenes, and wish I'd made the effort to do it sooner!


On Jan 27, 1:14 am, kamilski81  wrote:
> I have done the tutorial on the site, are there any other recommended
> readings?

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



Reasons why syncdb ignores an application?

2010-01-27 Thread phoebebright
I cannot find the reason why syncdb will not create tables from a
models.py.

It is quite happy to create the auth tables and ones from an external
app that is included in INSTALLED_APPS but it won't build the tables
from my 'web' folder.

I can put a print statement in the web.models.py and it appears.  It
is clearly parsing all the models, because if I put a foreignkey to a
model which doesn't exist, it complains until I fix the error, but it
won't build the tables.  I do a syncdb and nothing happens and nothing
is displayed.

Have tried running it with verbosity 2 and this folder is never
referred to.

Have included 'from web.models import *' in urls.py and admin.py for
luck.

Have tried copying the web folder to another name and putting that
name in the INSTALLED_APPS.

The only other symptom is that if I do  'python manage.py sql web'  I
get the error
Error: App with label web could not be found. Are you sure your
INSTALLED_APPS setting is correct?

Here is my INSTALLED_APPS:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'web',
'lifestream',
)

I have no idea what to try next!!

-- 
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: Number of total items in the database

2010-01-27 Thread Malcolm Box
On Wed, Jan 27, 2010 at 6:10 PM, Zeynel  wrote:

> Hello,
>
> How do I query the the total number of items in the database to put in
> a template?
>
> I want to add to this page http://swimswith.com/search/ that "There
> are currently [X] lawyers in the database."
>
>
Have a look at the count() method on Querysets.

So something like:  Lawyers.objects.count() will be the answer.

Cheers,

Malcolm

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



Number of total items in the database

2010-01-27 Thread Zeynel
Hello,

How do I query the the total number of items in the database to put in
a template?

I want to add to this page http://swimswith.com/search/ that "There
are currently [X] lawyers in the database."

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-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: Python Graph

2010-01-27 Thread Bhaskar Gara
I am really stupid. After cut & Paste I need to double check what i
pasted.

Thank you very much Dan and sorry for wasting your time.

Lesson learned.

On Jan 27, 11:16 am, Daniel Hilton  wrote:
> 2010/1/27 Bhaskar Gara :
>
>
>
>
>
> > No luck.
>
> > url.py
> > url(r'^member/score/compare/$', direct_to_template,
> >            {'template': 'member_score_compare.html'},
> > name='member_score_compare'),
>
> > view.py
> > def prev_score(request):
> >    template_name = 'member_score_compare.html'
> >    graph = graphs.BarGraph('vBar')
> >    graph.values = [380, 150, 260, 310, 430]
> >    myGraph =  graph.create()
> >    return render_to_response(template_name,
> >                   { 'graph': myGraph },
> >                    context_instance=RequestContext(request))
>
> > thank you
> > Bhaskar
>
> In your example, the request will never touch your view function as
> you're using the generic view to render straight to template.
> Try placing this at the top of your urls.py:
>
> from YOUR_APP_NAME.views import view
>
> And then in your urls.py:
>
> url(r'^member/score/compare/$', view,
>             {'template': 'member_score_compare.html'},
>  name='member_score_compare'),
>
> Although you'll prob get an error on your view name. Have a look 
> at:http://docs.djangoproject.com/en/1.1/topics/http/urls/#topics-http-urls
>
> HTH
>
> Dan
>
>
>
>
>
>
>
> > On Jan 27, 3:40 am, Daniel Hilton  wrote:
> >> 2010/1/27 Bhaskar Gara :
>
> >> > Hi,
>
> >> >    I am very new to django.  I am trying to use this library for my
> >> > graphs
> >> >http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>
> >> > In my Views.py
>
> >> > prev_score(request):
> >> >        graph = graphs.BarGraph('vBar')
> >> >        graph.values = [380, 150, 260, 310, 430]
> >> >        print graph.create()
>
> >> > In my Template  "score_compare.html"  in between the screen  I kept
> >> > below code where it need to display the graph.
>
> >> >                {{ prev_score }}
>
> >> > It not erroring out,  but the graph is not displaying.  Please help.
>
> >> > Thank you
> >> > Bhaskar
>
> >> Within a view function you can't print html out, you need to return
> >> the output of the function.
>
> >> So, using your example, this should give you your graph:
>
> >> from django.template import loader, Context
>
> >> def prev_score(request):
> >>     graph = graphs.BarGraph('vBar')
> >>     graph.values = [380, 150, 260, 310, 430]
> >>     myGraph =  graph.create()
> >>     t = loader.get_template('my_template.html')
> >>     c = Context({ 'graph': myGraph })
> >>     return HttpResponse(t.render(c))
>
> >> Have a read through this part of the 
> >> documentation:http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-v...
>
> >> HTH
> >> Dan
>
> >> > --
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Django users" group.
> >> > To post to this group, send email to django-us...@googlegroups.com.
> >> > To unsubscribe from this group, send email to 
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/django-users?hl=en.
>
> >> --
> >> Dan Hilton
> >> www.twitter.com/danhiltonwww.DanHilton.co.uk
> >> - Hide quoted text -
>
> >> - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Dan Hilton
> www.twitter.com/danhiltonwww.DanHilton.co.uk
> - Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

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

2010-01-27 Thread Karen Tracey
On Wed, Jan 27, 2010 at 12:07 PM, thanos  wrote:

> It's useless. The "The definitive guide to Django" by Holovaty and
> Kaplan-moss is okay, but the Pro version is really just a waste of
> paper and time.


More helpful than this would be a response to the actual question, which was
what version of Django is covered in the book, and how much content in it is
outdated.  The original poster didn't ask for a book critique.  A critique
that included some reasons for your assessment might be helpful, but this
critique is useless. Without any reasons for your assessment I'm left to
assume it just wasn't what you were looking for. It may well, however, be
what the original poster is looking for.

I don't have the book.  Based on the publication date, though, and comments
on the Amazon page for it, it appears to cover Django 1.0.  Thus it won't
cover any of the new features introduced in 1.1 and (soon) 1.2. Also
depending on how much it gets into detailed internals, some things may have
changed. But I'd expect a good bit of it is still quite valid and useful.

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: Python Graph

2010-01-27 Thread Daniel Hilton
2010/1/27 Bhaskar Gara :
> No luck.
>
> url.py
> url(r'^member/score/compare/$', direct_to_template,
>            {'template': 'member_score_compare.html'},
> name='member_score_compare'),
>
>
> view.py
> def prev_score(request):
>    template_name = 'member_score_compare.html'
>    graph = graphs.BarGraph('vBar')
>    graph.values = [380, 150, 260, 310, 430]
>    myGraph =  graph.create()
>    return render_to_response(template_name,
>                   { 'graph': myGraph },
>                    context_instance=RequestContext(request))
>
> thank you
> Bhaskar

In your example, the request will never touch your view function as
you're using the generic view to render straight to template.
Try placing this at the top of your urls.py:

from YOUR_APP_NAME.views import view

And then in your urls.py:


url(r'^member/score/compare/$', view,
{'template': 'member_score_compare.html'},
 name='member_score_compare'),

Although you'll prob get an error on your view name. Have a look at:
http://docs.djangoproject.com/en/1.1/topics/http/urls/#topics-http-urls

HTH

Dan


>
> On Jan 27, 3:40 am, Daniel Hilton  wrote:
>> 2010/1/27 Bhaskar Gara :
>>
>>
>>
>>
>>
>> > Hi,
>>
>> >    I am very new to django.  I am trying to use this library for my
>> > graphs
>> >http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>>
>> > In my Views.py
>>
>> > prev_score(request):
>> >        graph = graphs.BarGraph('vBar')
>> >        graph.values = [380, 150, 260, 310, 430]
>> >        print graph.create()
>>
>> > In my Template  "score_compare.html"  in between the screen  I kept
>> > below code where it need to display the graph.
>>
>> >                {{ prev_score }}
>>
>> > It not erroring out,  but the graph is not displaying.  Please help.
>>
>> > Thank you
>> > Bhaskar
>>
>> Within a view function you can't print html out, you need to return
>> the output of the function.
>>
>> So, using your example, this should give you your graph:
>>
>> from django.template import loader, Context
>>
>> def prev_score(request):
>>     graph = graphs.BarGraph('vBar')
>>     graph.values = [380, 150, 260, 310, 430]
>>     myGraph =  graph.create()
>>     t = loader.get_template('my_template.html')
>>     c = Context({ 'graph': myGraph })
>>     return HttpResponse(t.render(c))
>>
>> Have a read through this part of the 
>> documentation:http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-v...
>>
>> HTH
>> Dan
>>
>>
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> Dan Hilton
>> www.twitter.com/danhiltonwww.DanHilton.co.uk
>> - Hide quoted text -
>>
>> - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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.
>
>



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


-- 
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: "Pro Django" book still up to date

2010-01-27 Thread thanos
It's useless. The "The definitive guide to Django" by Holovaty and
Kaplan-moss is okay, but the Pro version is really just a waste of
paper and time.

Thanos Vassilakis

On Jan 27, 11:55 am, Achim Domma  wrote:
> Hi,
>
> I'm interested in buying the "Pro Django" book. I could not find any
> hint about what version it's written for. As it covers mostly
> internals and the ideas behind Django, it should not be outdated as
> quickly as other books. Has anybody read that book and can give some
> feedback about how useful it is for the current version of Django?
>
> cheers,
> Achim

-- 
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: Python Graph

2010-01-27 Thread Bhaskar Gara
No luck.

url.py
url(r'^member/score/compare/$', direct_to_template,
{'template': 'member_score_compare.html'},
name='member_score_compare'),


view.py
def prev_score(request):
template_name = 'member_score_compare.html'
graph = graphs.BarGraph('vBar')
graph.values = [380, 150, 260, 310, 430]
myGraph =  graph.create()
return render_to_response(template_name,
   { 'graph': myGraph },
context_instance=RequestContext(request))

thank you
Bhaskar

On Jan 27, 3:40 am, Daniel Hilton  wrote:
> 2010/1/27 Bhaskar Gara :
>
>
>
>
>
> > Hi,
>
> >    I am very new to django.  I am trying to use this library for my
> > graphs
> >http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>
> > In my Views.py
>
> > prev_score(request):
> >        graph = graphs.BarGraph('vBar')
> >        graph.values = [380, 150, 260, 310, 430]
> >        print graph.create()
>
> > In my Template  "score_compare.html"  in between the screen  I kept
> > below code where it need to display the graph.
>
> >                {{ prev_score }}
>
> > It not erroring out,  but the graph is not displaying.  Please help.
>
> > Thank you
> > Bhaskar
>
> Within a view function you can't print html out, you need to return
> the output of the function.
>
> So, using your example, this should give you your graph:
>
> from django.template import loader, Context
>
> def prev_score(request):
>     graph = graphs.BarGraph('vBar')
>     graph.values = [380, 150, 260, 310, 430]
>     myGraph =  graph.create()
>     t = loader.get_template('my_template.html')
>     c = Context({ 'graph': myGraph })
>     return HttpResponse(t.render(c))
>
> Have a read through this part of the 
> documentation:http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-v...
>
> HTH
> Dan
>
>
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Dan Hilton
> www.twitter.com/danhiltonwww.DanHilton.co.uk
> - Hide quoted text -
>
> - Show quoted text -

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



static media serve weird behavior

2010-01-27 Thread Vladimir Shulyak
Hello everyone!

Really strange problem with serving static files with
django.views.static.serve():

So I've got media/css dir with show_indexes=True for serve() method.
It gives me list like this:
Index of css/
# ../
# default.css
# general.css
...

It means that the script is able to locate both files and they both
exist. I want to retrieve this files, but... For "default.css" I get
404 and for "general.css" I got 200 response code.
Fortunately, DEBUG=True mode explains that for request which ends with
404 I got wrong media dir set incorrectly:
"/home/vladimir/.../source/mediaa/css/default.css".
But it is set explicitly in settings as:
"/home/vladimir/.../source/media/css/default.css".

And all this for exactly same directory! So seems like files in the
same dir served differently for some reason (it is true for other
files too, not only for those two).

So here is the question: where does the wrong path comes from? Is it
cached somewhere?

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-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: Google maps routes in geodjango

2010-01-27 Thread Peter Landry
Ubuntu has fairly up-to-date Postgis packages available, I believe. That
might be an easier route to start from if you're unfamiliar with building
from source.

On 1/27/10 12:04 PM, "Alexis Selves"  wrote:

> Hello again,
> I have another problem...
> When I want to install PostGIS using this
> http://geodjango.org/docs/install.html#postgis
> I receive this:
>  make -C liblwgeom
> make[1]: Entering directory `/home/petr/Skola/postgis-1.4.0/liblwgeom'
> gcc -g -O2  -fno-common -DPIC  -Wall -Wmissing-prototypes  -c -o
> measures.o measures.c
> In file included from measures.c:16:
> liblwgeom.h:18:31: error: ../postgis_config.h: No such file or
> directory
> make[1]: *** [measures.o] Error 1
> make[1]: Leaving directory `/home/petr/Skola/postgis-1.4.0/liblwgeom'
> make: *** [liblwgeom] Error 2
> I am hopeless or I don't know.. Everything I do is following the hints
> on official pages..
> I use ubuntu 9.10.. by the way..
> 
> 
> On 26 led, 18:56, Alessandro Pasotti  wrote:
>> 2010/1/26 Alexis Selves 
>> 
>> 
>> 
>>> Thanks for hints.
>> 
>>> But here is another problem, how can I store my data do geodb with
>>> javascript?
>>> I was searching several hours, but nothing...
>> 
>>> On 25 led, 15:40, Alessandro Pasotti  wrote:
 2010/1/25 Alexis Selves 
>> 
> Hi there,
> I am new here by the way.
> I have only simple question, how can I extract route from google map
> and save it into geodb as multipoint or etc..
> Thanks for answers.
>> 
 According to the GMap api docs, you can request driving directions from
>>> the
 client with or without geometric data for the routing polyline:
>> 
 http://code.google.com/intl/it-IT/apis/maps/documentation/services.ht...
>> 
 Once you have pulled the polyline from Gmap server, you can send them
>>> back
 to your server and store them in your geodb.
>> 
 You probably will want to decode the polyline from google's encoding
>>> format
 before storinghttp://
>>> facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/
>> 
 Hope this helps
 --
 Alessandro Pasotti
 w3:  www.itopen.it
>> 
>> You need some kind of Ajax XHR call from the client and a server-side piece
>> of software that gets the data coming from the client and put them into the
>> DB.
>> 
>> --
>> Alessandro Pasotti
>> w3:  www.itopen.it

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

2010-01-27 Thread diofeher
'Pro Django' by Marty Alchin and 'Practical Django Projects' by James
Bennett are also good books you should read.

-- 
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: Google maps routes in geodjango

2010-01-27 Thread Alexis Selves
Hello again,
I have another problem...
When I want to install PostGIS using this 
http://geodjango.org/docs/install.html#postgis
I receive this:
 make -C liblwgeom
make[1]: Entering directory `/home/petr/Skola/postgis-1.4.0/liblwgeom'
gcc -g -O2  -fno-common -DPIC  -Wall -Wmissing-prototypes  -c -o
measures.o measures.c
In file included from measures.c:16:
liblwgeom.h:18:31: error: ../postgis_config.h: No such file or
directory
make[1]: *** [measures.o] Error 1
make[1]: Leaving directory `/home/petr/Skola/postgis-1.4.0/liblwgeom'
make: *** [liblwgeom] Error 2
I am hopeless or I don't know.. Everything I do is following the hints
on official pages..
I use ubuntu 9.10.. by the way..


On 26 led, 18:56, Alessandro Pasotti  wrote:
> 2010/1/26 Alexis Selves 
>
>
>
> > Thanks for hints.
>
> > But here is another problem, how can I store my data do geodb with
> > javascript?
> > I was searching several hours, but nothing...
>
> > On 25 led, 15:40, Alessandro Pasotti  wrote:
> > > 2010/1/25 Alexis Selves 
>
> > > > Hi there,
> > > > I am new here by the way.
> > > > I have only simple question, how can I extract route from google map
> > > > and save it into geodb as multipoint or etc..
> > > > Thanks for answers.
>
> > > According to the GMap api docs, you can request driving directions from
> > the
> > > client with or without geometric data for the routing polyline:
>
> > >http://code.google.com/intl/it-IT/apis/maps/documentation/services.ht...
>
> > > Once you have pulled the polyline from Gmap server, you can send them
> > back
> > > to your server and store them in your geodb.
>
> > > You probably will want to decode the polyline from google's encoding
> > format
> > > before storinghttp://
> > facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/
>
> > > Hope this helps
> > > --
> > > Alessandro Pasotti
> > > w3:  www.itopen.it
>
> You need some kind of Ajax XHR call from the client and a server-side piece
> of software that gets the data coming from the client and put them into the
> DB.
>
> --
> Alessandro Pasotti
> w3:  www.itopen.it

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



"Pro Django" book still up to date

2010-01-27 Thread Achim Domma
Hi,

I'm interested in buying the "Pro Django" book. I could not find any
hint about what version it's written for. As it covers mostly
internals and the ideas behind Django, it should not be outdated as
quickly as other books. Has anybody read that book and can give some
feedback about how useful it is for the current version of Django?

cheers,
Achim

-- 
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: Display most popular video from each category

2010-01-27 Thread Gabriel Reis
Hi,

I would do something like this:

top_videos = {}
for i in xrange(1,6):
videos = Video.objects.filter(category=i).order_by('-hit_count')
if videos:
top_videos[i] = videos[0]


Then, access the top videos via the top_videos dict.

Cheers,

Gabriel

--
Gabriel de Carvalho Nogueira Reis
Software Developer
+44 7907 823942


On Wed, Jan 27, 2010 at 3:45 PM, grimmus  wrote:

> Hi,
>
> On the homepage of my site i display 1 main video and then the most
> popular video from each of the 5 categories, which is determined by a
> hit count.
>
> Basically i need something like the following
>
> tv_video = Video.objects.filter(category=1).order_by('-hit_count')
>
> But i need an object returned that gets the most popular video (just
> the first one) from each category (1-5)
>
> Does someone have an idea of the most efficient way to achieve this ?
>
> Thanks, hope i was clear.
>
> --
> 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.



Display most popular video from each category

2010-01-27 Thread grimmus
Hi,

On the homepage of my site i display 1 main video and then the most
popular video from each of the 5 categories, which is determined by a
hit count.

Basically i need something like the following

tv_video = Video.objects.filter(category=1).order_by('-hit_count')

But i need an object returned that gets the most popular video (just
the first one) from each category (1-5)

Does someone have an idea of the most efficient way to achieve this ?

Thanks, hope i was clear.

-- 
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: Python Graph

2010-01-27 Thread Bhaskar Gara
Thank you Dan

On Jan 27, 3:40 am, Daniel Hilton  wrote:
> 2010/1/27 Bhaskar Gara :
>
>
>
>
>
> > Hi,
>
> >    I am very new to django.  I am trying to use this library for my
> > graphs
> >http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>
> > In my Views.py
>
> > prev_score(request):
> >        graph = graphs.BarGraph('vBar')
> >        graph.values = [380, 150, 260, 310, 430]
> >        print graph.create()
>
> > In my Template  "score_compare.html"  in between the screen  I kept
> > below code where it need to display the graph.
>
> >                {{ prev_score }}
>
> > It not erroring out,  but the graph is not displaying.  Please help.
>
> > Thank you
> > Bhaskar
>
> Within a view function you can't print html out, you need to return
> the output of the function.
>
> So, using your example, this should give you your graph:
>
> from django.template import loader, Context
>
> def prev_score(request):
>     graph = graphs.BarGraph('vBar')
>     graph.values = [380, 150, 260, 310, 430]
>     myGraph =  graph.create()
>     t = loader.get_template('my_template.html')
>     c = Context({ 'graph': myGraph })
>     return HttpResponse(t.render(c))
>
> Have a read through this part of the 
> documentation:http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-v...
>
> HTH
> Dan
>
>
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Dan Hilton
> www.twitter.com/danhiltonwww.DanHilton.co.uk
> - Hide quoted text -
>
> - Show quoted text -

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

2010-01-27 Thread Karen Tracey
On Wed, Jan 27, 2010 at 10:02 AM, Malcolm Box  wrote:

> It was indented if you looked in the original message text - I suspect your
> (and my) default email program is stripping leading spaces.
>

How odd.  Looking at it in Gmail one space has been removed from the front
of all lines that had more than one leading space. Looking at it on the
Google Groups page the indentation is legal (if extremely hard to see
properly) Python. Another email client I use also shows it correctly. I've
not noticed Gmail doing that before.

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: View doesn't return HttpResponse object

2010-01-27 Thread Daniel Roseman
On Jan 27, 10:38 am, Ashok Prabhu  wrote:
> Hi,
>
> I have the following view which throws the error "The view
> TCDB.viewdb.views.dbout didn't return an HttpResponse object." I have
> tried various indentation for the return statement. But it doesn't
> seem to help. Can somebody help?
>
> def dbout(request):
>  try:
>   filter_string= request.GET.get('filter_string', '')
>   table_name=request.GET.get('table_name','')
>   field_name=request.GET.get('field_name','')
>   if field_name=='hostid':
>    results=eval(table_name).objects.filter(hostid__icontains=str
> (filter_string)).values()
>   elif field_name=='hostname':
>    results=eval(table_name).objects.filter(hostname__icontains=str
> (filter_string)).values()
>   elif field_name=='plat_manu_name':
>    results=eval(table_name).objects.filter
> (plat_manu_name__icontains=str(filter_string)).values()
>   elif field_name=='mac':
>    results=eval(table_name).objects.filter(mac__icontains=str
> (filter_string)).values()
>   return HttpResponse('No Exception')
>  except:
>   return HttpResponse('Exception Reached')
>
> Thanks,
> ~Ashok.

Firstly, why are you using a single character indent? If you used the
standard four-space indent, it would be much much easier to see your
blocks. Since, as you have discovered, indentation is critical in
Python, it makes sense to make it visible. In fact, a good reading of
PEP8 would make your code much more readable generally.

Please re-post your code with a decent indent, so we can see what's
going on.

Two other pointers which may help you generally:

Firstly, don't use a bare 'except'. You might be hiding all sorts of
errors. If you're expecting an exception, catch that specific one and
deal with it, and leave others to bubble up. They will be displayed
nicely on the Django error page.

Secondly, don't 'eval' strings coming directly from the user (ie in
request.GET). That's an open door for a hacker to run arbitrary code
on your system. Instead, use a dictionary of strings to look up
models:

model_dict = {'model1': Model1, 'model2': Model2}
results = model_dict[table_name].objects.filter(...)

--
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: View doesn't return HttpResponse object

2010-01-27 Thread Malcolm Box
On Wed, Jan 27, 2010 at 2:54 PM, Karen Tracey  wrote:

> On Wed, Jan 27, 2010 at 9:45 AM, Malcolm Box wrote:
>
>> That code looks fine to me.  I'd suggest sticking an "import
>> pdb;pdb.set_trace()" as the first line of the view, then stepping through
>> the code (run the server with manage.py runserver).  That should quickly
>> highlight any areas where the code flow isn't as you expect.
>>
>>
> Single stepping through in the debugger is a good suggestion.  However, the
> code as posted is not fine, since the blocks under try and except are not
> indented any further than the try/except statements, and they need to be.
> What was posted can't possibly be what is actually running since the posted
> code will generate an IndentationError on an attempt to import it.
>
> It was indented if you looked in the original message text - I suspect your
(and my) default email program is stripping leading spaces.

Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Geodjango - viable for this task? Please give input

2010-01-27 Thread Peter Landry
On 1/27/10 1:29 AM, "cc0"  wrote:

> A quick and basic rundown of what I need to do, (my project idea is
> still being hatched);
> 
> 1. I have a database with a number of coordinates (we are talking
> probably some ten thousand different coordinates)
> 
> 2. I need to relate these coordinates to specific regions on a map
> (pref. google maps), these regions should be rather small (for
> example, give or take, the size of an average county). I am aware that
> perhaps this is not possible to link to named geographical regions,
> but more so as polygons. However it is important that the coordinate
> then is not in the center of that polygon.
> 
> 3. This region then needs to be highlighted in a way that it is
> distinguishable on the map (this needs to be done for all regions
> related to a coordinate in the database)
> 
> 
> Then the question; I have never used django, much less geodjango,
> before. So I could use some input such as how well it would be suited
> for this task AND if it is a stable and well enough developed tool to
> work with on a project of considerable size.
> 
> I greatly appreciate any insightful input!

Hello,
This sounds like a perfect job for Geodjango. Based on my understanding of
what you've said, it would something like:
- A model with a PolygonField or MultiPolygon field to contain your areas
- A model with a PointField to contain your coordinates, and a foreign key
to the area model
- Some kind of pre_save or import process that uses an intersects query to
assign the appropriate area model to each coordinate model

GeoDjango also has strong support for drawing both points and polygons on a
variety of mapping apis, so that shouldn't be an issue.

Hope that helps!

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

2010-01-27 Thread Karen Tracey
On Wed, Jan 27, 2010 at 9:45 AM, Malcolm Box  wrote:

> That code looks fine to me.  I'd suggest sticking an "import
> pdb;pdb.set_trace()" as the first line of the view, then stepping through
> the code (run the server with manage.py runserver).  That should quickly
> highlight any areas where the code flow isn't as you expect.
>
>
Single stepping through in the debugger is a good suggestion.  However, the
code as posted is not fine, since the blocks under try and except are not
indented any further than the try/except statements, and they need to be.
What was posted can't possibly be what is actually running since the posted
code will generate an IndentationError on an attempt to import it.

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: RSS-newby Error was: No module named django.contrib.syndication.views

2010-01-27 Thread Karen Tracey
On Wed, Jan 27, 2010 at 6:23 AM, luupux  wrote:

> Hello , im have a newbye question
>
> I have a simple application named proxy  and i put simple rss feed .
> This is my error
>
> Request URL:http://localhost:8000/proxy/feeds/feedurl/
> Exception Type: ViewDoesNotExist
> Exception Value: Could not import
> siteupdate.proxy.views.django.contrib.syndication.views. Error was: No
> module named django.contrib.syndication.views
>

Notice it is reporting that it could not import:

siteupdate.proxy.views.django.contrib.syndication.views

which is not surprising, since it should just be
django.contrib.syndication.views

 [snip]

> 
> file proxy/url.py
> from django.conf.urls.defaults import *
> from siteupdate.proxy.models import listurl,hostserver
> from siteupdate.proxy.feeds import *
>
> feeds = {
>'feedurl': FeedName,
> }
> urlpatterns = patterns('siteupdate.proxy.views',
>(r'^feeds/(?P.*)/$',
> 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
> )
>

Why have you put 'siteupdate.proxy.views' as the view prefix on this
patterns call?  Given what you are showing -- a single pattern with a
fully-specified view --  the prefix on that patterns call should just be
''.  See the doc:

http://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix

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: View doesn't return HttpResponse object

2010-01-27 Thread Malcolm Box
That code looks fine to me.  I'd suggest sticking an "import
pdb;pdb.set_trace()" as the first line of the view, then stepping through
the code (run the server with manage.py runserver).  That should quickly
highlight any areas where the code flow isn't as you expect.

Cheers,

Malcolm

On Wed, Jan 27, 2010 at 10:38 AM, Ashok Prabhu wrote:

> Hi,
>
> I have the following view which throws the error "The view
> TCDB.viewdb.views.dbout didn't return an HttpResponse object." I have
> tried various indentation for the return statement. But it doesn't
> seem to help. Can somebody help?
>
> def dbout(request):
>  try:
>  filter_string= request.GET.get('filter_string', '')
>  table_name=request.GET.get('table_name','')
>  field_name=request.GET.get('field_name','')
>  if field_name=='hostid':
>   results=eval(table_name).objects.filter(hostid__icontains=str
> (filter_string)).values()
>  elif field_name=='hostname':
>   results=eval(table_name).objects.filter(hostname__icontains=str
> (filter_string)).values()
>  elif field_name=='plat_manu_name':
>   results=eval(table_name).objects.filter
> (plat_manu_name__icontains=str(filter_string)).values()
>  elif field_name=='mac':
>   results=eval(table_name).objects.filter(mac__icontains=str
> (filter_string)).values()
>  return HttpResponse('No Exception')
>  except:
>  return HttpResponse('Exception Reached')
>
>
> Thanks,
> ~Ashok.
>
> --
> 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.



RSS-newby Error was: No module named django.contrib.syndication.views

2010-01-27 Thread luupux
Hello , im have a newbye question

I have a simple application named proxy  and i put simple rss feed .
This is my error

Request URL:http://localhost:8000/proxy/feeds/feedurl/
Exception Type: ViewDoesNotExist
Exception Value: Could not import
siteupdate.proxy.views.django.contrib.syndication.views. Error was: No
module named django.contrib.syndication.views

Exception Location: /usr/lib/python2.5/site-packages/django/core/
urlresolvers.py in _get_callback, line 134
Python Executable:  /usr/bin/python
Python Version: 2.5.2


file proxy/url.py
from django.conf.urls.defaults import *
from siteupdate.proxy.models import listurl,hostserver
from siteupdate.proxy.feeds import *

feeds = {
'feedurl': FeedName,
}
urlpatterns = patterns('siteupdate.proxy.views',
(r'^feeds/(?P.*)/$',
'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
)

file proxy/feeds.py

from django.contrib.syndication.feeds import Feed
from siteupdate.proxy.models import listurl

class FeedName(Feed):
title = 'Django Bookmarks | Recent Bookmarks'
link = '/feeds/recent/'
description = 'Recent bookmarks posted to Django Bookmarks'

def items(self):
return listurl.objects.order_by('-id')[:2]


###
file proxy/model.py

from django.contrib.syndication.feeds import Feed
from siteupdate.proxy.models import listurl

class FeedName(Feed):
title = 'Django Bookmarks | Recent Bookmarks'
link = '/feeds/recent/'
description = 'Recent bookmarks posted to Django Bookmarks'

def items(self):
return listurl.objects.order_by('-id')[:2]
#
file templates/proxy/feeds/feedurl_description.html

{{ obj.description }}

#
file templates/proxy/feeds/feedurl_description.html

{{ obj.name }}

Where is error ?

Many  thanks in advance and Sorry my bad English

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



View doesn't return HttpResponse object

2010-01-27 Thread Ashok Prabhu
Hi,

I have the following view which throws the error "The view
TCDB.viewdb.views.dbout didn't return an HttpResponse object." I have
tried various indentation for the return statement. But it doesn't
seem to help. Can somebody help?

def dbout(request):
 try:
  filter_string= request.GET.get('filter_string', '')
  table_name=request.GET.get('table_name','')
  field_name=request.GET.get('field_name','')
  if field_name=='hostid':
   results=eval(table_name).objects.filter(hostid__icontains=str
(filter_string)).values()
  elif field_name=='hostname':
   results=eval(table_name).objects.filter(hostname__icontains=str
(filter_string)).values()
  elif field_name=='plat_manu_name':
   results=eval(table_name).objects.filter
(plat_manu_name__icontains=str(filter_string)).values()
  elif field_name=='mac':
   results=eval(table_name).objects.filter(mac__icontains=str
(filter_string)).values()
  return HttpResponse('No Exception')
 except:
  return HttpResponse('Exception Reached')


Thanks,
~Ashok.

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



Geodjango - viable for this task? Please give input

2010-01-27 Thread cc0
A quick and basic rundown of what I need to do, (my project idea is
still being hatched);

1. I have a database with a number of coordinates (we are talking
probably some ten thousand different coordinates)

2. I need to relate these coordinates to specific regions on a map
(pref. google maps), these regions should be rather small (for
example, give or take, the size of an average county). I am aware that
perhaps this is not possible to link to named geographical regions,
but more so as polygons. However it is important that the coordinate
then is not in the center of that polygon.

3. This region then needs to be highlighted in a way that it is
distinguishable on the map (this needs to be done for all regions
related to a coordinate in the database)


Then the question; I have never used django, much less geodjango,
before. So I could use some input such as how well it would be suited
for this task AND if it is a stable and well enough developed tool to
work with on a project of considerable size.

I greatly appreciate any insightful input!

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



Using two slugs to call a detail view? [newbie]

2010-01-27 Thread GJCGJC
Hi,

I'm trying to put a site together for a local charity. I'd like them
to be able to add new pages to the primary and secondary navigation
from the admin site and, importantly, I want them to be able to
specify what secondary pages belong to which primary pages.

I'm trying to do this with object list and object detail views - where
the list would serve up primary navigation pages and the detail their
sub-pages.

I'm trying to set up URLs to reflect this hierarchical structure but I
just can't get my head round it and I can't find anything in the
documentation that covers what I'm trying to do - which makes me think
I'm trying to do the wrong thing.

My models include:

class Category(models.Model):
title = models.CharField(max_length=250, help_text='Maximum 250
characters')
slug = models.SlugField(unique=True, help_text = 'Suggested slug
automatically generated from title. Must be unique')
description = models.TextField()
sort_index = models.IntegerField(unique=True,
help_text='Determines the order in which pages appear in the site
navigation (lowest to highest)')

This generates the primary navigation pages. The solution I came up
with for letting someone choose what primary navigation category an
entry appeared under was to include:

navigation_parent = models.ForeignKey(Category)
...
def get_absolute_url(self):
return '/%s/%s/' %  (self.navigation_parent, self.slug)

in the entry model.

I want my URLconf to be able to get the right page by catching the
category and the entry slug. I thought something like:

info_dict = { 'queryset': Entry.objects.all(), 'extra_context':
{ 'top_nav': Category.objects.order_by('sort_index') }, }
...
(r'^(?P[-\w]+)/(?P[-\w]+)/$', 'object_detail',
info_dict),

would work, but it doesn't. Ultimately, I also want to build sub-
navigation by listing all entries that share a navigation parent in
the page.

Please let me know if I'm going about this the wrong way, or if I
haven't included enough detail or am unclear, and I will update
accordingly.

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-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: Models, forms and inlineformset

2010-01-27 Thread andreas schmid
is this an add or an edit form? or both?

i have a similar inlineformset and i need to loop over the inline
objects to set the foreignkey to the parent object like:

if form.is_valid() and formset.is_valid(): # All validation rules pass
new_idea = form.save(commit=False)
new_idea.author = request.user
new_idea = form.save()
formset_models = formset.save(commit=False)
for f in formset_models:
f.idea = new_idea
f.save()
return HttpResponseRedirect(new_idea.get_absolute_url())


im actually experiencing problems with the edit form where i can get the
values displayed in the form if i want to edit but i get a

Exception Type: MultiValueDictKeyError
Exception Value:

Key 'activity_set-0-id' not found in  On Mon, Jan 4, 2010 at 23:27, Stefan Nitsche  > wrote:
>
> Hi,
>
> to begin with I would like to declare that I'm still on the
> beginner end of the scale when it comes to Python and Django.
>
> I have an app which has two models:
>
> class Item(models.Model):
> title = models.CharField()
> description_markdown = models.TextField()
>
> class ItemImage(models.Model):
> item = models.ForeignKey(Item)
> image = models.ImageField(upload_to='tmp')
>
> What I want to do now is to create a page where users can submit
> an item and upload an image (or images) at the same time. I can
> create a form using ModelForm for the Item-model and I can create
> a form for the ItemImage-model using inlineformset_factory, if I
> do this the submit page looks like it should. However it doesn't
> behave the way I want it to when saving, but to be honest I have
> no real idea of what I'm doing when it comes to the related
> model/form.
>
> If I understand it correctly when using inlineformset_factory I
> must give it an instance so that it can map the foreignkey,
> correct? So how do one go about and create a form where people can
> add "item" and "itemimages" at the same time? I'm feeling totaly
> lost any pointers would be greatly appreciated.
>
> -- 
> Stefan Nitsche
> ste...@nitsche.se 
>
>
>
> Ok I'm totally lost here. I've created an edit function which works
> splendidly except for the inline-part, it displays alright but it
> isn't saved at all.
>
> My models look like this:
> ==
>
> class Recipe(models.Model): 
> author = models.ForeignKey(User)
> name = models.CharField(max_length=255, verbose_name='Namn på rätten')
> category = models.ForeignKey('Category', verbose_name='Kategori')
> create_date = models.DateTimeField(auto_now_add=True)
> servings = models.CharField(max_length=10, verbose_name='Portioner')
> cooking_time = models.CharField(max_length=10,
> verbose_name='Tillagningstid')
> ingredients = models.TextField(verbose_name='Ingridienser')
> instructions = models.TextField(verbose_name='Instruktioner')
> oven_heat = models.CharField(max_length=10, null=True, blank=True,
> verbose_name='Ugnsvärme')
> serving_tips = models.TextField(null=True, blank=True,
> verbose_name='Serveringsförslag')
> tags = TagField(verbose_name='Taggar')
> slug = models.SlugField()
> published = models.NullBooleanField(default=1)
>
> class Image(models.Model):
> recipe = models.ForeignKey(Recipe)
> file = models.ImageField(upload_to=get_file_path)
>
> My view looks like this:
> =
> from django.shortcuts import render_to_response, get_object_or_404
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
> from nitsche.recipes.models import Category, Recipe, Image
> from nitsche.recipes.forms import RecipeForm
> from django.contrib.auth.decorators import login_required
> from django.forms.models import inlineformset_factory
>
> @login_required
> def edit(request, slug):
> ImageFormSet = inlineformset_factory(Recipe, Image)
> recipe = Recipe.objects.filter(published=True).get(slug=slug)
> form = RecipeForm(instance=recipe)
> formset = ImageFormSet(instance=recipe)
> if request.method == 'POST':
> form = RecipeForm(request.POST, instance=recipe)
> formset = ImageFormSet(request.POST, request.FILES,
> instance=recipe)
> if form.is_valid(): # All validation rules pass
> form.save()
> if formset.is_valid():
> formset.save() 
> return HttpResponseRedirect('/recept')
> return render_to_response('recipes/add.html',
>   {'form': form, 'formset': formset,
> 'slug':slug,},
>   context_instance=RequestContext(request))
>
> And finaly my template looks like this:
> 
>
> 
> {{ form.as_p }}
> 
> {{ 

Re: Multiple template_dirs?

2010-01-27 Thread djangonoob
Thank you it was my template directory which actually was templates/
photologue/templates. Still, your help was what led me to the result.

Take good care

-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Thank you it was my template directory which actually was templates/
photologue/templates. Still, your help was what led me to the result.

Take good care

-- 
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: Python Graph

2010-01-27 Thread Daniel Hilton
2010/1/27 Bhaskar Gara :
> Hi,
>
>    I am very new to django.  I am trying to use this library for my
> graphs
> http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>
>
> In my Views.py
>
> prev_score(request):
>        graph = graphs.BarGraph('vBar')
>        graph.values = [380, 150, 260, 310, 430]
>        print graph.create()
>
> In my Template  "score_compare.html"  in between the screen  I kept
> below code where it need to display the graph.
>
>                {{ prev_score }}
>
> It not erroring out,  but the graph is not displaying.  Please help.
>
> Thank you
> Bhaskar


Within a view function you can't print html out, you need to return
the output of the function.

So, using your example, this should give you your graph:



from django.template import loader, Context

def prev_score(request):
graph = graphs.BarGraph('vBar')
graph.values = [380, 150, 260, 310, 430]
myGraph =  graph.create()
t = loader.get_template('my_template.html')
c = Context({ 'graph': myGraph })
return HttpResponse(t.render(c))


Have a read through this part of the documentation:
http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-views

HTH
Dan


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



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Unfortunately it is still not displaying the templates in the
templates/photologue directory. I tried your idea. Is there anything
else you can suggest?

Thank you

-- 
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: Multiple template_dirs?

2010-01-27 Thread Mike Ramirez
On Wed, Jan 27, 2010 at 1:21 AM, djangonoob wrote:
> Hi Mike,
>
> Unfortunately it is still not displaying the templates in the
> templates/photologue directory. I tried your idea. Is there anything
> else you can suggest?
>

Make sure that "photologues" is quoted in the tuple and not a string literal.

PROJECT_DIR/templates/photologue directory is the correct directory your 
templates are in

PROJECT_DIR/templates should be a full path and readable by the user your web 
server is running as.

These are the main stoppers. As long as TEMPLATE_DIRS is formated fine.

Mike



-- 
The wise and intelligent are coming belatedly to realize that alcohol, and
not the dog, is man's best friend.  Rover is taking a beating -- and he 
should.
-- W.C. Fields


signature.asc
Description: This is a digitally signed message part.


Re: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Unfortunately it is still not displaying the templates in the
templates/photologue directory. I tried your idea. Is there anything
else you can suggest?

Thank you

-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Unfortunately it is still not displaying the templates in the
templates/photologue directory. I tried your idea. Is there anything
else you can suggest?

Thank you

-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Unfortunately it is still not displaying the templates in the
templates/photologue directory. I tried your idea. Is there anything
else you can suggest?

Thank you

-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Unfortunately it is still not displaying the templates in the
templates/photologue directory. I tried your idea. Is there anything
else you can suggest?

Thank you

-- 
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: 'Context' object has no attribute 'period'

2010-01-27 Thread Daniel Roseman
On Jan 27, 1:52 am, Andy  wrote:
> I am (still) new to Django and a novice at relational databases, so I
> am having some problems.  I've read and read, but can't sort this out.
>
> I save the session data in this view:
> def order(request):
>         if request.method == 'POST':
>                 form = OrderForm(request.POST)
>                 if form.is_valid():
>                         current_order = form.save()
>                         order_info = Context({'order_info': current_order})
>                         request.session['order_info'] = order_info

Here's your problem. Why are you using a Context() object here? That's
meant for sending variables to a template. There's no need to use it
anywhere else. You should just do:
   request.session['order_info'] = current_order

--
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Yes I noticed that we both had made typos :) No worries I tried your
first example and I will now use this one which I am sure will work.
Thank you very much.

On Jan 27, 10:37 am, Mike Ramirez  wrote:
> On Wednesday 27 January 2010 00:32:24 Mike Ramirez wrote:
>
> > base_tmpl_dir = os_path.join(PROJECT_PATH, 'templates')
> > TEMPLATE_DIRS = (
> >    base_tmpl_dir,
> >    os_path.join(base_tmpl_dir, photologue),
> > )
>
> Fixed a typo --- base_tmpl_dir should have a , after it in the tuple.
>
> Mike
>
> --
> Creativity is not always bred in an environment of tranquility;
> sometimes you have to squeeze a little to get the paste out of the tube.
>
>  signature.asc
> < 1KViewDownload

-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Yes I noticed that we both had made typos :) No worries I tried your
first example and I will now use this one which I am sure will work.
Thank you very much.

On Jan 27, 10:37 am, Mike Ramirez  wrote:
> On Wednesday 27 January 2010 00:32:24 Mike Ramirez wrote:
>
> > base_tmpl_dir = os_path.join(PROJECT_PATH, 'templates')
> > TEMPLATE_DIRS = (
> >    base_tmpl_dir,
> >    os_path.join(base_tmpl_dir, photologue),
> > )
>
> Fixed a typo --- base_tmpl_dir should have a , after it in the tuple.
>
> Mike
>
> --
> Creativity is not always bred in an environment of tranquility;
> sometimes you have to squeeze a little to get the paste out of the tube.
>
>  signature.asc
> < 1KViewDownload

-- 
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: Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi Mike,

Yes I noticed that we both had made typos :) No worries I tried your
first example and I will now use this one which I am sure will work.
Thank you very much.

On Jan 27, 10:37 am, Mike Ramirez  wrote:
> On Wednesday 27 January 2010 00:32:24 Mike Ramirez wrote:
>
> > base_tmpl_dir = os_path.join(PROJECT_PATH, 'templates')
> > TEMPLATE_DIRS = (
> >    base_tmpl_dir,
> >    os_path.join(base_tmpl_dir, photologue),
> > )
>
> Fixed a typo --- base_tmpl_dir should have a , after it in the tuple.
>
> Mike
>
> --
> Creativity is not always bred in an environment of tranquility;
> sometimes you have to squeeze a little to get the paste out of the tube.
>
>  signature.asc
> < 1KViewDownload

-- 
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: Multiple template_dirs?

2010-01-27 Thread Mike Ramirez
On Wednesday 27 January 2010 00:32:24 Mike Ramirez wrote:

> base_tmpl_dir = os_path.join(PROJECT_PATH, 'templates')
> TEMPLATE_DIRS = (
>   base_tmpl_dir,
>   os_path.join(base_tmpl_dir, photologue),
> )
> 

Fixed a typo --- base_tmpl_dir should have a , after it in the tuple.

Mike

-- 
Creativity is not always bred in an environment of tranquility;
sometimes you have to squeeze a little to get the paste out of the tube.


signature.asc
Description: This is a digitally signed message part.


Re: Multiple template_dirs?

2010-01-27 Thread Mike Ramirez
On Wednesday 27 January 2010 00:24:45 djangonoob wrote:
> Hi. I am new to django and never had to specify more than one
> TEMPLATE_DIRS. I am trying to add a second TEMPLATE_DIR to my existing
> one which looks like this:
> 
> TEMPLATE_DIRS = [
> os_path.join(PROJECT_PATH, 'templates'),
> )
> 
> The template I would also like to add is under templates/photologue.
> 
base_tmpl_dir = os_path.join(PROJECT_PATH, 'templates')
TEMPLATE_DIRS = (
base_tmpl_dir
os_path.join(base_tmpl_dir, photologue),
)

TEMPLATE_DIRS takes a tuple of paths to search for templates.[1]  In your 
example, I hope it was a typo but just in case [ and ) aren't matching 
enclosures. 

Mike

[1] http://docs.djangoproject.com/en/dev/ref/settings/#template-dirs



-- 
And you can't get any Watney's Red Barrel,
because the bars close every time you're thirsty...


signature.asc
Description: This is a digitally signed message part.


Re: Meta.widgets in ModelForm seems... ignored

2010-01-27 Thread Massimiliano della Rovere
Thanks foy your replies.
The class Fondo has in truth lots of Textfield to be displayed as CharField
(I am using django.forms to implement a search mask); the one posted was
only an excerpt.
I solved this way:

class FondoForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(FondoForm, self).__init__(*args, **kwargs)
 for nome, campo in self.fields.items():
self.fields[nome].required = False
 if type(campo.widget) == forms.Textarea:
self.fields[nome].widget = forms.TextInput()

class Meta:
model = Fondo

On Tue, Jan 26, 2010 at 16:05, KrcK ---  wrote:
> You can try this:
>
> class Fondo(models.Model):
> denominazione = models.CharField(max_length=200)
> storia= models.TextField(blank=True)
> class FondoForm(forms.ModelForm):
> storia = forms.CharField(widget=forms.Textarea)
>
> class Meta:
> model = Fondo
>
> I am not sure if this works.
>
>
>
> 2010/1/26 Daniel Roseman 
>>
>> On Jan 26, 11:45 am, Massimiliano della Rovere
>>  wrote:
>> > I use django 1.1.1 and I defined:
>> >
>> > class Fondo(models.Model):
>> > denominazione = models.CharField(max_length=200)
>> >  storia= models.TextField(blank=True)
>> >
>> > class FondoForm(forms.ModelForm):
>> >  class Meta:
>> >  model = Fondo
>> >  widgets = {'storia': forms.TextInput}
>> >
>> > but the 'storia' field is still shown as TextArea. Can you tell me
where
>> > do
>> > I err?
>>
>> The 'widgets' Meta option on modelforms is only available in the
>> development version. You seem to be using the wrong documentation -
>> you should be looking at
>> http://docs.djangoproject.com/en/1.1/topics/forms/modelforms/
>>
>> (Also it seems that the dev docs are missing the 'new in development
>> version' tag there.)
>> --
>> 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.
>>
>
> --
> 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.



Multiple template_dirs?

2010-01-27 Thread djangonoob
Hi. I am new to django and never had to specify more than one
TEMPLATE_DIRS. I am trying to add a second TEMPLATE_DIR to my existing
one which looks like this:

TEMPLATE_DIRS = [
os_path.join(PROJECT_PATH, 'templates'),
)

The template I would also like to add is under templates/photologue.

How can I achieve this please? Many thanks and kind regards.

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