Re: __unicode__(self):

2008-04-13 Thread 1234
add"self"

2008/4/14, Malcolm Tredinnick <[EMAIL PROTECTED]>:
>
>
>
> On Sun, 2008-04-13 at 22:04 -0700, Brandon Taylor wrote:
> > Hello everyone,
> >
> > I'm pretty new to Django, so please bear with me.
> >
> > When I'm defining a model, and I want to return a value to use in the
> > admin for the information to be displayed as such:
> >
> > from django.db import models
> >
> > class Link(models.Model):
> > name = models.CharField()
> > url = models.CharField()
> > position = models.PositiveSmallIntegerField()
> >
> > def __unicode__(self):
> > return name
>
>
> That will give you a NameError, since "name" does not exist. You want to
> do "return self.name" there.
>
>
> > Is it possible to concatenate fields for the def__unicode__(self)
> > method? I can't seem to find a way to do that, and was just wondering
> > if it's possible?
>
>
> A __unicode__ method must return a unicode string. That's all. How you
> construct that string is entirely up to you. If you want to construct it
> by putting various attribute values together, that's fine. It's just
> Python. So, for example,
>
> return u"%s %s" % (self.name, self.url)
>
> would return a concatenation of the name and url attributes. Season to
> taste.
>
> Regards,
> Malcolm
>
>
> --
> Honk if you love peace and quiet.
> http://www.pointy-stick.com/blog/
>
>
>
> >
>

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



facing problem with magnolia sync script

2008-04-13 Thread stranger

Hello everybody,

   I am writing a blog app where I am syncing my magnolia links to
my weblog. I am using the magnolia API for this. In my link model I
have a 'add_date' field to sync the created time of the magnolia
link.

 In the syncing function I am using

add_date = datetime(*(time.strptime(link("created").rstrip("-07:00"),
"%Y-%m-%dT%H:%M:%S")[0:6]))

to sync the 'created' time of the link. But when I try to sync the
script it synced 17 links and
failed in the 18th link.

