Django Tiny Mce: focus on tab

2009-10-01 Thread zweb

I have a tinymce field like this...

When I tab, the cursor just skips the tinymce text area and moves to
next field. ie it jumps from field tabindex 1 to field with tabindex
3. tinymce editor has tabindex 2. I am using django tinymce.

If anyone has come across this problem and know answer or see problem
with line below, please let me know

  description=forms.CharField(label=' Description*', widget=TinyMCE
(attrs={'cols': 90, 'rows': 20,'tabindex':'2'}),error_messages=
{'required':'! You must enter a Description.'})

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



Returning a file from a view

2009-10-01 Thread Rodrigo Cea

I am creating a password-protected file repository. I would like to
create a login_required view that returns the file without revealing
it's actual location in the file system.
Can I return an actual file (not it's location) from a view?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django 1.1, cx_oracle 5.0.2, Oracle 9i, NCLOB Textfield

2009-10-01 Thread alphacc

Ok if you change the NCLOB to CLOB in the django\db\backends\oracle
\creation.py and re-run a clear syncdb it works.
Now what are the limitation of CLOB vs NCLOB ? Will it affect other
part of the TextField methods ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom template tag problem: "No module named models"

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 8:47 PM, shacker  wrote:

>
> Found the problem. There were no namespace problems in my template
> tag, but there were (are) in the external app I'm using, which is the
> RSS aggregator used by the djangoproject.com site itself:
>
>
> http://code.djangoproject.com/browser/djangoproject.com/django_website/apps/aggregator
>
> The app is called "aggregator" and it includes  templatetags/
> aggregator.py
>
> So apparently this hasn't bitten the devs of the djangoproject.com
> site, but it bit me!
>
>
That template tags file avoids "from aggregator.models import" and uses
instead:

from django_website.apps.aggregator.models import Feed

That's an alternative to renaming the template tags file, an import that
sufficiently qualifies the duplicated name so as to avoid the problem.

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



Re: Custom template tag problem: "No module named models"

2009-10-01 Thread shacker

On Oct 1, 4:00 pm, Karen Tracey  wrote:

>
> Yes, you must simply ensure you name things in such a way that the models
> module you want to access is not hidden by something else. The original
> problem noted in the thread you reference resulted from re-using the
> application's name (bookmarks) as the name of the template tags file
> (bookmarks.py), which then attempted to import from the applications models
> (bookmarks.models).  Renaming the bookmarks.py template tags file to

Found the problem. There were no namespace problems in my template
tag, but there were (are) in the external app I'm using, which is the
RSS aggregator used by the djangoproject.com site itself:

http://code.djangoproject.com/browser/djangoproject.com/django_website/apps/aggregator

The app is called "aggregator" and it includes  templatetags/
aggregator.py

So apparently this hasn't bitten the devs of the djangoproject.com
site, but it bit me!

> Since you didn't include any specifics of the names you were using for
> anything here, it's hard to say what exactly was causing the problem in your
> case.  But there are no restrictions placed by Django on what a template
> tags library is "allowed" to access. Django doesn't attempt to enforce any
> sort of "only touch stuff from your own app" requirement.

That's what I thought :)
Thanks for nudging me to look more closely at this.

Scot

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



Re: Django 1.1, cx_oracle 5.0.2, Oracle 9i, NCLOB Textfield

2009-10-01 Thread alphacc

I installed 9i at home and did some more test.
With the same application  running (and updating the same field) I
discovered that the limit is not the same for my database.
It is now 1246 Characters.
I started a new application (a app with a model and a Textfield) and
the limitation is 1316.
I'll continue to debug but it seems the limitation doesn't mean much.
It is odd...

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



Re: combining user and userprofile in admin

2009-10-01 Thread Matt Schinckel



On Oct 2, 8:58 am, Matt Schinckel  wrote:
> On Oct 2, 3:20 am, booty  wrote:> I am creating an 
> application where I want the admin site to display
>
> > But I am not able to sort by these values (nor filter, nor search).
>


I seem to have missed this line.

You can use things in the search_fields attribute that look like
'user__username' to get access to related objects fields.

This doesn't seem to work for list_filter, though.

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



Re: combining user and userprofile in admin

2009-10-01 Thread Matt Schinckel


On Oct 2, 3:20 am, booty  wrote:
> I am creating an application where I want the admin site to display
> the User and the UserProfile (my extensions to the User class)
> together in the list view.
>
[snip]

> My problem is that I want my User Profile fields to be displayed in
> the User list page (http://.../admin/auth/user/) and be able to filter
> and sort by these (User Profile) fields. But admin does not seem to
> get access to the get_profile method:
>
> list_display = ('first_name',
>                     'last_name',
>                      #get_profile, #adding this does not give access
>                    )
>
> I can of course write a function in MyUserAdmin to give access to
> individual UserProfile properties, and they will be diplayed
> correctly. e.g.
>
> class MyUserAdmin(UserAdmin):
>     inlines = [
>         UserProfileInline,
>     ]
>
>     def home_page(self):
>          return self.get_profile().home_page
>
>     list_display = ('first_name',
>                     'last_name',
>                     home_page
>                    )
>
> But I am not able to sort by these values (nor filter, nor search).
>
> Is there anyway to have the admin site have access to the UserProfile
> model as if it was part of the User model?

Methods and properties that you have in either the AdminModel, or the
Model itself, that take no arguments, can be used in the
list_display.  Which appears to be what you have done.

Is there anything else you are trying to achieve other than this?

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



Re: OperationalError: unable to open database file, when saving existing object

2009-10-01 Thread pigmalione

Hi, Wim -
Thanks a lot for the reply.

I'm doing everything through code, since accessing the admin interface
is itself plagued with issues. And as far as I can tell, I am the same
user as the owner of the db-file (since I can also change privileges
on the file at will).

These are some more symptoms:
- when I issue "python manage.py createsuperuser" to create a
superuser I get an "unable to open database file" error again, still
the user is created on the db. However, it's created with attribute
is_superuser set to false.
- I can import objects from the db, delete objects from the db and
save new objects through the django python shell without a single
issue. Still if I import one of the saved objects, attempt to amend it
and then save() again, I get an error similar to the one above.

I'm not sure how to proceed. I've since come across some remedies on
the web which haven't proven very successful.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom template tag problem: "No module named models"

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 6:16 PM, shacker  wrote:

>
> Google apparently won't let me reply to an older thread:
>
> http://groups.google.com/group/django-users/browse_thread/thread/94239f017df4b12f
> so starting a new one.
>
> I too was hitting the "No module named models" problem when creating a
> template tag. I had the tag working perfectly when it communicated
> exclusively with the models belong to the app the templatetag lived
> in. But I needed to modify the tag to also get data from models in
> another of the project's apps. That other app imports fine from
> wherever I use it, but I could not get its models to be imported into
> the template tag. No amount of path tweaking, debugging, deleting .pyc
> files etc. would help.
>
> The docs say: "Custom template tags and filters must live inside a
> Django app. If they relate to an existing app it makes sense to bundle
> them there; otherwise, you should create a new app to hold them."
>
> They do not say whether a template tag should be able to talk to
> models from two different apps, but I assume they would be able to. My
> final solution was to merge the two apps into one. Not ideal, but not
> horrible in this particular circumstance. I did not try creating a new
> app just to hold the templatetag.
>
> Anyway, the question is, shouldn't template tags that live inside one
> app's directory also be able to get data from other apps?
>
>
Yes, you must simply ensure you name things in such a way that the models
module you want to access is not hidden by something else. The original
problem noted in the thread you reference resulted from re-using the
application's name (bookmarks) as the name of the template tags file
(bookmarks.py), which then attempted to import from the applications models
(bookmarks.models).  Renaming the bookmarks.py template tags file to
bookmark_tags, and deleting all old .pyc files resulting from the previous
name, fixed the problem.  (Why it took "many refreshes" to discover an
errant .pyc file that continued to cause trouble is unclear to me, I'm
unfamiliar with the tool mentioned as being used.)

Since you didn't include any specifics of the names you were using for
anything here, it's hard to say what exactly was causing the problem in your
case.  But there are no restrictions placed by Django on what a template
tags library is "allowed" to access. Django doesn't attempt to enforce any
sort of "only touch stuff from your own app" requirement.

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



Custom template tag problem: "No module named models"

2009-10-01 Thread shacker

Google apparently won't let me reply to an older thread:
http://groups.google.com/group/django-users/browse_thread/thread/94239f017df4b12f
so starting a new one.

I too was hitting the "No module named models" problem when creating a
template tag. I had the tag working perfectly when it communicated
exclusively with the models belong to the app the templatetag lived
in. But I needed to modify the tag to also get data from models in
another of the project's apps. That other app imports fine from
wherever I use it, but I could not get its models to be imported into
the template tag. No amount of path tweaking, debugging, deleting .pyc
files etc. would help.

The docs say: "Custom template tags and filters must live inside a
Django app. If they relate to an existing app it makes sense to bundle
them there; otherwise, you should create a new app to hold them."

They do not say whether a template tag should be able to talk to
models from two different apps, but I assume they would be able to. My
final solution was to merge the two apps into one. Not ideal, but not
horrible in this particular circumstance. I did not try creating a new
app just to hold the templatetag.

Anyway, the question is, shouldn't template tags that live inside one
app's directory also be able to get data from other apps?

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



Re: group by

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 4:38 PM, garyrob  wrote:

>
> Hello,
>
> Suppose I have a model my_model, with several fields, one of which is
> x. Suppose it's based on an SQL table with the same name.
>
> In SQL, I can:
>
> select x, count(*)
> from my_model
> group by x
>
> In order to get the number of rows with each value of x.
>
> I'm not sure how to do that in django. The annotate method looks like
> the closest thing, but it seems to depend on having many-to-many table
> relationships.
>

I don't know how you got that impression?


>
> Is there some easy way to do this in django that I'm missing? Seems
> like there should be!
>
>
my_model.objects.values('x').annotate(Count('x'))

Perhaps the bit you were missing was the effect of values():
http://docs.djangoproject.com/en/dev/topics/db/aggregation/#values

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



Re: Django + QT4

2009-10-01 Thread Markus Stumpf

On Wed, Sep 23, 2009 at 01:59:35PM -0700, Gustavo Henrique wrote:
> Is possible use django with qt4 for desktop apps?
> if yes, where I can find about this? anyone have a example to study?

A bit late maybe, but I stumbled over this today:
http://www.conceptive.be/~downloads/camelot/doc/sphinx/build/

It is not exactly with django, but looks close enough at first glance,
that maybe with a few tweaks ...

\Maex


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



group by

2009-10-01 Thread garyrob

Hello,

Suppose I have a model my_model, with several fields, one of which is
x. Suppose it's based on an SQL table with the same name.

In SQL, I can:

select x, count(*)
from my_model
group by x

In order to get the number of rows with each value of x.

I'm not sure how to do that in django. The annotate method looks like
the closest thing, but it seems to depend on having many-to-many table
relationships.

Is there some easy way to do this in django that I'm missing? Seems
like there should be!

Thanks,
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem moving project on other PC. No module found.

2009-10-01 Thread NMarcu

Hello,
   I made a project in Django, and runs grate on my PC. I have all my
files in a folder: "project". I copied to anoter PC via ssh, and on
that pc I configurate apache, and acces is from my browser via http,
but sometimes I got:
"Could not import project.operators.views. Error was: No module named
logic.curent_user".
I have a folder logic in project where is a file curent_user.py. Is
strange, beacuse n my PC I don't get this error. I got also another
error:
ImportError: No module named operators
I have a folder operators, where i put a empty file __init__.py. On my
PC I add in istalled_app, the operators, but on the other one, I tryit
to delete it, but I got the same error. What I'm 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem deleting object with foreignkey to self

2009-10-01 Thread Lavoie Francis
Hi,

I have a puzzle here I can't solve, if you have an idea or a starting  
point, it would be very useful and appreciated.

In order to have an easy way to link to the next object and the  
previous one (with special ordering), I add to my model two Foreignkey  
pointing to self. These keys point to the previous and next object.

When it saves a new object, it set the previous and the next object  
into these field.

But when I want to delete an object, the inheritance empty all the  
model's objects.

To go around this, I override the delete() method to set to None the  
next and previous of the foreign object.

But I have a problem when I do a batch delete.

Here is a schema
object1, object2, object3

objects1.next = object2
object1.previous = object3
object2.previous = object1
object2.next = object3
object3.previous = object2
object3.nest = object1

So if I delete object 1, I expect this result:
object2.previous = object3
object2.next = object3
object3.previous = object2
object3.next = object2

Here is the steps :

1. It set the previous.next and next.previous to another object  
instead of the one that is going to be delete()
2. Save previous and next object
3. It set the object.previous and object.next to None (no inheritance  
deletion)
4. It save the current object before being delete (no inheritance  
deletion)

The problem happens on step 2.

I need to call save two times on two different object. But the second  
save doesn't work. When delete() is called on the second object, the  
previous or next field that has been change is set to none. But when I  
check in the admin the field has been correctly saved.?!?

Is someone has an idea why it do that?
Or do you have a better way I can look at?

Thank you

Francis

Code:

def remove_product_position(self, selected_product):
 #print("remove_product_position is getting called")
 try:
 previous = selected_product.previous
 except:
 previous = None

 try:
 next = selected_product.next
 except:
 next = None

 if previous == next:
 """ in condition there is only one product """
 previous_product = selected_product.previous
 previous_product.next = selected_product.next
 previous_product.previous = selected_product.previous
 previous_product.save(reorder=False)
 else:
 next_product = selected_product.next
 next_product.previous = selected_product.previous
 next_product.save(reorder=False)

 previous_product = selected_product.previous
 previous_product.next = selected_product.next
 previous_product.save(reorder=False)

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



combining user and userprofile in admin

2009-10-01 Thread booty

I am creating an application where I want the admin site to display
the User and the UserProfile (my extensions to the User class)
together in the list view.

Currently, I have something like:

class UserProfile(models.Model):
" User profile class "
# That field link toward the django user class
user=models.ForeignKey(User, unique=True)

personal_title=models.CharField(max_length=20, null=True,
blank=True)
phone=models.CharField('telephone number',
   max_length=50,
   null=True, blank=True,
   help_text='Please include the country
code')


I am displaying the my own version of User in the admin site like
this:

class UserProfileInline(admin.StackedInline):
model = UserProfile

class MyUserAdmin(UserAdmin):
inlines = [
UserProfileInline,
]

admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)


My problem is that I want my User Profile fields to be displayed in
the User list page (http://.../admin/auth/user/) and be able to filter
and sort by these (User Profile) fields. But admin does not seem to
get access to the get_profile method:

list_display = ('first_name',
'last_name',
 #get_profile, #adding this does not give access
   )

I can of course write a function in MyUserAdmin to give access to
individual UserProfile properties, and they will be diplayed
correctly. e.g.

class MyUserAdmin(UserAdmin):
inlines = [
UserProfileInline,
]

def home_page(self):
 return self.get_profile().home_page

list_display = ('first_name',
'last_name',
home_page
   )

But I am not able to sort by these values (nor filter, nor search).

Is there anyway to have the admin site have access to the UserProfile
model as if it was part of the User model?

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



Re: Abstract model across apps

2009-10-01 Thread phoebebright

Karen,

Aghh - was editing a backup copy of the file, so django quite happy to
use abstract models from other apps.

However, my cunning plan does not work because of the many to many
relationships within microformats - can't have a many to many
relationship with an abstract model obviously.

Time to do some strategic copy and paste.

Thanks for your interest.

Phoebe.


On Oct 1, 6:21 pm, phoebebright  wrote:
> Karen,
>
> Am wanting to use the standard in django-microformats (with an s!) but
> want additional fields, so rather than change the models within
> microformats I thought I could be clever and make them all abstract
> and inherit them.  My suspicion is django doesn't like inheriting from
> another app, and maybe it shouldn't.  I can do some more exploration,
> but thought I would check I going in the right direction before
> proceeding.
>
> Phoebe.
>
> On Oct 1, 5:04 pm, Karen Tracey  wrote:
>
>
>
> > On Thu, Oct 1, 2009 at 10:59 AM, phoebebright 
> > wrote:
>
> > > I am trying to use use a hCalendar model from django-microformats as
> > > the base class for events in my own app,
>
> > > microformat.models.py
>
> > Is that really microformat.models.py or microformats.models.py?  I'm unsure
> > what you are using here, as searching on django-microformats brings up more
> > than one possibility.
>
> > > class hCalendar(LocationAwareMicroformat):
> > >    ...
> > >    class Meta:
>
> > >        abstract = True
>
> > This class here looks like it matches what you are using:
>
> >http://github.com/ntoll/microformats/blob/master/models.py#L638
>
> > Except it does not specify abstract=True in its class Meta:
>
> >http://github.com/ntoll/microformats/blob/master/models.py#L705
>
> > Are you using something else or have you modified this?
>
> > web.models.py
>
> > > class Event(hCalendar):
>
> > >    owner = models.ForeignKey(Account)
> > >    created = models.DateTimeField(default=datetime.now)
> > >    last_update = models.DateTimeField(auto_now = True)
>
> > > It doesn't seem to want to recognise the abstract = True, or is the
> > > problem with multi-inheritance?  The table generated is:
>
> > > CREATE TABLE `web_event` (
> > >  `hcalendar_ptr_id` int(11) NOT NULL,
> > >  `owner_id` int(11) NOT NULL,
> > >  `created` datetime NOT NULL,
> > >  `last_update` datetime NOT NULL,
> > >  PRIMARY KEY  (`hcalendar_ptr_id`),
> > >  KEY `web_event_owner_id` (`owner_id`),
> > >  CONSTRAINT `owner_id_refs_id_3952a136` FOREIGN KEY (`owner_id`)
> > > REFERENCES `web_account` (`id`)
> > > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
>
> > > Is this expected behaviour?
>
> > These models:
>
> > class Abs1(models.Model):
> >    abs1f = models.IntegerField()
> >    class Meta:
> >       abstract = True
>
> > class Abs2(Abs1):
> >    abs2f = models.IntegerField()
> >    class Meta:
> >       abstract = True
>
> > class Concrete(Abs2):
> >    pass
>
> > produce SQL:
>
> > BEGIN;
> > CREATE TABLE "ttt_concrete" (
> >     "id" integer NOT NULL PRIMARY KEY,
> >     "abs1f" integer NOT NULL,
> >     "abs2f" integer NOT NULL
> > )
> > ;
> > COMMIT;
>
> > so multiple levels of abstract models seems to work fine.
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Abstract model across apps

2009-10-01 Thread phoebebright

Karen,

Am wanting to use the standard in django-microformats (with an s!) but
want additional fields, so rather than change the models within
microformats I thought I could be clever and make them all abstract
and inherit them.  My suspicion is django doesn't like inheriting from
another app, and maybe it shouldn't.  I can do some more exploration,
but thought I would check I going in the right direction before
proceeding.

Phoebe.

On Oct 1, 5:04 pm, Karen Tracey  wrote:
> On Thu, Oct 1, 2009 at 10:59 AM, phoebebright wrote:
>
>
>
> > I am trying to use use a hCalendar model from django-microformats as
> > the base class for events in my own app,
>
> > microformat.models.py
>
> Is that really microformat.models.py or microformats.models.py?  I'm unsure
> what you are using here, as searching on django-microformats brings up more
> than one possibility.
>
> > class hCalendar(LocationAwareMicroformat):
> >    ...
> >    class Meta:
>
> >        abstract = True
>
> This class here looks like it matches what you are using:
>
> http://github.com/ntoll/microformats/blob/master/models.py#L638
>
> Except it does not specify abstract=True in its class Meta:
>
> http://github.com/ntoll/microformats/blob/master/models.py#L705
>
> Are you using something else or have you modified this?
>
> web.models.py
>
>
>
>
>
>
>
> > class Event(hCalendar):
>
> >    owner = models.ForeignKey(Account)
> >    created = models.DateTimeField(default=datetime.now)
> >    last_update = models.DateTimeField(auto_now = True)
>
> > It doesn't seem to want to recognise the abstract = True, or is the
> > problem with multi-inheritance?  The table generated is:
>
> > CREATE TABLE `web_event` (
> >  `hcalendar_ptr_id` int(11) NOT NULL,
> >  `owner_id` int(11) NOT NULL,
> >  `created` datetime NOT NULL,
> >  `last_update` datetime NOT NULL,
> >  PRIMARY KEY  (`hcalendar_ptr_id`),
> >  KEY `web_event_owner_id` (`owner_id`),
> >  CONSTRAINT `owner_id_refs_id_3952a136` FOREIGN KEY (`owner_id`)
> > REFERENCES `web_account` (`id`)
> > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
>
> > Is this expected behaviour?
>
> These models:
>
> class Abs1(models.Model):
>    abs1f = models.IntegerField()
>    class Meta:
>       abstract = True
>
> class Abs2(Abs1):
>    abs2f = models.IntegerField()
>    class Meta:
>       abstract = True
>
> class Concrete(Abs2):
>    pass
>
> produce SQL:
>
> BEGIN;
> CREATE TABLE "ttt_concrete" (
>     "id" integer NOT NULL PRIMARY KEY,
>     "abs1f" integer NOT NULL,
>     "abs2f" integer NOT NULL
> )
> ;
> COMMIT;
>
> so multiple levels of abstract models seems to work fine.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: form and related inline formset on same page

2009-10-01 Thread Daniel Roseman

On Oct 1, 3:09 pm, kurak  wrote:
> Hello,
> How can I render new form for object X and inline formset for model Y
> (with foreign key to X) on the same- the same way it's done in django-
> admin.
>
> I've been struggling with it for a while, I tried to render form and
> formset separately but it won't work this way.
>
> How should I approach this?

What doesn't work? What part of the documentation (http://
docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-an-inline-
formset-in-a-view) is not clear? What happens when you try?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django 1.1, cx_oracle 5.0.2, Oracle 9i, NCLOB Textfield

2009-10-01 Thread alphacc

> > This sounds like a character set encoding problem.  The first thing I
> > would try, if possible, is to 1) recompile cx_Oracle with the
> > WITH_UNICODE option enabled and 2) switch to Django trunk (Django 1.1
> > does not support this option).  This allows Django to send unicode
> > strings rather than encoded strings and usually solves these sorts of
> > problems.  Beware that this could break any other software using
> > cx_Oracle on the system.

I did compile the cx_Oracle 5.0.2 and change the backend with the
appropriate changeset.
No luck.
I tried to switch to the django trunk as well.

> > Does this problem occur when using the Django development web server?
> > Or only when using a production-quality web server?

Yes it happens as well when I use the dev server.

> > Finally, what happens if you replace "Database.CLOB" in line 364 of
> > django/db/backends/oracle/base.py with "Database.NCLOB" or
> > "Database.LONG_STRING"?

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



Re: Two Formset on the same page

2009-10-01 Thread Tom Evans

On Thu, 2009-10-01 at 08:52 -0700, Val Makykh wrote:
> Thanks for advice, Tom.
> 
> I've now followed it and have this exception:
> __
> Environment:
> 
> Request Method: GET
> Request URL: http://localhost:8000/results/2/1/
> Django Version: 1.1
> Python Version: 2.6.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'mysite.polls',
>  'django.contrib.admin',
>  'mysite.getindex']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
> 
> 
> Traceback:
> File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   92. response = callback(request, *callback_args,
> **callback_kwargs)
> File "C:\Users\Val Malykh\Django-1.1\django\bin\mysite\..\mysite
> \getindex\views.py" in results
>   83. urlFormSet = baseURLFormSet('url')

Re-read the documentation on formsets: the first positional argument
is /NOT/ a string, it is a dictionary of (usually) post data.

> File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
> __init__
>   44. self._construct_forms()
> File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
> _construct_forms
>   87. for i in xrange(self.total_form_count()):
> File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
> total_form_count
>   66. return self.management_form.cleaned_data
> [TOTAL_FORM_COUNT]
> File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
> _management_form
>   53. if not form.is_valid():
> File "C:\Python26\lib\site-packages\django\forms\forms.py" in is_valid
>   120. return self.is_bound and not bool(self.errors)
> File "C:\Python26\lib\site-packages\django\forms\forms.py" in
> _get_errors
>   111. self.full_clean()
> File "C:\Python26\lib\site-packages\django\forms\forms.py" in
> full_clean
>   234. value = field.widget.value_from_datadict(self.data,
> self.files, self.add_prefix(name))
> File "C:\Python26\lib\site-packages\django\forms\widgets.py" in
> value_from_datadict
>   170. return data.get(name, None)
> 
> Exception Type: AttributeError at /results/2/1/
> Exception Value: 'str' object has no attribute 'get'
> 
> 
> On 1 окт, 18:59, Tom Evans  wrote:
> > On Thu, 2009-10-01 at 07:26 -0700, Val Makykh wrote:
> > > Hello all.
> >
> > > I use Django 1.1.
> >
> > > I try to make two formsets on the same page.
> > > But  when I'm trying to use the data from POST, I have such problem:
> > > from POST each formset takes only first form with value. Where have I
> > > mistaken?
> >
> > Have you followed the advice for using more than one formset in a view?
> >
> > http://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-mor...
> >
> > Cheers
> >
> > Tom
> > 


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



Avoid queryset caching

2009-10-01 Thread Adrián Ribao

Hello,

I need to disable the queryset caching in two situations:
 * When I process a huge amount of rows, and for each one I have to
perform a new queryset. The script memory increases very quick and the
system run out of memory.
 * When I generate a form dinamically from a queryset.

Is there any way I could disable the caching system for a certain
queryset?

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



Re: Abstract model across apps

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 10:59 AM, phoebebright wrote:

>
> I am trying to use use a hCalendar model from django-microformats as
> the base class for events in my own app,
>
> microformat.models.py
>
>
Is that really microformat.models.py or microformats.models.py?  I'm unsure
what you are using here, as searching on django-microformats brings up more
than one possibility.


> class hCalendar(LocationAwareMicroformat):
>...
>class Meta:
>
>abstract = True
>
>
This class here looks like it matches what you are using:

http://github.com/ntoll/microformats/blob/master/models.py#L638

Except it does not specify abstract=True in its class Meta:

http://github.com/ntoll/microformats/blob/master/models.py#L705

Are you using something else or have you modified this?

web.models.py
>
> class Event(hCalendar):
>
>owner = models.ForeignKey(Account)
>created = models.DateTimeField(default=datetime.now)
>last_update = models.DateTimeField(auto_now = True)
>
> It doesn't seem to want to recognise the abstract = True, or is the
> problem with multi-inheritance?  The table generated is:
>
> CREATE TABLE `web_event` (
>  `hcalendar_ptr_id` int(11) NOT NULL,
>  `owner_id` int(11) NOT NULL,
>  `created` datetime NOT NULL,
>  `last_update` datetime NOT NULL,
>  PRIMARY KEY  (`hcalendar_ptr_id`),
>  KEY `web_event_owner_id` (`owner_id`),
>  CONSTRAINT `owner_id_refs_id_3952a136` FOREIGN KEY (`owner_id`)
> REFERENCES `web_account` (`id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
>
> Is this expected behaviour?
>

These models:

class Abs1(models.Model):
   abs1f = models.IntegerField()
   class Meta:
  abstract = True

class Abs2(Abs1):
   abs2f = models.IntegerField()
   class Meta:
  abstract = True

class Concrete(Abs2):
   pass

produce SQL:

BEGIN;
CREATE TABLE "ttt_concrete" (
"id" integer NOT NULL PRIMARY KEY,
"abs1f" integer NOT NULL,
"abs2f" integer NOT NULL
)
;
COMMIT;

so multiple levels of abstract models seems to work fine.

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



Re: doctest and sqllite

2009-10-01 Thread gentlestone

thx Karen

it's true, strange, but so it is

On 1. Okt, 17:41 h., Karen Tracey  wrote:
> On Thu, Oct 1, 2009 at 10:29 AM, gentlestone  wrote:
>
> > I have this model:
>
> > from django.db import models
>
> > class Subjekt(models.Model):
> >    """
> >    >>> osoba = Osoba(meno = "Ludmila", priezvisko = "Safarova")
> >    >>> osoba
> >    
> >    >>> subjekt = Subjekt(nazov = "Zaba s.r.o.", osoba = osoba)
> >    >>> subjekt
> >    
> >    >>> subjekt.osoba.save()
> >    >>> subjekt.osoba
> >    
> >    >>> subjekt.osoba.id
> >    1
> >    """
>
> [further description of problem with save() of subjekt snipped]
>
> At the time you create the subjekt instance, the related osoba instance has
> not been saved.  Therefore it does not have an id.  If you check
> subjekt.osoba_id, you will see it does not exist. It is subjekt.osoba_id
> that is stored in the table and it not existing it what leads to the error
> on save. (The value will not be pulled from subjekt.osoba.id on save() of
> subjekt, it is only set when osoba is assigned to subjekt.)  You should
> save() the osoba instance before creating the related subjekt 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two Formset on the same page

2009-10-01 Thread Val Makykh

Thanks for advice, Tom.

I've now followed it and have this exception:
__
Environment:

Request Method: GET
Request URL: http://localhost:8000/results/2/1/
Django Version: 1.1
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'mysite.polls',
 'django.contrib.admin',
 'mysite.getindex']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Users\Val Malykh\Django-1.1\django\bin\mysite\..\mysite
\getindex\views.py" in results
  83. urlFormSet = baseURLFormSet('url')
File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
__init__
  44. self._construct_forms()
File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
_construct_forms
  87. for i in xrange(self.total_form_count()):
File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
total_form_count
  66. return self.management_form.cleaned_data
[TOTAL_FORM_COUNT]
File "C:\Python26\lib\site-packages\django\forms\formsets.py" in
_management_form
  53. if not form.is_valid():
File "C:\Python26\lib\site-packages\django\forms\forms.py" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "C:\Python26\lib\site-packages\django\forms\forms.py" in
_get_errors
  111. self.full_clean()
File "C:\Python26\lib\site-packages\django\forms\forms.py" in
full_clean
  234. value = field.widget.value_from_datadict(self.data,
self.files, self.add_prefix(name))
File "C:\Python26\lib\site-packages\django\forms\widgets.py" in
value_from_datadict
  170. return data.get(name, None)

Exception Type: AttributeError at /results/2/1/
Exception Value: 'str' object has no attribute 'get'


On 1 окт, 18:59, Tom Evans  wrote:
> On Thu, 2009-10-01 at 07:26 -0700, Val Makykh wrote:
> > Hello all.
>
> > I use Django 1.1.
>
> > I try to make two formsets on the same page.
> > But  when I'm trying to use the data from POST, I have such problem:
> > from POST each formset takes only first form with value. Where have I
> > mistaken?
>
> Have you followed the advice for using more than one formset in a view?
>
> http://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-mor...
>
> Cheers
>
> Tom
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: doctest and sqllite

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 10:29 AM, gentlestone  wrote:

>
> I have this model:
>
> from django.db import models
>
> class Subjekt(models.Model):
>"""
>>>> osoba = Osoba(meno = "Ludmila", priezvisko = "Safarova")
>>>> osoba
>
>>>> subjekt = Subjekt(nazov = "Zaba s.r.o.", osoba = osoba)
>>>> subjekt
>
>>>> subjekt.osoba.save()
>>>> subjekt.osoba
>
>>>> subjekt.osoba.id
>1
>"""
>
[further description of problem with save() of subjekt snipped]

At the time you create the subjekt instance, the related osoba instance has
not been saved.  Therefore it does not have an id.  If you check
subjekt.osoba_id, you will see it does not exist. It is subjekt.osoba_id
that is stored in the table and it not existing it what leads to the error
on save. (The value will not be pulled from subjekt.osoba.id on save() of
subjekt, it is only set when osoba is assigned to subjekt.)  You should
save() the osoba instance before creating the related subjekt 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



session intermittently disappears just after login

2009-10-01 Thread Jeff Gentry

Hi there ...

(this is also posted to 
stackoverflow: 
http://stackoverflow.com/questions/1504537/django-session-intermittently-disappears-just-after-login)

In my django app, I handle login in the following manner. Users go to a
gateway page (index.html) - if they are not currently logged in, there
will be a login/password form along with the other material. On successful
login (or if they otherwise go to that page while logged in), the page is
rendered slightly differently (sans login form).

The way I am handling that is in the view for index.html I do:

logged_in = request.user.is_authenticated()

and then the logged_in variable is passed to the template, which is
checked to see which version of the page it renders.

When a user logs in, the login view calls:

user = authenticate(username=username, password=password)
if user is not None:
   login(request, user)

And then they are redirected back to index.html.

More often than not, this works perfectly fine. What I see though is that
sometimes between the HttpResponseRedirect and the index view is that
request.user is wiped out. I have been logging this for a while now,
writing to the log as the last item in the login view and first item in
the index view. The effect it has for the user is that it looks like they
incorrectly logged in (except w/ no message telling them that).

It does seem to come in spurts, as in the system will be fine for a while,
and then I'll see it happen to a user 4-5 times in a row. I should also
note that I've never seen/heard of this happening at any point except at
the login, as far as I can tell (it is possible that it has happened and
no one has complained) once they're in, they're in.

Am I doing something obviously wrong with my login methodology here?



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



Re: doctest and sqllite

2009-10-01 Thread gentlestone

the same confusing result I've got in the python interpeter -
manage.py shell
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Abstract model across apps

2009-10-01 Thread phoebebright

I am trying to use use a hCalendar model from django-microformats as
the base class for events in my own app,

microformat.models.py

class hCalendar(LocationAwareMicroformat):
...
class Meta:

abstract = True

web.models.py

class Event(hCalendar):

owner = models.ForeignKey(Account)
created = models.DateTimeField(default=datetime.now)
last_update = models.DateTimeField(auto_now = True)

It doesn't seem to want to recognise the abstract = True, or is the
problem with multi-inheritance?  The table generated is:

CREATE TABLE `web_event` (
  `hcalendar_ptr_id` int(11) NOT NULL,
  `owner_id` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `last_update` datetime NOT NULL,
  PRIMARY KEY  (`hcalendar_ptr_id`),
  KEY `web_event_owner_id` (`owner_id`),
  CONSTRAINT `owner_id_refs_id_3952a136` FOREIGN KEY (`owner_id`)
REFERENCES `web_account` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin

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



Re: Two Formset on the same page

2009-10-01 Thread Tom Evans

On Thu, 2009-10-01 at 07:26 -0700, Val Makykh wrote:
> Hello all.
> 
> I use Django 1.1.
> 
> I try to make two formsets on the same page.
> But  when I'm trying to use the data from POST, I have such problem:
> from POST each formset takes only first form with value. Where have I
> mistaken?

Have you followed the advice for using more than one formset in a view?

http://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-more-than-one-formset-in-a-view

Cheers

Tom


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



Re: Reading text files into mysql database

2009-10-01 Thread Carlos Gustavo
Thanks, Mark!!!

Deeply appreciated!

-Carlos

On Thu, Oct 1, 2009 at 10:26 AM, Mark (Nosrednakram)  wrote:

>
> Hello,
>
> If your data is in a CSV format I have a tool I wrote to do this a
> while ago that has served me well several times:
> http://projects.django-development.info/trac/dd_csvloader   To
> download if you want as a CSV check for a snippet at
> djangosnippets.org.  http://www.djangosnippets.org/snippets/1697/ is
> one such snippet.  You can also use the manager to import/export data
> is several formats see
> http://docs.djangoproject.com/en/dev/ref/django-admin/#loaddata-fixture-fixture
> .
> Just a few links to get you started.
>
> Good Luck,
> Mark
>
> On Oct 1, 7:25 am, Carlos Gustavo  wrote:
> > Hi All,
> >
> > I am a django newbie and so far it has been great.
> >
> > How do I populate a mysql database table with data from a text file?
> >
> > Also How do I dump results of a database query into a text file.
> >
> > I have already created my django model for the mysql table.
> >
> > Thanks in advance.
> >
> > -Carlos
> >
>

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



Re: Reading text files into mysql database

2009-10-01 Thread Carlos Gustavo
Thanks, Shawn!!!

Deeply appreciated!

-Carlos.

On Thu, Oct 1, 2009 at 10:38 AM, Shawn Milochik wrote:

>
>
> On Oct 1, 2009, at 9:25 AM, Carlos Gustavo wrote:
>
> >
> > Hi All,
> >
> > I am a django newbie and so far it has been great.
> >
> > How do I populate a mysql database table with data from a text file?
> >
> > Also How do I dump results of a database query into a text file.
> >
> > I have already created my django model for the mysql table.
> >
> > Thanks in advance.
> >
> > -Carlos
>
>
> To populate the database with the contents of a text file, write a
> script that imports your Django model, open the file (perhaps using
> the csv module, if it's a csv file), and iterate through the file,
> creating new instances of your model and saving them.
>
> Here's a barebones example I made by taking something I actually use
> and cutting out most of it so it's clear: http://pastebin.com/f651cf8de
>
> As for dumping the output of a query to a text file, that depends. The
> first thing that springs to mind is to write a method in the model
> which dumps the data you want in the format you want. So, for example,
> if your model has a csv_format(self) method, you could do the
> queryset, then iterate through it, writing instance.csv_format() to a
> text file.
>
> Shawn
>
>
>
> >
>

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



Re: Two Formset on the same page

2009-10-01 Thread Shawn Milochik

Are both Django forms being rendered in the  same HTML form, or are  
they separate?

If they're in separate HTML forms, that could be the 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Two Formset on the same page

2009-10-01 Thread Val Makykh

Hello all.

I use Django 1.1.

I try to make two formsets on the same page.
But  when I'm trying to use the data from POST, I have such problem:
from POST each formset takes only first form with value. Where have I
mistaken?

Sourse:

In views.py:
__
def results(request, countOfTerms, countOfUrls):
def errorHandle(error):
termFormSet = baseTermFormSet()
urlFormSet = baseURLFormSet()
return render_to_response('form.html', {
'error' : error,
'termFormSet' : termFormSet,
'urlFormSet' : urlFormSet
})
countOfTermsNumber = int(countOfTerms)
countOfUrlsNumber = int(countOfUrls)
baseTermFormSet = formset_factory(TermForm,
formset=BaseTermFormSet, extra = countOfTermsNumber)
baseURLFormSet = formset_factory(URLForm, formset=BaseURLFormSet,
extra = countOfUrlsNumber)
if request.method == 'POST': # If the form has been submitted...
termFormSet = baseTermFormSet(request.POST) # A form bound to
the POST data
urlFormSet = baseURLFormSet(request.POST)
if (termFormSet.is_valid() and urlFormSet.is_valid()): # All
validation rules pass
#if True:
terms = []
urls = []

for term in termFormSet._get_cleaned_data():
terms.append(term['term'])
for url in urlFormSet._get_cleaned_data():
urls.append(url['url'])
# Here we've couning TF for URL
urlCounts = []
for url in urls:
termCounts = []
termRefs = indexCount(url,terms)
for i in range(len(terms)):
termCountRefs = []
termCountRefs.append(terms[i])
termCountRefs.append(termRefs[i])
termCounts.append(termCountRefs)


return render_to_response('search.html',{
 'terms':
termCounts,
 'urls': urls
 })

In forms.py:
class BaseTermFormSet(BaseFormSet):

def clean(self):
if any(self.errors):
 # Don't bother validating the formset unless each form is
valid on its own
return
terms = []
for i in range(0, self.total_form_count()):
form = self.forms[i]
term = form.cleaned_data['term']
if term in terms:
raise forms.ValidationError, "Terms must be
different."
terms.append(term)
return terms

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



Re: Reading text files into mysql database

2009-10-01 Thread Shawn Milochik


On Oct 1, 2009, at 9:25 AM, Carlos Gustavo wrote:

>
> Hi All,
>
> I am a django newbie and so far it has been great.
>
> How do I populate a mysql database table with data from a text file?
>
> Also How do I dump results of a database query into a text file.
>
> I have already created my django model for the mysql table.
>
> Thanks in advance.
>
> -Carlos


To populate the database with the contents of a text file, write a  
script that imports your Django model, open the file (perhaps using  
the csv module, if it's a csv file), and iterate through the file,  
creating new instances of your model and saving them.

Here's a barebones example I made by taking something I actually use  
and cutting out most of it so it's clear: http://pastebin.com/f651cf8de

As for dumping the output of a query to a text file, that depends. The  
first thing that springs to mind is to write a method in the model  
which dumps the data you want in the format you want. So, for example,  
if your model has a csv_format(self) method, you could do the  
queryset, then iterate through it, writing instance.csv_format() to a  
text file.

Shawn



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



Re: Database Consistecy using Django ORM

2009-10-01 Thread Geobase Isoscale
Many Thanks,

Rama, thanks again, I have taken a look at South, I understand Django
Evolution project is on going.(its mature to use it?)

Russell, thanks again, You have supplied invaluable information that would
have me taken ages to decipher.

New Question, Is it possible to use UML and OCL or others like WebML
 modelling tools with Django. Because I find the conceptual design , logical
design  and physical design  tend to be more comphrensive rather than just
using the models.py classes that can overlook relationships, integrity
constaints and assosiations.


Many Thanks

Isoscale

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



doctest and sqllite

2009-10-01 Thread gentlestone

I have this model:

from django.db import models

class Subjekt(models.Model):
"""
>>> osoba = Osoba(meno = "Ludmila", priezvisko = "Safarova")
>>> osoba

>>> subjekt = Subjekt(nazov = "Zaba s.r.o.", osoba = osoba)
>>> subjekt

>>> subjekt.osoba.save()
>>> subjekt.osoba

>>> subjekt.osoba.id
1
"""
class Meta:
verbose_name = "subjekt"
verbose_name_plural = "subjekty"
nazov = models.CharField(
unique = True,
max_length = 60,
verbose_name = "nazov",
)
osoba = models.OneToOneField(
'Osoba',
verbose_name = "osoba",
related_name = 'subjekt'
)
def __unicode__(self):
return "%s - %s" % (self.nazov, self.osoba)

class Osoba(models.Model):
"""
>>> Osoba(meno = "Ludmila", priezvisko = "Safarova")

"""
class Meta:
verbose_name = "osoba"
verbose_name_plural = "osoby"
meno = models.CharField(
max_length = 60,
verbose_name = "meno",
)
priezvisko = models.CharField(
max_length = 60,
verbose_name = "priezvisko",
)
def __unicode__(self):
return "%s %s" % (self.priezvisko, self.meno)

So far - the manage.py test with SQLite is succesful - the result is
OK. But after I append this line to the test:
>>> subjekt.save()

so the whole test is:
class Subjekt(models.Model):
"""
>>> osoba = Osoba(meno = "Ludmila", priezvisko = "Safarova")
>>> osoba

>>> subjekt = Subjekt(nazov = "Zaba s.r.o.", osoba = osoba)
>>> subjekt

>>> subjekt.osoba.save()
>>> subjekt.osoba

>>> subjekt.osoba.id
1
>>> subjekt.save()
"""
I got this error message:

FAIL: Doctest: konres.subjekty.models.Subjekt
--
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/test/_doctest.py",
line 2180, in runTest
raise self.failureException(self.format_failure(new.getvalue
()).encode('UTF-8'))
AssertionError: Failed doctest test for konres.subjekty.models.Subjekt
  File "/Users/iM1/Sites/konres/../konres/subjekty/models.py", line 3,
in Subjekt

--
File "/Users/iM1/Sites/konres/../konres/subjekty/models.py", line 16,
in konres.subjekty.models.Subjekt
Failed example:
subjekt.save()
Exception raised:
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/test/
_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
  File "", line 1, in

subjekt.save()
  File "/Library/Python/2.5/site-packages/django/db/models/
base.py", line 410, in save
self.save_base(force_insert=force_insert,
force_update=force_update)
  File "/Library/Python/2.5/site-packages/django/db/models/
base.py", line 495, in save_base
result = manager._insert(values, return_id=update_pk)
  File "/Library/Python/2.5/site-packages/django/db/models/
manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
  File "/Library/Python/2.5/site-packages/django/db/models/
query.py", line 1087, in insert_query
return query.execute_sql(return_id)
  File "/Library/Python/2.5/site-packages/django/db/models/sql/
subqueries.py", line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
  File "/Library/Python/2.5/site-packages/django/db/models/sql/
query.py", line 2369, in execute_sql
cursor.execute(sql, params)
  File "/Library/Python/2.5/site-packages/django/db/backends/
sqlite3/base.py", line 193, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: subjekty_subjekt.osoba_id may not be NULL

And I don't know why. The model instance osoba is saved and has an id
1. The ugly doctest lies!

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



Re: Reading text files into mysql database

2009-10-01 Thread Mark (Nosrednakram)

Hello,

If your data is in a CSV format I have a tool I wrote to do this a
while ago that has served me well several times:
http://projects.django-development.info/trac/dd_csvloader   To
download if you want as a CSV check for a snippet at
djangosnippets.org.  http://www.djangosnippets.org/snippets/1697/ is
one such snippet.  You can also use the manager to import/export data
is several formats see 
http://docs.djangoproject.com/en/dev/ref/django-admin/#loaddata-fixture-fixture.
Just a few links to get you started.

Good Luck,
Mark

On Oct 1, 7:25 am, Carlos Gustavo  wrote:
> Hi All,
>
> I am a django newbie and so far it has been great.
>
> How do I populate a mysql database table with data from a text file?
>
> Also How do I dump results of a database query into a text file.
>
> I have already created my django model for the mysql table.
>
> Thanks in advance.
>
> -Carlos
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



not required in Atom feeds

2009-10-01 Thread peppergrower

Question about Django's syndication framework: why does it require a
link for each item/entry in a feed?  As far as I can tell, this is
optional in the Atom specification (http://www.atomenabled.org/
developers/syndication/atom-format-spec.php#element.link):

>> The "atom:link" element defines a reference from an entry or feed to a Web 
>> resource. This specification assigns no meaning to the content (if any) of 
>> this element.

I ask because I'm creating feeds that are user-customizable, and since
their entries are arranged uniquely for each custom feed, there isn't
a comparable view for each entry on my website.  Consequently, there
isn't anything I can link to; I can define a unique ID for each entry,
as Atom requires, but a link just doesn't make sense.

I guess I'm going to override the Atom1Feed generator class so I don't
have to specify a link, but it would be nice if the per-item link
attribute were made optional in the future.  Is it worth suggesting as
a fix in Django's bug tracker?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



form and related inline formset on same page

2009-10-01 Thread kurak

Hello,
How can I render new form for object X and inline formset for model Y
(with foreign key to X) on the same- the same way it's done in django-
admin.

I've been struggling with it for a while, I tried to render form and
formset separately but it won't work this way.

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



Error with IPython shell and Django

2009-10-01 Thread Symbios

Hello,

I was using the python shell to test my Django model, and I got this
error :

In [91]: MediaCollection.objects.by_country("gabon")
Out[91]: ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (12, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (72, 0))

ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/IPython/ultraTB.py", line
662, in text
locals,formatvalue=var_repr))
  File "/usr/lib/python2.5/inspect.py", line 812, in formatargvalues
specs.append(strseq(args[i], convert, join))
  File "/usr/lib/python2.5/inspect.py", line 767, in strseq
return convert(object)
  File "/usr/lib/python2.5/inspect.py", line 809, in convert
return formatarg(name) + formatvalue(locals[name])
KeyError: 'connection'

IPython's exception reporting continues...

---
ValueErrorTraceback (most recent call
last)

/home/david/dev/cremtest/ in ()

/var/lib/python-support/python2.5/IPython/Prompts.pyc in __call__
(self, arg)
549
550 # and now call a possibly user-defined print
mechanism
--> 551 manipulated_val = self.display(arg)
552
553 # user display hooks can change the variable to be
stored in

/var/lib/python-support/python2.5/IPython/Prompts.pyc in _display
(self, arg)
575 return IPython.generics.result_display(arg)
576 except TryNext:
--> 577 return self.shell.hooks.result_display(arg)
578
579 # Assign the default display method:

/var/lib/python-support/python2.5/IPython/hooks.pyc in __call__(self,
*args, **kw)
133 #print "prio",prio,"cmd",cmd #dbg
134 try:
--> 135 ret = cmd(*args, **kw)
136 return ret
137 except ipapi.TryNext, exc:

/var/lib/python-support/python2.5/IPython/hooks.pyc in result_display
(self, arg)
163
164 if self.rc.pprint:
--> 165 out = pformat(arg)
166 if '\n' in out:
167 # So that multi-line strings line up with the left
column of

/usr/lib/python2.5/pprint.pyc in pformat(self, object)
109 def pformat(self, object):
110 sio = _StringIO()
--> 111 self._format(object, sio, 0, 0, {}, 0)
112 return sio.getvalue()
113

/usr/lib/python2.5/pprint.pyc in _format(self, object, stream, indent,
allowance, context, level)
127 self._readable = False
128 return
--> 129 rep = self._repr(object, context, level - 1)
130 typ = _type(object)
131 sepLines = _len(rep) > (self._width - 1 - indent -
allowance)

/usr/lib/python2.5/pprint.pyc in _repr(self, object, context, level)
193 def _repr(self, object, context, level):
194 repr, readable, recursive = self.format(object,
context.copy(),
--> 195 self._depth,
level)
196 if not readable:
197 self._readable = False

/usr/lib/python2.5/pprint.pyc in format(self, object, context,
maxlevels, level)
205 and whether the object represents a recursive
construct.
206 """
--> 207 return _safe_repr(object, context, maxlevels, level)
208
209

/usr/lib/python2.5/pprint.pyc in _safe_repr(object, context,
maxlevels, level)
290 return format % _commajoin(components), readable,
recursive
291
--> 292 rep = repr(object)
293 return rep, (rep and not rep.startswith('<')), False
294

/var/lib/python-support/python2.5/django/db/models/query.pyc in
__repr__(self)
145
146 def __repr__(self):
--> 147 data = list(self[:REPR_OUTPUT_SIZE + 1])
148 if len(data) > REPR_OUTPUT_SIZE:
149 data[-1] = "...(remaining elements truncated)..."

/var/lib/python-support/python2.5/django/db/models/query.pyc in __len__
(self)
160 self._result_cache = list(self.iterator())
161 elif self._iter:
--> 162 self._result_cache.extend(list(self._iter))
163 return len(self._result_cache)
164

/var/lib/python-support/python2.5/django/db/models/query.pyc in
iterator(self)
273 extra_select = self.query.extra_select.keys()
274 index_start = len(extra_select)
--> 275 for row in self.query.results_iter():
276 if fill_cache:
277 obj, _ = get_cached_row(self.model, row,
index_start,

/var/lib/python-support/python2.5/django/db/models/sql/query.pyc in
results_iter(self)
204 

Re: Database Consistecy using Django ORM

2009-10-01 Thread Russell Keith-Magee

On Thu, Oct 1, 2009 at 5:14 PM, Geobase Isoscale  wrote:
> Hi  Everyone,
>
> I would like to know how to Add a new Collumn to an already created table in
> Django.

As noted by Rama - the answer here is either to use raw ALTER
statements, or to use a tool like South or Django Evolution to
automate (or semi-automate) the schema update process.

> I would like to know whether one can create database triggers,
> create database functions, database Index and database views using  Django
> ORM.

Django produces indices automatically in some circumstances (such as
foreign key columns). You can also direct  Django to generate indices
on columns that you know will need to support lookups. See the
documentation about the db_index attribute on fields.

As for triggers, database functions and views - Django doesn't provide
built-in support for any of these. However, you can define custom SQL
for your Django tables, and this custom SQL can define triggers etc.
You can also define models that wrap views that you define yourself -
look for the "managed" attribute on models.

> I'm investigation to what extend does Django support database
> consistency.

Depends on exactly what you mean. Django will define database-level
constraints for things like foreign keys, but it doesn't apply any
database-level data validation hooks.

> If anyone has more information on the pros and cons of ORM with
> regard to database design. I'm connected Postgres database with its PostGIS
> extention.

This is a completely open ended question - ultimately, you are the
only person who can answer this sort of question for your own
circumstances. The ORM is powerful, but it does have limitations.
Whether those limitations will matter to you will depend entirely on
your expectations and your use case.

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



Reading text files into mysql database

2009-10-01 Thread Carlos Gustavo

Hi All,

I am a django newbie and so far it has been great.

How do I populate a mysql database table with data from a text file?

Also How do I dump results of a database query into a text file.

I have already created my django model for the mysql table.

Thanks in advance.

-Carlos

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



Re: Trouble with Messages feature in django.contrib.auth

2009-10-01 Thread willfe

On Sep 30, 7:50 pm, Karen Tracey  wrote:
> On Wed, Sep 30, 2009 at 6:28 PM, willfe  wrote:
>
> > *sigh* I was just about to post this as-is, and tried one more thing,
> > which fixed it. I hadn't added context_instance=RequestContext
> > (request) to the end of the render_to_response() return in the
> > specific method I was working with. I'd added it to a different one
> > instead. It's fixed and working -- I'll put on a dunce cap and sit in
> > the corner until I've learned my lesson :)
>
> Hmm...yeah, that's the other common reason for things not to appear when
> expected, if they're set by a context processor and you haven't used
> RequestContext. I'm surprised, though, that the debug toolbar showed
> messages being in the context in the case where you were not passing a
> RequestContext...that seems pretty misleading.  I haven't used debug toolbar
> in a little while though so perhaps I'm misunderstanding something about
> what it was showing.

Yeah, it definitely confused me for a bit before realizing my goof.

This does raise another question though -- is there ever an instance
where I *shouldn't* be using RequestContext in a view (that emits a
real page instead of a redirect)? If it's meant to be used pretty much
everywhere, is there a more DRY way of using it than bolting on
context_instance=RequestContext(request) to the argument list of
render_to_response()?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'NoneType' object has no attribute 'widget'

2009-10-01 Thread Karen Tracey
On Thu, Oct 1, 2009 at 5:33 AM, dijxtra  wrote:

>
> On Sep 30, 5:12 pm, Karen Tracey  wrote:
> > On Wed, Sep 30, 2009 at 10:53 AM, dijxtra  wrote:
> >
> > > I'm getting "'NoneType' object has no attribute 'widget'" exception
> > > and I just can't figure out where is the problem. Here is my error:
> >
> > > Django Version: 1.1
> >
> > > Traceback:
> > > [snip]
> >
> > In this form:
> >
> >1. class DiaryEntryForm(ModelForm):
> >2. importance = models.IntegerField(choices=IMPORTANCE_CHOICES)
> >3. class Meta:
> >4. model = DiaryEntry
> >5. fields = ['text', 'date', 'type', 'importance']
> >
> > 'importance' has been specified as a model field instead of a form field.
> > It needs to be a form field, since this is a form, not a model.
>
> Damn. This one was obvious. But, despite of this bugfix, the error
> still remains.
>
> This one: http://pastebin.com/pastebin.php?diff=m1867a8ad
> Gives me this:
> Django Version: 1.1
>
> Traceback:
> [snip]
>
234. value = field.widget.value_from_datadict(self.data,
> self.files, self.add_prefix(name))
>
> Exception Value: 'NoneType' object has no attribute 'widget'
>
>
OK, looking a bit further, the form lists 'type' in fields but I do not see
that field in the model?

(If you were only adding 'importance' to the form explicitly in order to try
to fix this error, best to get rid of it.  Best to go back to the simplest
version of your code that had problems when posting looking for solutions.
Posting the original version modified with fixes that don't fix the problem
just makes it more confusing.)

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



unicode and manage.py test

2009-10-01 Thread gentlestone

I wrote a piece of code for correct slugification:

_MAP = {
# LATIN
u'À': 'A', u'Á': 'A', u'Â': 'A', u'Ã': 'A', u'Ä': 'A', u'Å': 'A',
u'Æ': 'AE', u'Ç':'C',
u'È': 'E', u'É': 'E', u'Ê': 'E', u'Ë': 'E', u'Ì': 'I', u'Í': 'I',
u'Î': 'I',
u'Ï': 'I', u'Ð': 'D', u'Ñ': 'N', u'Ò': 'O', u'Ó': 'O', u'Ô': 'O',
u'Õ': 'O', u'Ö':'O',
u'Ő': 'O', u'Ø': 'O', u'Ù': 'U', u'Ú': 'U', u'Û': 'U', u'Ü': 'U',
u'Ű': 'U',
u'Ý': 'Y', u'Þ': 'TH', u'ß': 'ss', u'à':'a', u'á':'a', u'â': 'a',
u'ã': 'a', u'ä':'a',
u'å': 'a', u'æ': 'ae', u'ç': 'c', u'è': 'e', u'é': 'e', u'ê': 'e',
u'ë': 'e',
u'ì': 'i', u'í': 'i', u'î': 'i', u'ï': 'i', u'ð': 'd', u'ñ': 'n',
u'ò': 'o', u'ó':'o',
u'ô': 'o', u'õ': 'o', u'ö': 'o', u'ő': 'o', u'ø': 'o', u'ù': 'u',
u'ú': 'u',
u'û': 'u', u'ü': 'u', u'ű': 'u', u'ý': 'y', u'þ': 'th', u'ÿ': 'y',
# LATIN_SYMBOLS
u'©':'(c)',
# GREEK
u'α':'a', u'β':'b', u'γ':'g', u'δ':'d', u'ε':'e', u'ζ':'z',
u'η':'h', u'θ':'8',
u'ι':'i', u'κ':'k', u'λ':'l', u'μ':'m', u'ν':'n', u'ξ':'3',
u'ο':'o', u'π':'p',
u'ρ':'r', u'σ':'s', u'τ':'t', u'υ':'y', u'φ':'f', u'χ':'x',
u'ψ':'ps', u'ω':'w',
u'ά':'a', u'έ':'e', u'ί':'i', u'ό':'o', u'ύ':'y', u'ή':'h',
u'ώ':'w', u'ς':'s',
u'ϊ':'i', u'ΰ':'y', u'ϋ':'y', u'ΐ':'i',
u'Α':'A', u'Β':'B', u'Γ':'G', u'Δ':'D', u'Ε':'E', u'Ζ':'Z',
u'Η':'H', u'Θ':'8',
u'Ι':'I', u'Κ':'K', u'Λ':'L', u'Μ':'M', u'Ν':'N', u'Ξ':'3',
u'Ο':'O', u'Π':'P',
u'Ρ':'R', u'Σ':'S', u'Τ':'T', u'Υ':'Y', u'Φ':'F', u'Χ':'X',
u'Ψ':'PS', u'Ω':'W',
u'Ά':'A', u'Έ':'E', u'Ί':'I', u'Ό':'O', u'Ύ':'Y', u'Ή':'H',
u'Ώ':'W', u'Ϊ':'I', u'Ϋ':'Y',
# TURKISH
u'ş':'s', u'Ş':'S', u'ı':'i', u'İ':'I', u'ç':'c', u'Ç':'C',
u'ü':'u', u'Ü':'U',
u'ö':'o', u'Ö':'O', u'ğ':'g', u'Ğ':'G',
# RUSSIAN
u'а':'a', u'б':'b', u'в':'v', u'г':'g', u'д':'d', u'е':'e',
u'ё':'yo', u'ж':'zh',
u'з':'z', u'и':'i', u'й':'j', u'к':'k', u'л':'l', u'м':'m',
u'н':'n', u'о':'o',
u'п':'p', u'р':'r', u'с':'s', u'т':'t', u'у':'u', u'ф':'f',
u'х':'h', u'ц':'c',
u'ч':'ch', u'ш':'sh', u'щ':'sh', u'ъ':'', u'ы':'y', u'ь':'',
u'э':'e', u'ю':'yu', u'я':'ya',
u'А':'A', u'Б':'B', u'В':'V', u'Г':'G', u'Д':'D', u'Е':'E',
u'Ё':'Yo', u'Ж':'Zh',
u'З':'Z', u'И':'I', u'Й':'J', u'К':'K', u'Л':'L', u'М':'M',
u'Н':'N', u'О':'O',
u'П':'P', u'Р':'R', u'С':'S', u'Т':'T', u'У':'U', u'Ф':'F',
u'Х':'H', u'Ц':'C',
u'Ч':'Ch', u'Ш':'Sh', u'Щ':'Sh', u'Ъ':'', u'Ы':'Y', u'Ь':'',
u'Э':'E', u'Ю':'Yu', u'Я':'Ya',
# UKRAINIAN
u'Є':'Ye', u'І':'I', u'Ї':'Yi', u'Ґ':'G', u'є':'ye', u'і':'i',
u'ї':'yi', u'ґ':'g',
# CZECH
u'č':'c', u'ď':'d', u'ě':'e', u'ň':'n', u'ř':'r', u'š':'s',
u'ť':'t', u'ů':'u',
u'ž':'z', u'Č':'C', u'Ď':'D', u'Ě':'E', u'Ň':'N', u'Ř':'R',
u'Š':'S', u'Ť':'T', u'Ů':'U', u'Ž':'Z',
# POLISH
u'ą':'a', u'ć':'c', u'ę':'e', u'ł':'l', u'ń':'n', u'ó':'o',
u'ś':'s', u'ź':'z',
u'ż':'z', u'Ą':'A', u'Ć':'C', u'Ę':'e', u'Ł':'L', u'Ń':'N',
u'Ó':'o', u'Ś':'S',
u'Ź':'Z', u'Ż':'Z',
# LATVIAN
u'ā':'a', u'č':'c', u'ē':'e', u'ģ':'g', u'ī':'i', u'ķ':'k',
u'ļ':'l', u'ņ':'n',
u'š':'s', u'ū':'u', u'ž':'z', u'Ā':'A', u'Č':'C', u'Ē':'E',
u'Ģ':'G', u'Ī':'i',
u'Ķ':'k', u'Ļ':'L', u'Ņ':'N', u'Š':'S', u'Ū':'u', u'Ž':'Z'
}

def slugify(name):
u"""
>>> slugify(u'Žabovitá zmiešaná kaša s.r.o')
u'zabovita-zmiesana-kasa-sro'
"""
for key, value in _MAP.iteritems():
name = name.replace(key, value)
return defaultfilters.slugify(name)

I know the code is slow and it can be written better, but that is not
the point. When I run the manage.py test, it work and everything is
ok, but if I change some letter, for example the excpected string from
u'zabovita-zmiesana-kasa-sro' to u'Zabovita-zmiesana-kasa-sro' I got
an error message:

FAIL: Doctest: bookit.businesses.models.slugify
--
Traceback (most recent call last):
  File "/Library/Python/2.5/site-packages/django/test/_doctest.py",
line 2180, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: 

Seems to be my Python interepreter doesn't recognize unicode
characters. After a while browsing I found some solutions. One of them
is modify the Django software and correct the bug for myself, but I'm
not sure it is the way I want to go. Second is not use Django test
framework and run tests in python like this:

if __name__ == "__main__":
import sys, codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)

print u"Žabovitá zmiešaná kaša"
import doctest
doctest.testmod()

Finally, I found this answer on the internet:

The standard solution for doctests is to never use print in these
cases.
Rather, just display the string value, which will appear with hex
encoding for any non-ASCII characaters. The output is then completely
safe from decoding problems. This is what we do throughout the Django
internal tests whenever the output is likely to produce non-ASCII
characters.


Re: {% for articles in article_list %}

2009-10-01 Thread Daniel Roseman

On Oct 1, 11:56 am, Matt  wrote:
> How do you add an article to that? I mean put some python and django
> code down so I can understand it but, here's what I think it might be:
>
> example.py
>
> #!C:/Python/python
>
> import datetime
>
> today = datetime.datetime.today()
>
> class article_list():
>      class articles():
>         def from_Sarah():
>              def Fire():
>                 headline = "Fire in Manhattan"
>                 description = "There was a fire in New York City at
> %s" % today
>                 content = "There was a gruesome fire"
>
> example.html
>
> 
> 
> {% block title %}Articles from Sarah{% endblock title}
> 
> 
> 
> {% block content %}
>    {% for articles in article list %}
>         {{articles.from_Sarah.headline}}
>         {{articles.from_Sarah.description}}
>         {{articles.from_Sarah.content}}
>   {% endfor %}
> {% endblock content %}
> 
> 
>
> Thats how it's supposed to be right?

Er, no.

Please read the excellent documentation, starting with the tutorial,
at http://docs.djangoproject.com.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can i filter choices in ManyToMany Box by request.user in Admin Site?

2009-10-01 Thread Cousteau

This is my simplified code:

# models.py
class Category(models.Model):
user = models.ForeignKey(User)
text = models.CharField(max_length=200)
slug = models.SlugField(max_length=200, editable=False)

class Book(models.Model):
isbn = models.CharField(max_length=32)
title = models.CharField(max_length=255)
categories = models.ManyToManyField(Category)


# admin.py

""" overwrite queryset in order the user only see books belongs to na
category belong to him, in chage_list view """

class BookAdmin(admin.ModelAdmin):
list_display = ('isbn', 'title')
search_fields = ['isbn','title']

def queryset(self, request):
user = request.user
self.user = user
if not user.is_superuser:
qs = self.model._default_manager.get_query_set().filter
(category__user=user)
else:
qs = self.model._default_manager.get_query_set().all
()
ordering = self.ordering or ()
if ordering:
qs = qs.order_by(*ordering)
return qs

This all is ok. But when i go to the "book" detail page in admin site.
The "Category" Multiple Select box show all categories of all users,
not only the user's ones. What i'm looking for is the way i can filter
the choices list in that Multiple Select Box by user.

Thanks all

Gonzalo Salvador



On 1 oct, 11:29, Cousteau  wrote:
> Hello:
>
> I'm trying to filter the choices in a Multiple select box in admin
> site, in order to show only those belongs to the user
>
> Is it posssible?

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



{% for articles in article_list %}

2009-10-01 Thread Matt

How do you add an article to that? I mean put some python and django
code down so I can understand it but, here's what I think it might be:

example.py

#!C:/Python/python

import datetime

today = datetime.datetime.today()

class article_list():
 class articles():
def from_Sarah():
 def Fire():
headline = "Fire in Manhattan"
description = "There was a fire in New York City at
%s" % today
content = "There was a gruesome fire"

example.html



{% block title %}Articles from Sarah{% endblock title}



{% block content %}
   {% for articles in article list %}
{{articles.from_Sarah.headline}}
{{articles.from_Sarah.description}}
{{articles.from_Sarah.content}}
  {% endfor %}
{% endblock content %}



Thats how it's supposed to be right?





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



How can i filter choices in ManyToMany Box by request.user in Admin Site?

2009-10-01 Thread Cousteau

Hello:

I'm trying to filter the choices in a Multiple select box in admin
site, in order to show only those belongs to the user

Is it posssible?


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



Re: 'NoneType' object has no attribute 'widget'

2009-10-01 Thread dijxtra

If I remove that line, the "'NoneType' object has no attribute
'widget' " exception is still thrown at if not f.is_valid():. That's
why I trid to define it again...

On Oct 1, 11:44 am, Rama Vadakattu  wrote:
> 'importance' field is already comming from model.
> Why did you defined again in the forms? (remove it and check out
> whether error is occurring or not)
>
> On Oct 1, 2:33 pm, dijxtra  wrote:
>
> > On Sep 30, 5:12 pm, Karen Tracey  wrote:
>
> > > On Wed, Sep 30, 2009 at 10:53 AM, dijxtra  wrote:
>
> > > > I'm getting "'NoneType' object has no attribute 'widget'" exception
> > > > and I just can't figure out where is the problem. Here is my error:
>
> > > > Django Version: 1.1
>
> > > > Traceback:
> > > > [snip]
>
> > > In this form:
>
> > >    1. class DiaryEntryForm(ModelForm):
> > >    2.     importance = models.IntegerField(choices=IMPORTANCE_CHOICES)
> > >    3.     class Meta:
> > >    4.         model = DiaryEntry
> > >    5.         fields = ['text', 'date', 'type', 'importance']
>
> > > 'importance' has been specified as a model field instead of a form field.
> > > It needs to be a form field, since this is a form, not a model.
>
> > Damn. This one was obvious. But, despite of this bugfix, the error
> > still remains.
>
> > This one:http://pastebin.com/pastebin.php?diff=m1867a8ad
> > Gives me this:
> > Django Version: 1.1
>
> > Traceback:
> > File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
> > get_response
> >   92.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "C:\Python26\lib\site-packages\django\contrib\auth\decorators.py"
> > in __call__
> >   78.             return self.view_func(request, *args, **kwargs)
> > File "C:\Documents and Settings\nick\My Documents\freediary\..
> > \freediary\diary\actions.py" in add_entry
> >   11.     if not f.is_valid():
> > File "C:\Python26\lib\site-packages\django\forms\forms.py" in is_valid
> >   120.         return self.is_bound and not bool(self.errors)
> > File "C:\Python26\lib\site-packages\django\forms\forms.py" in
> > _get_errors
> >   111.             self.full_clean()
> > File "C:\Python26\lib\site-packages\django\forms\forms.py" in
> > full_clean
> >   234.             value = field.widget.value_from_datadict(self.data,
> > self.files, self.add_prefix(name))
>
> > Exception Value: 'NoneType' object has no attribute 'widget'
>
> > I also tried this one:http://pastebin.com/pastebin.php?diff=m4c55050
> > And it gives me python exception:
> > Validating models...
> > Unhandled exception in thread started by  > 0x0110DAB0>
> > Traceback (most recent call last):
> >   File "C:\Python26\lib\site-packages\django\core\management\commands
> > \runserver.
> > py", line 48, in inner_run
> >     self.validate(display_num_errors=True)
> >   File "C:\Python26\lib\site-packages\django\core\management\base.py",
> > line 249,
> >  in validate
> >     num_errors = get_validation_errors(s, app)
> >   File "C:\Python26\lib\site-packages\django\core\management
> > \validation.py", lin
> > e 28, in get_validation_errors
> >     for (app_name, error) in get_app_errors().items():
> >   File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> > line 131, in
> >  get_app_errors
> >     self._populate()
> >   File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> > line 58, in
> > _populate
> >     self.load_app(app_name, True)
> >   File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> > line 74, in
> > load_app
> >     models = import_module('.models', app_name)
> >   File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
> > 35, in im
> > port_module
> >     __import__(name)
> >   File "C:\Documents and Settings\nick\My Documents\freediary\..
> > \freediary\diary
> > \models.py", line 47, in 
> >     class DiaryEntryForm(forms.ModelForm):
> >   File "C:\Documents and Settings\nick\My Documents\freediary\..
> > \freediary\diary
> > \models.py", line 49, in DiaryEntryForm
> >     importance = forms.IntegerField
> > (choices=DiaryEntry.IMPORTANCE_CHOICES)
> >   File "C:\Python26\lib\site-packages\django\forms\fields.py", line
> > 173, in __in
> > it__
> >     super(IntegerField, self).__init__(*args, **kwargs)
> > TypeError: __init__() got an unexpected keyword argument 'choices'
>
> > Any ideas what to do next?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'NoneType' object has no attribute 'widget'

2009-10-01 Thread Rama Vadakattu

'importance' field is already comming from model.
Why did you defined again in the forms? (remove it and check out
whether error is occurring or not)

On Oct 1, 2:33 pm, dijxtra  wrote:
> On Sep 30, 5:12 pm, Karen Tracey  wrote:
>
>
>
> > On Wed, Sep 30, 2009 at 10:53 AM, dijxtra  wrote:
>
> > > I'm getting "'NoneType' object has no attribute 'widget'" exception
> > > and I just can't figure out where is the problem. Here is my error:
>
> > > Django Version: 1.1
>
> > > Traceback:
> > > [snip]
>
> > In this form:
>
> >    1. class DiaryEntryForm(ModelForm):
> >    2.     importance = models.IntegerField(choices=IMPORTANCE_CHOICES)
> >    3.     class Meta:
> >    4.         model = DiaryEntry
> >    5.         fields = ['text', 'date', 'type', 'importance']
>
> > 'importance' has been specified as a model field instead of a form field.
> > It needs to be a form field, since this is a form, not a model.
>
> Damn. This one was obvious. But, despite of this bugfix, the error
> still remains.
>
> This one:http://pastebin.com/pastebin.php?diff=m1867a8ad
> Gives me this:
> Django Version: 1.1
>
> Traceback:
> File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   92.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "C:\Python26\lib\site-packages\django\contrib\auth\decorators.py"
> in __call__
>   78.             return self.view_func(request, *args, **kwargs)
> File "C:\Documents and Settings\nick\My Documents\freediary\..
> \freediary\diary\actions.py" in add_entry
>   11.     if not f.is_valid():
> File "C:\Python26\lib\site-packages\django\forms\forms.py" in is_valid
>   120.         return self.is_bound and not bool(self.errors)
> File "C:\Python26\lib\site-packages\django\forms\forms.py" in
> _get_errors
>   111.             self.full_clean()
> File "C:\Python26\lib\site-packages\django\forms\forms.py" in
> full_clean
>   234.             value = field.widget.value_from_datadict(self.data,
> self.files, self.add_prefix(name))
>
> Exception Value: 'NoneType' object has no attribute 'widget'
>
> I also tried this one:http://pastebin.com/pastebin.php?diff=m4c55050
> And it gives me python exception:
> Validating models...
> Unhandled exception in thread started by  0x0110DAB0>
> Traceback (most recent call last):
>   File "C:\Python26\lib\site-packages\django\core\management\commands
> \runserver.
> py", line 48, in inner_run
>     self.validate(display_num_errors=True)
>   File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 249,
>  in validate
>     num_errors = get_validation_errors(s, app)
>   File "C:\Python26\lib\site-packages\django\core\management
> \validation.py", lin
> e 28, in get_validation_errors
>     for (app_name, error) in get_app_errors().items():
>   File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 131, in
>  get_app_errors
>     self._populate()
>   File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 58, in
> _populate
>     self.load_app(app_name, True)
>   File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 74, in
> load_app
>     models = import_module('.models', app_name)
>   File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>     __import__(name)
>   File "C:\Documents and Settings\nick\My Documents\freediary\..
> \freediary\diary
> \models.py", line 47, in 
>     class DiaryEntryForm(forms.ModelForm):
>   File "C:\Documents and Settings\nick\My Documents\freediary\..
> \freediary\diary
> \models.py", line 49, in DiaryEntryForm
>     importance = forms.IntegerField
> (choices=DiaryEntry.IMPORTANCE_CHOICES)
>   File "C:\Python26\lib\site-packages\django\forms\fields.py", line
> 173, in __in
> it__
>     super(IntegerField, self).__init__(*args, **kwargs)
> TypeError: __init__() got an unexpected keyword argument 'choices'
>
> Any ideas what to do next?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database Consistecy using Django ORM

2009-10-01 Thread Rama Vadakattu

On one thing  which i can guide you is
you can use
1.django evolutions
Link : http://code.google.com/p/django-evolution/
2.south
LInk: http://south.aeracode.org/
to add a new column to an already created table via django.



On Oct 1, 2:14 pm, Geobase Isoscale  wrote:
> Hi  Everyone,
>
> I would like to know how to Add a new Collumn to an already created table in
> Django. I would like to know whether one can create database triggers,
> create database functions, database Index and database views using  Django
> ORM. I'm investigation to what extend does Django support database
> consistency. If anyone has more information on the pros and cons of ORM with
> regard to database design. I'm connected Postgres database with its PostGIS
> extention.
>
> Your contribution will be highly appreciated.
>
> Isoscale.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'NoneType' object has no attribute 'widget'

2009-10-01 Thread dijxtra



On Sep 30, 5:12 pm, Karen Tracey  wrote:
> On Wed, Sep 30, 2009 at 10:53 AM, dijxtra  wrote:
>
> > I'm getting "'NoneType' object has no attribute 'widget'" exception
> > and I just can't figure out where is the problem. Here is my error:
>
> > Django Version: 1.1
>
> > Traceback:
> > [snip]
>
> In this form:
>
>    1. class DiaryEntryForm(ModelForm):
>    2.     importance = models.IntegerField(choices=IMPORTANCE_CHOICES)
>    3.     class Meta:
>    4.         model = DiaryEntry
>    5.         fields = ['text', 'date', 'type', 'importance']
>
> 'importance' has been specified as a model field instead of a form field.
> It needs to be a form field, since this is a form, not a model.

Damn. This one was obvious. But, despite of this bugfix, the error
still remains.

This one: http://pastebin.com/pastebin.php?diff=m1867a8ad
Gives me this:
Django Version: 1.1

Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\auth\decorators.py"
in __call__
  78. return self.view_func(request, *args, **kwargs)
File "C:\Documents and Settings\nick\My Documents\freediary\..
\freediary\diary\actions.py" in add_entry
  11. if not f.is_valid():
File "C:\Python26\lib\site-packages\django\forms\forms.py" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "C:\Python26\lib\site-packages\django\forms\forms.py" in
_get_errors
  111. self.full_clean()
File "C:\Python26\lib\site-packages\django\forms\forms.py" in
full_clean
  234. value = field.widget.value_from_datadict(self.data,
self.files, self.add_prefix(name))

Exception Value: 'NoneType' object has no attribute 'widget'



I also tried this one:
http://pastebin.com/pastebin.php?diff=m4c55050
And it gives me python exception:
Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\django\core\management\commands
\runserver.
py", line 48, in inner_run
self.validate(display_num_errors=True)
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 249,
 in validate
num_errors = get_validation_errors(s, app)
  File "C:\Python26\lib\site-packages\django\core\management
\validation.py", lin
e 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
line 131, in
 get_app_errors
self._populate()
  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
line 58, in
_populate
self.load_app(app_name, True)
  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
line 74, in
load_app
models = import_module('.models', app_name)
  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "C:\Documents and Settings\nick\My Documents\freediary\..
\freediary\diary
\models.py", line 47, in 
class DiaryEntryForm(forms.ModelForm):
  File "C:\Documents and Settings\nick\My Documents\freediary\..
\freediary\diary
\models.py", line 49, in DiaryEntryForm
importance = forms.IntegerField
(choices=DiaryEntry.IMPORTANCE_CHOICES)
  File "C:\Python26\lib\site-packages\django\forms\fields.py", line
173, in __in
it__
super(IntegerField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'choices'

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



Database Consistecy using Django ORM

2009-10-01 Thread Geobase Isoscale
Hi  Everyone,

I would like to know how to Add a new Collumn to an already created table in
Django. I would like to know whether one can create database triggers,
create database functions, database Index and database views using  Django
ORM. I'm investigation to what extend does Django support database
consistency. If anyone has more information on the pros and cons of ORM with
regard to database design. I'm connected Postgres database with its PostGIS
extention.

Your contribution will be highly appreciated.

Isoscale.

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



Re: Pass a non-pickable object in between pages without using the session

2009-10-01 Thread Gabriel Rossetti

Karen Tracey wrote:
> On Wed, Sep 30, 2009 at 1:49 PM, Gabriel Rossetti 
> > wrote:
>
> > Why can't it be pickled?
>
> Because it has a socket open
>
> > Clearly, since every request is independent,
> > if it really can't be pickled there is no way of passing it from one
> > to the next. Could you store the necessary values to recreate the
> > object?
> >
>
> That is what I currently doing, but the object creation is expensive
> which is why I was looking for another way. So I can't have some sort
> of global dict that would store my objects and the key could be stored
> in the session?
>
>
> No.  Consider that your Django app may well be deployed in a 
> multi-process web server.  Each request can be routed to a different 
> process for handling.  A socket created in one process won't be 
> accessible from the other processes.
>
> Karen
Thank you for this explanation Karen. I understand better why there are 
differences in between the development server and apache.

Gabriel

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



Re: Pass a non-pickable object in between pages without using the session

2009-10-01 Thread Gabriel Rossetti

Carsten Reimer wrote:
> Hi,
>
> Karen Tracey schrieb:
>   
>> On Wed, Sep 30, 2009 at 1:49 PM, Gabriel Rossetti 
>> > wrote:
>>
>>  > Why can't it be pickled?
>>
>> Because it has a socket open
>>
>>  > Clearly, since every request is independent,
>>  > if it really can't be pickled there is no way of passing it from one
>>  > to the next. Could you store the necessary values to recreate the
>>  > object?
>>  >
>>
>> That is what I currently doing, but the object creation is expensive
>> which is why I was looking for another way. So I can't have some sort
>> of global dict that would store my objects and the key could be stored
>> in the session?
>> 
>
>
> does the socket really need to be kept open? If it is the only item that 
> prevents pickling the object consider using the __setstate__ and 
> __getstate__ methods (s. 
> http://docs.python.org/library/pickle.html#object.__getstate__ and 
> http://docs.python.org/library/pickle.html#object.__setstate__ for details).
>
> For example delete the socket from the object's __dict__ in the 
> __getstate__ method (called before the object is pickled) and place the 
> parameters for socket recreation in the object's __dict__ so that they 
> will get pickled. Return the object's __dict__ from this method.
> In __setstate__ (takes the unpickled __dict__ as parameter) get those 
> parameters for the socket from the unpickled object's __dict__, recreate 
> the socket and delete the parameters.
>
> Or is the socket creation the expensive action of this object. Then 
> please forget what I have writte because it will not help you.
>
> Otherwise here are examples of possible __getstate__/__setstate__ 
> methods for your case:
>
> def create_socket(self, socket_parameters):
>  """Creates the socket with the given parameters"""
>
> def __getstate__(self):
>  """Called when the object is pickled"""
>  self.socket_parameters = parameters_for_recreation
>  del self.socket
>  return self.__dict__
>
> def __setstate__(self, newstate):
>  """Called when the object is unpickled"""
>  self.__dict__ = newstate
>  self.socket = self.create_socket(self.socket_parameters)
>  del self.socket_parameters
>
>
> Hth
>
> with best regards
>
> Carsten
>
>
>   
Hello Carston,

Thank you for your idea, unfortunately the socket creation is expensive 
because it also logs on to a server (thus there is a handshake, auth, 
etc). But I didn't know about __getstate__/__setstate__, thank you very 
much, it could be useful somewhere else.

Best regards,
Gabriel

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



Re: Peepcode like screencasts for Django

2009-10-01 Thread hrishy

Hi Benjamin

Excellent thansk for the link

--- On Thu, 1/10/09, Benjamin Buch  wrote:

> From: Benjamin Buch 
> Subject: Re: Peepcode like screencasts for Django
> To: django-users@googlegroups.com
> Date: Thursday, 1 October, 2009, 7:55 AM
> 
> I especially enjoyed Eric Florenzano's excellent screencast
> series  
> 'Django From the Ground Up'.
> 
> You'll find it here:
> http://thisweekindjango.com/screencasts/
> 
> There are no screencasts on http://djangodose yet,
> but I think this is a good place to look out for
> screencasts in the  
> future.
> 
> -benjamin
> 
> Am 01.10.2009 um 06:47 schrieb hrishy:
> 
> > Hi
> >
> > Rails programmers have many screencasts like http://railscasts.com/  
> > to bring newbie programmers upto speed is there
> anything like tahat  
> > available for Django
> >
> > regards
> 
> 
> > 
> 


  

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



Re: composite primary keys?

2009-10-01 Thread nausikaa


Hi again

What I wrote is wrong sorry, I didn't read the ticket properly.
You can't do multi-column primary keys in django (yet).

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



Re: How to get result from manytomany?

2009-10-01 Thread veasna bunhor
Thanks you very much. Now it's work.

On Thu, Oct 1, 2009 at 3:06 PM, Anıl KARADAĞ  wrote:

>
> Hi,
>
> veasna bunhor yazmış:
> > I have two models :
> >
> > class Individual(models.Model):
> > name = models.CharField(max_length=200)
> >* is_author = models.BooleanField()*
> > active = models.BooleanField(default=True)
> >
> 
> > class Book(models.Model):
> > title = models.CharField(max_length=200)
> > *authors = models.ManyToManyField(Individual,
> > related_name="author_for", blank=True, null=True)*
>
> you used related_name for model so you should call format similar to
> author.author_for.all()
>
> Q: What is meaning of "related_name" and how we use it?
> A:
>
> http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name
> >
> --
> >
> > Can i make the query to get all the books that is_author?
> >  i have tried:
> > >>>authors =
> Individual.objects.filter(is_author=True).filter(active=True)
> > >>>for author in authors:
> >print author.name 
> >for book in author.book_set.all():
> >   print book.title
> >
> > >
>
>
> >
>

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



Re: How to get result from manytomany?

2009-10-01 Thread Anıl KARADAĞ

Hi,

veasna bunhor yazmış:
> I have two models :
>
> class Individual(models.Model):
> name = models.CharField(max_length=200)
>* is_author = models.BooleanField()*
> active = models.BooleanField(default=True)
> 
> class Book(models.Model):
> title = models.CharField(max_length=200)
> *authors = models.ManyToManyField(Individual, 
> related_name="author_for", blank=True, null=True)*

you used related_name for model so you should call format similar to 
author.author_for.all()

Q: What is meaning of "related_name" and how we use it?
A: 
http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name
> --
>
> Can i make the query to get all the books that is_author?
>  i have tried:
> >>>authors = Individual.objects.filter(is_author=True).filter(active=True)
> >>>for author in authors:
>print author.name 
>for book in author.book_set.all():
>   print book.title
>
> >


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



How to get result from manytomany?

2009-10-01 Thread veasna bunhor
I have two models :

class Individual(models.Model):
name = models.CharField(max_length=200)
   * is_author = models.BooleanField()*
active = models.BooleanField(default=True)

class Book(models.Model):
title = models.CharField(max_length=200)
*authors = models.ManyToManyField(Individual, related_name="author_for",
blank=True, null=True)*
--

Can i make the query to get all the books that is_author?
 i have tried:
>>>authors = Individual.objects.filter(is_author=True).filter(active=True)
>>>for author in authors:
   print author.name
   for book in author.book_set.all():
  print book.title

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



Re: Pass a non-pickable object in between pages without using the session

2009-10-01 Thread Carsten Reimer

Hi,

Karen Tracey schrieb:
> On Wed, Sep 30, 2009 at 1:49 PM, Gabriel Rossetti 
> > wrote:
> 
>  > Why can't it be pickled?
> 
> Because it has a socket open
> 
>  > Clearly, since every request is independent,
>  > if it really can't be pickled there is no way of passing it from one
>  > to the next. Could you store the necessary values to recreate the
>  > object?
>  >
> 
> That is what I currently doing, but the object creation is expensive
> which is why I was looking for another way. So I can't have some sort
> of global dict that would store my objects and the key could be stored
> in the session?


does the socket really need to be kept open? If it is the only item that 
prevents pickling the object consider using the __setstate__ and 
__getstate__ methods (s. 
http://docs.python.org/library/pickle.html#object.__getstate__ and 
http://docs.python.org/library/pickle.html#object.__setstate__ for details).

For example delete the socket from the object's __dict__ in the 
__getstate__ method (called before the object is pickled) and place the 
parameters for socket recreation in the object's __dict__ so that they 
will get pickled. Return the object's __dict__ from this method.
In __setstate__ (takes the unpickled __dict__ as parameter) get those 
parameters for the socket from the unpickled object's __dict__, recreate 
the socket and delete the parameters.

Or is the socket creation the expensive action of this object. Then 
please forget what I have writte because it will not help you.

Otherwise here are examples of possible __getstate__/__setstate__ 
methods for your case:

def create_socket(self, socket_parameters):
 """Creates the socket with the given parameters"""

def __getstate__(self):
 """Called when the object is pickled"""
 self.socket_parameters = parameters_for_recreation
 del self.socket
 return self.__dict__

def __setstate__(self, newstate):
 """Called when the object is unpickled"""
 self.__dict__ = newstate
 self.socket = self.create_socket(self.socket_parameters)
 del self.socket_parameters


Hth

with best regards

Carsten


-- 
Carsten Reimer
Web Developer
carsten.rei...@galileo-press.de
Phone +49.228.42150.73

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Phone +49.228.42150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Managing Directors: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn


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



Re: Include multiple entries in Atom feed

2009-10-01 Thread peppergrower

I think I figured this out.  What Django's syndication refers to as
"items" are the same thing the Atom specification calls
"entries."  (I'd thought that an "item" referred to a single Django
model instance, but this clearly isn't the case when I look at the raw
XML generated by my feed.)

On Sep 28, 9:17 pm, peppergrower 
wrote:
> I've read Django's documentation on its syndication framework, and
> it's mostly pretty thorough.  I set up an Atom feed that seems to work
> just fine.  However, I'd like to include the last several entries in
> my feed: how can I do this in Django?  (I'm creating an Atom 1.0 feed,
> in case it matters.)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Peepcode like screencasts for Django

2009-10-01 Thread Benjamin Buch

I especially enjoyed Eric Florenzano's excellent screencast series  
'Django From the Ground Up'.

You'll find it here:
http://thisweekindjango.com/screencasts/

There are no screencasts on http://djangodose yet,
but I think this is a good place to look out for screencasts in the  
future.

-benjamin

Am 01.10.2009 um 06:47 schrieb hrishy:

> Hi
>
> Rails programmers have many screencasts like http://railscasts.com/  
> to bring newbie programmers upto speed is there anything like tahat  
> available for Django
>
> regards


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



Peepcode like screencasts for Django

2009-10-01 Thread hrishy

Hi 

Rails programmers have many screencasts like http://railscasts.com/ to bring 
newbie programmers upto speed is there anything like tahat available for Django

regards




  

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