ManyToManyField problem?

2007-12-12 Thread Young Gyu Park
class Entry(models.Model):
blog = models.ForeignKey(Blog,related_name='entries')
Title = models.CharField(maxlength=250, blank=False, null=False)
Slug = models.SlugField(maxlength=250, blank=False, null=False,
prepopulate_from=('Title',))
Content = models.TextField(blank=False, null=False)
Post_Date = models.DateTimeField(auto_now_add=True)
tags = blog.select_relates().tags # models.ManyToManyField('Tag',
blank=True, related_name='entries')
Pictures = models.ForeignKey('Picture', blank=True, null=True,
related_name='entries')
Files = models.ForeignKey('File', blank=True, null=True,
related_name='entries')
# comments = models.ForeignKey(Comment, blank=True, null=True,
related_name='entries')
Is_Draft = models.BooleanField(default=False, help_text="Draft entries
are visible only to the author and admins")
Comments_Allowed = models.BooleanField(default=True)
Trackbacks_Allowed = models.BooleanField(default=False)

class Tag(models.Model):
blog = models.ForeignKey(Blog,related_name='tags')
Name = models.CharField(maxlength=250)
Slug = models.SlugField(maxlength=250, prepopulate_from=('Name',))
Total_ref = models.IntegerField(blank=True, default=0)
Font_size = models.IntegerField(blank=True, default=0)

This is the two table that I'm using.

What I want to do is in this models that I want to refer the Tag list by not
all tag list but Blog.tag list

When I execute this code in the web, I can see the whole tag list.
But I want to see the tag list belonged to blog's user

If I can solve this problem in the template code, but I want to solve this
problem in terms of models.
Because this solution could be more neat.

Give me a clue

Thanks, always

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



__init__() got an unexpected keyword argument 'max_length'

2007-12-12 Thread DjangoFett

I get the above error when running an application via apache2. not
when i use the built in 'python mange.py runserver' command.

I've done a svn update with the current trunk both directly into my
site-packages directory and to another directory with an 'ln' link
inside the site-packages directory. i have another server that
currently uses the 'max_length' directive without problem. i have
copied that directory into the proper local directory as well with no
help either. this error is greatly stifling my development of a
current project and i need any information that could help. please
help! :-)

Randall Prince
--~--~-~--~~~---~--~~
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: GeoDjango: Invalid spatial reference pointer returned from "OGR_L_GetSpatialRef"

2007-12-12 Thread Justin Bronn

> Should the example still work with the latest svn revision of
> GeoDjango? The IPython session is pasted below.

Yes, it should work.  You found a bug -- I just fixed it in r6916.

There have been some significant changes to GeoDjango since FOSS4G
(e.g., GEOS & GDAL refactors, distance queries, additional spatial
backends).  However, substantively, everything should still work as
shown.  This particular bug is an artifact of the GDAL library
refactoring: the census shapefiles do not explicitly give a spatial
reference, which is NAD83, and the `srs` property should be None
instead of raising an exception.  One thing that has explicitly
changed is that `models.GeoMixin` is no longer required for geographic
models.

Thanks for the detailed report and traceback.

Best Regards,
-Justin
--~--~-~--~~~---~--~~
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: Accessing Multiple Databases

2007-12-12 Thread Ben Ford
Hi folks,

I was going to keep quiet on this until I was a bit further along... I've
just started work on re-hashing multiple-db support to make it a bit more
flexible. The existing code is quite hard to update with trunk as it makes a
lot of changes to django's core codebase. I've also found it a little hard
to work with in some more complicated contexts. (I'm not knocking it at all,
it just doesn't quite do it for me). So in the spirit of "scratch your own
itch" I'm going to have a play with it.

I wasn't going to mention it until I was further along, for two reasons: One
that I didn't want to add more noise to this topic - it seems to rear it's
head all on it's own fairly regularly! Two, I'm not really sure how much
time I can commit to this - I'm just on my way back to the UK after an
absence of nearly 2.5 years so I have a lot of catching up to do!! I will
however do my best and will update with my progress (and some docs) at some
usable point in the future.

Cheers,
Ben

On 13/12/2007, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
>
> On Dec 13, 2007 12:25 AM, Derek Steinkamp <[EMAIL PROTECTED]> wrote:
> >
> > As an aside, I think it is a real showstopper to not include this
> > feature in the main trunk... I can't believe the triage stage on the
> > feature request was recently changed to "Someday/Maybe". To me it seems
> > obvious that all of the data that a Django app could need might not
> > reside on the same database for any number of reasons.
>
> It may well be a real showstopper - for you. Is it a showstopper for
> everyone? Not even close. To date, I have never had a need for
> multi-db support. There are a large number of Django sites out there
> that are successfully deployed without support for multi-db.
>
> If multi-db were to magically materialize in the Django source tree,
> would it be a valuable addition? Yes, certainly. Hence, the
> "Someday/Maybe" tag.
>
> The "Someday/Maybe" tag is an indication that we (that is, the core
> developers) are not opposed to introducing this feature, but it's not
> on our immediate to-do list. At the moment, the big issues consuming
> our time are things like:
> * Completing the transition to newforms, thereby resolving the issues
> with edit_inline and core=True
> * Refactoring the query engine to resolve the myriad known issues with
> order_by, select_related, and table joins
>
> Whereas multi-db is of interest to _some_ users, edit_inline and join
> issues affect virtually _all_ users. Developer time is limited, so we
> have to prioritize, and the issues that will be addressed first are
> those that:
>
> 1) affect the most people.
> 2) affect the core developers personally.
>
> Using this scheme, multi-db falls quite some way down the to-do list.
>
> > Perhaps I'll put some work into this when I have some time and get it
> > caught up with the latest trunk.
>
> If multi-db support is important to you, then this is the most helpful
> thing you can do.
>
> Yours,
> Russ Magee %-)
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+6281317958862

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



GeoDjango: Invalid spatial reference pointer returned from "OGR_L_GetSpatialRef"

2007-12-12 Thread Joe

I'm following along with the GeoDjango_Presentation.pdf at [1] from
the FOSS4G 2007 presentation at [2], using the shapefile
'st99_d00.shp' from [3]. When trying the example code listed on the
bottom slide of page 11 in the pdf , I get an error:

SRSException: Invalid spatial reference pointer returned from
"OGR_L_GetSpatialRef".

This occurs on both Debian Etch and OS X 10.4 (both are using GDAL
version 1.4.2 and python 2.4 with ctypes package installed). I'm just
starting out with GeoDjango so I'm not sure if it's an installation
problem or the code. I was able to successfully run the third-party
library installation tests at [4] and also the DataSource example at
[5], in case that helps to shed any light on the soundness of my
installation.

Should the example still work with the latest svn revision of
GeoDjango? The IPython session is pasted below.

Thanks,
Joe