File "path/to/myproject/apps/links/models.py", line 79, in
sync_magnolia_links
add_date =
datetime(*(time.strptime(link("created").rstrip("-07:00"), "%Y-%m-%dT
%H:%M:%S")[0:6]))
  File "/usr/local/lib/python2.5/_strptime.py", line 331, in strptime
(data_string, format))
ValueError: time data did not match format:  data=2008-03-30T22:43
fmt=%Y-%m-%dT%H:%M:%S

We can observe that my 18th link has timestamp of T22:43 where the
seconds are missing. Can anyone suggest me a way yo bypass that
problem..



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



Re: __unicode__(self):

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 22:04 -0700, Brandon Taylor wrote:
> Hello everyone,
> 
> I'm pretty new to Django, so please bear with me.
> 
> When I'm defining a model, and I want to return a value to use in the
> admin for the information to be displayed as such:
> 
> from django.db import models
> 
> class Link(models.Model):
> name = models.CharField()
> url = models.CharField()
> position = models.PositiveSmallIntegerField()
> 
> def __unicode__(self):
> return name

That will give you a NameError, since "name" does not exist. You want to
do "return self.name" there.

> Is it possible to concatenate fields for the def__unicode__(self)
> method? I can't seem to find a way to do that, and was just wondering
> if it's possible?

A __unicode__ method must return a unicode string. That's all. How you
construct that string is entirely up to you. If you want to construct it
by putting various attribute values together, that's fine. It's just
Python. So, for example,

return u"%s %s" % (self.name, self.url)

would return a concatenation of the name and url attributes. Season to
taste.

Regards,
Malcolm

-- 
Honk if you love peace and quiet. 
http://www.pointy-stick.com/blog/


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



__unicode__(self):

2008-04-13 Thread Brandon Taylor

Hello everyone,

I'm pretty new to Django, so please bear with me.

When I'm defining a model, and I want to return a value to use in the
admin for the information to be displayed as such:

from django.db import models

class Link(models.Model):
name = models.CharField()
url = models.CharField()
position = models.PositiveSmallIntegerField()

def __unicode__(self):
return name

class Admin:
ordering = ['position']

class Meta:
verbose_name_plural = 'Links'


Is it possible to concatenate fields for the def__unicode__(self)
method? I can't seem to find a way to do that, and was just wondering
if it's possible?

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



Re: Security concerns about publically exposing admin tool

2008-04-13 Thread Justin Lilly
It isn't out of date per se. It is, however, going to be revamped when we
have a stable replacement. You can find more information on the wiki at
http://code.djangoproject.com/wiki/NewformsAdminBranch
 -justin

On Mon, Apr 14, 2008 at 12:32 AM, meppum <[EMAIL PROTECTED]> wrote:

>
> newforms-admin? Should i not be modeling my applications on how the
> admin is constructed? is it out of date (other then not using
> modelforms)?
>
> On Apr 14, 12:10 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
> > Once newforms-admin hits you will be able to change that if you
> > want(without hacking on the django source).
> >
> > On Apr 13, 11:08 pm, meppum <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I simply meant that after a few failed password attempts the user is
> > > not presented with a CAPTCHA or something. I'll keep all this in mind.
> >
> > > On Apr 13, 11:54 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > > wrote:
> >
> > > > On Sun, 2008-04-13 at 20:36 -0700, meppum wrote:
> > > > > I noticed that most django sites including djangoproject.com and
> even
> > > > > curse.com allow their admin sites to be accessed through the web.
> This
> > > > > seems like a bit of a security concern as someone could create a
> bot
> > > > > to attempt to collect passwords.
> >
> > > > > Is this common practice or am I wrong about the admin sites
> ability to
> > > > > be cracked with brute force?
> >
> > > > Django's admin is no more or less susceptible to brute force
> password
> > > > cracking than any other site requiring a login. It's a function of
> good
> > > > password choice, not whether something is visible via the web.
> >
> > > > Malcolm
> >
> > > > --
> > > > Why be difficult when, with a little bit of effort, you could be
> > > > impossible.http://www.pointy-stick.com/blog/- Hide quoted text -
> >
> > - Show quoted text -
> >
>


-- 
Justin Lilly
Web Developer/Designer
http://justinlilly.com

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



Re: Problem storing utf-8 in MySQL

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 21:30 -0700, Rob Hudson wrote:
> On Apr 13, 6:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
> > Do you mean that you are coming across a case of trying to store 4-byte
> > UTF-8 sequences in MySQL? Or do you mean that you've managed to create a
> > database table with the incorrect encoding and only realised this after
> > you've stored data in the table? Or is there a third possibility?
> 
> Thanks for the follow up...
> 
> In my particular case I have an old database with content that has
> built up over the years from a PHP website.  I'm re-building the site
> in Django and am working on a database migration script.  For various
> text fields in the old tables I was hitting this same error,
> "Incorrect string value: '\x[something or other]'  for column
> '[something]' at row 1".
> 
> I actually ended solving it by telling MySQLdb to "use_unicode", e.g.:
> db = MySQLdb.connect(host=OLD_DB_HOST, user=OLD_DB_USER,
> passwd=OLD_DB_PASS, db=OLD_DB_NAME, use_unicode=True)
> 
> I believe the old tables were latin-1 encoded so it seems like this
> forces them to be unicode encoded which made pushing into the new
> tables as utf8 work correctly?

Might work. Depends if it really is all latin1 encoded or really UTF-8
that has been shoved into a latin1 table (PHP has known problems with
trying to do that, apparently).

This thread  -- [1] -- might be of some interest to you if you're
looking to re-encode your data. Both the suggestions there are
essentially the same process.

[1]
http://groups.google.com/group/django-users/browse_frm/thread/7f7b48dae87f38b4/73d0954bc8ea8673#73d0954bc8ea8673

Regards,
Malcolm

-- 
Remember that you are unique. Just like everyone else. 
http://www.pointy-stick.com/blog/


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



Re: Modeling authentication after the admin site

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 21:23 -0700, meppum wrote:
> I was looking at the why the admin site handles authentication and
> noticed that there are three private methods in
> django.contrib.admin.views.decorators: _display_login_form,
> _encode_post_data, _decode_post_data. It looks like these do more to
> ensure that nothing as been done to tamper with the user cookie, etc.
> 
> Why isn't this built into the authentication framework?

Because that's the way the universe works sometimes.

Those particular decorators have nothing to do with authentication. They
use the authentication framework, but they don't provide authentication.
They are utility decorators for managing the data flow of some forms and
exhibit one approach to that problem, but hardly the only one. If you
want to use them, import them and use them. Nothing's stopping you.

But stop worrying so much about the "why" and just use the stuff you
want to. If you spend all your time wondering why things are where they
are, you won't get anything done. Sometimes things just are the way they
are, possibly for historical reasons (particularly true in Open Source
software), not for any bigger reason.

Malcolm

-- 
Borrow from a pessimist - they don't expect it back. 
http://www.pointy-stick.com/blog/


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



Re: Problem storing utf-8 in MySQL

2008-04-13 Thread Rob Hudson

On Apr 13, 6:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> Do you mean that you are coming across a case of trying to store 4-byte
> UTF-8 sequences in MySQL? Or do you mean that you've managed to create a
> database table with the incorrect encoding and only realised this after
> you've stored data in the table? Or is there a third possibility?

Thanks for the follow up...

In my particular case I have an old database with content that has
built up over the years from a PHP website.  I'm re-building the site
in Django and am working on a database migration script.  For various
text fields in the old tables I was hitting this same error,
"Incorrect string value: '\x[something or other]'  for column
'[something]' at row 1".

I actually ended solving it by telling MySQLdb to "use_unicode", e.g.:
db = MySQLdb.connect(host=OLD_DB_HOST, user=OLD_DB_USER,
passwd=OLD_DB_PASS, db=OLD_DB_NAME, use_unicode=True)

I believe the old tables were latin-1 encoded so it seems like this
forces them to be unicode encoded which made pushing into the new
tables as utf8 work correctly?

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



Re: Security concerns about publically exposing admin tool

2008-04-13 Thread [EMAIL PROTECTED]

Once newforms-admin hits you will be able to change that if you
want(without hacking on the django source).

On Apr 13, 11:08 pm, meppum <[EMAIL PROTECTED]> wrote:
> I simply meant that after a few failed password attempts the user is
> not presented with a CAPTCHA or something. I'll keep all this in mind.
>
> On Apr 13, 11:54 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Sun, 2008-04-13 at 20:36 -0700, meppum wrote:
> > > I noticed that most django sites including djangoproject.com and even
> > > curse.com allow their admin sites to be accessed through the web. This
> > > seems like a bit of a security concern as someone could create a bot
> > > to attempt to collect passwords.
>
> > > Is this common practice or am I wrong about the admin sites ability to
> > > be cracked with brute force?
>
> > Django's admin is no more or less susceptible to brute force password
> > cracking than any other site requiring a login. It's a function of good
> > password choice, not whether something is visible via the web.
>
> > Malcolm
>
> > --
> > Why be difficult when, with a little bit of effort, you could be
> > impossible.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Security concerns about publically exposing admin tool

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 20:36 -0700, meppum wrote:
> I noticed that most django sites including djangoproject.com and even
> curse.com allow their admin sites to be accessed through the web. This
> seems like a bit of a security concern as someone could create a bot
> to attempt to collect passwords.
> 
> Is this common practice or am I wrong about the admin sites ability to
> be cracked with brute force?

Django's admin is no more or less susceptible to brute force password
cracking than any other site requiring a login. It's a function of good
password choice, not whether something is visible via the web.

Malcolm

-- 
Why be difficult when, with a little bit of effort, you could be
impossible. 
http://www.pointy-stick.com/blog/


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



Re: Security concerns about publically exposing admin tool

2008-04-13 Thread Jacob Kaplan-Moss

On Sun, Apr 13, 2008 at 10:36 PM, meppum <[EMAIL PROTECTED]> wrote:
>  Is this common practice or am I wrong about the admin sites ability to
>  be cracked with brute force?

I was curious about this once, too, so I ran a dictionary attack bot
I, erm, "obtained" against my Django admin once. It took about fifteen
hours to find a valid admin password -- and that was a shitty password
(a common household cleaning product, actually) -- but in that time
the site did 30x normal traffic; I'd expect any competent sysadmin
would notice that much extra traffic from a single IP!

If you're extra-paranoid, it's pretty easy to restrict admin access to
particular IPs (do that on the Apache level), move the site from
"/admin/" to somewhere else, or even run the admin on a seperate
server completely behind a firewall. I know of one Django installation
that's only accessible through a VPN.

Jacob

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



Re: Security concerns about publically exposing admin tool

2008-04-13 Thread [EMAIL PROTECTED]

There's no reason you have to put it at /admin/ , you could always put
it somewhere else(/boogy_man/) for security through obscurity.

On Apr 13, 10:36 pm, meppum <[EMAIL PROTECTED]> wrote:
> I noticed that most django sites including djangoproject.com and even
> curse.com allow their admin sites to be accessed through the web. This
> seems like a bit of a security concern as someone could create a bot
> to attempt to collect passwords.
>
> Is this common practice or am I wrong about the admin sites ability to
> be cracked with brute force?
>
> -meppum
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to display a image in the template?

2008-04-13 Thread [EMAIL PROTECTED]

You need to actually be serving static content:
http://www.djangoproject.com/documentation/static_files/

On Apr 13, 10:25 pm, Duke <[EMAIL PROTECTED]> wrote:
> Hi
> Can any tell me how to display a image in the hrml in Django
>
> 
> 
>  Hello, Image
> 
> 
> 
> 
>
> this html is not displaying the image
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to display a image in the template?

2008-04-13 Thread Duke

Hi
Can any tell me how to display a image in the hrml in Django



 Hello, Image





this html is not displaying the image


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



Re: Help with getting drop-downs to work

2008-04-13 Thread steve skelton

acch!-- idiocy located and destroyed.

there was a null field in the countries list.

Yahoo!! thanks!

On Apr 13, 9:26 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sun, Apr 13, 2008 at 9:48 PM, steve skelton <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > thanks - I've tried it both ways and with __str__ get the error
>
> > __str__ returned non-string (type NoneType).
>
> That's odd...
>
>
>
> > the top-level error dump is
>
> > Request Method: GET
> > Request URL:http://localhost:8000/admin/papers_admin/paper/35/
> > Exception Type: TypeError
> > Exception Value:__str__ returned non-string (type NoneType)
> > Exception Location: C:\Python25\lib\site-packages\django\db\models
> > \fields\__init__.py in get_choices, line 302
>
> > all the models where I apply
>
> > __str__ are of the form
>
> > class LuPaperContentRegion(models.Model):
> >paper_content_region = models.CharField(maxlength=150)
>
> >def __str__(self):
> >return self.paper_content_region
>
> >class Meta:
> >db_table='lu_paper_content_region'
>
> Are you building these models from scratch with a new database or working
> with a pre-existing database?  The fact you are specifying db_table in Meta
> makes me think maybe you are trying to map models over an already-existing
> table?  Which can be done, but if the Django model definition isn't
> correctly mapping the real table it might lead to problems.
>
> Right now as that model is defined to Django, the Django admin would not
> allow paper_content_region to be set to null, which is the only way I can
> think of that your __str__() would return None.  So I'm confused how you are
> getting this error.
>
> list to the FK model as
>
>
>
> >Country = models.ForeignKey(LuCountry)
>
> > since this would be a link to the LuCountry table by the ID and my
> > expectation is this might display the ID in the linked table, not a
> > string so perhaps this may be the source of the problem -- but that is
> > just a guess.
>
> Now, the target for the ForeignKey here is LuCountry, which we haven't seen
> before.  Is this the one having a problem or is it the one with
> LuPaperContentRegion?  If its LuCountry that's having the problem that's the
> model we need to see.
>
> To back up to a conceptual level, what the admin is trying to do is build a
> list of all possible targets for this foreign key, in human-readable form,
> for the select drop-down box.  Under the covers it will know the primary key
> ID of each of the elements in the list, and that is what will be stored in
> the table when you select one, but to make it easier to select the right one
> it is going to present the user a friendly list.  So it's essentially going
> to select all the elements in the target table and call your __str__
> function for each one.  (There is an option to turn this off and force the
> user to enter raw IDs for cases where your tables are too large for this
> approach to work well, but you're not using that here.)
>
> So, if you are working with a pre-existing table, any null values in fields
> you are returning with __str__ could be causing this problem.  And that's
> about the only wild guess I have right now to explain what you are seeing.
>
> Karen
>
> > Thanks for your response - hopefully there is a simple thing I am not
> > getting.
>
> > On Apr 13, 8:35 pm, Michael <[EMAIL PROTECTED]> wrote:
> > > Try changing __unicode__ to __str__. The unicode merge was after .96 and
> > > therefore it isn't looking for __unicode__ to define the name of the
> > field.
>
> > > Hope that helps,
>
> > > Michael
>
> > > On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <
> > [EMAIL PROTECTED]>
> > > wrote:
>
> > > > sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> > > > (server) and 5.1.11 (client) and my local install is on Vista laptop
> > > > with Apache and PHP also installed.
>
> > > > On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> > > > > Trying to get admin on my system to load values based on related
> > > > > tables on db.  I have set the FK on the papers table to tie with the
> > > > > PK of each look-up table and set models like so:
>
> > > > > class LuPaperContentEra(models.Model):
> > > > >paper_content_era = models.CharField(blank=True, maxlength=150)
>
> > > > >def __unicode__(self):
> > > > >return self.paper_content_era
>
> > > > >class Meta:
> > > > >db_table='lu_paper_content_era'
>
> > > > > The main table, which should contain drop-downs for things like the
> > > > > model/table above, has things like:
>
> > > > > class Paper(models.Model):
> > > > >... many fields defined
> > > > >PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> > > > >... more fields defined
>
> > > > >class Meta:
> > > > >db_table='papers_admin'
>
> > > > >class Admin:
> > > > >list_display=('id','FirstName','LastName','Institution')
> > > > >search_fields=['LastNa

Re: Accessing Session from urls.py

2008-04-13 Thread [EMAIL PROTECTED]

I would do per request url routing: 
http://www.b-list.org/weblog/2007/nov/06/urlconf/

On Apr 13, 9:17 pm, "Cole Tuininga" <[EMAIL PROTECTED]> wrote:
> Hey folks -
>
> I'm looking to make url "routing" choices based on some values from
> the session.  That is, I want to change the url->view mapping based on
> the session variables.  Problem is, I can't seem to figure out how to
> access the session from urls.py.  I understand that outside views I
> can load up a session object by importing
> django.contrib.sessions.models.Session and then doing a get by using a
> pk of the session id.  But since I don't know how to access the
> request object from within urls.py, I don't know how to get the cookie
> value containing the session id.  :)  And if I could access the
> request object, I wouldn't need to go through that rigamarole, since
> I'd be able to just access request.session directly.
>
> Help?  (I'm using Django 0.96.1, btw)
>
> Many thanks!
>
> --
> Cole Tuiningahttp://www.tuininga.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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with getting drop-downs to work

2008-04-13 Thread steve skelton

yes I am working with legacy data transferred from FileMaker.  That's
why I put in the meta table so the "real" import will work, once it's
ready for production.

There are actually 5 "look up" tables as I call them:

lu_country <-- any countries already selected from the existing data.
the main table papers_admin has just the ID stored for each country.

the remaining tables

lu_paper_content_era
lu_paper_content_genus
lu_paper_content_region
lu_paper_content_topic

Don't really have any data from the source but I set all to 0 in the
main table as this corresponds with a "nothing selected" value in the
look-up table.

So, there are no nulls in the main table for any of these look-up
tables.

And, from what you're saying, Django is smart enough to grab the text
component in the UI and store the ID in the actual table, which is
very cool -- are you sure that's true?  I don't have to tell Django
anything?  What if there's several columns for an ID - what gets
picked for display?  Confusion reigns

Anyhow, I have worked to make sure my db design is expected to only
store the ID selected from a list, not the text, true to the heart of
a RDBMS.

All of these fields are INTEGER, not null as well.

But there are weird little gremlins running around!

I thought "well, let's just rename the main table to something that
doesn't exist yet in syncdb to see what happens" and renamed the model
papers_admin to papers_admin_W_FK -- sycndb just ignored my change.
of course I saved, but re-edited the Models.py file to
papers_admin_Uno_Mas and again syncdb just refuses to notice my
changes.

To make matters worse, the results for inspectdb doesn't even list the
existing tables correctly (papers_admin is now papersadmin), and the
foreign key fields don't exist.  results from SQL papers_app do show
most of the fields from the Model but some of the fields that should
have FK set do and some don't:

`PaperContent_Era_id` integer NOT NULL, <-- where be yon
REFERENCES?
`PaperContent_Genus_id` integer NOT NULL REFERENCES
`lu_paper_content_genus` (`id`),
`PaperContent_Region_id` integer NOT NULL REFERENCES
`lu_paper_content_region` (`id`),
`PaperContent_Topic_id` integer NOT NULL,  <-- where be yon
REFERENCES?

I understand Django will append _ID for FK set fields so I can
understand that these fields may not be explicitly listed in Models.py
but I do have them as columns in the parent table.

And, as I've always noticed, syncdb ALWAYS sets all columns to NOT
NULL regardless of what's in the models file, which is a bit
annoying.  All of this doesn't help of course.  I don't know if
there's any issues with MySQL 5.1, say...

All very weird... I guess i could break this down to one table and one
look-up table first as it's hard to tell what's going on, but my hope
was there's some simple idiocy I am committing.

It's a bit frustrating because if I could get this one last issue
resolved I have gone quite a ways towards finishing this little job.
This is my very first Django project, BTW.

Thanks for all your help!

On Apr 13, 9:26 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sun, Apr 13, 2008 at 9:48 PM, steve skelton <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > thanks - I've tried it both ways and with __str__ get the error
>
> > __str__ returned non-string (type NoneType).
>
> That's odd...
>
>
>
> > the top-level error dump is
>
> > Request Method: GET
> > Request URL:http://localhost:8000/admin/papers_admin/paper/35/
> > Exception Type: TypeError
> > Exception Value:__str__ returned non-string (type NoneType)
> > Exception Location: C:\Python25\lib\site-packages\django\db\models
> > \fields\__init__.py in get_choices, line 302
>
> > all the models where I apply
>
> > __str__ are of the form
>
> > class LuPaperContentRegion(models.Model):
> >paper_content_region = models.CharField(maxlength=150)
>
> >def __str__(self):
> >return self.paper_content_region
>
> >class Meta:
> >db_table='lu_paper_content_region'
>
> Are you building these models from scratch with a new database or working
> with a pre-existing database?  The fact you are specifying db_table in Meta
> makes me think maybe you are trying to map models over an already-existing
> table?  Which can be done, but if the Django model definition isn't
> correctly mapping the real table it might lead to problems.
>
> Right now as that model is defined to Django, the Django admin would not
> allow paper_content_region to be set to null, which is the only way I can
> think of that your __str__() would return None.  So I'm confused how you are
> getting this error.
>
> list to the FK model as
>
>
>
> >Country = models.ForeignKey(LuCountry)
>
> > since this would be a link to the LuCountry table by the ID and my
> > expectation is this might display the ID in the linked table, not a
> > string so perhaps this may be the source of the problem -- but that is
> > just a guess.
>
> Now, the target for th

Re: Help with getting drop-downs to work

2008-04-13 Thread Kenneth Gonsalves


On 14-Apr-08, at 8:25 AM, Karen Tracey wrote:

> I just tried that command and it works for me.  Are you behind a  
> corporate firewall?  I've seen reports that they sometimes  
> interfere with svn traffic, depending on how they are configured.   
> The usual workaround is to use https:// instead of http:// but it  
> doesn't seem that Django's repository is set up to support  
> https://, so I'm not sure what to recommend if a corporate firewall  
> is what is getting in the way, other than to try from somewhere else.

I have seen that a lot - for some weird reason corporate firewalls  
allow https and not http for svn. I changed all my repos to https for  
this reason.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: How to redirect if already logged in

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 19:53 -0700, meppum wrote:
> Okay. So how would I have both an "access gate" that people would be
> redirected to if they try to access a page that requires them to be
> logged in first and a homepage that allows them to login, but
> redirects them to the "access gate" if there is an error while logging
> in (from the homepage)?

The homepage (with the login boxes) won't be access protected. So
anybody can view it. Then your login view would redirect to your access
gate if there was any problem with the login.

Regards,
Malcolm

-- 
The cost of feathers has risen; even down is up! 
http://www.pointy-stick.com/blog/


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



Re: Help with getting drop-downs to work

2008-04-13 Thread Karen Tracey
On Sun, Apr 13, 2008 at 9:59 PM, steve skelton <[EMAIL PROTECTED]>
wrote:

>
> thanks - I am also confused about whether I have the "latest and
> greatest" install as the djangoproject lists .96 as the latest release
> and running
>

.96 is the latest "official release", but not the "latest & greatest".  0.96
is about a year old now and there have been some significant additional
functions added since then.  Unicode support you've already run into,
autoescape is another one, plus a year's worth of bug fixes and little
improvements.  They haven't been packaged into an official release because
there are still some more backwards-incompatible improvements coming in
(newforms-admin, maybe some of queryset-refactor) and the developers have
decided it's better overall for users who go with official releases to have
to make just one (bigger) step/conversion from 0.96 to 1.0 rather than a
series of smaller ones.

But a lot of people want the new functions sooner rather than later, so they
run with an SVN checkout.  Which is generally fine, since the Django trunk
is usually quite stable.  Backwards incompatible changes that are made are
listed (http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges) so
that as people update their SVN checkouts they can make whatever changes
might be necessary.


> svn co http://code.djangoproject.com/svn/django/trunk/ in cmd.exe
> returns an error
>
> PROPFIND request failed on '/svn/django/trunk'
>

I just tried that command and it works for me.  Are you behind a corporate
firewall?  I've seen reports that they sometimes interfere with svn traffic,
depending on how they are configured.  The usual workaround is to use
https:// instead of http:// but it doesn't seem that Django's repository is
set up to support https://, so I'm not sure what to recommend if a corporate
firewall is what is getting in the way, other than to try from somewhere
else.

Karen

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



Re: How to redirect if already logged in

2008-04-13 Thread meppum

Okay. So how would I have both an "access gate" that people would be
redirected to if they try to access a page that requires them to be
logged in first and a homepage that allows them to login, but
redirects them to the "access gate" if there is an error while logging
in (from the homepage)?

On Apr 13, 10:33 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-04-13 at 19:27 -0700, meppum wrote:
> > The behavior of the admin tool is to require a login, but if the user
> > is already logged in they are redirected to the index page. I looked
> > at both the template and the view for the root url of the admin tool
> > but didn't see how this is being down.
>
> It's not being done that way. In fact, the opposite is happening. If you
> try to access the admin site and you are NOT logged in, you are
> redirected to the login page. This is done via the
> staff_member_required() wrapper around the index() function in
> django.contrib.admin.views.main.
>
> That's the normal way authenticated access is implemented, too. Normal
> URL accesses go the intended page, but first check for permission and,
> if not permitted, redirect to the login section (or elsewhere). That
> means that logged in people don't have the extra network round-trip of
> the HTTP redirect call.
>
> Regards,
> Malcolm
>
> --
> The cost of feathers has risen; even down is 
> up!http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to redirect if already logged in

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 19:27 -0700, meppum wrote:
> The behavior of the admin tool is to require a login, but if the user
> is already logged in they are redirected to the index page. I looked
> at both the template and the view for the root url of the admin tool
> but didn't see how this is being down.

It's not being done that way. In fact, the opposite is happening. If you
try to access the admin site and you are NOT logged in, you are
redirected to the login page. This is done via the
staff_member_required() wrapper around the index() function in
django.contrib.admin.views.main.

That's the normal way authenticated access is implemented, too. Normal
URL accesses go the intended page, but first check for permission and,
if not permitted, redirect to the login section (or elsewhere). That
means that logged in people don't have the extra network round-trip of
the HTTP redirect call.

Regards,
Malcolm

-- 
The cost of feathers has risen; even down is up! 
http://www.pointy-stick.com/blog/


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



Re: Help with getting drop-downs to work

2008-04-13 Thread Karen Tracey
On Sun, Apr 13, 2008 at 9:48 PM, steve skelton <[EMAIL PROTECTED]>
wrote:

>
> thanks - I've tried it both ways and with __str__ get the error
>
> __str__ returned non-string (type NoneType).
>

That's odd...


> the top-level error dump is
>
> Request Method: GET
> Request URL:http://localhost:8000/admin/papers_admin/paper/35/
> Exception Type: TypeError
> Exception Value:__str__ returned non-string (type NoneType)
> Exception Location: C:\Python25\lib\site-packages\django\db\models
> \fields\__init__.py in get_choices, line 302
>
> all the models where I apply
>
> __str__ are of the form
>
> class LuPaperContentRegion(models.Model):
>paper_content_region = models.CharField(maxlength=150)
>
>def __str__(self):
>return self.paper_content_region
>
>class Meta:
>db_table='lu_paper_content_region'


Are you building these models from scratch with a new database or working
with a pre-existing database?  The fact you are specifying db_table in Meta
makes me think maybe you are trying to map models over an already-existing
table?  Which can be done, but if the Django model definition isn't
correctly mapping the real table it might lead to problems.

Right now as that model is defined to Django, the Django admin would not
allow paper_content_region to be set to null, which is the only way I can
think of that your __str__() would return None.  So I'm confused how you are
getting this error.

list to the FK model as
>
>Country = models.ForeignKey(LuCountry)
>
> since this would be a link to the LuCountry table by the ID and my
> expectation is this might display the ID in the linked table, not a
> string so perhaps this may be the source of the problem -- but that is
> just a guess.
>

Now, the target for the ForeignKey here is LuCountry, which we haven't seen
before.  Is this the one having a problem or is it the one with
LuPaperContentRegion?  If its LuCountry that's having the problem that's the
model we need to see.

To back up to a conceptual level, what the admin is trying to do is build a
list of all possible targets for this foreign key, in human-readable form,
for the select drop-down box.  Under the covers it will know the primary key
ID of each of the elements in the list, and that is what will be stored in
the table when you select one, but to make it easier to select the right one
it is going to present the user a friendly list.  So it's essentially going
to select all the elements in the target table and call your __str__
function for each one.  (There is an option to turn this off and force the
user to enter raw IDs for cases where your tables are too large for this
approach to work well, but you're not using that here.)

So, if you are working with a pre-existing table, any null values in fields
you are returning with __str__ could be causing this problem.  And that's
about the only wild guess I have right now to explain what you are seeing.

Karen


> Thanks for your response - hopefully there is a simple thing I am not
> getting.
>
> On Apr 13, 8:35 pm, Michael <[EMAIL PROTECTED]> wrote:
> > Try changing __unicode__ to __str__. The unicode merge was after .96 and
> > therefore it isn't looking for __unicode__ to define the name of the
> field.
> >
> > Hope that helps,
> >
> > Michael
> >
> > On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <
> [EMAIL PROTECTED]>
> > wrote:
> >
> >
> >
> > > sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> > > (server) and 5.1.11 (client) and my local install is on Vista laptop
> > > with Apache and PHP also installed.
> >
> > > On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> > > > Trying to get admin on my system to load values based on related
> > > > tables on db.  I have set the FK on the papers table to tie with the
> > > > PK of each look-up table and set models like so:
> >
> > > > class LuPaperContentEra(models.Model):
> > > >paper_content_era = models.CharField(blank=True, maxlength=150)
> >
> > > >def __unicode__(self):
> > > >return self.paper_content_era
> >
> > > >class Meta:
> > > >db_table='lu_paper_content_era'
> >
> > > > The main table, which should contain drop-downs for things like the
> > > > model/table above, has things like:
> >
> > > > class Paper(models.Model):
> > > >... many fields defined
> > > >PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> > > >... more fields defined
> >
> > > >class Meta:
> > > >db_table='papers_admin'
> >
> > > >class Admin:
> > > >list_display=('id','FirstName','LastName','Institution')
> > > >search_fields=['LastName']
> >
> > > > However, Admin displays the drop-down as
> >
> > > > LuPaperContactEra object, NOT the actual human-readable value list.
> >
> > > > I feel I am probably close to getting this to work but can't seem to
> > > > find the right direction in which to be "nudged".
> >
> > > > Thanks!
> >
>

--~--~-~--~-

Accessing Session from urls.py

2008-04-13 Thread Cole Tuininga

Hey folks -

I'm looking to make url "routing" choices based on some values from
the session.  That is, I want to change the url->view mapping based on
the session variables.  Problem is, I can't seem to figure out how to
access the session from urls.py.  I understand that outside views I
can load up a session object by importing
django.contrib.sessions.models.Session and then doing a get by using a
pk of the session id.  But since I don't know how to access the
request object from within urls.py, I don't know how to get the cookie
value containing the session id.  :)  And if I could access the
request object, I wouldn't need to go through that rigamarole, since
I'd be able to just access request.session directly.

Help?  (I'm using Django 0.96.1, btw)

Many thanks!

-- 
Cole Tuininga
http://www.tuininga.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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strange, strange behaviour

2008-04-13 Thread Malcolm Tredinnick


On Mon, 2008-04-14 at 03:58 +0200, Monica Leko wrote:
[...]
> In settings.py I have
> 
> INSTALLED_APPS = (
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.admin',
>  'django.contrib.auth',
>  "app.app_chart",
> )
> 
> PYTHONPATH is: C:\Documents and Settings\Boris\Desktop\django\app

The Python path must include the *parent* directories of anything you
are importing. That is a standard Python requirement.

Since you are trying to import app.app_chart, you need to have the
parent directory of app/ in your Python path (which you don't; you only
have the parent of app_chart in your Python path). Alternatively, change
the string from "app.app_chart" to just "app_chart" in the
INSTALLED_APPS list.

Regards,
Malcolm

-- 
Success always occurs in private and failure in full view. 
http://www.pointy-stick.com/blog/


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



Re: Help with getting drop-downs to work

2008-04-13 Thread steve skelton

thanks - I am also confused about whether I have the "latest and
greatest" install as the djangoproject lists .96 as the latest release
and running

svn co http://code.djangoproject.com/svn/django/trunk/ in cmd.exe
returns an error

PROPFIND request failed on '/svn/django/trunk'

the latest version listed is 0.96.1 so ??

but I do suspect my problem stems from the FK connection to the lookup
table is only returning the ID number, not the text field:


File "C:\Python25\lib\site-packages\django\db\models\fields
\__init__.py" in get_choices
  302. lst = [(getattr(x, self.rel.get_related_field().attname),
str(x)) for x in
rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]

I notice the reference to get_related_field() there.  I could be
wrong, that does make some sense.

On Apr 13, 8:36 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> > (server) and 5.1.11 (client) and my local install is on Vista laptop
> > with Apache and PHP also installed.
>
> The problem is your code below is using __unicode__ as the method to display
> itself, and that was not added until after the 0.96 release.  So when the
> (0.96.1) admin goes to display your objects it doesn't find the str() method
> it looks for to do that, so just displays the kind of object it is.
>
> So, you can either upgrade to an SVN checkout of Django, or change your
> __unicode__ methods to str ones.  If you stick with 0.96.1, you'll also need
> to watch out for other things added since then, since it seems you are using
> doc that is post-0.96.1, or switch to using the 0.96 docs.
>
> Karen
>
> On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
>
> > > Trying to get admin on my system to load values based on related
> > > tables on db.  I have set the FK on the papers table to tie with the
> > > PK of each look-up table and set models like so:
>
> > > class LuPaperContentEra(models.Model):
> > >paper_content_era = models.CharField(blank=True, maxlength=150)
>
> > >def __unicode__(self):
> > >return self.paper_content_era
>
> > >class Meta:
> > >db_table='lu_paper_content_era'
>
> > > The main table, which should contain drop-downs for things like the
> > > model/table above, has things like:
>
> > > class Paper(models.Model):
> > >... many fields defined
> > >PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> > >... more fields defined
>
> > >class Meta:
> > >db_table='papers_admin'
>
> > >class Admin:
> > >list_display=('id','FirstName','LastName','Institution')
> > >search_fields=['LastName']
>
> > > However, Admin displays the drop-down as
>
> > > LuPaperContactEra object, NOT the actual human-readable value list.
>
> > > I feel I am probably close to getting this to work but can't seem to
> > > find the right direction in which to be "nudged".
>
> > > Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Strange, strange behaviour

2008-04-13 Thread Monica Leko

My appname was app, ant then I renamed app to app_chart.  My
application works like a charm, but when I tried to run som unittests
today, i got som unexpected error which wasn't there when app was the
name of application

  File "C:\Python25\lib\site-packages\django\db\models\base.py", line
169, in add_to_class
value.contribute_to_class(cls, name)
  File "C:\Python25\lib\site-packages\django\db\models\options.py",
line 53, in contribute_to_class
setattr(self, 'verbose_name_plural',
meta_attrs.pop('verbose_name_plural', self.verbose_name + 's'))
  File "C:\Python25\lib\site-packages\django\utils\functional.py",
line 42, in __wrapper__
res = self.__func(*self.__args, **self.__kw)
  File "C:\Python25\lib\site-packages\django\utils\translation\trans_real.py",
line 268, in gettext
_default = translation(settings.LANGUAGE_CODE)
  File "C:\Python25\lib\site-packages\django\utils\translation\trans_real.py",
line 197, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File "C:\Python25\lib\site-packages\django\utils\translation\trans_real.py",
line 180, in _fetch
app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]),
appname[p+1:])
ImportError: No module named app

In settings.py I have

INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
 'django.contrib.auth',
 "app.app_chart",
)

PYTHONPATH is: C:\Documents and Settings\Boris\Desktop\django\app

and the testfile is in app folder

Any ideas?

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



Re: Help with getting drop-downs to work

2008-04-13 Thread steve skelton

thanks - I've tried it both ways and with __str__ get the error

__str__ returned non-string (type NoneType).

the top-level error dump is

Request Method: GET
Request URL:http://localhost:8000/admin/papers_admin/paper/35/
Exception Type: TypeError
Exception Value:__str__ returned non-string (type NoneType)
Exception Location: C:\Python25\lib\site-packages\django\db\models
\fields\__init__.py in get_choices, line 302

all the models where I apply

__str__ are of the form

class LuPaperContentRegion(models.Model):
paper_content_region = models.CharField(maxlength=150)

def __str__(self):
return self.paper_content_region

class Meta:
db_table='lu_paper_content_region'

Now, I am a little confused as to the general set-up for attaching a
list to the FK model as

Country = models.ForeignKey(LuCountry)

since this would be a link to the LuCountry table by the ID and my
expectation is this might display the ID in the linked table, not a
string so perhaps this may be the source of the problem -- but that is
just a guess.

Thanks for your response - hopefully there is a simple thing I am not
getting.

On Apr 13, 8:35 pm, Michael <[EMAIL PROTECTED]> wrote:
> Try changing __unicode__ to __str__. The unicode merge was after .96 and
> therefore it isn't looking for __unicode__ to define the name of the field.
>
> Hope that helps,
>
> Michael
>
> On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> > (server) and 5.1.11 (client) and my local install is on Vista laptop
> > with Apache and PHP also installed.
>
> > On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> > > Trying to get admin on my system to load values based on related
> > > tables on db.  I have set the FK on the papers table to tie with the
> > > PK of each look-up table and set models like so:
>
> > > class LuPaperContentEra(models.Model):
> > >paper_content_era = models.CharField(blank=True, maxlength=150)
>
> > >def __unicode__(self):
> > >return self.paper_content_era
>
> > >class Meta:
> > >db_table='lu_paper_content_era'
>
> > > The main table, which should contain drop-downs for things like the
> > > model/table above, has things like:
>
> > > class Paper(models.Model):
> > >... many fields defined
> > >PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> > >... more fields defined
>
> > >class Meta:
> > >db_table='papers_admin'
>
> > >class Admin:
> > >list_display=('id','FirstName','LastName','Institution')
> > >search_fields=['LastName']
>
> > > However, Admin displays the drop-down as
>
> > > LuPaperContactEra object, NOT the actual human-readable value list.
>
> > > I feel I am probably close to getting this to work but can't seem to
> > > find the right direction in which to be "nudged".
>
> > > Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with getting drop-downs to work

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 18:28 -0700, steve skelton wrote:
> sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> (server) and 5.1.11 (client) and my local install is on Vista laptop
> with Apache and PHP also installed.

Unicode support went in after 0.96 was released (and 0.96.1 is 0.96 +
security fixes only), so the __unicode__ method will not be called in
your example.

I see now that we've accidentally left off the "new in development
version" annotation on the __unicode__ documentation in model-api.txt,
but, anyway, that's the situation. Use __str__ only for 0.96.

Regards,
Malcolm

-- 
I just got lost in thought. It was unfamiliar territory. 
http://www.pointy-stick.com/blog/


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



Re: Problem storing utf-8 in MySQL

2008-04-13 Thread Malcolm Tredinnick

Rob,

On Sun, 2008-04-13 at 13:28 -0700, Rob Hudson wrote:
[...]
> For those of us having a very similar problem elsewhere, what's a good
> general solution?

Depends on the general problem. :-)

Do you mean that you are coming across a case of trying to store 4-byte
UTF-8 sequences in MySQL? Or do you mean that you've managed to create a
database table with the incorrect encoding and only realised this after
you've stored data in the table? Or is there a third possibility?

Regards,
Malcolm

-- 
Why be difficult when, with a little bit of effort, you could be
impossible. 
http://www.pointy-stick.com/blog/


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



Re: How to overwrite the hyperlink of objects in change list template of django admin?

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 06:20 -0700, Leon wrote:
> Hi,
>   I use django admin to manage a table. There is a hyperlink for
> each object in the change_list template, which will bring me to the
> change_form template. I want to change that hyperlink and redirect it
> to another url to handle. I didn't want to customize the current
> change_form for this model because it is still used somewhere else.
>   Anybody knows how to do it?

It's possible, but fairly fiddly. You can create a custom
change_list.html template for just that application + model name
combination (since the admin interface tries to load a template under
admin///change_list.html as one of the options for
that page). Then you need to write a template that displays what you
would like, which possibly means duplicating a lot of the logic of the
original page and the template tags that construct it. With a bit of
tracing through the code (admin/templates/admin/change_list.html,
admin/tempates/admin/change_list_result.html,
admin/templatetags/admin_list.py, admin/views/main.py) it should be
quite possible to achieve what you want. Take your time and you'll get
there (or use newforms-admin or wait for newforms-admin to be merged
into trunk, both of which will be easier).