[1] http://www.foss4g2007.org/presentations/viewattachment.php?attachment_id=78
[2] http://www.foss4g2007.org/presentations/view.php?abstract_id=222
[3] http://www.census.gov/geo/cob/bdy/st/st00shp/st99_d00_shp.zip
[4] 
http://code.djangoproject.com/wiki/GeoDjangoInstall#Third-PartyLibraryInstallationTests
[5] http://code.djangoproject.com/wiki/GeoDjangoExtras#DataSource


This IPython session is also pasted at http://dpaste.com/hold/27869/ :
==

In [1]: from django.contrib.gis.utils import ogrinfo

In [2]: ogrinfo('st99_d00.shp',num_features=1)
data source : st99_d00.shp
 layer 0
  shape type: Polygon
  # features: 273
---
django.contrib.gis.gdal.error.SRSException
 Traceback (most recent call last)

/home/joe/foss4g/

/usr/lib/python2.4/site-packages/django/contrib/gis/utils/ogrinfo.py
in ogrinfo(data_source, num_features)
 27 print "  shape type: %s" %
GEO_CLASSES[layer.geom_type.num].__name__
 28 print "  # features: %s" % len(layer)
---> 29 print " srs: %s" % layer.srs
 30 extent_tup = layer.extent.tuple
 31 print "  extent: %s - %s" % (extent_tup[0:2],
extent_tup[2:4])

/usr/lib/python2.4/site-packages/django/contrib/gis/gdal/layer.py in srs(self)
100 def srs(self):
101 "Returns the Spatial Reference used in this Layer."
--> 102 ptr = get_layer_srs(self._ptr)
103 if ptr:
104 return SpatialReference(clone_srs(ptr))

/usr/lib/python2.4/site-packages/django/contrib/gis/gdal/prototypes/errcheck.py
in check_srs(result, func, cargs)
 89 result = c_void_p(result)
 90 if not result:
---> 91 raise SRSException('Invalid spatial reference pointer
returned from "%s".' % func.__name__)
 92 return result
 93

SRSException: Invalid spatial reference pointer returned from
"OGR_L_GetSpatialRef".

--~--~-~--~~~---~--~~
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: newforms / modelform save

2007-12-12 Thread l5x

OMG, call it "3:15AM syndrome"

Thank you J.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: newforms / modelform save

2007-12-12 Thread Joseph Kocherhans

On 12/12/07, l5x <[EMAIL PROTECTED]> wrote:
>
> Unfortunately, it creates second record, when using your solution,
> instead of updating.

Well then instead of instantiating a new object will 'Full()', why
aren't you getting an existing object and passing it into the form
instead of a new object?

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: #6189: IntegrityError: Field "may not be NULL" even though blank=True

2007-12-12 Thread Karen Tracey
On Dec 11, 2007 11:55 PM, Tyson Tate <[EMAIL PROTECTED]> wrote:

>
> I submitted bug #6189 [1], but I thought I should ping django-users to
> see if anyone has encountered this before or knows of a workaround.
>
> In summary, despite adding "blank=True" to my fields, many of them
> throw IntegrityErrors when I try to save them with blank values in the
> admin interface.
>
> [1] 
>

You need to specify null=True for these fields as well (and re-sync your
database).  The error you are seeing is coming from the database, which is
currently set up to not allow NULL values for these fields.  So even though
admin is allowing blank values, the database does not accept the NULL that
these turn into when admin tries to save the model instance.

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: newforms / modelform save

2007-12-12 Thread l5x

Unfortunately, it creates second record, when using your solution,
instead of updating.
--~--~-~--~~~---~--~~
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: FileField upload directory

2007-12-12 Thread Malcolm Tredinnick


On Thu, 2007-12-13 at 11:49 +1000, Tristan King wrote:
> Hi,
> 
> Is there a way to point the FileField upload directory to somewhere that
> isn't under the MEDIA_ROOT ?

This type of question has been asked very frequently on the list in the
past. A number of solutions have been proposed on the list. Please at
least type the proposed subject line of your email into the search box
on http://groups.google.com/group/django-users/ so that we don't get
lots of repeated questions. Searching more broadly on Google will turn
up a lot of useful tips as well.

You'll also notice, if you expand your search a bit further, that
there's ongoing development work to make this all bit more "public API",
requiring less poking about under the covers.

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: newforms / modelform save

2007-12-12 Thread Joseph Kocherhans

On 12/12/07, l5x <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I have a model with two ForeignKeys (User and another model). I cannot
> set them to editable=False, because Admin needs to see them and
> modify.
>
> So I've created ModelForm  and excluded those two fields. And now:
>
> 1) when I'm trying to *update* the content by MyModelForm.save() :
> there is error that foreignkeys cannot be null
> 2) i thought that it saves (inserts) if there isn't any record
> already , and if there is - it just updates - but it does not(?) see
> 1)
> 3) i've tried to assign these values manually:
>
> full = Full()
> form_full = FullForm(full, request.POST)
>
> form_full.my_first_fk = 2
> form_full.my_second_fk = 3
> form_full.save()

The code above is just assigning arbitrary attributes to the form
object, not the model object. You probably want something more like
this:

full = Full(my_first_fk=2, my_second_fk=3)
form_full = FullForm(full, request.POST)
new_full = form_full.save()

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



FileField upload directory

2007-12-12 Thread Tristan King

Hi,

Is there a way to point the FileField upload directory to somewhere that
isn't under the MEDIA_ROOT ?

I want this because i want to be able to upload files, but not have them
accessible via the web.

I've worked around this by making a new url to the upload directory and
making a view which raises a Http404, which works fine, but I don't
think is an ideal solution.

I think having the upload_to directory point to a absolute file path
rather than one relative the the media_root dir would make more sense,
since users can specify the media_root if they wish, but it's not
enforced.

Any thoughts?
Thanks,
-Tristan


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



newforms / modelform save

2007-12-12 Thread l5x

Hello,

I have a model with two ForeignKeys (User and another model). I cannot
set them to editable=False, because Admin needs to see them and
modify.

So I've created ModelForm  and excluded those two fields. And now:

1) when I'm trying to *update* the content by MyModelForm.save() :
there is error that foreignkeys cannot be null
2) i thought that it saves (inserts) if there isn't any record
already , and if there is - it just updates - but it does not(?) see
1)
3) i've tried to assign these values manually:

full = Full()
form_full = FullForm(full, request.POST)

form_full.my_first_fk = 2
form_full.my_second_fk = 3
form_full.save()

but without success.

Of course I can just use the form to check if it is_valid() and then
use model with request.POST, but it is not elegant.

What do you think about it? What am I doing wrong?
--~--~-~--~~~---~--~~
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: Stuck implementing editable ordered lists

2007-12-12 Thread toomim

ForiegnKey works great! Thanks so much man!

The drop-menu of choices is a good idea too. I'll do that!