Note that this sort of customisation does require you to read some
Python code and templates and do a bit of design work. There isn't a
step-by-step guide, so if you aren't up to being able to read the code a
bit, this probably isn't the right sort of customisation to be trying to
make.

Regards,
Malcolm

-- 
Tolkien is hobbit-forming. 
http://www.pointy-stick.com/blog/


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



Re: Help with getting drop-downs to work

2008-04-13 Thread Karen Tracey
On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <[EMAIL PROTECTED]>
wrote:

>
> sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> (server) and 5.1.11 (client) and my local install is on Vista laptop
> with Apache and PHP also installed.
>

The problem is your code below is using __unicode__ as the method to display
itself, and that was not added until after the 0.96 release.  So when the
(0.96.1) admin goes to display your objects it doesn't find the str() method
it looks for to do that, so just displays the kind of object it is.

So, you can either upgrade to an SVN checkout of Django, or change your
__unicode__ methods to str ones.  If you stick with 0.96.1, you'll also need
to watch out for other things added since then, since it seems you are using
doc that is post-0.96.1, or switch to using the 0.96 docs.

Karen

On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> > Trying to get admin on my system to load values based on related
> > tables on db.  I have set the FK on the papers table to tie with the
> > PK of each look-up table and set models like so:
> >
> > class LuPaperContentEra(models.Model):
> >paper_content_era = models.CharField(blank=True, maxlength=150)
> >
> >def __unicode__(self):
> >return self.paper_content_era
> >
> >class Meta:
> >db_table='lu_paper_content_era'
> >
> > The main table, which should contain drop-downs for things like the
> > model/table above, has things like:
> >
> > class Paper(models.Model):
> >... many fields defined
> >PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> >... more fields defined
> >
> >class Meta:
> >db_table='papers_admin'
> >
> >class Admin:
> >list_display=('id','FirstName','LastName','Institution')
> >search_fields=['LastName']
> >
> > However, Admin displays the drop-down as
> >
> > LuPaperContactEra object, NOT the actual human-readable value list.
> >
> > I feel I am probably close to getting this to work but can't seem to
> > find the right direction in which to be "nudged".
> >
> > Thanks!
> >
>

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



Re: Help with getting drop-downs to work

2008-04-13 Thread Michael
Try changing __unicode__ to __str__. The unicode merge was after .96 and
therefore it isn't looking for __unicode__ to define the name of the field.

Hope that helps,

Michael

On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <[EMAIL PROTECTED]>
wrote:

>
> sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> (server) and 5.1.11 (client) and my local install is on Vista laptop
> with Apache and PHP also installed.
>
> On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> > Trying to get admin on my system to load values based on related
> > tables on db.  I have set the FK on the papers table to tie with the
> > PK of each look-up table and set models like so:
> >
> > class LuPaperContentEra(models.Model):
> >paper_content_era = models.CharField(blank=True, maxlength=150)
> >
> >def __unicode__(self):
> >return self.paper_content_era
> >
> >class Meta:
> >db_table='lu_paper_content_era'
> >
> > The main table, which should contain drop-downs for things like the
> > model/table above, has things like:
> >
> > class Paper(models.Model):
> >... many fields defined
> >PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> >... more fields defined
> >
> >class Meta:
> >db_table='papers_admin'
> >
> >class Admin:
> >list_display=('id','FirstName','LastName','Institution')
> >search_fields=['LastName']
> >
> > However, Admin displays the drop-down as
> >
> > LuPaperContactEra object, NOT the actual human-readable value list.
> >
> > I feel I am probably close to getting this to work but can't seem to
> > find the right direction in which to be "nudged".
> >
> > Thanks!
> >
>

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



Re: Tag

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 13:22 -0300, Claudio Escudero wrote:
> Hi,
> 
> What is block-like tag?

Something with a start and end tag. For example, {%block %}...{%
endblock %}, or {% if %}{% else %}...{% endif %}

Regards,
Malcolm

-- 
The cost of feathers has risen; even down is up! 
http://www.pointy-stick.com/blog/


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



Re: Help with getting drop-downs to work

2008-04-13 Thread steve skelton

sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
(server) and 5.1.11 (client) and my local install is on Vista laptop
with Apache and PHP also installed.

On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> Trying to get admin on my system to load values based on related
> tables on db.  I have set the FK on the papers table to tie with the
> PK of each look-up table and set models like so:
>
> class LuPaperContentEra(models.Model):
>paper_content_era = models.CharField(blank=True, maxlength=150)
>
>def __unicode__(self):
>return self.paper_content_era
>
>class Meta:
>db_table='lu_paper_content_era'
>
> The main table, which should contain drop-downs for things like the
> model/table above, has things like:
>
> class Paper(models.Model):
>... many fields defined
>PaperContent_Era = models.ForeignKey(LuPaperContentEra)
>... more fields defined
>
>class Meta:
>db_table='papers_admin'
>
>class Admin:
>list_display=('id','FirstName','LastName','Institution')
>search_fields=['LastName']
>
> However, Admin displays the drop-down as
>
> LuPaperContactEra object, NOT the actual human-readable value list.
>
> I feel I am probably close to getting this to work but can't seem to
> find the right direction in which to be "nudged".
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Help with getting drop-downs to work

2008-04-13 Thread steve skelton

Trying to get admin on my system to load values based on related
tables on db.  I have set the FK on the papers table to tie with the
PK of each look-up table and set models like so:

class LuPaperContentEra(models.Model):
   paper_content_era = models.CharField(blank=True, maxlength=150)

   def __unicode__(self):
   return self.paper_content_era

   class Meta:
   db_table='lu_paper_content_era'

The main table, which should contain drop-downs for things like the
model/table above, has things like:

class Paper(models.Model):
   ... many fields defined
   PaperContent_Era = models.ForeignKey(LuPaperContentEra)
   ... more fields defined

   class Meta:
   db_table='papers_admin'

   class Admin:
   list_display=('id','FirstName','LastName','Institution')
   search_fields=['LastName']

However, Admin displays the drop-down as

LuPaperContactEra object, NOT the actual human-readable value list.

I feel I am probably close to getting this to work but can't seem to
find the right direction in which to be "nudged".

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



Re: Announcing the Django Dash!

2008-04-13 Thread Jonathan Lukens

What about Python libraries like PIL or ReportLab?

On Apr 11, 10:42 pm, "Daniel Lindsley" <[EMAIL PROTECTED]> wrote:
> We'd like to announce the firstDjangoDash
> (http://www.djangodash.com/) to the community.DjangoDashis a web
> application building competition forDjangodevelopers. The gist is
> that you and (optionally) one other person can form a team and have 48
> hours to crank out a fullDjangoapplication. Your application will
> then be pitted against others for bragging rights (and hopefully some
> prizes).
>
> ==
>
> What IsDjangoDash?
> A 48 hour, start-to-finish race to produce the bestDjango-based web
> application you can. Mostly for fun/bragging rights but we're working
> on upping the ante.
>
> Who Can Compete?
> Anyone but myself and (hopefully) three other judges, though this is
> subject to change depending on popularity.
>
> When Is It?
> We'll be hosting theDashon May 31 - June 1, 2008.
>
> Where?
> We're running this over the web, so you can be anywhere you like.
> Coffee shop, work (though we're not responsible for the ramifications
> of that one), at home, wherever you can find internet access and
> power.
>
> How Can I Compete?
> First, please peruse the rules and judging information 
> athttp://www.djangodash.com/. We will be opening registration for teams
> on May 3, 2008. You're not allowed to start anything but ideas and
> paper mockups until the competition begins on May 31, 2008.
>
> Why?
> It's a chance to test yourself and push your limits. A chance to show
> people what you're capable of. Maybe some exposure. But mostly because
> we've found competitions like this to be a lot of fun.
>
> ==
>
> More details can be found athttp://www.djangodash.com/. We will keep
> it updated as things develop. If you're interested in competing in theDash, 
> we'd appreciate if you'd fill out the mini-email form on the
> front page so we can get an idea of how many people are interested.
>
> How can I help out?
> TheDashis really missing two things right now. First, we'd like to
> have three fair judges signed on to help judge the apps once the
> competition is over. Second, we're looking for sponsors who can
> provide prizes as awards. No minimum/maximum dollar value is
> required/requested. More details on this can be found 
> athttp://www.djangodash.com/sponsors/.
>
> Thanks and hope to see some of you competing!
>
> Daniel Lindsley
> Toast Drivenhttp://www.toastdriven.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: can i join your group

2008-04-13 Thread andy baxter

a.f wrote:
> am intersting in web desgining & puplishing
> e books & soft wear
> seo & ather stuff
>   
If you can read this, you're already subscribed to the group.

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



Latest passages youtube

2008-04-13 Thread ahmad

Latest passages youtube

http://www.youtube.com/watch?v=wS1hPZiuXnk

http://www.youtube.com/watch?v=sSutNlV4Tq0

   http://www.youtube.com/watch?v=K20FaUQpCEk

http://www.youtube.com/watch?v=wgkDtlod8Wg

http://www.youtube.com/watch?v=FOCNi-bCA-U

http://www.youtube.com/watch?v=ZN7NvdrF_Ok

http://www.youtube.com/watch?v=6MWFSy1md-Y

http://www.lecalame.org/english/html/index.htm


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



Re: TemplateSyntaxError when moving from 0.96.1 to SVN

2008-04-13 Thread Ramiro Morales

On Sun, Apr 13, 2008 at 7:36 PM, Gonzalo Delgado
<[EMAIL PROTECTED]> wrote:
> Hi there, I'm trying to move my django projects to  0.97-pre (trunk). The 
> first error I get is this one (when trying to load the admin interface in a 
> small project):
>
>  TemplateSyntaxError at /admin
>  Template u'admin/base_site.html' cannot be extended, because it doesn't exist

Are you extending the admin app UI?.

>
>  Is there a guide for this kind of migration?

Yes, take a look at

http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges

Regards,

-- 
 Ramiro Morales

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



TemplateSyntaxError when moving from 0.96.1 to SVN

2008-04-13 Thread Gonzalo Delgado
Hi there, I'm trying to move my django projects to  0.97-pre (trunk). The first 
error I get is this one (when trying to load the admin interface in a small 
project):

TemplateSyntaxError at /admin
Template u'admin/base_site.html' cannot be extended, because it doesn't exist

Is there a guide for this kind of migration?

Thanks!

-- 
Gonzalo Delgado <[EMAIL PROTECTED]>


pgpNOe1gkT19T.pgp
Description: PGP signature


problem installing GeoDjango (ERROR: Testing closing Polygon objects)

2008-04-13 Thread Tyler Erickson

I have been trying to install GeoDjango for the first time following
the instructions on: http://code.djangoproject.com/wiki/GeoDjangoInstall
The install seems to go fine, but I get an error when running the
test_gdal.run() test that is testing the closing of a polygon object
(output included at end of message)

Here is my setup:
-
Ubuntu 7.10
GDAL - package libgdal1-1.4.0, version 1.4.1-6build1 (installed by
synaptic)
PostgreSQL 8.3 (installed by synaptic)
PostGIS 1.2.1 (built with GEOS="3.0.0-CAPI-1.4.1" PROJ="Rel. 4.5.0,
22, Oct 2006")

My PythonPath contains /usr/lib/ogdi which is where libgdal.so is
located.
In [7]: sys.path
Out[7]:
['',
 '/home/terickson/eclipse_workspace/django_gis_test/django_gis_test',
 '/usr/lib/python25.zip',
 '/usr/lib/python2.5',
 '/usr/lib/python2.5/plat-linux2',
 '/usr/lib/python2.5/lib-tk',
 '/usr/lib/python2.5/lib-dynload',
 '/usr/local/lib/python2.5/site-packages',
 '/usr/lib/python2.5/site-packages',
 '/usr/lib/python2.5/site-packages/Numeric',
 '/usr/lib/python2.5/site-packages/PIL',
 '/home/terickson/eclipse_workspace/django_gis',
 '/usr/lib/ogdi',
 '/usr/lib/python2.5/site-packages/gst-0.10',
 '/var/lib/python-support/python2.5',
 '/usr/lib/python2.5/site-packages/gtk-2.0',
 '/var/lib/python-support/python2.5/gtk-2.0',
 '/var/lib/python-support/python2.5/IPython/Extensions',
 '/home/terickson/.ipython']

Any thoughts on what is causing the test to fail?

- Tyler



[EMAIL PROTECTED]:~/eclipse_workspace/django_gis_test/
django_gis_test$ python manage.py shell
Python 2.5.1 (r251:54863, Mar  7 2008, 04:10:12)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.1 -- An enhanced Interactive Python.
?   -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help-> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.contrib.gis.gdal import HAS_GDAL

In [2]: print HAS_GDAL
True

In [3]: from django.contrib.gis.tests import test_gdal

In [4]: test_gdal.run()
...
BEGIN - expecting IllegalArgumentException; safe to ignore.

ERROR 1: IllegalArgumentException: points must form a closed
linestring

END - expecting IllegalArgumentException; safe to ignore.

E.
==
ERROR: Testing closing Polygon objects.
--
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/contrib/gis/tests/
test_gdal_geom.py", line 201, in test07b_closepolygons
self.assertEqual(10, poly.point_count) # Two closing points
should've been added
  File "/usr/lib/python2.5/site-packages/django/contrib/gis/gdal/
geometries.py", line 568, in point_count
return sum([self[i].point_count for i in xrange(self.geom_count)])
  File "/usr/lib/python2.5/site-packages/django/contrib/gis/gdal/
geometries.py", line 549, in __getitem__
return OGRGeometry(clone_geom(get_geom_ref(self._ptr, index)),
self.srs)
  File "/usr/lib/python2.5/site-packages/django/contrib/gis/gdal/
geometries.py", line 131, in __init__
self.__class__ = GEO_CLASSES[self.geom_type.num]
  File "/usr/lib/python2.5/site-packages/django/contrib/gis/gdal/
geometries.py", line 204, in geom_type
return OGRGeomType(get_geom_type(self._ptr))
  File "/home/terickson/eclipse_workspace/django_gis/django/contrib/
gis/gdal/geomtype.py", line 24, in __init__
raise OGRException('Invalid OGR Integer Type: %d' % type_input)
OGRException: Invalid OGR Integer Type: -2147483646

--
Ran 45 tests in 0.397s

FAILED (errors=1)

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



Re: Custom field not created with model inheritance

2008-04-13 Thread Julien

Sorry, I forgot to mention. I'm using the queryset-refactor branch.

On Apr 14, 1:40 am, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Do you use proper django branch with model inheritance support? Trunk
> doesn't
>
> On Apr 13, 5:37 pm, Julien <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm trying to have a model inherit from another which has a custom
> > field:
>
> > import uuid
> > from django.db import models
> > from django.db.models.fields import CharField
>
> > class UuidField(CharField):# <- The custom field
> > def __init__(self, verbose_name=None, name=None, auto=False,
> > **kwargs):
> > self.auto = auto
> > kwargs['max_length'] = 36
> > kwargs['unique'] = True
> > if auto:
> > kwargs['editable'] = False
> > kwargs['blank'] = True
> > super(UuidField, self).__init__(verbose_name, name, **kwargs)
>
> > def pre_save(self, model_instance, add):
> > value = super(UuidField, self).pre_save(model_instance, add)
> > if (not value) and self.auto:
> > # Assign a new value for this attribute if required.
> > value = str(uuid.uuid1())
> > setattr(model_instance, self.attname, value)
> > return value
>
> > def get_internal_type(self):
> > return "UuidField"
>
> > Then, I do:
>
> > class AbstractClass(models.Model):
> > uuid = UuidField(auto=True)
> > name = models.CharField(max_length=80, blank=True)
> > class Meta:
> > abstract = True
>
> > class MyClass(AbstractClass):
> > title = models.CharField(max_length=80, blank=True)
>
> > The problem is that when I run syncdb, the table 'myclass' only
> > contains the attributes 'name' and 'title', not 'uuid'.
>
> > What am I missing. Do I need to alter the UUIField class to make it
> > compatible with model inheritance?
>
> > Thanks a lot!
>
> > Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



can i join your group

2008-04-13 Thread a.f

am intersting in web desgining & puplishing
e books & soft wear
seo & ather stuff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem storing utf-8 in MySQL

2008-04-13 Thread Rob Hudson

On Mar 21, 4:19 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> OK, got it now.  Turns out the answer is in the clear-as-mud error message,
> sort of:
>
> Warning: Incorrect string value: '\xF0\x90\x8C\xBC\xF0\x90...'
>
> x'f0908cbc' is a valid 4-byte UTF-8 value, only MySQL doesn't support 4-byte
> UTF-8.  Its 'utf8' character set only supports up to 3-byte UTF-8, see:
>
> http://dev.mysql.com/doc/refman/5.0/en/charset-unicode.html
>
> Support for 4-byte UTF-8 is listed near the top of what's coming in 6.0:
>
> http://dev.mysql.com/doc/refman/6.0/en/mysql-nutshell.html
>
> I've seen references to turning off strict mode in MySQL to get rid of
> problems like this, but haven't played with that at all.  I'm not sure what
> MySQL will do with the problem data if you turn off strict mode.
>
> If you want to just remove the problematic 4-byte UTF-8 codes from the file,
> they're only present in the Gothic (line 47) and 2nd Vietnamese (line 123)
> of the "I Can Eat Glass" translations.  Without those two translations MySQL
> accepts the data.
>
> Karen

For those of us having a very similar problem elsewhere, what's a good
general solution?

1. Check that the table is indeed utf8.
2. ???

Does attempting to re-encode the UTF8 string work?  Try the mysql
strict mode thing you mentioned?

Thanks,
Rob


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



How to check if a value of a model field has changed?

2008-04-13 Thread Patrick Lauber

Hi all,

I need to find out in a pre_save signal if a value of a model has  
changed. So far i had no luck with a solution. Is there a way to do  
that besides loading the instance again in the pre_save signal?

cheers

Pat

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



Re: Tag

2008-04-13 Thread Alex Koshelev

Look at the docs:
http://www.djangoproject.com/documentation/templates_python/#parsing-until-another-block-tag

On Apr 13, 8:22 pm, "Claudio Escudero" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> What is block-like tag?
> =/
>
> Thanks,
> Claudio
>
> On Sat, Apr 12, 2008 at 10:26 PM, Malcolm Tredinnick <
>
>
>
> [EMAIL PROTECTED]> wrote:
>
> > On Sat, 2008-04-12 at 18:45 -0300, Claudio Escudero wrote:
> > > Hi,
>
> > > Please, is there any way to put tag inside tag?
>
> > No, this isn't possible. Use a block-like tag (something with a start
> > tag and an end tag) if you want to do something like this.
>
> > Regards,
> > Malcolm
>
> > --
> > The cost of feathers has risen; even down is up!
> >http://www.pointy-stick.com/blog/
>
> --
> Claudio Escudero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Tag

2008-04-13 Thread Claudio Escudero
Hi,

What is block-like tag?
=/

Thanks,
Claudio

On Sat, Apr 12, 2008 at 10:26 PM, Malcolm Tredinnick <
[EMAIL PROTECTED]> wrote:

>
>
> On Sat, 2008-04-12 at 18:45 -0300, Claudio Escudero wrote:
> > Hi,
> >
> > Please, is there any way to put tag inside tag?
>
> No, this isn't possible. Use a block-like tag (something with a start
> tag and an end tag) if you want to do something like this.
>
> Regards,
> Malcolm
>
> --
> The cost of feathers has risen; even down is up!
> http://www.pointy-stick.com/blog/
>
>
> >
>