On Dec 12, 2:19 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > However, after I have SAVED a pub, I cannot change the Person field of
> > its PubAuthors from the inlined page on the Pub admin page! Here's a
> > screenshot:http://code.djangoproject.com/attachment/ticket/6118/badorderedmanyto...
>
> This is documented behaviour for the 
> OneToOneField:http://www.djangoproject.com/documentation/model-api/#one-to-one-rela...
>
> Quote: 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
>
> > Can anyone suggest a better way to do this?
>
> Perhaps make PubAuthor.person a ForeignKey instead of a OneToOneField
> (realize also that OneToOneField behaviour is expected to change soon,
> so it's not really recommended to use that field.)
>
> If you do decide to switch that field to a ForeignKey, be sure to drop
> your existing tables and regenerate them.
>
> >  Ideally I wouldn't require
> > my admin users to manually specify the index of each author in the
> > right-hand column either.
>
> You would either have to do that or provide a drop down of choices
> with a number range in them. Without the index or some other key, you
> won't be able to tell Django to order the authors for you :)
>
> -Rajesh
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



PyAMF 0.1.0 alpha

2007-12-12 Thread Arnar

Hello folks,

As a followup to previous posts on this list, some people might be
interested in the following:

We are pleased to announce the first alpha version of PyAMF.

PyAMF [1] is a lightweight library that allows Flash and Python
applications to communicate via Adobe's ActionScript Message Format.

A summary of features in this release:

 * AMF0 and AMF3 encoders/decoders
 * Support for IExternalizable, ArrayCollection, ObjectProxy,
ByteArray,
RecordSet and RemoteObject
 * Remoting gateways for Twisted, WSGI, and Django
 * Authentication/setCredentials support (AMF0 only)
 * zlib compression support for ByteArray
 * Remoting client with httplib

Check out the download page [2] and installation instructions [3].

Got questions? First stop is the mailing list [4].

Cheers,

The PyAMF Team

[1] - http://pyamf.org
[2] - http://pyamf.org/wiki/Download
[3] - http://pyamf.org/wiki/Install
[4] - http://pyamf.org/wiki/MailingList

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



#6189: IntegrityError: Field "may not be NULL" even though blank=True

2007-12-12 Thread Tyson Tate

I submitted bug #6189 [1], but I thought I should ping django-users to  
see if anyone has encountered this before or knows of a workaround.

In summary, despite adding "blank=True" to my fields, many of them  
throw IntegrityErrors when I try to save them with blank values in the  
admin interface.

[1] 

Regards,
Tyson

--~--~-~--~~~---~--~~
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: Accessing Multiple Databases

2007-12-12 Thread Russell Keith-Magee

On Dec 13, 2007 12:25 AM, Derek Steinkamp <[EMAIL PROTECTED]> wrote:
>
> As an aside, I think it is a real showstopper to not include this
> feature in the main trunk... I can't believe the triage stage on the
> feature request was recently changed to "Someday/Maybe". To me it seems
> obvious that all of the data that a Django app could need might not
> reside on the same database for any number of reasons.

It may well be a real showstopper - for you. Is it a showstopper for
everyone? Not even close. To date, I have never had a need for
multi-db support. There are a large number of Django sites out there
that are successfully deployed without support for multi-db.

If multi-db were to magically materialize in the Django source tree,
would it be a valuable addition? Yes, certainly. Hence, the
"Someday/Maybe" tag.

The "Someday/Maybe" tag is an indication that we (that is, the core
developers) are not opposed to introducing this feature, but it's not
on our immediate to-do list. At the moment, the big issues consuming
our time are things like:
* Completing the transition to newforms, thereby resolving the issues
with edit_inline and core=True
* Refactoring the query engine to resolve the myriad known issues with
order_by, select_related, and table joins

Whereas multi-db is of interest to _some_ users, edit_inline and join
issues affect virtually _all_ users. Developer time is limited, so we
have to prioritize, and the issues that will be addressed first are
those that:

1) affect the most people.
2) affect the core developers personally.

Using this scheme, multi-db falls quite some way down the to-do list.

> Perhaps I'll put some work into this when I have some time and get it
> caught up with the latest trunk.

If multi-db support is important to you, then this is the most helpful
thing you can do.

Yours,
Russ Magee %-)

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

2007-12-12 Thread Empty

Wouldn't it just involve creating a backend that has nothing to do
with a database?  Seems pretty straightforward to me.

Michael
blog.michaeltrier.com

On Dec 12, 2007 1:52 PM, Nathan Fiedler <[EMAIL PROTECTED]> wrote:
>
> This topic has come up once or twice before, but it doesn't seem like
> a solution exists. Basically I'm looking for a recommended pattern for
> creating Django models that have no association with a database (i.e.
> "tableless").
>
> Curiously, ticket #419 has to do with enabling tableless models, but
> it was resolved as "duplicate", with no reference to any other ticket.
> Has this really been resolved, and if so, what happened?
>
> Thanks
>
> n
>
> >
>

--~--~-~--~~~---~--~~
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: readable object

2007-12-12 Thread IdNotFound


Hello,

After you mentioned this on #django, I went on hacking something as I
told you. I'm not sure what are the guidelines in this list for
posting code, so I'll just paste below, since dpaste can vanish
eventually. Please forgive me since this is my first post. Let me know
and it won't happen again ;-))

Check if this is sort of what you had in mind... Currently, it prints
on screen (I was using the shell) but you could of course easily
change that for whatever suits your needs. I haven't tested much, but
seems to work fine with ForeignKey() and ManyToManyField().


== start cutting here ==

#
# you can also find this in... http://dpaste.com/hold/27861/
#

from django.newforms.models import model_to_dict

def model_to_human(model):
d = model_to_dict(model)

for (k, v) in d.items():

try:
# test for relation manager
value = unicode(eval('model.'+k+'.all()'))
except AttributeError:
# nope, not that!

# let's prettify the output Django-style
inst = str(eval('model.'+k+'.__class__'))
fullClass = inst.split(' ')[1][1:-2] # gets ""
splitted = fullClass.split('.')

value = str(eval('model.'+k))
if len(splitted) > 1:
# this is not a builtin type, so we can prettify it
className = splitted[-1] # gets last dotted part
value = '<'+ className +': '+ value +'>'

print str(k) +': '+ value


== end cutting here ==


Hope it helps,
Eduardo "IdNotFound"


On Dec 12, 5:13 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> Is there an easy way to print an object in html?  Basically with
> display names and manytomany relationships resolved.  (just for
> viewing)
>
> I was thinking to write something like model_to_dict(obj)  that
> resolves a bunch of stuff and makes it more readable.  But returns a
> big html string similar to printing a form but without input fields.
>
> Anything like that exist already?
>
> --
> Milan
--~--~-~--~~~---~--~~
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 REST: update tables

2007-12-12 Thread Malcolm Tredinnick


On Tue, 2007-12-11 at 15:18 -0800, crybaby wrote:
> I have a view which allows users to upload pictures and add tags,
> description to them.  I have to update two tables: post and img
> 
> If I want to do this by REST, how do you do this?  Is REST only suited
> for manipulating one resource(one table) at a time?

REST doesn't know anything about tables. It's a style of resource
addressing. A "resource" here means something you can talk to over
HTTP .That may or may not have a one-to-one correspondence with
something in the backend or persistence layer of your application. For
anything even vaguely complex -- a blog post, a travel booking, a
recipe, an address book entry-- it will refer to more than one object,
so your case is typical, rather than unusual.