-- 
Claudio Escudero

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



Re: unknown encoding: utf-8 error

2008-04-13 Thread Cephire

With help from the forum members and through many pages on the net, I
was able to build a stand-alone app. I've blogged about it, with the
hope that it might be helpful to someone else. Feel free to comment if
there are any improvement.

http://www.jjude.com/index.php/archives/70

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



Re: Custom field not created with model inheritance

2008-04-13 Thread Alex Koshelev

Do you use proper django branch with model inheritance support? Trunk
doesn't

On Apr 13, 5:37 pm, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to have a model inherit from another which has a custom
> field:
>
> import uuid
> from django.db import models
> from django.db.models.fields import CharField
>
> class UuidField(CharField):# <- The custom field
> def __init__(self, verbose_name=None, name=None, auto=False,
> **kwargs):
> self.auto = auto
> kwargs['max_length'] = 36
> kwargs['unique'] = True
> if auto:
> kwargs['editable'] = False
> kwargs['blank'] = True
> super(UuidField, self).__init__(verbose_name, name, **kwargs)
>
> def pre_save(self, model_instance, add):
> value = super(UuidField, self).pre_save(model_instance, add)
> if (not value) and self.auto:
> # Assign a new value for this attribute if required.
> value = str(uuid.uuid1())
> setattr(model_instance, self.attname, value)
> return value
>
> def get_internal_type(self):
> return "UuidField"
>
> Then, I do:
>
> class AbstractClass(models.Model):
> uuid = UuidField(auto=True)
> name = models.CharField(max_length=80, blank=True)
> class Meta:
> abstract = True
>
> class MyClass(AbstractClass):
> title = models.CharField(max_length=80, blank=True)
>
> The problem is that when I run syncdb, the table 'myclass' only
> contains the attributes 'name' and 'title', not 'uuid'.
>
> What am I missing. Do I need to alter the UUIField class to make it
> compatible with model inheritance?
>
> Thanks a lot!
>
> Julien
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OneToOneField unchangeable

2008-04-13 Thread Manuel Meyer

> On Sun, Apr 13, 2008 at 8:34 AM, Manuel Meyer  
> <[EMAIL PROTECTED]> wrote:
>
> > No, that's they way it is documented as working.  The one-to-one
> > field acts as the primary key for the model, and primary keys can't
> > be edited.  From http://www.djangoproject.com/documentation/model-
> > api/#one-to-one-relationships:
> >
> > This OneToOneField will actually replace the primary key id field
> > (since one-to-one relations share the same primary key), and will
> > be displayed as a read-only field when you edit an object in the
> > admin interface:
> Oh, I definitely missed that :)
>
> But:
>
> now I tried this:
>
> item = models.ForeignKey(Article, edit_inline=models.TABULAR,
> num_in_admin=1, max_num_in_admin=1 )
>
> in HeaderImage. Now each time some field of Article is changed, a
> assigned HeaderImage is deleted.
> I doubt, that this is a feature too.
> But what is wrong now?
>
> Sounds like:
>
> http://code.djangoproject.com/ticket/2413
>
> In short, inline edited objects with FileFields (or ImageFields)  
> have some problems in the old admin.  I believe these problems are  
> fixed in newforms-admin, so you might want to try using that branch  
> for your case.
>
> Karen

If I add a save(), it seems to work:


class HeaderImage(models.Model):
 """
 A HeaderImage of an Article.
 """
 picture = models.ImageField(null=True, upload_to='./ 
images/',core=True)
 item = models.ForeignKey(Article, edit_inline=models.TABULAR,  
max_num_in_admin=1)
 remove = models.BooleanField(default=False)

 def __unicode__(self):
 return self.picture

 def save(self):
 super(CategoryImage,self).save()
 if self.remove:
 self.delete()


 def delete(self):
 if not self.picture==None and not self.picture=='':
 basename, format = self.picture.rsplit('.', 1)
 miniature_folder  = os.path.join(s.MEDIA_ROOT, basename 
+'/')

 if os.path.exists(miniature_folder):
 dir = os.getcwd()
 os.chdir(miniature_folder)
 listdir=os.listdir(miniature_folder)
 for i in listdir:
 os.remove(i)
 os.chdir(dir)
 os.removedirs(miniature_folder)
 super(HeaderImage,self).delete()

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



Custom field not created with model inheritance

2008-04-13 Thread Julien

Hi,

I'm trying to have a model inherit from another which has a custom
field:

import uuid
from django.db import models
from django.db.models.fields import CharField

class UuidField(CharField):# <- The custom field
def __init__(self, verbose_name=None, name=None, auto=False,
**kwargs):
self.auto = auto
kwargs['max_length'] = 36
kwargs['unique'] = True
if auto:
kwargs['editable'] = False
kwargs['blank'] = True
super(UuidField, self).__init__(verbose_name, name, **kwargs)

def pre_save(self, model_instance, add):
value = super(UuidField, self).pre_save(model_instance, add)
if (not value) and self.auto:
# Assign a new value for this attribute if required.
value = str(uuid.uuid1())
setattr(model_instance, self.attname, value)
return value

def get_internal_type(self):
return "UuidField"


Then, I do:

class AbstractClass(models.Model):
uuid = UuidField(auto=True)
name = models.CharField(max_length=80, blank=True)
class Meta:
abstract = True


class MyClass(AbstractClass):
title = models.CharField(max_length=80, blank=True)


The problem is that when I run syncdb, the table 'myclass' only
contains the attributes 'name' and 'title', not 'uuid'.

What am I missing. Do I need to alter the UUIField class to make it
compatible with model inheritance?

Thanks a lot!

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



How to overwrite the hyperlink of objects in change list template of django admin?

2008-04-13 Thread Leon

Hi,
  I use django admin to manage a table. There is a hyperlink for
each object in the change_list template, which will bring me to the
change_form template. I want to change that hyperlink and redirect it
to another url to handle. I didn't want to customize the current
change_form for this model because it is still used somewhere else.
  Anybody knows how to do it?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Feel free to test queryset-refactor branch

2008-04-13 Thread Ivan Illarionov

Glad to hear that queryset-refactor is almost ready.

Currently, I noticed that there are few SQL portability issues and few
old queryset API issues (eg in admin). I already filed #6956 and
#6957.  I do some heavy testing of this branch and I will report
anything that goes wrong.

Regards,
--
Ivan

On Apr 13, 3:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> We're getting pretty close to merging queryset-refactor into trunk and
> would like to do this as soon as practical. There are still a couple of
> enhancements to add (#5420, mostly), one bug to fix (#5937) and some
> internal tweaking to do, but all the main stuff is ready to be used.
>
> So if anybody wants to test it out, go ahead. Read the wiki page[1] if
> you've got code that does any slightly unusual stuff, but for existing
> code that works on trunk, there shouldn't be any real changes required.
>
> [1]http://code.djangoproject.com/wiki/QuerysetRefactorBranch
>
> File any bug reports in Trac against the queryset-refactor
> "version" (please do NOT put the qs-rf keyword on the ticket; I'm using
> that for other purposes). Bug reports that are regressions from existing
> functionality are more interesting and important at the moment than
> feature enhancements to the new features, since the latter case can be
> dealt with at our leisure (they're not features that people are already
> relying upon).
>
> If you see any different results testing against the branch compared to
> trunk, it would be interesting to know about them. Reduce it to a small
> example before opening a ticket, wherever possible. Please don't make me
> wade through dozens of lines of code just to get to one query that is
> relevant. Bear in mind, though, that the difference could be because a
> bug existed in trunk and the branch is now giving the correct result. So
> make sure your test case is valid (even I got bitten by that in a
> project I wrote).
>
> Regards,
> Malcolm
>
> --
> The sooner you fall behind, the more time you'll have to catch 
> up.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OneToOneField unchangeable

2008-04-13 Thread Karen Tracey
On Sun, Apr 13, 2008 at 8:34 AM, Manuel Meyer <[EMAIL PROTECTED]>
wrote:

>
> > No, that's they way it is documented as working.  The one-to-one
> > field acts as the primary key for the model, and primary keys can't
> > be edited.  From http://www.djangoproject.com/documentation/model-
> > api/#one-to-one-relationships:
> >
> > This OneToOneField will actually replace the primary key id field
> > (since one-to-one relations share the same primary key), and will
> > be displayed as a read-only field when you edit an object in the
> > admin interface:
> Oh, I definitely missed that :)
>
> But:
>
> now I tried this:
>
> item = models.ForeignKey(Article, edit_inline=models.TABULAR,
> num_in_admin=1, max_num_in_admin=1 )
>
> in HeaderImage. Now each time some field of Article is changed, a
> assigned HeaderImage is deleted.
> I doubt, that this is a feature too.
> But what is wrong now?
>

Sounds like:

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

In short, inline edited objects with FileFields (or ImageFields) have some
problems in the old admin.  I believe these problems are fixed in
newforms-admin, so you might want to try using that branch for your case.

Karen


> Here my models:
>
> class Article(models.Model):
> title = models.CharField(_("Full Name"), maxlength=255)
>  slug = models.SlugField(_("Slug Name"), prepopulate_from=
> ("title",), unique=True, help_text=_("This is a short, descriptive
> name of the shirt that will be used in the URL link to this item"))
> text = models.TextField(_("Text of article"),  blank=True,
> null=True)
> category = models.ManyToManyField(Category, filter_interface=True)
> date = models.DateTimeField(auto_now=True)
> from django.contrib.auth.models import User
> owner = models.ForeignKey(User, blank=True, null=True)
>
> class HeaderImage(models.Model):
> """
> A HeaderImage of an Article.
>  """
> picture = models.ImageField(null=True, upload_to='./
> images/',core=True)
>  item = models.ForeignKey(Article, edit_inline=models.TABULAR,
> num_in_admin=1, max_num_in_admin=1 )
>
> def __unicode__(self):
> return self.picture
>
> def delete(self):
> if not self.picture==None and not self.picture=='':
> basename, format = self.picture.rsplit('.', 1)
> miniature_folder  = os.path.join(s.MEDIA_ROOT, basename
> +'/')
>
> if os.path.exists(miniature_folder):
> dir = os.getcwd()
> os.chdir(miniature_folder)
> listdir=os.listdir(miniature_folder)
> for i in listdir:
> os.remove(i)
> os.chdir(dir)
> os.removedirs(miniature_folder)
> super(HeaderImage,self).delete()
>
> def get_image_url(self):
> return '/'+s.MEDIA_URL+self.picture
>
> def get_image_path(self):
> return s.MEDIA_ROOT+'/'+self.picture
>
> class Admin:
> pass
>
>
>
> >
>

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



Re: OneToOneField unchangeable

2008-04-13 Thread Manuel Meyer

> No, that's they way it is documented as working.  The one-to-one  
> field acts as the primary key for the model, and primary keys can't  
> be edited.  From http://www.djangoproject.com/documentation/model- 
> api/#one-to-one-relationships:
>
> This OneToOneField will actually replace the primary key id field  
> (since one-to-one relations share the same primary key), and will  
> be displayed as a read-only field when you edit an object in the  
> admin interface:
Oh, I definitely missed that :)

But:

now I tried this:

item = models.ForeignKey(Article, edit_inline=models.TABULAR,  
num_in_admin=1, max_num_in_admin=1 )

in HeaderImage. Now each time some field of Article is changed, a  
assigned HeaderImage is deleted.
I doubt, that this is a feature too.
But what is wrong now?

Here my models:

class Article(models.Model):
 title = models.CharField(_("Full Name"), maxlength=255)
 slug = models.SlugField(_("Slug Name"), prepopulate_from= 
("title",), unique=True, help_text=_("This is a short, descriptive  
name of the shirt that will be used in the URL link to this item"))
 text = models.TextField(_("Text of article"),  blank=True,  
null=True)
 category = models.ManyToManyField(Category, filter_interface=True)
 date = models.DateTimeField(auto_now=True)
 from django.contrib.auth.models import User
 owner = models.ForeignKey(User, blank=True, null=True)

class HeaderImage(models.Model):
 """
 A HeaderImage of an Article.
 """
 picture = models.ImageField(null=True, upload_to='./ 
images/',core=True)
 item = models.ForeignKey(Article, edit_inline=models.TABULAR,  
num_in_admin=1, max_num_in_admin=1 )

 def __unicode__(self):
 return self.picture

 def delete(self):
 if not self.picture==None and not self.picture=='':
 basename, format = self.picture.rsplit('.', 1)
 miniature_folder  = os.path.join(s.MEDIA_ROOT, basename 
+'/')

 if os.path.exists(miniature_folder):
 dir = os.getcwd()
 os.chdir(miniature_folder)
 listdir=os.listdir(miniature_folder)
 for i in listdir:
 os.remove(i)
 os.chdir(dir)
 os.removedirs(miniature_folder)
 super(HeaderImage,self).delete()

 def get_image_url(self):
 return '/'+s.MEDIA_URL+self.picture

 def get_image_path(self):
 return s.MEDIA_ROOT+'/'+self.picture

 class Admin:
 pass
  


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



Re: Overriding returned contents of user objects

2008-04-13 Thread Tane Piper

Hi again,

I seem to have come a cropper with this.  Although it returns the
fields I want on other models, on my Project model it seems to affect
it's functions and attribues  For example, in this line:

projects = [project for project in Project.projects.all() if
project.get_permissions(request.user).view_project]

if I try do:

projects = [project for project in
Project.projects.all().values('project_id', 'project_name') if
project.get_permissions(request.user).view_project]

I get this error:

'dict' object has no attribute 'get_permissions'

I have tried passing it as a field but it comes back that it doesn't
exist.  Any suggestions?

On Sun, Apr 13, 2008 at 12:56 PM, Tane Piper
<[EMAIL PROTECTED]> wrote:
> Hi Malcolm,
>
>  values() seems to be the way to go for now.  I've extracted some of
>  the code back to a context variable, and anything within a view I'll
>  just have to try and make it as efficient as possible, while still
>  removing the user object from the context.
>
>
>
>  On Sun, Apr 13, 2008 at 11:59 AM, Malcolm Tredinnick
>  <[EMAIL PROTECTED]> wrote:
>  >
>  >
>  >  On Sun, 2008-04-13 at 11:46 +0100, Tane Piper wrote:
>  >  [...]
>  >
>  > > What I want to
>  >  > know is there any way I could simplify the method and have it remove
>  >  > the password field any time a user object is being selected as part of
>  >  > a related query??
>  >
>  >  Not really, unless you use values(). For any model, if the Python object
>  >  is being constructed, it pulls back all the values it needs to populate
>  >  the attributes. The password hash is an attribute of the User model.
>  >
>  >
>  >  >  I'm sure there is a need for it when doing
>  >  > authorisation, but once a session has been confirmed, is it needed
>  >  > again?
>  >
>  >  Login isn't the only time when the password hash might be needed (for
>  >  example, it's displayed and editable in the admin screen) and it would
>  >  be quite hacky to introduce a special case for saying when that field
>  >  shouldn't be displayed. You're using the User object in public-readable
>  >  situations, which isn't really part of the design. So change your design
>  >  a bit so that you're not throwing around this information if you don't
>  >  want it displayed. Yes, anything can be serialised using json, but that
>  >  doesn't mean you should indiscriminately do so or that the framework
>  >  should accommodate that.
>  >
>  >  It might make sense in your situation to just pull back the values()
>  >  that you need for various objects and serialise that dictionary. Or you
>  >  could make another pass through the projects list and blank out the
>  >  attribute(s) you aren't interested in, such as _project_manager_cache.
>  >
>  >  Regards,
>  >  Malcolm
>  >
>  >  --
>  >  A clear conscience is usually the sign of a bad memory.
>  >  http://www.pointy-stick.com/blog/
>  >
>  >
>  >  >  >
>  >
>
>
>
>
>
> --
>  Tane Piper
>  Blog - http://digitalspaghetti.me.uk
>  Skype: digitalspaghetti
>
>  This email is: [ ] blogable [ x ] ask first [ ] private
>



-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
Skype: digitalspaghetti

This email is: [ ] blogable [ x ] ask first [ ] private

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



How to Choose an Unlimited Web Hosting for free

2008-04-13 Thread Free Domain & Web Hosting

How to Choose an Unlimited Web Hosting
1) Visit www.axealis.com to get domain and hosting
2) Unlimited Bandwidth ,this mean unlimited data transmission for your
client access.
2) Unlimited Space , you can upload file for unlimited .
3) Unlimited Email , many of email account can created .
5) SSL Security , used SSL / HTTPS to protect your web .
6) LINUX , WINDOWS and MAC , can access form many operating system.

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



Re: Overriding returned contents of user objects

2008-04-13 Thread Tane Piper

Hi Malcolm,

values() seems to be the way to go for now.  I've extracted some of
the code back to a context variable, and anything within a view I'll
just have to try and make it as efficient as possible, while still
removing the user object from the context.

On Sun, Apr 13, 2008 at 11:59 AM, Malcolm Tredinnick
<[EMAIL PROTECTED]> wrote:
>
>
>  On Sun, 2008-04-13 at 11:46 +0100, Tane Piper wrote:
>  [...]
>
> > What I want to
>  > know is there any way I could simplify the method and have it remove
>  > the password field any time a user object is being selected as part of
>  > a related query??
>
>  Not really, unless you use values(). For any model, if the Python object
>  is being constructed, it pulls back all the values it needs to populate
>  the attributes. The password hash is an attribute of the User model.
>
>
>  >  I'm sure there is a need for it when doing
>  > authorisation, but once a session has been confirmed, is it needed
>  > again?
>
>  Login isn't the only time when the password hash might be needed (for
>  example, it's displayed and editable in the admin screen) and it would
>  be quite hacky to introduce a special case for saying when that field
>  shouldn't be displayed. You're using the User object in public-readable
>  situations, which isn't really part of the design. So change your design
>  a bit so that you're not throwing around this information if you don't
>  want it displayed. Yes, anything can be serialised using json, but that
>  doesn't mean you should indiscriminately do so or that the framework
>  should accommodate that.
>
>  It might make sense in your situation to just pull back the values()
>  that you need for various objects and serialise that dictionary. Or you
>  could make another pass through the projects list and blank out the
>  attribute(s) you aren't interested in, such as _project_manager_cache.
>
>  Regards,
>  Malcolm
>
>  --
>  A clear conscience is usually the sign of a bad memory.
>  http://www.pointy-stick.com/blog/
>
>
>  >
>



-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
Skype: digitalspaghetti

This email is: [ ] blogable [ x ] ask first [ ] private

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



Re: Feel free to test queryset-refactor branch

2008-04-13 Thread Julien

Hi Malcolm,

I've been using the branch on a project in development for a few weeks
now, and haven't come across any issue yet - although I can't say I've
pushed it to its limits.

Glad to hear it's close to be merged to trunk.

Thanks so much for this massive contribution!

Best,

Julien

On Apr 13, 9:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> We're getting pretty close to merging queryset-refactor into trunk and
> would like to do this as soon as practical. There are still a couple of
> enhancements to add (#5420, mostly), one bug to fix (#5937) and some
> internal tweaking to do, but all the main stuff is ready to be used.
>
> So if anybody wants to test it out, go ahead. Read the wiki page[1] if
> you've got code that does any slightly unusual stuff, but for existing
> code that works on trunk, there shouldn't be any real changes required.
>
> [1]http://code.djangoproject.com/wiki/QuerysetRefactorBranch
>
> File any bug reports in Trac against the queryset-refactor
> "version" (please do NOT put the qs-rf keyword on the ticket; I'm using
> that for other purposes). Bug reports that are regressions from existing
> functionality are more interesting and important at the moment than
> feature enhancements to the new features, since the latter case can be
> dealt with at our leisure (they're not features that people are already
> relying upon).
>
> If you see any different results testing against the branch compared to
> trunk, it would be interesting to know about them. Reduce it to a small
> example before opening a ticket, wherever possible. Please don't make me
> wade through dozens of lines of code just to get to one query that is
> relevant. Bear in mind, though, that the difference could be because a
> bug existed in trunk and the branch is now giving the correct result. So
> make sure your test case is valid (even I got bitten by that in a
> project I wrote).
>
> Regards,
> Malcolm
>
> --
> The sooner you fall behind, the more time you'll have to catch 
> up.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Feel free to test queryset-refactor branch

2008-04-13 Thread Malcolm Tredinnick

We're getting pretty close to merging queryset-refactor into trunk and
would like to do this as soon as practical. There are still a couple of
enhancements to add (#5420, mostly), one bug to fix (#5937) and some
internal tweaking to do, but all the main stuff is ready to be used.

So if anybody wants to test it out, go ahead. Read the wiki page[1] if
you've got code that does any slightly unusual stuff, but for existing
code that works on trunk, there shouldn't be any real changes required.

[1] http://code.djangoproject.com/wiki/QuerysetRefactorBranch

File any bug reports in Trac against the queryset-refactor
"version" (please do NOT put the qs-rf keyword on the ticket; I'm using
that for other purposes). Bug reports that are regressions from existing
functionality are more interesting and important at the moment than
feature enhancements to the new features, since the latter case can be
dealt with at our leisure (they're not features that people are already
relying upon).

If you see any different results testing against the branch compared to
trunk, it would be interesting to know about them. Reduce it to a small
example before opening a ticket, wherever possible. Please don't make me
wade through dozens of lines of code just to get to one query that is
relevant. Bear in mind, though, that the difference could be because a
bug existed in trunk and the branch is now giving the correct result. So
make sure your test case is valid (even I got bitten by that in a
project I wrote).

Regards,
Malcolm

-- 
The sooner you fall behind, the more time you'll have to catch up. 
http://www.pointy-stick.com/blog/


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



Re: Overriding returned contents of user objects

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 11:46 +0100, Tane Piper wrote:
[...]
> What I want to
> know is there any way I could simplify the method and have it remove
> the password field any time a user object is being selected as part of
> a related query?? 

Not really, unless you use values(). For any model, if the Python object
is being constructed, it pulls back all the values it needs to populate
the attributes. The password hash is an attribute of the User model.

>  I'm sure there is a need for it when doing
> authorisation, but once a session has been confirmed, is it needed
> again?

Login isn't the only time when the password hash might be needed (for
example, it's displayed and editable in the admin screen) and it would
be quite hacky to introduce a special case for saying when that field
shouldn't be displayed. You're using the User object in public-readable
situations, which isn't really part of the design. So change your design
a bit so that you're not throwing around this information if you don't
want it displayed. Yes, anything can be serialised using json, but that
doesn't mean you should indiscriminately do so or that the framework
should accommodate that.

It might make sense in your situation to just pull back the values()
that you need for various objects and serialise that dictionary. Or you
could make another pass through the projects list and blank out the
attribute(s) you aren't interested in, such as _project_manager_cache.

Regards,
Malcolm

-- 
A clear conscience is usually the sign of a bad memory. 
http://www.pointy-stick.com/blog/


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



Overriding returned contents of user objects

2008-04-13 Thread Tane Piper

Hi there,

I'm currently building a Django app that uses JavaScript and Ajax.
One of the things I am doing is within each view, as well as
outputting a variable as standard, I also JSON encode any objects on
the page and return them as well, so when the page loads, they are in
the DOM as values I can use to manipulate the page.

One of the issues I am having is with the code below for example:

def get_project_list(request):
member = Member.members.get(user__exact = request.user)
projects = [project for project in Project.projects.all() if
project.get_permissions(request.user).view_project]

if request.is_ajax():
template = 'project/project_list_ajax.html'
else:
template = 'project/project_list.html'

return render_to_response(template,
{
'view_title': "All Projects",
'projects': projects,
'json_output': json_encode({'projects' : projects, 'user'
: member}),
}, context_instance=RequestContext(request)
)

i then output it like this


var hgfront = {{json_output}}


When I go into the DOM tab in Firebug, I can see the variables in the
dom.  All are attached to a hgfront object, so for example, a page
might look like this in the dom

+ hgfront
+ options
+ projects
+0
+_project_manager_cache
name
id
.

As you can see, each object is converted into JSON, but the problem
comes when I get a project, as you can see it passes along the
_project_manager_cache - which is the user object.  Now the problem I
am having is the users password, although hashed, is showing like so:

_project_manager_cache
Object username=tanep first_name=Tane last_name=Piper
date_joined
"2008-04-10 18:40:55"
email
"[EMAIL PROTECTED]"
first_name
"Tane"
id
2
is_active
true
is_staff
true
is_superuser
true
last_login
"2008-04-10 22:46:12"
last_name
"Piper"
password
"sha1$65c5c$ac5966b3082279392h737373144cf6db200c3"
username
"tanep"

The problem is that this isn't even being done with a select_related()
query, so the object is automatically being output.  What I want to
know is there any way I could simplify the method and have it remove
the password field any time a user object is being selected as part of
a related query??  I'm sure there is a need for it when doing
authorisation, but once a session has been confirmed, is it needed
again?

-- 
Tane Piper
Blog - http://digitalspaghetti.me.uk
Skype: digitalspaghetti

This email is: [ ] blogable [ x ] ask first [ ] private

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



Re: Django Tutorial Site not in Admin

2008-04-13 Thread garazy

Apologies, I thought the class Admin was at the base didn't realise it
was under the class Polls. That has fixed it now.


Gary




On Apr 13, 8:31 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 13-Apr-08, at 3:54 PM, garazy wrote:
>
> > It does not appear in the admin when I login with the superuser
> > account that got created when I installed the project. Please let me
> > know what other information you need me to provide to debug this large
> > problem.
>
> please post your models.py file
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Tutorial Site not in Admin

2008-04-13 Thread Kenneth Gonsalves


On 13-Apr-08, at 3:54 PM, garazy wrote:

> It does not appear in the admin when I login with the superuser
> account that got created when I installed the project. Please let me
> know what other information you need me to provide to debug this large
> problem.

please post your models.py file

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Django Tutorial Site not in Admin

2008-04-13 Thread garazy

Hi,

I am using the SVN version of Django version 0.97-pre-SVN-7419 on
Ubuntu Edgy with mysql database.

I have followed the tutorial, the shell code works fine and my DB is
hooked up correctly.

I have the admin working, I added the

 class Admin:
pass


to the mysite/polls/models.py file



It does not appear in the admin when I login with the superuser
account that got created when I installed the project. Please let me
know what other information you need me to provide to debug this large
problem.


Please help,

Gary



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



Re: How to reiterate something "n" times in django template?

2008-04-13 Thread fizban

On 13 Apr, 12:01, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
[snip]
>  But, again, that won't work for this particular draft
> spec. Smells like a problem with the spec to me, since it restricts the
> options a fair bit and makes for somewhat unreadable names, but so be
> it.

Yeah, I didn't realize it is in the "moribund" list, I thought it was
a work in progress ;)

Well, I'll just think at the best approach for defining the tags
popularity (I don't like the approaches I've seen so far) and create
the filter if needed

Thanks

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



Re: How to reiterate something "n" times in django template?

2008-04-13 Thread Malcolm Tredinnick


On Sun, 2008-04-13 at 01:52 -0700, fizban wrote:
> Hi,
> 
> Given that I'm using django-tagging to show a tagcloud, is there any
> way to, given "tag.font_size", to make the template print
> "tag.font_size" times the letter "v"?
> 
> What I'm trying to accomplish is to make a tagcloud compliant to the
> htagcloud microformat draft.. so:
> 
> sometag <- tag.font_size = 1
> someothertag <- tag.font_size = 5
> 
> I haven't been able to find any reference to "reiterations" in the
> django templates documentation (and {% for elem in elem_list %}
> doesn't obviously fit.. so it leads me to think there isn't an easy
> way to do so?

It's considered fairly easy to write a template filter and that would be
one way to do this: a filter that when applied to a template variable
returned the appropriate string. If you're really wedded to the idea of
using htagcloud (which doesn't exactly seem to have set the microformats
world on fire), that's the approach that will be simplest.

An approach thats even easier, if you're willing to change the CSS class
names, is to use classes of popular1, popular2, etc., and then use

class="popular{{ tag.font_size }}"

in your template. But, again, that won't work for this particular draft
spec. Smells like a problem with the spec to me, since it restricts the
options a fair bit and makes for somewhat unreadable names, but so be
it.

Regards,
Malcolm

-- 
Why can't you be a non-conformist like everyone else? 
http://www.pointy-stick.com/blog/


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



ANN: dupdater.py v0.6.0 -- Django project evolution utility

2008-04-13 Thread srackham

New version and rename of updater.py utility (see previous post
http://groups.google.com/group/django-users/browse_thread/thread/d9c16173c6ee2436).

Documentation here:

http://www.methods.co.nz/django/dupdater.html

Project repo and download here:

http://hg.sharesource.org/dupdater/


Cheers, Stuart
--
Stuart Rackham

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



How to reiterate something "n" times in django template?

2008-04-13 Thread fizban

Hi,

Given that I'm using django-tagging to show a tagcloud, is there any
way to, given "tag.font_size", to make the template print
"tag.font_size" times the letter "v"?

What I'm trying to accomplish is to make a tagcloud compliant to the
htagcloud microformat draft.. so:

sometag <- tag.font_size = 1
someothertag <- tag.font_size = 5

I haven't been able to find any reference to "reiterations" in the
django templates documentation (and {% for elem in elem_list %}
doesn't obviously fit.. so it leads me to think there isn't an easy
way to do so?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---