Essentially, here, your "resource" is supported by a single view. That
view can do whatever it needs to in order to store the information
supplied (or retrieve the information requested). It may well have to
split up the input and store it into multiple models. That's what views
are for: executing any Python code you need to.

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: Stuck implementing editable ordered lists

2007-12-12 Thread Rajesh Dhawan

Hi,

> However, after I have SAVED a pub, I cannot change the Person field of
> its PubAuthors from the inlined page on the Pub admin page! Here's a
> screenshot:http://code.djangoproject.com/attachment/ticket/6118/badorderedmanyto...

This is documented behaviour for the OneToOneField:
http://www.djangoproject.com/documentation/model-api/#one-to-one-relationships

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

> Can anyone suggest a better way to do this?

Perhaps make PubAuthor.person a ForeignKey instead of a OneToOneField
(realize also that OneToOneField behaviour is expected to change soon,
so it's not really recommended to use that field.)

If you do decide to switch that field to a ForeignKey, be sure to drop
your existing tables and regenerate them.

>  Ideally I wouldn't require
> my admin users to manually specify the index of each author in the
> right-hand column either.

You would either have to do that or provide a drop down of choices
with a number range in them. Without the index or some other key, you
won't be able to tell Django to order the authors for you :)

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



Personal Development is Bringing Artificial Intelligence to the Internet

2007-12-12 Thread Naeem

Personal Development is Bringing Artificial Intelligence to the Internet


It never ceases to amaze me... that the personal development industry is
growing as rapidly as it is. When you see that self help is being used
to raise money for charities, it doesn't come as much of a surprise.

http://doiop.com/uak3t5


Insuring Your Jewelry - Is It Worth It?


Insuring your jewelry with a policy of its own is very much worthwhile
considering that the coverage is quite broad and the premiums low. Even
though homeowners insurance is supposed to have a jewelry insurance
component built in.

http://doiop.com/95god2


Insuring your Diamonds


When you buy loose diamonds, just as when you buy diamond jewelry, it's
really important to get them insured. Loose diamonds can be difficult to
identify if stolen, so they're often more vulnerable than jewelry.

http://doiop.com/1im2be


--~--~-~--~~~---~--~~
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: Accessing Multiple Databases

2007-12-12 Thread koenb

Please also have a look at ticket #4747. It was/is an effort to bring
multi db a little bit closer to trunk. Regrettably, I have not had the
time (nor the need) to continue working on this.
Good luck.

Koen

On 12 dec, 16:25, Derek Steinkamp <[EMAIL PROTECTED]> wrote:
> Thanks for the link, it is very helpful. I see the last attachments are
> the docs committed by you -- I'll be giving those a read here shortly.
>
> As an aside, I think it is a real showstopper to not include this
> feature in the main trunk... I can't believe the triage stage on the
> feature request was recently changed to "Someday/Maybe". To me it seems
> obvious that all of the data that a Django app could need might not
> reside on the same database for any number of reasons.
>
> Perhaps I'll put some work into this when I have some time and get it
> caught up with the latest trunk.
>
> Derek
>
> [EMAIL PROTECTED] wrote:
> > There is a Multiple Database Branch which is not under active
> > development...and doesn't have some of the new stuff in the
> > trunk...but I'm using it in one of my projects...works pretty good for
> > the most part.
>
> >http://code.djangoproject.com/wiki/MultipleDatabaseSupport
>
> > On Dec 11, 2:48 pm, Derek Steinkamp <[EMAIL PROTECTED]> wrote:
>
> >> I read through all the relevant documentation but I couldn't find any
> >> info on an issue I am about to face: accessing multiple tables in
> >> different databases with Django.
>
> >> Here's a quick example:
> >> My Django app (MyApp) has r/w access to the MyApp database on
> >> MySQLserver1, and all of MyApp models live within here. I now need to
> >> access a pre-existing database/table on MySQLserver2 to bring in some
> >> data relevant to MyApp.
>
> >> My ultimate question is: does Django support accessing models that live
> >> in/on different databases/servers within one app? If so, how do I do
> >> this? If not, what should I be doing?
>
> >> Thanks,
> >> Derek
--~--~-~--~~~---~--~~
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: readable object

2007-12-12 Thread Marty Alchin

You might look into databrowse[1], which is available in the SVN
version of Django. There are some screenshots[2] available as well, so
you can like to see what it's like.

-Gul

[1] http://www.djangoproject.com/documentation/databrowse/
[2] 
http://www.flickr.com/photos/ubernostrum/2010704987/in/set-72157603155401014/

On Dec 12, 2007 2:13 PM, Milan Andric <[EMAIL PROTECTED]> wrote:
>
> Is there an easy way to print an object in html?  Basically with
> display names and manytomany relationships resolved.  (just for
> viewing)
>
> I was thinking to write something like model_to_dict(obj)  that
> resolves a bunch of stuff and makes it more readable.  But returns a
> big html string similar to printing a form but without input fields.
>
> Anything like that exist already?
>
> --
> Milan
> >
>

--~--~-~--~~~---~--~~
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: Model advice, i18n and content

2007-12-12 Thread Antoni Aloy

Just an issue, I've lots of problems with Django i18n and cachés. So
if you decide not to use different urls for the language and just take
the page language from the browser or let the user to change it
manually, be careful with per-view-cache as far as I know is not i18n
friendly.

-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

--~--~-~--~~~---~--~~
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: readable object

2007-12-12 Thread Milan Andric



On Dec 12, 1:13 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> Is there an easy way to print an object in html?  Basically with
> display names and manytomany relationships resolved.  (just for
> viewing)
>
> I was thinking to write something like model_to_dict(obj)  that
> resolves a bunch of stuff and makes it more readable.  But returns a
> big html string similar to printing a form but without input fields.
>
> Anything like that exist already?
>

In case you've never seen model_to_dict() I recently found out about
it from Magus the great on IRC.
http://code.djangoproject.com/browser/django/trunk/django/newforms/models.py#L148

Always asking for more!

TIA --

--~--~-~--~~~---~--~~
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: readable object

2007-12-12 Thread shaleh

>On Wed Dec 12 11:13 , Milan Andric <[EMAIL PROTECTED]> wrote:
> Is there an easy way to print an object in html?  Basically with display 
> names and manytomany relationships resolved.  (just for viewing)
> I was thinking to write something like model_to_dict(obj)  that resolves a 
> bunch of stuff and makes it more readable.
> But returns a big html string similar to printing a form but without input 
> fields.  Anything like that exist already?

Have you considered Python's "Pretty Print" module?

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



readable object

2007-12-12 Thread Milan Andric

Is there an easy way to print an object in html?  Basically with
display names and manytomany relationships resolved.  (just for
viewing)

I was thinking to write something like model_to_dict(obj)  that
resolves a bunch of stuff and makes it more readable.  But returns a
big html string similar to printing a form but without input fields.

Anything like that exist already?

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



Tableless models?

2007-12-12 Thread Nathan Fiedler

This topic has come up once or twice before, but it doesn't seem like
a solution exists. Basically I'm looking for a recommended pattern for
creating Django models that have no association with a database (i.e.
"tableless").

Curiously, ticket #419 has to do with enabling tableless models, but
it was resolved as "duplicate", with no reference to any other ticket.
Has this really been resolved, and if so, what happened?

Thanks

n

--~--~-~--~~~---~--~~
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: multiplehiddeninput assigning to list

2007-12-12 Thread Milan Andric

Nevermind this one.. I just switched when I assign my
request.session['foo'] value to the GET instead of the POST, seems to
work fine.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



2GB Free Online Storage !

2007-12-12 Thread marko osman
Diino enables you to Store, Share, Access & Protect your important files.

Free online photo Album, Free online auto-matic Back-up, Free Access your
MP3 music online, 2 GB For Free!

That's right, we are happy to give you a whopping great 2GB of secure online
storage
where you can manage and share your files easily. For Free!

Get Free Code: Limited Time Only!
http://www.dpbolvw.net/click-2667396-10497819



--~--~-~--~~~---~--~~
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: Model advice, i18n and content

2007-12-12 Thread yml

Hello Remco,

A subset of what you are looking for is provided by this library:
  * http://code.google.com/p/django-multilingual/

I found it very easy to work with hand I was able to modify flatpage
(since this was what I was looking) in a very small amount of time.
What it will bring to you :
  * a nice admin interface to handle your multilingual content
  * The right language will be served to your user
An exemple of it can be found there : http://yml.alwaysdata.net
The content is available in 2 languages french and english.
  * I am also missing some icons to see the current language and other
languages available. Of course you could jump from one to the other by
clicking on it

I hope that will help you.

What it will not do :
 * easy to connect the same article in both languages (no idea on how
to do that)
 * the language in the url (also they were some discussion about it
there : 
http://groups.google.com/group/django-multilingual/browse_frm/thread/b05fc30232069e1d)
The output is not yet completely clear to me
  *


On Dec 12, 4:46 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi Remco,
>
> ...
>
>
>
> > Now, the question. I see two obvious way to model this. Say my blog has an
> > 'Article' model.
>
> > Then:
>
> > - Either two different versions are separate Articles, the article has a
> > language code, and it has optional fields 'this_article_in_dutch' and
> > 'this_article_in_english', that lead to the other version, if it exists.
>
> > or
>
> > - One article holds both versions; they share a creation date, and have
> > separate fields for 'context_dutch' and 'content_english', same for title
> > and slug.
>
> > I think it should be the first. But I was wondering what other approaches
> > others have taken, I can't be the first one with this sort of issue.
>
> Another way of modeling this:
>
> class ArticleContainer(Model):
> "Language neutral container for an article"
> slug = SlugField(unique=True)
>
> class Article(Model):
> "Language specific article"
> container = ForeignKey(ArticleContainer)
> lang = CharField(max_length=2, db_index=True)
> #title = ...
>
> class Meta:
> unique_together = (('container', 'lang'),)
>
> def other_versions(self):
> return self.container.article_set.exclude(pk=self.pk)
>
> def comments(self):
> return self.container.comment_set.all()
>
> > Comments are an issue. In principle I'd want comments to one article also
> > appear under the other, language doesn't matter. But I'm not sure.
>
> class Comment(Model):
> "Comments are common to all language flavors of an article"
> container = ForeignKey(ArticleContainer)
> #comment = ...
>
> It's also possible to turn the Article.lang field into a ForeignKey to
> a Language reference object if you foresee needing to hang other
> objects off of a particular language.
>
> -Rajesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database

2007-12-12 Thread shaleh

>On Tue Dec 11 17:57 , Goldy <[EMAIL PROTECTED]> wrote:
> My Django database was created using sqlite3 and therefore produced a file 
> called mydb.py. I was wondering if this file could be connected to and
> examined interactively by sqlite3 as if i had inserted the tables myself? 

a very easy way is '$ manage.py dbshell', this will fire up the right frontend 
for the configured database and let you interact with it.

Give the docs a look, they really are quite good.

--~--~-~--~~~---~--~~
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: Trying to reuse models and forms

2007-12-12 Thread Kirk Strauser
On Wednesday 12 December 2007, l5x wrote:
> form_for_instance? Check:
> http://www.djangoproject.com/documentation/newforms/#generating-forms-for
>-models

That's only in the SVN version, but if we have to move from .96 to SVN to 
get it then so be it.
-- 
Kirk Strauser


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


multiplehiddeninput assigning to list

2007-12-12 Thread Milan Andric

Hello,

I ran into a problem recently (after updating to latest svn) where I'm
assigning a list to a widgets.MultipleHiddenInput field  but the list
is rendered as a string in the html form.

How do I assign a list to a multipleinput form field so it's rendered
appropriately?

The problem is exhibited when I do (in the view)
new_data['foo'] = [u'6', u'8']  or [6,8]
form = Form(new_data)

... then in the html the hidden input value="[u'6',
u'8']" instead of
name="foo_0" value="6"  and name="foo_1" value="8"

What am I doing wrong?  It's probably a recent patch I missed.

Thanks,

Milan
--~--~-~--~~~---~--~~
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: Trying to reuse models and forms

2007-12-12 Thread l5x

form_for_instance? Check: 
http://www.djangoproject.com/documentation/newforms/#generating-forms-for-models
--~--~-~--~~~---~--~~
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: Model advice, i18n and content

2007-12-12 Thread Rajesh Dhawan

Hi Remco,

...
> Now, the question. I see two obvious way to model this. Say my blog has an
> 'Article' model.
>
> Then:
>
> - Either two different versions are separate Articles, the article has a
> language code, and it has optional fields 'this_article_in_dutch' and
> 'this_article_in_english', that lead to the other version, if it exists.
>
> or
>
> - One article holds both versions; they share a creation date, and have
> separate fields for 'context_dutch' and 'content_english', same for title
> and slug.
>
> I think it should be the first. But I was wondering what other approaches
> others have taken, I can't be the first one with this sort of issue.

Another way of modeling this:

class ArticleContainer(Model):
"Language neutral container for an article"
slug = SlugField(unique=True)

class Article(Model):
"Language specific article"
container = ForeignKey(ArticleContainer)
lang = CharField(max_length=2, db_index=True)
#title = ...

class Meta:
unique_together = (('container', 'lang'),)

def other_versions(self):
return self.container.article_set.exclude(pk=self.pk)

def comments(self):
return self.container.comment_set.all()

> Comments are an issue. In principle I'd want comments to one article also
> appear under the other, language doesn't matter. But I'm not sure.

class Comment(Model):
"Comments are common to all language flavors of an article"
container = ForeignKey(ArticleContainer)
#comment = ...

It's also possible to turn the Article.lang field into a ForeignKey to
a Language reference object if you foresee needing to hang other
objects off of a particular language.

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



Trying to reuse models and forms

2007-12-12 Thread Kirk Strauser
I have a user profile model that gets accessed from the admin section of my 
site:

class UserProfile(models.Model):
MARKETS = [('B', 'Both'),
   ('D', 'Domestic'),
   ('I', 'International')]

market = models.CharField(maxlength=1, choices=MARKETS, core=True)

When viewed in /admin, that field appears as the expected select widget.  
I'm trying to wrap this (and a few other models) into a user-editable page 
elsewhere on the site, but it's giving me fits:

>>> form = newforms.form_for_instance(umod.UserProfile())()
>>> print form['market']


Is there a way to get it to render as a select widget with the same values 
as in /admin?  I'm going to be doing such things quite a few times and I 
don't want to have to repeat the same definitions in a bunch of places.

Many thanks,
-- 
Kirk Strauser


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


Re: Accessing Multiple Databases

2007-12-12 Thread Derek Steinkamp

Thanks for the link, it is very helpful. I see the last attachments are 
the docs committed by you -- I'll be giving those a read here shortly.

As an aside, I think it is a real showstopper to not include this 
feature in the main trunk... I can't believe the triage stage on the 
feature request was recently changed to "Someday/Maybe". To me it seems 
obvious that all of the data that a Django app could need might not 
reside on the same database for any number of reasons.

Perhaps I'll put some work into this when I have some time and get it 
caught up with the latest trunk.

Derek


[EMAIL PROTECTED] wrote:
> There is a Multiple Database Branch which is not under active
> development...and doesn't have some of the new stuff in the
> trunk...but I'm using it in one of my projects...works pretty good for
> the most part.
>
> http://code.djangoproject.com/wiki/MultipleDatabaseSupport
>
> On Dec 11, 2:48 pm, Derek Steinkamp <[EMAIL PROTECTED]> wrote:
>   
>> I read through all the relevant documentation but I couldn't find any
>> info on an issue I am about to face: accessing multiple tables in
>> different databases with Django.
>>
>> Here's a quick example:
>> My Django app (MyApp) has r/w access to the MyApp database on
>> MySQLserver1, and all of MyApp models live within here. I now need to
>> access a pre-existing database/table on MySQLserver2 to bring in some
>> data relevant to MyApp.
>>
>> My ultimate question is: does Django support accessing models that live
>> in/on different databases/servers within one app? If so, how do I do
>> this? If not, what should I be doing?
>>
>> Thanks,
>> Derek
>> 
> >
>   


--~--~-~--~~~---~--~~
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 set ForeignKey with generic create view?

2007-12-12 Thread Kellen

In your input form you need to pass the blog object id.

You should rather look into using the contrib.comments app rather than
reinventing the comments system.

Kellen

On Dec 10, 8:01 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
> Hello,
> I have this model:
>
> class BlogComment(Model):
> blogEntry = ForeignKey(BlogEntry, edit_inline=STACKED,
> num_in_admin=1)
> author = CharField(max_length=100, core=True)
> authorMail = EmailField(blank=True)
> content = TextField(core=True)
>
> Now I want to use the generic.create_update.create_object to create an
> BlogComment. My question is how to define which BlogEntry object it
> uses as ForeignKey?
>
> Thanks,
>
> Florian
--~--~-~--~~~---~--~~
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 set ForeignKey with generic create view?

2007-12-12 Thread Florian Lindner


Am 10.12.2007 um 20:01 schrieb Florian Lindner:

>
> Hello,
> I have this model:
>
> class BlogComment(Model):
>blogEntry = ForeignKey(BlogEntry, edit_inline=STACKED,
> num_in_admin=1)
>author = CharField(max_length=100, core=True)
>authorMail = EmailField(blank=True)
>content = TextField(core=True)
>
> Now I want to use the generic.create_update.create_object to create an
> BlogComment. My question is how to define which BlogEntry object it
> uses as ForeignKey?

Well, really noboby how can give me a hint on this?

Florian

--~--~-~--~~~---~--~~
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: about tagging app and tags cloud

2007-12-12 Thread Lic. José M. Rodriguez Bacallao
ok, it fix the problem of the font_size attr but the distribution of
values is too spaced. For example, if I got two tags: politics, linux.
the count for those tags are:
politics: 6
linux: 4

when it generate the font_size attr, for "politics" the size is 6 and
for "linux" the size is 0. It can't be posible.

On Dec 11, 2007 8:48 PM, Kellen <[EMAIL PROTECTED]> wrote:
>
> There's a bug:
> http://code.google.com/p/django-tagging/issues/detail?id=54
>
> For which there is a patch, which changes in tagging/utils.py:
> -thresholds = [math.pow(max_weight - min_weight + 1,
> float(i) / float(steps)) \
> +thresholds = [min_weight + math.pow(max_weight -
> min_weight, float(i) / float(steps)) \
>
> On Dec 11, 10:00 pm, "Lic. Jos� M. Rodriguez Bacallao"
> <[EMAIL PROTECTED]> wrote:
> > I'm controling the font size with CSS, that is not the problem, the
> > problem is with the code for tags cloud that it doesn't generate the
> > font_size attr for some tags.
> >
>
> > On Dec 11, 2007 3:44 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > Just control the default font size with a little CSS? (presuming
> > > you're using this for [X]HTML output)
> >
> > > On Dec 11, 8:26 pm, "Lic. Jos� M. Rodriguez Bacallao"
> >
> > > <[EMAIL PROTECTED]> wrote:
> > > > hi folks, I need to generate a tags cloud for a model and I'm using
> > > > the tagging app from google code. I do something like this:
> >
> > > > cloud = Tag.objects.cloud_for_model(NewsEntry, 6)
> >
> > > > and generate the html cloud based in the "font_size" attr from the
> > > > tags list "cloud". The problem come when I realize that some of the
> > > > tags in that list (cloud) doesn't contain a "font_size" attr> I was
> > > > looking inside the code of the tagging app and I saw that when the
> > > > "count" attr of the tag is less than any of the values of threshold
> > > > list it doesn't add the "font_size" attr, so, how can I generate the
> > > > tags cloud?
> >
> > > > --
> > > > Lic. Jos� M. Rodriguez Bacallao
> > > > Cupet
> > > > -
> > > > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
> > > > mismo.
> >
> > > > Recuerda: El arca de Noe fue construida por aficionados, el titanic
> > > > por profesionales
> > > > -
> >
> > --
> > Lic. Jos� M. Rodriguez Bacallao
> > Cupet
> > -
> > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo 
> > mismo.
> >
> > Recuerda: El arca de Noe fue construida por aficionados, el titanic
> > por profesionales
> > -
> >
>



-- 
Lic. Jos� M. Rodriguez Bacallao
Cupet
-
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.

Recuerda: El arca de Noe fue construida por aficionados, el titanic
por profesionales
-

--~--~-~--~~~---~--~~
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: Extra_context question

2007-12-12 Thread bjornkri

Ignore that question!

That was a bit stupid, the Notes are passed with the pages as
page.note_set.all()... or something to that effect.

On Dec 12, 12:34 pm, bjornkri <[EMAIL PROTECTED]> wrote:
> I've a feeling I'm going about this completely wrong...
>
> So I have a model called Page, and each Page can have a number of
> Notes.
>
> Now, I'm displaying the pages with a generic view, and I thought I'd
> pass the Notes along as extra_context. It looks somewhat like this:
>
> (r'^pages/(?P\d+)/$',
> 'django.views.generic.list_detail.object_detail', { 'queryset' :
> Page.objects.all(), 'extra_context' : {'notes' :
> Note.objects.filter(page__id__exact=1)}}),
>
> And that works, with the '1' hard coded. But how can I pass the number
> defined in  to the filter? Should I do this somehow
> completely differently?
>
> Thanks,
> -Björn
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Model advice, i18n and content

2007-12-12 Thread Remco Gerlich
Hi,

Let's say I want to create yet another blog app, and I want to write
articles in multiple languages - English and Dutch, in this case.

Some articles will be English-only, some will be Dutch-only. Many articles
will be available in both languages.

People browsing in one language should see indexes, lists of articles,
categories, 'newest posts' things etc only for that language.

But it should be easy to connect the same article in both languages - if I'm
looking at an article and switch languages, and if it has a version
in the other language, the result should be to see that page.

I want to have the language code in the URL, because they're separate pages.
e.g. mysite.com/blog/en/2007/12/12/some-slug/ and
mysite.com/blog/nl/2007/12/12/een-of-andere-slug , or at some
other place in the URL (I'm totally undecided, from using the subdomain for
this to having it as the last part of the URL).

Somewhere in the back of my mind is that I might want to add a language
sometime in the future, but it's vague enough and uncertain enough that we
can ignore that possibility for now.

Comments are an issue. In principle I'd want comments to one article also
appear under the other, language doesn't matter. But I'm not sure.

Now, the question. I see two obvious way to model this. Say my blog has an
'Article' model.

Then:

- Either two different versions are separate Articles, the article has a
language code, and it has optional fields 'this_article_in_dutch' and
'this_article_in_english', that lead to the other version, if it exists.

or

- One article holds both versions; they share a creation date, and have
separate fields for 'context_dutch' and 'content_english', same for title
and slug.



I think it should be the first. But I was wondering what other approaches
others have taken, I can't be the first one with this sort of issue.

Greetings,
Remco Gerlich

--~--~-~--~~~---~--~~
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: File upload on external server

2007-12-12 Thread Jarek Zgoda

Julien napisał(a):

> My Django project is served my a certain hosting company, and all the
> static data (videos, images, etc.) is served by an external server in
> another hosting company. The static data is access through an A ip
> redirection for static.mydomain.com
> 
> I'd like to allow users of the website to upload files which would be
> stored on the external server?
> Is that possible, and if so, how? From the documentation I have seen,
> it seems like the FileField object can only save files on a local
> absolute path...
> 
> Any idea?

http://code.djangoproject.com/wiki/AmazonSimpleStorageService is good
starting point (if it works for S3, you should be able to derive from it).

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

--~--~-~--~~~---~--~~
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: File upload on external server

2007-12-12 Thread David Reynolds


On 12 Dec 2007, at 11:55 am, Julien wrote:

> My Django project is served my a certain hosting company, and all the
> static data (videos, images, etc.) is served by an external server in
> another hosting company. The static data is access through an A ip
> redirection for static.mydomain.com
>
> I'd like to allow users of the website to upload files which would be
> stored on the external server?
> Is that possible, and if so, how? From the documentation I have seen,
> it seems like the FileField object can only save files on a local
> absolute path...

I think the general way that is suggested is to nfs share the folder  
from the media server to the application folder. I seem to remember  
it being talked about in the djangobook.

Thanks,

David

-- 
David Reynolds
[EMAIL PROTECTED]



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



File upload on external server

2007-12-12 Thread Julien

Hi there,

My Django project is served my a certain hosting company, and all the
static data (videos, images, etc.) is served by an external server in
another hosting company. The static data is access through an A ip
redirection for static.mydomain.com

I'd like to allow users of the website to upload files which would be
stored on the external server?
Is that possible, and if so, how? From the documentation I have seen,
it seems like the FileField object can only save files on a local
absolute path...

Any idea?

Many thanks,

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



Extra_context question

2007-12-12 Thread bjornkri

I've a feeling I'm going about this completely wrong...

So I have a model called Page, and each Page can have a number of
Notes.

Now, I'm displaying the pages with a generic view, and I thought I'd
pass the Notes along as extra_context. It looks somewhat like this:

(r'^pages/(?P\d+)/$',
'django.views.generic.list_detail.object_detail', { 'queryset' :
Page.objects.all(), 'extra_context' : {'notes' :
Note.objects.filter(page__id__exact=1)}}),

And that works, with the '1' hard coded. But how can I pass the number
defined in  to the filter? Should I do this somehow
completely differently?

Thanks,
-Björn
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Stuck implementing editable ordered lists

2007-12-12 Thread toomim

Hi, I'm having trouble. My model has publications and authors, and the
order of authors matters and should be specified by users of the admin
interface. To implement the ordered list, I made an intermediary model
called "PubAuthor", where the user has to enter a number for each
author to specify the ordering. I inline this into the Pub admin view
with foreignkey.

However, after I have SAVED a pub, I cannot change the Person field of
its PubAuthors from the inlined page on the Pub admin page! Here's a
screenshot: 
http://code.djangoproject.com/attachment/ticket/6118/badorderedmanytomany.png

Can anyone suggest a better way to do this? Ideally I wouldn't require
my admin users to manually specify the index of each author in the
right-hand column either.

--- models.py: ---

from django.db import models
import datetime

class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
homepage_url = models.URLField(blank=True)
class Admin:
pass
def __unicode__(self):
return self.first_name + ' ' + self.last_name
def __str__(self):
return self.first_name + ' ' + self.last_name


class Pub(models.Model):
title = models.CharField(max_length=200)
icon = models.ImageField(upload_to='icons', height_field=True,
width_field=True, blank=True)
pdf_url = models.URLField(verify_exists=True, blank=True)
class Admin:
pass
def __str__(self):
return self.title


class PubAuthor(models.Model):
person = models.OneToOneField(Person, core=True)
author_number = models.IntegerField(core=True, blank=False,
null=False)
pub = models.ForeignKey(Pub, edit_inline=models.TABULAR,
num_in_admin=5)
class Admin:
pass
def __str__(self):
return self.person.__str__() + ' ' + str(self.author_number)


--~--~-~--~~~---~--~~
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: Performance of a django website

2007-12-12 Thread Nic

"Karen Tracey" <[EMAIL PROTECTED]> writes:

> On Dec 11, 2007 1:49 PM, Richard Coleman <[EMAIL PROTECTED]> wrote:
>
>> 1. Static content and dynamic are on the same server (that will change
>> on production).  But they are on different apache virtual.  Mod_python
>> is turned off for the static stuff.  Hitting only a static page is very
>> fast (6500 requests per second).  Hitting the dynamic side is slow (300
>> requests per second).
>>
>> 2. It's gigE between the web server and mysql server, on a dedicated
>> switch.  The database is working pretty hard (7000 selects per second),
>> but doesn't seem to be the bottleneck.  The webserver is hammered
>> (typing any command takes a long time).
>>
>
> DB handling 7000 selects/sec while web server is serving 300 pages/sec
> implies each page request is generating >20 select requests.  Does that seem
> reasonable to you based on the content of the page you are serving?  (It
> seems high to me.)  Brian Morton provided a pointer to the doc for
> select_related, which could help to reduce the number of selects.  Even if
> the database is keeping up, so many round-trips talking to it for a single
> page request is going to add up.


Have you tried a connection pool?


-- 
Nic Ferrier
http://www.woome.com - Enjoy the minute!

--~--~-~--~~~---~--~~
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: docs for the new ModelForm() class

2007-12-12 Thread annacoder

For me, I 'happened' to see the modelforms doc page, and I love using
it.
I wish it were more prominently displayed.


On Dec 12, 12:35 am, John M <[EMAIL PROTECTED]> wrote:
> No, I don't need anything added, I'm just slow and didn't see the link
> at the end of the newforms doc, dh.
>
> Thanks everyone, I love this group, took only 2min to get an answer!!
>
> John
>
> On Dec 11, 11:32 am, "Joseph Kocherhans" <[EMAIL PROTECTED]>
> wrote:
>
> > On 12/11/07, John M <[EMAIL PROTECTED]> wrote:
>
> > > I love newforms, and as soon as I 'master' form_for_instance/model,
> > > you guys come out with something totally awesome, sub-classing
> > > something called ModelForm, wow.
>
> > > now, where do i get 'docs' for this?  Would the developer group be
> > > best,I've found some good stuff there, and a few examples here and
> > > there.
>
> > What do you want in addition to the official 
> > docs?http://www.djangoproject.com/documentation/modelforms/Ifthere's
> > somethings specific that *isn't* covered, just ask on django-users.
>
> > Please don't post questions to the developer list though. Most of us
> > read django-users as well, and that's where questions belong. The
> > developer list is for discussing the development of Django itself.
>
> > 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: Noob question: Which Linux distribution is "best" for Django?

2007-12-12 Thread eXt

VMWare is a very good suggestion. Another option is to use VirtualBox
which is also free.

On 11 Gru, 19:22, Joe <[EMAIL PROTECTED]> wrote:
> To make things easy, you could download VMware Server - run that on
> your windows box and install the prebuilt appliances. That'd make it
> easy to try out a few linux versions. VMware is free as are the
> appliances.
>
> I use ubuntu primarily.
>
> j
>
> On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > till now I've been experimenting with Django (development version)
> > under Win2k. But Windows sucks. So I dare to make my first steps with
> > Linux. Most of you will surely say I won't regret this decision ;-).
> > But since I haven't any experience with Linux yet, I want to choose a
> > distribution that is best suited for someone coming from the Windows-
> > world AND suited to establish a Django development environment. Well,
> > I'm not even sure if there will be any great difference between
> > several distributions regarding these aspects. Any comment is welcome.
>
> > Regards,
> > Andreas
--~--~-~--~~~---~--~~
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: Noob question: Which Linux distribution is "best" for Django?

2007-12-12 Thread Andreas Pfrengle

VMware seems to be a good idea - but I'll probably install win2k again
from Ubuntu as main system ;-) My win-machine has gotten so bloated
and slow that it is anyways time for a new installation. That's the
reason why I wanted a new system at all.

Arch also looks lean and fast, but the docs for Ubuntu are a big plus
to me.

Regards,
Andreas

On Dec 11, 7:22 pm, Joe <[EMAIL PROTECTED]> wrote:
> To make things easy, you could download VMware Server - run that on
> your windows box and install the prebuilt appliances. That'd make it
> easy to try out a few linux versions. VMware is free as are the
> appliances.
>
> I use ubuntu primarily.
>
> j
>
> On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > till now I've been experimenting with Django (development version)
> > under Win2k. But Windows sucks. So I dare to make my first steps with
> > Linux. Most of you will surely say I won't regret this decision ;-).
> > But since I haven't any experience with Linux yet, I want to choose a
> > distribution that is best suited for someone coming from the Windows-
> > world AND suited to establish a Django development environment. Well,
> > I'm not even sure if there will be any great difference between
> > several distributions regarding these aspects. Any comment is welcome.
>
> > Regards,
> > Andreas
--~--~-~--~~~---~--~~
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: Catching 413 response

2007-12-12 Thread Jarek Zgoda

Jeremy Dunck napisał(a):
> I think you want tramline.
> Or you want ticket #2070
> 
> Sorry you've received no helpful response in the meantime.
> 
> On Dec 7, 2007 8:58 AM, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
>> Did anybody manage to catch in Django 413 response (request entity too
>> large), thrown by http servers eg. when size of uploaded file exceeds
>> limit? I cann't find any way to communicate this response to application.

Sorry, I meant 403 response, not 413.

Anyway, it seems there's no such possibility, as the server just drops
incoming request after receiving too many bytes. The request never gets
passed to application in case of nginx (I don't know how this relates to
other http servers).

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

--~--~-~--~~~---~--~~
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: Noob question: Which Linux distribution is "best" for Django?

2007-12-12 Thread Ben Ford
I third it... except for the fact that this is a newby asking. Given that
fact I'd have to say (k)ubuntu. Personally I love Arch!!
Ben

On 12/12/2007, Aspersieman <[EMAIL PROTECTED]> wrote:
>
>
> Lic. José M. Rodriguez Bacallao wrote:
> > I will recommend Arch, is simple and powerful.
> >
> > On Dec 11, 2007 1:22 PM, Joe <[EMAIL PROTECTED]> wrote:
> >
> >> To make things easy, you could download VMware Server - run that on
> >> your windows box and install the prebuilt appliances. That'd make it
> >> easy to try out a few linux versions. VMware is free as are the
> >> appliances.
> >>
> >> I use ubuntu primarily.
> >>
> >> j
> >>
> >>
> >> On Dec 9, 9:57 am, Andreas Pfrengle <[EMAIL PROTECTED]> wrote:
> >>
> >>> Hello,
> >>>
> >>> till now I've been experimenting with Django (development version)
> >>> under Win2k. But Windows sucks. So I dare to make my first steps with
> >>> Linux. Most of you will surely say I won't regret this decision ;-).
> >>> But since I haven't any experience with Linux yet, I want to choose a
> >>> distribution that is best suited for someone coming from the Windows-
> >>> world AND suited to establish a Django development environment. Well,
> >>> I'm not even sure if there will be any great difference between
> >>> several distributions regarding these aspects. Any comment is welcome.
> >>>
> >>> Regards,
> >>> Andreas
> >>>
> >>>
> >
> >
> >
> >
> I second the Arch suggestion - it's awesome!
>
> --
>
> The three things to remember about Llamas:
> 1) They are harmless
> 2) They are deadly
> 3) They are made of lava, and thus nice to cuddle.
>
>
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+6281317958862

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