Access records from two tables

2009-01-06 Thread Praveen

Models.py

class Listing(models.Model):
  name = models.CharField(max_length=20)
  description = models.TextField(max_length = 100)
  website = models.URLField()
  category = models.ForeignKey(Category)

class Category(models.Model):
  category_code = models.CharField(max_length = 50, primary_key=True,
blank=False)
  category_name = models.CharField(max_length = 50,)
  def __unicode__(self):
return self.category_code

i have cat_list.html which list all the category with name only as
link if some one wants to know more details he/she may click on that
link.

urls.py

(r'^category/category_view/$','mysite.library.views.categories'),
(r'^category/category_view/(?P\w+)/
$','mysite.library.views.category_info'),

views.py

def categories(request):
result_category = Category.objects.all()
return render_to_response("cat_list.html",
{'result_category':result_category})

def category_info(request, category_code):
result_category = get_object_or_404(Category, pk = category_code)
->result_listing = get_object_or_404(Listing, pk = id)
print result_category
return render_to_response("category_view.html",
{'result_category':result_category,'result_listing':result_listing})

see -->result_listing in category_info function. i want to display
some info of Listing tables of corresponding category_code.

when i use

1--> result_listing = get_object_or_404(Listing, pk = id) then i get
an error
id() takes exactly one argument (0 given)

2--> result_listing = get_object_or_404(Listing, pk = category_id)
then i am not getting the exact result cause Category(category_code)
is checking with Listing(id). it should check with category_id of
Listing tables.

i do not know how may i access corresponding records from two tables.

--~--~-~--~~~---~--~~
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: Making changes to models

2009-01-06 Thread Karen Tracey
On Wed, Jan 7, 2009 at 12:48 AM, Travis Veazey
wrote:

> So now we get to the question: As I can't even begin to conceive of myself
> being the only person in this boat, I have to believe there's one or more
> generally-accepted and "good" ways of dealing with updating database
> structures while maintaining data, aren't there? What method(s) do y'all use
> when you need to do things like this?
>

There are at least four external projects focused on this topic.  You might
want to check out this thread on the developer's list:

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

which I think gives pointers to all the main/active ones.

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



Making changes to models

2009-01-06 Thread Travis Veazey
Hi all.
Still feeling my way through Django development, working on my first app
still, and I've hit what looks to be a huge hurdle: Django has no in-built
mechanism for dealing with making changes to the structure of models.

Okay, fine, I can understand the reasons for that, and while I think it
would still be nice to at least provide the option to those of us who want
to risk our data on a series of automatically-generating ALTER TABLE
statements, I can understand why the folks behind Django didn't give it to
us.

That said, I can't be the only one who has planned out a long sequence of
point releases as I build my app and release new functionality on a regular
basis, a lot of which will require not just new models but changes to
existing ones. As one example, I'm currently adding the ability to "tag"
blog entries; my BlogEntry model already existed, of course, and adding

tags=models.ManyToManyField(Tag)

to it resulted in syncdb, obviously, not creating the new linking table.
(Well, maybe it's not obvious at first glance that the creation of a new
table would not occur since it's triggered by a change to a model who's
table already exists, but we'll get past that, too.)

So now we get to the question: As I can't even begin to conceive of myself
being the only person in this boat, I have to believe there's one or more
generally-accepted and "good" ways of dealing with updating database
structures while maintaining data, aren't there? What method(s) do y'all use
when you need to do things like this?

TIA,
Travis

--~--~-~--~~~---~--~~
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: Could not import settings

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 2:49 PM, Bradley  wrote:

>
> I move an existing website running django onto a shared webhost via
> FastCGI.
>
> No matter what I do, I get the following error:
>
> ImportError: Could not import settings 'seymourherald.settings' (Is it
> on sys.path? Does it have syntax errors?): No module named
> seymourherald.settings
>
> my DJANGO_SETTINGS_MODULE is set to wwwroot.settings and yet I still
> get the above error.  I'm pretty new to django, is there any other
> place where it would be looking for seymourherald.settings
>

What you say you have DJANGO_SETTINGS_MODULE set to:

wwwroot.settings

does not match what the error message says it is set to:

seymourherald.settings

Which one is right?


> Django located here:
> ~/djtrunk/
>
> My website here:
> ~/seymourherald.com/wwwroot
> ~/seymourherald.com/wwwroot/settings.py
>

>From this, assuming
~/seymourherald.com/is
on your PYTHONPATH, and the process executing the code has permission
to
read that directory tree, then a setting of
DJANGO_SETTING_MODULE=wwwroot.settings should work.  However that is not the
setting that the code that is running is using, based on the error message
it is giving.  Somewhere it is getting a value of seymourherald.settings for
DJANGO_SETTINGS_MODULE.

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



Base Class and Multiple SubClasses

2009-01-06 Thread Mathieu Steele

I'm trying to find the right way to make an instance of a subclass of
a model also an instance of a different subclass in the model, like
so:

class Person(models.Model):
   ...


class Customer(Person):
   ...


class Employee(Person):
  ...



If I have an instance of Employee that I want to have as a customer as
well, I can simply add the pk from person for employee into the
customer table. With this value in the database, Django treats the
person as a Customer when used as a customer, and as an employee when
used as an employee.

What is the correct way to do this? Is it possible without introducing
custom sql?

I'm thinking that I should be able to do something like:

c = Customer.objects.create(pk=Employee.pk)

but I can't seem to get it to work for me.
--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Kenneth Gonsalves

On Tuesday 06 Jan 2009 5:18:57 pm HB wrote:
> What is your favorite IDE for coding Django projects?

geany

-- 
regards
KG
http://lawgon.livejournal.com

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



Re: wondering how to do something similar to save_model for inline.

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 10:10 PM, Timboy  wrote:

>
> Still no solution to this. It has been confirmed by another user. Is
> it a bug?
>

(Where was it confirmed by another user?  I don't see that.)

The doc list "save_formset" under "ModelAdmin methods" yet you seem to have
added it to your inline admin class.  I also don't see any indication in the
traceback you posted that your custom method is being called, which leads me
to think where you have put it is not where it needs to be in order for it
to be called.

(Also you changed formset.save_m2m() from the example in the docs to
formset.save().  I doubt that this change is correct.)

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



what type of data structure should I use?

2009-01-06 Thread backdoc

I have a list of links (say ~200) that I want to display in several
different orders, all on one page.  The first question is am I better
off to hit the database for every different order?

Then, when I click a link, I am changing many of the attributes about
that link (like hit count, last accessed, and so on).  I'm updating my
database with AJAX.  But, I need to update my lists on my page, as
well.  Right now, I'm faking it by using jQuery scripts to alter some
of the values on the page.  This is somewhat efficient, but it doesn't
reorder my links (the hit count gets bumped, but the order of the list
is now off).

I'm at a loss of what kind of object that I could possibly use client
side (for speed), then also update the database in the backend.  But,
I don't want to have to requery the database, after updating, then
transfer all of that data back to the client side.  I'd rather manage
it in two places and on the next page refresh, the client will get the
version from the database.

I haven't looked into caching yet.  I wasn't really thinking that it
would factor into the question.  It will become a factor later when I
start using it.  But, I wasn't figuring that it would be the tool to
solve my questions from above.

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



Re: ModelForm Default Value for Foreign Key

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 10:08 PM, Chris  wrote:

>
> I've created a ModelForm from a model containing a foreign key field
> (called user) linked to my User class. When the form is saved, I want
> this value to be set to the current authenticated user. What's the
> best way to do this?
>
> My form's save method takes the current user as an argument. I've
> tried adding self.cleaned_data['user'] = user to this method, but it
> appears to be ignored by the form.


http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

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: Your IDE of choice

2009-01-06 Thread backdoc

screen + vim is very powerful.  That's what I use, too.  Too bad the
learning curve is so steep.

On Jan 6, 6:52 am, Tim Chase  wrote:
> > What is your favorite IDE for coding Django projects?
>
> screen + vim + pdb + bash
> [+ lynx/dillo/firefox/epiphany for browsing]
> [+ sqlite3/mysql/psql for console database access]
>
> > Any ideas about PyDev and ActiveState Komodo IDE?
>
> Not tried either here.
>
> -tim
--~--~-~--~~~---~--~~
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: Speeding up the tests, what am I missing?

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 9:25 PM, Todd O'Bryan  wrote:

>
> On Tue, Jan 6, 2009 at 6:23 PM, Russell Keith-Magee
>  wrote:
> > There are some plans in place to speed up test cases using
> > transactions; I'm hoping to be able to look at this once I put the
> > aggregation and F() code to bed, in the next week or so.
> >
> This does sound exciting. I look forward to it.
>

The ticket to look at for this is #8138:

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

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: How to: Inverted ForeignKey usage - Using admin a little backwards?

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 8:01 PM, ZebZiggle  wrote:

>
> Hi all,
>
> Sorry for the cryptic subject line, but I don't know how else to
> describe it.
>
> I have two tables:
>
> class Opportunity(models.Model):
>  ...
>
> class Deal(models.Model):
>   opp = models.ForeignKey(Opportunity)
>  ...
>
> However, in the admin, I want the user to enter the data for the
> Opportunity and then have a table-like UI to add new Deals ... kind of
> like a ManyToManyField. I can't use ManyToMany since I don't want the
> Opportunity to show any other Deals already created.
>
> What I don't want, as it will too confusing for the users, is the
> default behavior: to have to create an Opportunity and then a bunch of
> Deals from which they pick the same Opportunity over and over again.
>
> Can this be done or do I need to make some sort of custom page for
> this? If so, how can I integrate it with the rest of the admin UI just
> for the Opportunity table?
>

This is common and supported, described here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

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: creating formset is very slow

2009-01-06 Thread Jeff FW

Post the code for DataForm--I'll bet it's hitting the database a
number of times.  That would be the only reason I can think of that it
would take that long.  I just created a formset containing simple
forms, and it instantiated almost instantly--even with 2000 forms.

-Jeff

On Jan 6, 3:21 pm, "Kottiyath Nair"  wrote:
> I tried with 500 forms instead of 25. Now the time is becoming appaling.---
> 117 seconds. Second time it hung.
>
> 2009-01-07 01:42:13,812 INFO Start - 4.46984183744e-006
> 2009-01-07 01:42:13,812 INFO Formset Class created- 0.000422958783868
> 2009-01-07 01:44:11,703 INFO Created new formset- 117.90750668
> 2009-01-07 01:44:17,203 INFO All forms done - 123.39991647
> 2009-01-07 01:44:17,217 INFO Start - 123.416734808
> 2009-01-07 01:44:17,217 INFO Formset Class created- 123.41704658
>
> Regards
> K
>
> On 1/7/09, Kottiyath Nair  wrote:
>
>
>
> > Hi all,
> >    My web application sends a medium size data grid (20 elements). I was
> > using formsets for the same.
> >    The issue I am facing is that the formset instantiation is very very
> > slow. I timed it and it is taking ~4-7 seconds for it to instantiate.
> >    Is there someway the speed can be increased?
>
> > There are no files sent. I am planning to, later.
> > The code:
> >             logging.info('Start - %s' %time.clock())
> >             DataFormSet = formset_factory(DataForm, extra=25)
> >             logging.info('Formset Class created- %s' %time.clock())
> >             formset = DataFormSet(request.POST, request.FILES)
> >             logging.info('Created new formset- %s'%time.clock())
>
> > From my logs:
> > 2009-01-06 22:53:30,671 INFO Start - 0
> > 2009-01-06 22:53:30,671 INFO Formset Class created- 0.000403403225829
> > 2009-01-06 22:53:34,296 INFO Created new formset- 3.62182316468
> >   or later
> > 2009-01-06 22:56:37,500 INFO Start - 186.836136716
> > 2009-01-06 22:56:37,500 INFO Formset Class created- 186.836445135
> > 2009-01-06 22:56:43,108 INFO Created new formset- 192.440754621
>
> >    Please note that I am running the whole thing under the django
> > development server in my laptop itself and not a server.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



could not import settings error, FastCGI

2009-01-06 Thread Bradley

I'm having a strange problem in that I can make any change that I want
to the .fcgi file, short of deleting it and I get the same django
error about seymourherald.settings not found.  I can delete the entire
contents of the file so all it has in it is #!/path/to/python and it
still gives me this error message. How on earth is it still loading
django?  Error message looks like

ImportError: Could not import settings 'seymourherald.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
seymourherald.settings

So I've been trying to troubleshoot why it can't find
seymourherald.settings and I guess I've determined it doesn't have to
do with my .fcgi file.  I've checked and rechecked my PYTHONPATH, any
other ideas?

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



Re: Your IDE of choice

2009-01-06 Thread bedros

I'm very happy with Komodo Edit 5.0 for editing python

SyncroSVN client for subversion; not free, but it's cheap and worth
the money; very happy with it. http://www.syncrosvnclient.com/

multi-platform and intuitive interface


On Jan 6, 12:32 pm, Ovnicraft  wrote:
> 2009/1/6 Berco Beute 
>
>
>
> > On Jan 6, 2:35 pm, Pigletto  wrote:
>
> > > So, Netbeans is currently my IDE of choice. Good svn integration,
> > > faster than eclipse and komodo, stable, nice markup highlighting.
>
> > +1
> > I'm using SciTe and emacs for simple, single file editing.
> > I've used pydev for a while but eclipse's startup time is too long.
> > I've tried Eric (which is really nice), but the editor is less feature
> > rich than pydev and the auto-completion is hard to configure
> > Then I switched to Netbeans (after having used it 10 years ago for
> > Java development) and I'm really suprised by its speed and feature
> > richnes. The auto-completion is the best I've encountered. Highly
> > recommended.
>
> +1
> and this comeshttp://wiki.netbeans.org/Python70Roadmap
>
>
>
> > 2B
>
> --
> [b]question = (to) ? be : !be; .[/b]
--~--~-~--~~~---~--~~
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: wondering how to do something similar to save_model for inline.

2009-01-06 Thread Timboy

Still no solution to this. It has been confirmed by another user. Is
it a bug?

On Dec 29 2008, 2:33 pm, Timboy  wrote:
> DB is sqlite3. Deleted DB file syncd and still same traceback.
> here is proper traceback paste:http://dpaste.com/103517/
>
> On Dec 28, 9:10 pm, Praveen  wrote:
>
> > This is your database error..
>
> > On Dec 28, 8:32 am, Timboy  wrote:
>
> > > Great link. I was really excited to try it.
>
> > > Here is my new inline:
> > > class rentalInline(admin.TabularInline):
> > >     model= Rent
> > >     extra = 3
> > >     raw_id_fields = ('movie',)
> > >     exclude = ['rented_by']
>
> > >     def save_formset(self, request, form, formset, change):
> > >         instances = formset.save(commit=False)
> > >         for instance in instances:
> > >             instance.rented_by = request.user
> > >             instance.save()
> > >         formset.save()
>
> > > I am still getting the same issue:
> > > Traceback:
> > > File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> > > in get_response
> > >   86.                 response = callback(request, *callback_args,
> > > **callback_kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > > in root
> > >   157.                 return self.model_page(request, *url.split('/',
> > > 2))
> > > File "/usr/lib/python2.5/site-packages/django/views/decorators/
> > > cache.py" in _wrapped_view_func
> > >   44.         response = view_func(request, *args, **kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > > in model_page
> > >   176.         return admin_obj(request, rest_of_url)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > > options.py" in __call__
> > >   197.             return self.change_view(request, unquote(url))
> > > File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
> > > _commit_on_success
> > >   238.                 res = func(*args, **kw)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > > options.py" in change_view
> > >   583.                     self.save_formset(request, form, formset,
> > > change=True)
> > > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > > options.py" in save_formset
> > >   382.         formset.save()
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save
> > >   372.         return self.save_existing_objects(commit) +
> > > self.save_new_objects(commit)
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > > save_new_objects
> > >   407.             self.new_objects.append(self.save_new(form,
> > > commit=commit))
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > > save_new
> > >   473.         return save_instance(form, new_obj, exclude=
> > > [self._pk_field.name], commit=commit)
> > > File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
> > > save_instance
> > >   59.         instance.save()
> > > File "/home/richard/work/svn/moviedb/../moviedb/store/models.py" in
> > > save
> > >   91.         super(Rent, self).save(**kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
> > > save
> > >   307.         self.save_base(force_insert=force_insert,
> > > force_update=force_update)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
> > > save_base
> > >   379.                 result = manager._insert(values,
> > > return_id=update_pk)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/manager.py" in
> > > _insert
> > >   138.         return insert_query(self.model, values, **kwargs)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
> > > insert_query
> > >   888.     return query.execute_sql(return_id)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/sql/
> > > subqueries.py" in execute_sql
> > >   308.         cursor = super(InsertQuery, self).execute_sql(None)
> > > File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py"
> > > in execute_sql
> > >   1700.         cursor.execute(sql, params)
> > > File "/usr/lib/python2.5/site-packages/django/db/backends/util.py" in
> > > execute
> > >   19.             return self.cursor.execute(sql, params)
>
> > > Exception Type: IntegrityError at /admin/store/renter/4/
> > > Exception Value: null value in column "rented_by_id" violates not-null
> > > constraint
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



ModelForm Default Value for Foreign Key

2009-01-06 Thread Chris

I've created a ModelForm from a model containing a foreign key field
(called user) linked to my User class. When the form is saved, I want
this value to be set to the current authenticated user. What's the
best way to do this?

My form's save method takes the current user as an argument. I've
tried adding self.cleaned_data['user'] = user to this method, but it
appears to be ignored by the form.
--~--~-~--~~~---~--~~
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: Speeding up the tests, what am I missing?

2009-01-06 Thread Todd O'Bryan

On Tue, Jan 6, 2009 at 6:23 PM, Russell Keith-Magee
 wrote:
>
> On Wed, Jan 7, 2009 at 4:51 AM, Todd O'Bryan  wrote:
>>
>> So, I've been trying to speed up tests. Surprise. I came across a
>> fairly easy solution, so I'm sure I must be missing something. If
>> someone could tell me what I'm missing, I'd really appreciate it.
> ...
>> MyTestCaseSubclass.dirties_db = True
> ...
>> So, what am I missing? I know this doesn't deal with doctests--the db
>> gets cleaned for all of those, but does anyone see when this is just
>> going to blow up in my face?
>
> This approach will (clearly) speed up tests. I have three objections
> to the technique.
>
> The first objection is a relatively minor syntactical wart. Using a
> normal assignment to set the dirty bit means your test code is mixing
> test code with setup code. I'd rather see this sort of thing as a
> decorator, so that the test i
>
I shan't argue with you. It is less than elegant.

> The second objection is more significant: the technique is entirely
> manual, and prone to error. If you get all the dirties_db markers
> correct, your tests will be much faster; however, if you get one
> wrong, you could get all sorts of unexpected consequences, and the
> problems won't be reported in the test that actually has the incorrect
> dirty marker. The order in which tests doesn't necessarily match the
> order in which they are defined in the test case; if you run a subset
> of tests, all bets on predictable test output are off.
>
You're right, of course. But the only thing you can do wrong is mark a
test that actually dirties the database as dirties_db = False.
Changing the superclass from MyTestCase back to django.test.TestCase
should be able to determine if that's the problem. And it's not like
writing tests is that easy to begin with. I find that I screw up a
significant percentage the first time I write them, so I have to debug
my test cases just like I have to debug my code.

> The third objection is that in my experience, genuine 0-write test
> cases aren't actually that common. This will, of course, vary wildly
> depending on your particular project, but I seem to recall looking at
> this sort of change and came to the conclusion that it wouldn't
> actually speed up the Django test suite that much. Feel free to prove
> me wrong.
>
As I mentioned in the reply to Malcolm, there are some writes that I
don't care about. Since it's only within a single TestCase class, I
shouldn't need to worry about changes to the session and last_login
and such if I know I'm not testing those things. Clearly this requires
more thinking than I should have to do, but at this point I'm willing
to try the trade-off. I'll probably be back in a few weeks to tell you
it wasn't worth it. :-)

> There are some plans in place to speed up test cases using
> transactions; I'm hoping to be able to look at this once I put the
> aggregation and F() code to bed, in the next week or so.
>
This does sound exciting. I look forward to it.

Thanks for the input!
Todd

--~--~-~--~~~---~--~~
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: Speeding up the tests, what am I missing?

2009-01-06 Thread Todd O'Bryan

On Tue, Jan 6, 2009 at 6:05 PM, Malcolm Tredinnick
 wrote:
>
> On Tue, 2009-01-06 at 14:51 -0500, Todd O'Bryan wrote:
> [...]
>
>> So, what am I missing? I know this doesn't deal with doctests--the db
>> gets cleaned for all of those, but does anyone see when this is just
>> going to blow up in my face?
>
> For that to work reliably, you would need to deeply know the internals
> of Django to know which calls are going to dirty the database in some
> way. For example, if your tests simulate a user's interactions at all,
> there will be changes to the session.
>
Right. For example, every time a user logs in, the last_login gets
updated. I would say dirties_db = False in most of those cases,
because I just don't check the last_login time in my tests.

> So, sure, it's possible, although duplicates a lot of code, but it's
> also a bit fragile. Russell Keith-Magee and I have had a number of
> conversations over the past couple of years about speeding up the tests
> for Django itself and we keep looking at this one. But, at the end of
> the day, every set of non-significant tests touch the database in some
> way, with very, very few exceptions (template rendering being one such
> exception).
>
> If it works for you, sure, keep going. But when things suddenly start
> failing in interesting ways down the track (when you have 500 tests in
> your suite), expect to set aside time to debug your testing harness
> setup, rather than your tests.
>
Forewarned is forearmed. The worst that could happen is that I have to
switch from extending MyTestCase to django.test.TestCase if I can't
figure out what's causing the problem. I agree it's a little hacky,
but I have such a short attention span... :-)

> There are other plans moving along slowly to speed up the tests for some
> databases (capable databases with proper transaction support :-) ),
> wherein a lot of tests can just run inside a transaction and roll back
> at the end. But there are a few corner cases still to work out there, so
> it's not quite ready yet.
>
Looking forward to it. Thanks for the warnings--I'm sure I will get
bitten at some point.

Todd

--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread elithrar

I primarily use TextMate on OS X - before that, I used Coda but it
didn't have a plugin architecture back then (for Django templates).
--~--~-~--~~~---~--~~
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: ? Import Error for admin djangobook

2009-01-06 Thread elithrar

As you're using a recent (last couple of months) checkout and/or
Django 1.0, you'll find that there have been some changes to the way
the admin application works. See here: 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/
- this should set you on the right path to learning about these
changes.

As the Django Book doesn't cover these - unfortunately it does things
the pre newforms-admin way - I'd suggest using the official tutorial
to familiarize yourself with the framework: 
http://docs.djangoproject.com/en/dev/intro/tutorial01.

On Jan 7, 5:13 am, "Paul Campbell"  wrote:
> Working examples in djangobook /1.0 chapter06
>
> Can not get the Admin Interface to display using suggested urls.py /
> settings.py
>
> #urls
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
>     (r'^admin/', include('django.contrib.admin.urls')),
> )

--~--~-~--~~~---~--~~
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: Import models from CSV files?

2009-01-06 Thread Victor Hooi

heya,

Whoops...forgot. I'm also confused on the recommended way to deal with
duplicates? (not duplicate .csv files, but duplicate entries, perhaps
in two different ones.). Just do a plain search for each entry? Or is
there a better way?

On Jan 7, 11:55 am, Victor Hooi  wrote:
> heya,
>
> Valts, thanks for the reply - that looks interesting, and is similar
> in some ways to what I want - definitely going to check out the code.
> Basically, I just wanted a simple file-upload form, for the user to
> upload the two .CSVfiles. Then, there's quite a bit of processing to
> do on the two files, currently in a small python script.
>
> My question was more along the lines of where should put all of the
> logic? Should it be in the model itself, somewhere, and the file-
> upload form just passes across the raw data from the .csvfiles? Where
> would the file-handling stuff go? Is it easier to do it via raw SQL,
> or via the django models? Any chance of sample code =)?
>
> Cheers,
> Victor
>
> On Jan 6, 7:05 pm, "Valts Mazurs"  wrote:
>
> > Hello,
>
> > Maybe this app could be helpful for 
> > you:http://code.google.com/p/django-batchimport/
>
> > If you have toimportlots of data I would suggest creating python script
> > that reads the files and inserts the data in database either using Django
> > ORM or plain SQL. In case of hundreds of thousands of rows I would commit
> > the changes to database after number of inserts (e.g., 100) instead of every
> > insert.
>
> > Best regards,
> > --
> > Valts
>
> > On Tue, Jan 6, 2009 at 07:02, Victor Hooi  wrote:
>
> > > heya,
>
> > > This question might seem a bit simple, but what's the best way to
> > > instantiate models from .csvfiles?
>
> > > Essentially, I have two .csvfiles. One contains a list of people, and
> > > their access rights (one-to-many). The second .csvfile contains a log
> > > of doorway access (just a bunch of sequential lines). I have a simple
> > > python script which imports these two .csvfiles, does some processing
> > > (the files are quite messy), creates user and access-entry objects,
> > > and produces a reconciliation with a list of exceptions (basically
> > > door entries which aren't in the list of user/access rights). Each
> > > user is just a dictionary, with their username as key, and a tuple of
> > > dictionary objects for their various access rights.
>
> > > I would like a simple django project toimportthese logs, instantiate
> > > models, and then basically manage it via the in-built admin interface,
> > > hopefully saving a lot of time =). (will also need to deal with
> > > duplicates). Is there a smart way to go about doing this project, or
> > > any existing addons I can leverage off?
>
> > > Thanks,
> > > Victor
--~--~-~--~~~---~--~~
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: Inverted ForeignKey usage - Using admin a little backwards?

2009-01-06 Thread ZebZiggle

Hi all,

Sorry for the cryptic subject line, but I don't know how else to
describe it.

I have two tables:

class Opportunity(models.Model):
  ...

class Deal(models.Model):
   opp = models.ForeignKey(Opportunity)
 ...

However, in the admin, I want the user to enter the data for the
Opportunity and then have a table-like UI to add new Deals ... kind of
like a ManyToManyField. I can't use ManyToMany since I don't want the
Opportunity to show any other Deals already created.

What I don't want, as it will too confusing for the users, is the
default behavior: to have to create an Opportunity and then a bunch of
Deals from which they pick the same Opportunity over and over again.

Can this be done or do I need to make some sort of custom page for
this? If so, how can I integrate it with the rest of the admin UI just
for the Opportunity table?

Thanks!
-Z
--~--~-~--~~~---~--~~
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: Import models from CSV files?

2009-01-06 Thread Victor Hooi

heya,

Valts, thanks for the reply - that looks interesting, and is similar
in some ways to what I want - definitely going to check out the code.
Basically, I just wanted a simple file-upload form, for the user to
upload the two .CSV files. Then, there's quite a bit of processing to
do on the two files, currently in a small python script.

My question was more along the lines of where should put all of the
logic? Should it be in the model itself, somewhere, and the file-
upload form just passes across the raw data from the .csv files? Where
would the file-handling stuff go? Is it easier to do it via raw SQL,
or via the django models? Any chance of sample code =)?

Cheers,
Victor

On Jan 6, 7:05 pm, "Valts Mazurs"  wrote:
> Hello,
>
> Maybe this app could be helpful for 
> you:http://code.google.com/p/django-batchimport/
>
> If you have to import lots of data I would suggest creating python script
> that reads the files and inserts the data in database either using Django
> ORM or plain SQL. In case of hundreds of thousands of rows I would commit
> the changes to database after number of inserts (e.g., 100) instead of every
> insert.
>
> Best regards,
> --
> Valts
>
> On Tue, Jan 6, 2009 at 07:02, Victor Hooi  wrote:
>
> > heya,
>
> > This question might seem a bit simple, but what's the best way to
> > instantiate models from .csv files?
>
> > Essentially, I have two .csv files. One contains a list of people, and
> > their access rights (one-to-many). The second .csv file contains a log
> > of doorway access (just a bunch of sequential lines). I have a simple
> > python script which imports these two .csv files, does some processing
> > (the files are quite messy), creates user and access-entry objects,
> > and produces a reconciliation with a list of exceptions (basically
> > door entries which aren't in the list of user/access rights). Each
> > user is just a dictionary, with their username as key, and a tuple of
> > dictionary objects for their various access rights.
>
> > I would like a simple django project to import these logs, instantiate
> > models, and then basically manage it via the in-built admin interface,
> > hopefully saving a lot of time =). (will also need to deal with
> > duplicates). Is there a smart way to go about doing this project, or
> > any existing addons I can leverage off?
>
> > Thanks,
> > Victor
--~--~-~--~~~---~--~~
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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 16:07 -0800, rabbi wrote:
> i was actually already reading that page... but it's 1:00am and maybe
> i glazed over it without registering :)
> 
> i've now temporarily fixed my admin page problem by just copying all
> files to the apache document root, but later i will need to learn what
> a "symbolic link" is as it sounds like a nicer solution

You said you were using Windows XP. So, out of the box, symbolic links
won't work. I believe there are tools that allow you to create them if
the filesystem is NTFS, but since the last time I used Windows in any
serious fashion was 1998, I'm not in any position to recommend anything.
It's just one of those limitations you have to accept when choosing
Windows (every OS choice has trade-offs).

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread rabbi

i was actually already reading that page... but it's 1:00am and maybe
i glazed over it without registering :)

i've now temporarily fixed my admin page problem by just copying all
files to the apache document root, but later i will need to learn what
a "symbolic link" is as it sounds like a nicer solution

the online documentation is excellent by the way!
this is the first time ive tried web development, first time ive used
HTML, python, django, any web server, etc and ive managed to get a
basic site up and running largely thanks to the documentation

much appreciated
alex

On Jan 7, 12:52 am, Malcolm Tredinnick 
wrote:
> On Tue, 2009-01-06 at 15:33 -0800, rabbi wrote:
> > thanks a lot malcom, that's great advice.
> > for the record, initially i had "DATABASE_NAME = 'vocab'"
>
> > i have another question; after changing from runserver to apache the
> > django admin page now looks very ugly... it's lost all formatting etc
>
> The development server helps you out (and gives false expectations in
> the process if you're not paying attention) by automatically serving up
> the CSS and Javascript files. This isn't the case when you switch to a
> real webserver, since you need to tell the webserver how to find those
> files. Django isn't going to automatically serve things like CSS,
> images, and Javascript, as they're static files and web servers can do a
> much better job serving them and providing things like expiry times than
> running it through a Python program.
>
> This is where I unfortunately have to say "read the documentation,"
> since we've spent more than a few hours writing up instructions about
> this. Have a look at
>
>        http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1
>
> (in fact, read that whole page if you haven't done so already). You
> might need to also look up the appropriate documentation in the Apache
> manuals (e.g. if you don't know what the Location directive means), but
> hopefully things should be reasonably clear if you're already familiar
> with Apache configuration a bit and/or take your time.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 15:33 -0800, rabbi wrote:
> thanks a lot malcom, that's great advice.
> for the record, initially i had "DATABASE_NAME = 'vocab'"
> 
> i have another question; after changing from runserver to apache the
> django admin page now looks very ugly... it's lost all formatting etc
> 

The development server helps you out (and gives false expectations in
the process if you're not paying attention) by automatically serving up
the CSS and Javascript files. This isn't the case when you switch to a
real webserver, since you need to tell the webserver how to find those
files. Django isn't going to automatically serve things like CSS,
images, and Javascript, as they're static files and web servers can do a
much better job serving them and providing things like expiry times than
running it through a Python program.

This is where I unfortunately have to say "read the documentation,"
since we've spent more than a few hours writing up instructions about
this. Have a look at

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1

(in fact, read that whole page if you haven't done so already). You
might need to also look up the appropriate documentation in the Apache
manuals (e.g. if you don't know what the Location directive means), but
hopefully things should be reasonably clear if you're already familiar
with Apache configuration a bit and/or take your time.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread rabbi

thanks a lot malcom, that's great advice.
for the record, initially i had "DATABASE_NAME = 'vocab'"

i have another question; after changing from runserver to apache the
django admin page now looks very ugly... it's lost all formatting etc

is this normal or is it a problem i can repair. maybe the admin
templates can no longer be located?


On Jan 7, 12:23 am, Malcolm Tredinnick 
wrote:
> On Tue, 2009-01-06 at 15:12 -0800, rabbi wrote:
>
> [...]
>
> > i've now got it running on apache/mod_python too, but i had to
> > hardcode the entire path to the db file in settings.py:
> >    "DATABASE_NAME = 'C:/Documents and Settings/Rabbi/Desktop/Django
> > Code/mysite/vocab'"
>
> > is this really necessary or is there a nicer way that will work
> > anywhere?
>
> Ah.. that change makes sense. SQLite is a nice database in some ways,
> and one of the things it does is not require you to create the database
> file ahead of time (it's created when you first access it, although it
> will be empty). The drawback is that if you misspell of mis-specify the
> database path in any way, a new file is created or accessed somewhere
> and will, indeed, be empty. Which is what you were seeing.
>
> You do need to specify the full path to the database file in your
> settings like the above. It's the only way the webserver can know where
> it is (your previous setting, whatever it was, happened to work by
> accident when you were using "runserver", since it was a relative path
> that just happened to be correct relative to where you were running
> from).
>
> Generally, the settings file for a project is one of the things you
> should expect to have to make small changes to as you move a collection
> of apps around between machines or installations. If you're careful,
> when developing, you should be able to set things up so that it's the
> *only* file you need to worry about tweaking and even possibly split it
> up into settings that are always valid and things like the above,
> path-sensitive value, that you know you need to change. Some people put
> the stuff they always need to change -- those settings which are
> machine-specific -- into a file called, say, local_settings.py and then,
> at the end of their settings.py, they write
>
>         try:
>             from local_settings import *
>         except ImportError:
>              pass
>
> The try...except is just in case you may not always have a
> local_settings file, but if you know it's always going to be there, you
> might leave out that try...except. Also, by putting this at the end, any
> local_settings values will override the previous settings values, which
> provides a good way to change things as well.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 15:12 -0800, rabbi wrote:

[...]
> i've now got it running on apache/mod_python too, but i had to
> hardcode the entire path to the db file in settings.py:
>"DATABASE_NAME = 'C:/Documents and Settings/Rabbi/Desktop/Django
> Code/mysite/vocab'"
> 
> is this really necessary or is there a nicer way that will work
> anywhere?

Ah.. that change makes sense. SQLite is a nice database in some ways,
and one of the things it does is not require you to create the database
file ahead of time (it's created when you first access it, although it
will be empty). The drawback is that if you misspell of mis-specify the
database path in any way, a new file is created or accessed somewhere
and will, indeed, be empty. Which is what you were seeing.

You do need to specify the full path to the database file in your
settings like the above. It's the only way the webserver can know where
it is (your previous setting, whatever it was, happened to work by
accident when you were using "runserver", since it was a relative path
that just happened to be correct relative to where you were running
from).

Generally, the settings file for a project is one of the things you
should expect to have to make small changes to as you move a collection
of apps around between machines or installations. If you're careful,
when developing, you should be able to set things up so that it's the
*only* file you need to worry about tweaking and even possibly split it
up into settings that are always valid and things like the above,
path-sensitive value, that you know you need to change. Some people put
the stuff they always need to change -- those settings which are
machine-specific -- into a file called, say, local_settings.py and then,
at the end of their settings.py, they write

try:
from local_settings import *
except ImportError:
 pass

The try...except is just in case you may not always have a
local_settings file, but if you know it's always going to be there, you
might leave out that try...except. Also, by putting this at the end, any
local_settings values will override the previous settings values, which
provides a good way to change things as well.

Regards,
Malcolm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Speeding up the tests, what am I missing?

2009-01-06 Thread Russell Keith-Magee

On Wed, Jan 7, 2009 at 4:51 AM, Todd O'Bryan  wrote:
>
> So, I've been trying to speed up tests. Surprise. I came across a
> fairly easy solution, so I'm sure I must be missing something. If
> someone could tell me what I'm missing, I'd really appreciate it.
...
> MyTestCaseSubclass.dirties_db = True
...
> So, what am I missing? I know this doesn't deal with doctests--the db
> gets cleaned for all of those, but does anyone see when this is just
> going to blow up in my face?

This approach will (clearly) speed up tests. I have three objections
to the technique.

The first objection is a relatively minor syntactical wart. Using a
normal assignment to set the dirty bit means your test code is mixing
test code with setup code. I'd rather see this sort of thing as a
decorator, so that the test i

The second objection is more significant: the technique is entirely
manual, and prone to error. If you get all the dirties_db markers
correct, your tests will be much faster; however, if you get one
wrong, you could get all sorts of unexpected consequences, and the
problems won't be reported in the test that actually has the incorrect
dirty marker. The order in which tests doesn't necessarily match the
order in which they are defined in the test case; if you run a subset
of tests, all bets on predictable test output are off.

The third objection is that in my experience, genuine 0-write test
cases aren't actually that common. This will, of course, vary wildly
depending on your particular project, but I seem to recall looking at
this sort of change and came to the conclusion that it wouldn't
actually speed up the Django test suite that much. Feel free to prove
me wrong.

There are some plans in place to speed up test cases using
transactions; I'm hoping to be able to look at this once I put the
aggregation and F() code to bed, in the next week or so.

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



Re: File upload failing occasionally

2009-01-06 Thread Graham Dumpleton



On Jan 6, 10:31 pm, ppdo  wrote:
> To Karen: yes, I meant TCP RST, sorry.
>
> Update:
>
> Using mod_wsgi made the problem go away for Firefox.
>
> Limiting my research to an interaction problem between Apache and
> Safari, I stumbled upon this bug report for Apache
> https://bugs.webkit.org/show_bug.cgi?id=5760 that describes something
> very similar to what is happening and it is apparently still open.

For which the problem was identified as being in MacOSX Foundation
framework. Supposedly fixed in 10.5.5, but some people still having
problems after updating to that revision of OS.

Thanks for finding that page in webkit issue tracker, will be good one
to keep in mind id others see similar problem. I'll have to see if
disabling keep alive solves my ab performance tests.

Graham

> Reading this gave me the idea to try and disable the keepalive and,
> though I need to test it more extensively, it seems the problem is
> gone.
>
> A simple:
>
> BrowserMatch "Safari" nokeepalive
>
> in the Apache configuration did the trick. As on the production server
> this application will not have to stand much traffic anyway, it should
> be ok also without keepalive.
>
> I'll update this thread if I have more findings.
>
> Thank you both for your ideas!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: OperationalError at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread rabbi

>>I've gone through the Django tutorial and it worked fine when using
>>the default development server that is provided with Django (python
>>manage.py runserver)

yeh, like I said. it works fine with the django-provided development
server

i've now got it running on apache/mod_python too, but i had to
hardcode the entire path to the db file in settings.py:
   "DATABASE_NAME = 'C:/Documents and Settings/Rabbi/Desktop/Django
Code/mysite/vocab'"

is this really necessary or is there a nicer way that will work
anywhere?
--~--~-~--~~~---~--~~
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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 11:59 -0800, rabbi wrote:
[...]
> I want to deploy my little test site though, so I've been trying to
> get it running on Apache and I keep getting this error:
> "OperationalError at /swenglish/
> no such table: swenglish_entry"
> 
> The error seems to be happening on this line:
> "entry_list = [e.eng_val + " = " + e.swe_val for e in Entry.objects.all
> ()]"

So the error is telling you that the database table doesn't exist for
the Entry model. Did you remember to run "python manage.py syncdb" after
creating the models?

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Speeding up the tests, what am I missing?

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 14:51 -0500, Todd O'Bryan wrote:
[...]

> So, what am I missing? I know this doesn't deal with doctests--the db
> gets cleaned for all of those, but does anyone see when this is just
> going to blow up in my face?

For that to work reliably, you would need to deeply know the internals
of Django to know which calls are going to dirty the database in some
way. For example, if your tests simulate a user's interactions at all,
there will be changes to the session.

So, sure, it's possible, although duplicates a lot of code, but it's
also a bit fragile. Russell Keith-Magee and I have had a number of
conversations over the past couple of years about speeding up the tests
for Django itself and we keep looking at this one. But, at the end of
the day, every set of non-significant tests touch the database in some
way, with very, very few exceptions (template rendering being one such
exception).

If it works for you, sure, keep going. But when things suddenly start
failing in interesting ways down the track (when you have 500 tests in
your suite), expect to set aside time to debug your testing harness
setup, rather than your tests.

There are other plans moving along slowly to speed up the tests for some
databases (capable databases with proper transaction support :-) ),
wherein a lot of tests can just run inside a transaction and roll back
at the end. But there are a few corner cases still to work out there, so
it's not quite ready yet.

Regards,
Malcolm



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

2009-01-06 Thread phoebebright

Thanks for that clarification.  I am finding that a lot of assumptions
are made in the documentation about previous knowledge.  The
documentation can appear very confusing until you understand the
background, then it magically becomes blindingly obvious and helpful!
I must write down more of these moments of clarification!


Maybe starting a collection of seemingly obvious statements would be
helpful for newbies:
- django is a module for python, so a basic knowledge of python is
required, although much can be learned by looking at examples and
reading the django documentation.
- django includes a templating language that has a limited set of
commands, so python code will not work there.
- unlike php, your django code can be anywhere on the server and
apache directives (right term) are used to redirect http requests to
your urls.py and from there to the rest of your programs.
- the apache directives may be in the httpd.conf file or vhost.conf
file or other include files.  It just depends how your server is
setup.
- building querysets.  If you want to add lots of filters in seperate
lines.  eg. if x: filter on a, if y: filter on b, etc. then start by
selecting all into a new queryset and then build up additional filters
on the new queryset.

query=Car.objects.all()

if request.GET.get('transmission','Any') != "Any":
query=query.filter(transmission=request.GET.get
('transmission','Any'))
if request.GET.get('fuels','Any') != "Any":
query=query.filter(fuel_type=request.GET.get('fuels','Any'))
if request.GET.get('bodies','Any') != "Any":
query=query.filter(body_type=request.GET.get('bodies','Any'))

etc...




On Jan 6, 9:51 pm, "Malinka Rellikwodahs" 
wrote:
> On Tue, Jan 6, 2009 at 16:49, Jeff Anderson  wrote:
> > phoebebright wrote:
> >> Thanks for your response. Do you think a working knowledge of python
> >> is essential for django then?  And do I import modules the same in
> >> django and python?  Are there any python things you can't do in
> >> django?
>
> yes you should be able to in django do anything you can do in python
>
>
>
> > Django *is* Python. In fact, Django is only a Python library. It is not
> > its own language.
>
> excluding the template language obviously that isn't python
--~--~-~--~~~---~--~~
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: Shouldn't blank=True imply null=True?

2009-01-06 Thread Malinka Rellikwodahs

On Tue, Jan 6, 2009 at 17:47, Malcolm Tredinnick
 wrote:

> This thread is about whether blank=True, null=False (the fourth
> possibility) ever makes sense for non-text fields.

not sure if django supports binary data or any form of arrays but in
those cases it could make sense to have blank=True and null=False,
because you could have for whatever reason a situation where you'd
have an array of zero length which afaics is the same as an empty
string, and could have a requirement outside of django to allow those
values but not allow nulls

--~--~-~--~~~---~--~~
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: Circular imports between managers and models

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote:
> Hi,
> Suppose I have two classes in "models.py", namely A and B. And there
> is the manager for B as BManager in "managers.py". BManager makes use
> of clas A.
> 
> This situation leads to circular imports between "managers.py" and
> "models.py" for which I can't find a solution.

Since you don't tell us what you're doing currently, we'll have to break
out the crystal ball and see if the vapours let us guess as to the false
starts you might have made. It's hard to correct existing code without
knowing what it is. :-)

However, there shouldn't be any circular import problems. You just have
to remember to import only the module, not names inside the module in
one of the files. To wit...

In models.py:

from django.db import models

from managers import BManager

class A(models.Model):
...

class B(models.Model):
...
objects = BManager()

In managers.py:

from django.db import models

import models

class BManager(models.Manager):
...
# Refer to models.ModelA inside methods without problems.

When Python is importing models.py, it will see that it has to import
managers.py. So it does that, which says "import models". Python knows
that it has already imported (or is in the process of importing)
models.py, so it doesn't do it again, it just continues on. Providing it
does not need to refer to the contents of "models" (e.g. models.ModelA)
whilst parsing the managers module, there is no problem.

Circular import problems arise if you try to do "from models import
ModelA" in managers, because models isn't yet fully imported, so Python
cannot look up the ModelA inside that module. Problems would also arise
if you wrote something like this:

class BManager(models.Manager):
fred = models.ModelA.objects.all()

since the class definition is processed (executed) at parsing time,
which would require access to models.ModelA, which isn't available yet.
But that wouldn't be particularly sensible in any case (ModelA's
contents are dynamic, so reading it only at import time is inflexible).
If you have something like this:

class BManager(models.Manager):
def fred(self):
return models.ModelA.objects.all()

Then the statements inside fred() are not executed until the method is
called (they are parsed, but not executed, when the file is imported).
When you get around to calling method fred(), "models" will be fully
imported and there will be no problems.

> 
> Assuming that I need to separate models and manager into different
> files, so merging them is not an option,

If you have some particularly twisted set up, then you'll simply need to
drop that assumption. It's not really a requirement for functionality,
merely a style issue. And sometimes style has to take a backseat to
practicality.

>  are there any best practices

Best practice is "whatever works and is maintainable". People get far
too hung up on sticking a best practice label on things to the point
that it becomes devalued. Sure, some approaches look neater than others,
but I see too many people spinning their wheels wondering about the
unique "best" (in some truly debatable sense) solution, rather than just
getting on and solving their problems.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread Daniel Roseman

On Jan 6, 2:59 pm, rabbi  wrote:
> Hi everyone,
> I've gone through the Django tutorial and it worked fine when using
> the default development server that is provided with Django (python
> manage.py runserver)
>
> I want to deploy my little test site though, so I've been trying to
> get it running on Apache and I keep getting this error:
> "OperationalError at /swenglish/
> no such table: swenglish_entry"
>
> The error seems to be happening on this line:
> "entry_list = [e.eng_val + " = " + e.swe_val for e in Entry.objects.all
> ()]"
>
> Apache and mod_python work with a "hello world" test
>
> I'm running:
> Windows XP (sorry)
> Python 2.5.4
> mod_python 3.3.1
> Apache 2.2.11
>
> Thanks in advance for any help you can give me!

Well, have you created the table? Did you run manage.py syncdb?
--
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: Shouldn't blank=True imply null=True?

2009-01-06 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 08:03 -0800, dchandek wrote:
[...]
> The only gotcha I've encountered here is that practically speaking
> null=True requires blank=True. 

That isn't always valid and it's not the direction that's being proposed
in this thread. One of the design goals of Django is to work relatively
smoothly with databases that aren't necessarily solely populated or
created by the Django libraries. Thus, you might well have a situation
where the web interface is provided through Django code and, for that
situation, it would never make sense to supply empty data (hence
blank=False). However, some external process or entirely different web
interface might also be providing data that does contain NULL values. Or
you might be using a pre-existing database that contains NULL values in
the column.

Hence null=True. So null=True, blank=False is a sensible set up,
although less common than null=True, blank=True and null=False,
blank=False.

This thread is about whether blank=True, null=False (the fourth
possibility) ever makes sense for non-text fields.

Regards,
Malcolm



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

2009-01-06 Thread Petite Abeille


On Jan 6, 2009, at 8:55 PM, MA wrote:

> Django vs. WObject(s).

WObject? Do you mean NeXT/Apple's WebObjects?

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

Cheers,

--
PA.
http://alt.textdrive.com/nanoki/

--~--~-~--~~~---~--~~
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 at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread rabbi

I forgot to mention, I'm using SQLite3

On Jan 6, 8:59 pm, rabbi  wrote:
> Hi everyone,
> I've gone through the Django tutorial and it worked fine when using
> the default development server that is provided with Django (python
> manage.py runserver)
>
> I want to deploy my little test site though, so I've been trying to
> get it running on Apache and I keep getting this error:
> "OperationalError at /swenglish/
> no such table: swenglish_entry"
>
> The error seems to be happening on this line:
> "entry_list = [e.eng_val + " = " + e.swe_val for e in Entry.objects.all
> ()]"
>
> Apache and mod_python work with a "hello world" test
>
> I'm running:
> Windows XP (sorry)
> Python 2.5.4
> mod_python 3.3.1
> Apache 2.2.11
>
> Thanks in advance for any help you can give me!
--~--~-~--~~~---~--~~
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: IOError: request data read error

2009-01-06 Thread Graham Dumpleton



On Jan 7, 4:04 am, Chunlei  Wu  wrote:
> Thanks a lot Graham. I will upgrade my modwsgi to v2.3. Looking
> forward to the v3.0 to see if the fix on issue #29 will fix my problem
> as well.

Actually, my reference to issue #29 is a bit wrong. That issue relates
to connection being closed when trying to write the response. In your
case the issue is when connection is closed or has a problem when
reading the response. The reduction in unnecessary logging in that
issue will not change what you are seeing. When a read fails you will
still see an exception being raised and if your code or Django isn't
doing anything specifically about that and just passing it back, you
will get the same behaviour as you do now.

Graham

> Chunlei
>
> On Jan 5, 3:40 pm, Graham Dumpleton 
> wrote:
>
> > On Jan 6, 4:41 am, Chunlei  Wu  wrote:
>
> > > Hi,
>
> > >        We have a web app running on Django 1.0 / modwsgi 2.0 / Apache
>
> > Latest mod_wsgi is 2.3, you should really think about upgrading. :-)
>
> > > 2.2.3. Sparsely, about 2~3 times a week, I receive emails about
> > > IOError as below:
>
> > > ...
> > >   File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
> > > core/handlers/wsgi.py", line 69, in safe_copyfileobj
> > >     buf = fsrc.read(min(length, size))
>
> > > IOError: request data read error
>
> > > Mostly it happens on the root URL, but there is a case from other URL.
> > > I suspect that it is related to the network connection problem, but I
> > > can not re-produce it. Can anybody explain what  doe this error mean
> > > exactly? Thanks.
>
> > It means that low level Apache functions returned an error when trying
> > to read request content.
>
> > Unfortunately, the particular Apache function used to get the request
> > content is one that effectively looses the even lower level Apache
> > error number which would be useful in qualifying what caused the
> > problem. In other words, the Apache function just says there was an
> > error and not what it was. Technically some different set of Apache
> > functions could be used to do the same thing, without loss of the
> > error code when a problem does occur, but that is a bit trickier and
> > involves more work. Changing how it is done might occur, but not soon.
>
> > More than likely though, it is a variation on another error that can
> > come back when reading request content as described in:
>
> >  http://code.google.com/p/modwsgi/issues/detail?id=29
>
> > That one can occur when user/client aborts the connection. This can
> > occur when they are trigger happy on the reload button.
>
> > To try and reproduce it, perhaps perform a file upload and before it
> > has completed keep pressing the reload button for the page.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Solved: admin import fails

2009-01-06 Thread pcsnow

The url below has information in "Part2"
has a revised urls.py and also discussion of admin.py



http://docs.djangoproject.com/en/dev/


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



? Import Error for admin djangobook

2009-01-06 Thread Paul Campbell
Working examples in djangobook /1.0 chapter06

Can not get the Admin Interface to display using suggested urls.py /
settings.py

#urls
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
)

#settings.py - # snip

ROOT_URLCONF = 'mysite.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)

INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.auth',
'django.contrib.admin',
#'django.contrib.admindocs',
'mysite.books',
)
Fedora 8 -

 django.VERSION
(1, 0, 2, 'final', 0)
['django.contrib.contenttypes', 'django.contrib.sessions',
'django.contrib.auth', 'django.contrib.admin', 'mysite.books']

Funny when I used admindocs, I could get the login screen but then it failed

Suggestions ?
Change versions of python or django ?

Portion of output -


Request URL: http://127.0.0.1:8000/admin/  Exception Type: ImportError
 Exception
Value:

No module named urls

 Exception Location:
/usr/lib/python2.5/site-packages/django/core/urlresolvers.py
in _get_urlconf_module, line 198  Python Executable: /usr/bin/python  Python
Version: 2.5.1  Python Path: ['/home/pwc/django/mysite',
'/usr/lib/python25.zip', '/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
'/usr/lib/python2.5/lib-dynload', '/usr/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages/Numeric',
'/usr/lib/python2.5/site-packages/PIL',
'/usr/lib/python2.5/site-packages/gst-0.10',
'/usr/lib/python2.5/site-packages/gtk-2.0']

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



Django vs. WObject...

2009-01-06 Thread MA

Hi,

Since our management  team is trying to select the platform for
further development, I'm in process to prepare the case
( presentation)  Django vs. WObject(s).

Though both frameworks seems to be very similar in the goals, they are
obviously quite different in their internals.

I'm wondering if somebody has experience of working with both, and can
highlight the major advantage/disadvantages ( week / strong points) of
one and/or another.  In particular, I'm wondering in the areas of
   -  stability ( pick loads, etc);
   - easy for deployment/management;
   - development cycle;
   ...

Thank you for your kind attention to this matter.

Alex.

P.S> I'm really far from any intention to start a 'fan/religious war'
here. It just looks like both platforms are very close with the
original goals, and I would like to present  a fair/accurate picture
in my presentation...





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



OperationalError at /swenglish/ , no such table: swenglish_entry

2009-01-06 Thread rabbi

Hi everyone,
I've gone through the Django tutorial and it worked fine when using
the default development server that is provided with Django (python
manage.py runserver)

I want to deploy my little test site though, so I've been trying to
get it running on Apache and I keep getting this error:
"OperationalError at /swenglish/
no such table: swenglish_entry"

The error seems to be happening on this line:
"entry_list = [e.eng_val + " = " + e.swe_val for e in Entry.objects.all
()]"

Apache and mod_python work with a "hello world" test

I'm running:
Windows XP (sorry)
Python 2.5.4
mod_python 3.3.1
Apache 2.2.11

Thanks in advance for any help you can give me!

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



Could not import settings

2009-01-06 Thread Bradley

I move an existing website running django onto a shared webhost via
FastCGI.

No matter what I do, I get the following error:

ImportError: Could not import settings 'seymourherald.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
seymourherald.settings

my DJANGO_SETTINGS_MODULE is set to wwwroot.settings and yet I still
get the above error.  I'm pretty new to django, is there any other
place where it would be looking for seymourherald.settings

Django located here:
~/djtrunk/

My website here:
~/seymourherald.com/wwwroot
~/seymourherald.com/wwwroot/settings.py

DocumentRoot:
~/public_html/seymourherald
~/public_html/seymourherald/.htaccess
~/public_html/seymourherald/cgi-bin
~/public_html/seymourherald/cgi-bin/wwwroot.fcgi

--~--~-~--~~~---~--~~
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: Newbie: Help to understand string handling

2009-01-06 Thread Malinka Rellikwodahs

On Tue, Jan 6, 2009 at 16:49, Jeff Anderson  wrote:
> phoebebright wrote:
>> Thanks for your response. Do you think a working knowledge of python
>> is essential for django then?  And do I import modules the same in
>> django and python?  Are there any python things you can't do in
>> django?

yes you should be able to in django do anything you can do in python

>>
> Django *is* Python. In fact, Django is only a Python library. It is not
> its own language.

excluding the template language obviously that isn't python

--~--~-~--~~~---~--~~
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: Newbie: Help to understand string handling

2009-01-06 Thread Jeff Anderson
phoebebright wrote:
> Thanks for your response. Do you think a working knowledge of python
> is essential for django then?  And do I import modules the same in
> django and python?  Are there any python things you can't do in
> django?
>   
Django *is* Python. In fact, Django is only a Python library. It is not
its own language.



signature.asc
Description: OpenPGP digital signature


Re: Newbie: Help to understand string handling

2009-01-06 Thread phoebebright

Thanks for your response. Do you think a working knowledge of python
is essential for django then?  And do I import modules the same in
django and python?  Are there any python things you can't do in
django?



On Jan 6, 8:18 pm, "Alex Koshelev"  wrote:
> Yes. Django is just Python
>
> On Tue, Jan 6, 2009 at 11:14 PM, phoebebright  
> wrote:
>
> > As a newbie to both python and django (ex PHP) I am not clear on when
> > I can use python functions and when I can't.
>
> > I want to do some simple string handling in a view, search and replace
> > for example, but can't find anything in the documentation.  I assume
> > this means that I can use python string handling?
>
>
--~--~-~--~~~---~--~~
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: is it possible to provide initial data for a model with a foreign key to User model?

2009-01-06 Thread adrian

Many thanks.  I am using MySQL with InnoDB, as a matter of fact.  When
I installed MySQL that's what it recommended.

Your suggestion works fine.   I was trying Person as a subclass of
User, and couldn't get that
to initialize.

On Jan 3, 4:55 am, "Russell Keith-Magee" 
wrote:
> On Sat, Jan 3, 2009 at 3:01 AM, adrian  wrote:
>
> > I happen to have a bunch of models that all haveforeignkeys, but
> > there is an order in which they could all be initialized.   I have
> > figured out how to initialize the built-in User model usingJsondata,
> > but I can't initialize any models that refer to it using aforeign
> >key.  Is this possible and if so how?
>
> Yes, it is possible. If you have a model something like:
>
> class Person(Model):
>    user = ForeignKey(User)
>    name = CharField(...)
>
> this will serialize something like:
>
> {
>     "model": "myapp.person',
>     "pk": 1,
>     "fields": {
>         "user": 3,
>         "name": "Fred"
>     }
>
> }
>
> The reference to a user is just the primarykeyof the object you want
> to refer to. If you want a more comprehensive example using your own
> models, try creating some instances using the Python API, then use the
> manage.py dumpdata command to produce sample fixtures.
>
> Generally speaking, you don't need to worry about the order of
> initialization. In your fixture, you can define the Person then the
> User, or the User and then the Person - it doesn't matter.
>
> If you're using SQLite or MySQL with MyISAM tables, there is no
> referential integrity to worry about, so you can create a Person that
> refers to a User that doesn't exist yet. As long as you eventually
> create the User, you won't have any problems.
>
> If you're using Postgres, all the fixtures are loaded in a
> transaction, and referential integrity isn't checked until the end of
> the transaction. As long as the Person and the User are both loaded at
> the end of fixture loading, the order in which they are created
> doesn't matter.
>
> The only exception to this rule is MySQL with InnoDB tables - which,
> because of its retarted referential integrity, insists on checking
> references at the end of every commit, rather than at the end of the
> transactional block. This means that you have to manually check that
> the fixture with an ordering such that the User is loaded before the
> Person.
>
> Until MySQL fixes its referential integrity rules for InnoDB, this
> limitation can't be avoided in the general case. Any form of circular
> reference between models will always pose difficulties - there is no
> way to provide an ordering that is guaranteed to load successfully.
>
> 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
-~--~~~~--~~--~--~---



Re: Your IDE of choice

2009-01-06 Thread Ovnicraft
2009/1/6 Berco Beute 

>
> On Jan 6, 2:35 pm, Pigletto  wrote:
>
> > So, Netbeans is currently my IDE of choice. Good svn integration,
> > faster than eclipse and komodo, stable, nice markup highlighting.
>
> +1
> I'm using SciTe and emacs for simple, single file editing.
> I've used pydev for a while but eclipse's startup time is too long.
> I've tried Eric (which is really nice), but the editor is less feature
> rich than pydev and the auto-completion is hard to configure
> Then I switched to Netbeans (after having used it 10 years ago for
> Java development) and I'm really suprised by its speed and feature
> richnes. The auto-completion is the best I've encountered. Highly
> recommended.

+1
and this comes http://wiki.netbeans.org/Python70Roadmap

>
>
> 2B
> >
>


-- 
[b]question = (to) ? be : !be; .[/b]

--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Berco Beute

On Jan 6, 2:35 pm, Pigletto  wrote:

> So, Netbeans is currently my IDE of choice. Good svn integration,
> faster than eclipse and komodo, stable, nice markup highlighting.

+1
I'm using SciTe and emacs for simple, single file editing.
I've used pydev for a while but eclipse's startup time is too long.
I've tried Eric (which is really nice), but the editor is less feature
rich than pydev and the auto-completion is hard to configure
Then I switched to Netbeans (after having used it 10 years ago for
Java development) and I'm really suprised by its speed and feature
richnes. The auto-completion is the best I've encountered. Highly
recommended.

2B
--~--~-~--~~~---~--~~
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: creating formset is very slow

2009-01-06 Thread Kottiyath Nair
I tried with 500 forms instead of 25. Now the time is becoming appaling.---
117 seconds. Second time it hung.

2009-01-07 01:42:13,812 INFO Start - 4.46984183744e-006
2009-01-07 01:42:13,812 INFO Formset Class created- 0.000422958783868
2009-01-07 01:44:11,703 INFO Created new formset- 117.90750668
2009-01-07 01:44:17,203 INFO All forms done - 123.39991647
2009-01-07 01:44:17,217 INFO Start - 123.416734808
2009-01-07 01:44:17,217 INFO Formset Class created- 123.41704658

Regards
K

On 1/7/09, Kottiyath Nair  wrote:
>
> Hi all,
>My web application sends a medium size data grid (20 elements). I was
> using formsets for the same.
>The issue I am facing is that the formset instantiation is very very
> slow. I timed it and it is taking ~4-7 seconds for it to instantiate.
>Is there someway the speed can be increased?
>
> There are no files sent. I am planning to, later.
> The code:
> logging.info('Start - %s' %time.clock())
> DataFormSet = formset_factory(DataForm, extra=25)
> logging.info('Formset Class created- %s' %time.clock())
> formset = DataFormSet(request.POST, request.FILES)
> logging.info('Created new formset- %s'%time.clock())
>
> From my logs:
> 2009-01-06 22:53:30,671 INFO Start - 0
> 2009-01-06 22:53:30,671 INFO Formset Class created- 0.000403403225829
> 2009-01-06 22:53:34,296 INFO Created new formset- 3.62182316468
>   or later
> 2009-01-06 22:56:37,500 INFO Start - 186.836136716
> 2009-01-06 22:56:37,500 INFO Formset Class created- 186.836445135
> 2009-01-06 22:56:43,108 INFO Created new formset- 192.440754621
>
>
>Please note that I am running the whole thing under the django
> development server in my laptop itself and not a server.
>

--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Vitaly Babiy
Bernard does komodo have a open files function (open file in project based
on file name search) like there is text mate or gedit with plugin
(gedit-openfiles).

Vitaly Babiy


On Tue, Jan 6, 2009 at 3:10 PM, Bernard  wrote:

>
> I use Komodo IDE 5 everyday for every Python/Django/PHP/Drupal
> projects at work and damn it works well.
>
> What I love about it:
>
> * Key bindings(shortcuts) for almost everything
> * Simple subversion integration so I don't have to switch to another
> window to commit something.
> * Search & Replace , Regex toolkit
> * Code Snippets. I have plenty of those for Django templates, HTML,
> CSS, Python & PHP.
> * http://code.google.com/p/django-komodo-kit/ for more django goodness
> in Komodo Edit or IDE
>
> What I hate about it:
> * a little slow to start but once it's fired, there's nothing stopping
> it.
>
> what it looks like on my laptop :
>
> http://www.picoodle.com/view.php?img=/3/1/6/f_komodoidem_51d0317.png=img37
>
> On Jan 6, 6:48 am, HB  wrote:
> > Hey,
> > What is your favorite IDE for coding Django projects?
> > Any ideas about PyDev and ActiveState Komodo IDE?
> > Thanks.
> >
>

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



Re: Newbie: Help to understand string handling

2009-01-06 Thread Alex Koshelev

Yes. Django is just Python


On Tue, Jan 6, 2009 at 11:14 PM, phoebebright  wrote:
>
> As a newbie to both python and django (ex PHP) I am not clear on when
> I can use python functions and when I can't.
>
> I want to do some simple string handling in a view, search and replace
> for example, but can't find anything in the documentation.  I assume
> this means that I can use python string handling?
>
>
> >
>

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



Newbie: Help to understand string handling

2009-01-06 Thread phoebebright

As a newbie to both python and django (ex PHP) I am not clear on when
I can use python functions and when I can't.

I want to do some simple string handling in a view, search and replace
for example, but can't find anything in the documentation.  I assume
this means that I can use python string handling?


--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Bernard

I use Komodo IDE 5 everyday for every Python/Django/PHP/Drupal
projects at work and damn it works well.

What I love about it:

* Key bindings(shortcuts) for almost everything
* Simple subversion integration so I don't have to switch to another
window to commit something.
* Search & Replace , Regex toolkit
* Code Snippets. I have plenty of those for Django templates, HTML,
CSS, Python & PHP.
* http://code.google.com/p/django-komodo-kit/ for more django goodness
in Komodo Edit or IDE

What I hate about it:
* a little slow to start but once it's fired, there's nothing stopping
it.

what it looks like on my laptop :
http://www.picoodle.com/view.php?img=/3/1/6/f_komodoidem_51d0317.png=img37

On Jan 6, 6:48 am, HB  wrote:
> Hey,
> What is your favorite IDE for coding Django projects?
> Any ideas about PyDev and ActiveState Komodo IDE?
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Speeding up the tests, what am I missing?

2009-01-06 Thread Todd O'Bryan

So, I've been trying to speed up tests. Surprise. I came across a
fairly easy solution, so I'm sure I must be missing something. If
someone could tell me what I'm missing, I'd really appreciate it.

So, first I created my own subclass of django.test.TestCase:

class MyTestCase(django.test.TestCase):
# see code below

Then I wrote unit tests, subclassing MyTestCase

class TestParticularThing(MyTestCase):
fixtures = ['mydata', 'myotherdata.json']
dirties_db = True

def test_something(self):
TestParticularThing.dirties_db = False
resp = self.client.get('/some/url')
self.assertContains(resp, 'blah')

def test_something_else(self):
TestParticularThing.dirties_db = True
resp = self.client.post('/another/url', {'var': 'value'})
self.assertRedirects(resp, '/redirect/url')

So here's the code for MyTestCase. I just overrode the _pre_setup
method so that it checks the dirties_db attribute of the class. If it
both exists and is set to False, flushing and repopulating the db is
skipped, otherwise the db is cleaned as usual.

class MyTestCase(django.test.TestCase):
def _pre_setup(self):
"""Performs any pre-test setup. This includes:
* Flushing the database.
* If the Test Case class has a 'fixtures' member, installing the
  named fixtures.
* If the Test Case class has a 'urls' member, replace the
  ROOT_URLCONF with it.
* Clearing the mail test outbox.
"""
if not hasattr(self.__class__, 'dirties_db') or
self.__class__.dirties_db:
print "Cleaning db"
call_command('flush', verbosity=0, interactive=False)
if hasattr(self, 'fixtures'):
# We have to use this slightly awkward syntax due to the fact
# that we're using *args and **kwargs together.
call_command('loaddata', *self.fixtures, **{'verbosity': 0})
if hasattr(self.__class__, 'dirties_db'):
self.__class__.dirties_db = True
if hasattr(self, 'urls'):
self._old_root_urlconf = settings.ROOT_URLCONF
settings.ROOT_URLCONF = self.urls
clear_url_caches()
mail.outbox = []

So, to use this, add a class attribute dirties_db = True to your own
subclass of MyTestCase. In any test methods that don't dirty the db,
add:

MyTestCaseSubclass.dirties_db = False

and the next test method that's run in that class won't bother to
flush and repopulate the database. To be explicit, you can set

MyTestCaseSubclass.dirties_db = True

in methods that dirty the database, but if you forget to explicitly
set the value to False, it will be True and the db will be cleaned.

Just trying it on some model and request/response tests, I got a
speed-up from nearly a minute to less than 20 seconds for 13 tests.

So, what am I missing? I know this doesn't deal with doctests--the db
gets cleaned for all of those, but does anyone see when this is just
going to blow up in my face?

Thanks,
Todd

--~--~-~--~~~---~--~~
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: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers

On 6 jan, 19:45, Ben Eliott  wrote:
> Not that pretty/efficient but you could use contenttype contrib
> temporarily.
> IF ClassB has a ForeignKey to Class A could you extract the Class A
> model from  a foreign key via Class B's  .meta?
> Or the Class B could have a callable method which returned the
> instance of the model you want...
> Not sure whether/how these will work but just throwing out some ideas.
>

This looks to me like dirty hacks that only add accidental complexity
instead of adressing the real problem. At least importing within a
method is a simple, well-known and idiomatic solution to circular
imports. The "correct" solution would be to turn models.py into a
package, split its content in submodules (with class A and B in
distinct submodules, each with their own manager), and use the
package's __init__.py to expose the submodule's Model classes at the
top-level, but IIRC this doesn't work well in Django (never had that
problem FWIW, since I tend to split my projects into a lot of small
apps).


--~--~-~--~~~---~--~~
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: Comments Framework and Authentication

2009-01-06 Thread Tim

OK - this was more or less resolved by following the advice here:
http://tinyurl.com/63rd76 This allowed me to essentially check for
valid comment deletion permissions before forwarding to the main
comment delete view. The only difference was my wrapper view; I
checked if the currently-logged-in user was the commenter, commentee
or staff before forwarding to the view.

On Jan 5, 11:01 am, Tim  wrote:
> Maybe a little brevity is in order - how do I grant temporary
> privileges to a user to delete a comment rather than keeping that
> power fully in the hands of a comments moderator?
>
> - Tim
>
> On Jan 3, 7:23 pm, Tim  wrote:
>
> > Hi all -
>
> > I am having a bit of difficulty with the Django comments framework -
> > more specifically, dealing with comment modifications by site users as
> > well as moderators.
>
> > Basically, I have a site in which users can post comments (using the
> > out-of-the-box commenting framework). I'd like to have a flexible
> > comment deletion environment in which comments could be deleted by the
> > user associated with the model attached to the comment or the original
> > poster of the comment - e.g., for a blog posting, I'd like the blog
> > writer to be able to delete inappropriate or offensive comments, but
> > I'd also like the commenter to be able to delete a comment they made
> > if they had second thoughts about it.
>
> > The commenting framework supports basic permissions for a user to
> > moderate comments via the "perms.comment.can_delete" value. However, I
> > obviously don't want to grant this permission to every user; this
> > would mean a malicious user could just delete comments at will whether
> > they belonged to them or not. I believe it's possible to do all the
> > logic to find out if a user is allowed to delete a comment in a custom
> > view and then forward the request to the official deletion view - but
> > then I still run into the check if the user is authorized to delete
> > comments or not. I am really loath to change the core commenting code
> > itself. Is there a better way to do it?
>
> > Here's a quickly hacked together template that kind of shows what I'm
> > trying to do (along with all my debugging junk):
>
> > 
> >     {% if perms.comment.can_delete %}
> >         You can delete comments.
> >     {% else %}
> >         You cannot delete comments.
> >     {% endif %}
> >     {% ifequal comment.user_id user_profile_id %}
> >         ...display a button to delete...
> >     {% endifequal %}
> >     {% if my_page %}
> >         ...display a button to delete...
> >     {% endif %}
> > 
>
> > - Tim
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Issues with setting attrs and Media when creating my own widget

2009-01-06 Thread Adam Stein

I'm trying to subclass the Select widget, so that I can create an
editable scrolling list (done via JavaScript code that I found).

My entire class is as follows:

--Code--
from django import forms

class ComboBox(forms.Select):
class Media:
js = ("/js/wise/comboBox.js",)

def __init__(self, choices=()):
# Set up calls to the combo box JavaScript
attrs = {
"onFocus":  "return combo_focus(this);",
"onChange": "return combo_change(this);",
"onKeyDown":"return combo_keydown(this, event);",
"onKeyPress":   "return combo_keypress(this, event);",
"onKeyUp":  "return combo_keyup(this, event);",
"onClick":  "return combo_click(this, '');"
}

super(ComboBox, self).__init__(attrs, choices)
--Code--

The form that uses it looks like:

--Code--
class TestTargetForm(forms.Form):
# Family name
fname = forms.ModelChoiceField(
queryset=TargetFamily.objects.all(),
required = False,
label = "Family Name",
empty_label = "[Match All]",
widget = ComboBox
)
--Code--

Issue #1:

I figured out that I can add HTML attributes by setting the 'attrs'
variable.  Which means I only need to create __init__() and not
render().  That works fine except that I want to call a JavaScript
function with a string (the onClick attribute).

The single quotes get escaped.  How would you pass a string to a
JavaScript function using 'attrs'?

Issue #2:

The 'class Media' definition is being ignored when running through the
Django server.  I can import my class in python, instantiate the class,
and print the media:

python manage.py shell
>>> from share.widgets import ComboBox
>>> print ComboBox().media


but when I look at the web page source coming back from the Django
server, that  text isn't there.  Did I need to do
anything else?

I would appreciate any help either by example or pointers to examples or
docs.  I looked in the Django source and it looks like the admin stuff
sets Media just like I'm doing.  The Django doc page for Media also
shows an example that looks just like what I'm doing (doesn't mention
that I have to do anything else).

-- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


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



Django: creating formset is very slow

2009-01-06 Thread Kottiyath Nair
Hi all,
   My web application sends a medium size data grid (20 elements). I was
using formsets for the same.
   The issue I am facing is that the formset instantiation is very very
slow. I timed it and it is taking ~4-7 seconds for it to instantiate.
   Is there someway the speed can be increased?

There are no files sent. I am planning to, later.
The code:
logging.info('Start - %s' %time.clock())
DataFormSet = formset_factory(DataForm, extra=25)
logging.info('Formset Class created- %s' %time.clock())
formset = DataFormSet(request.POST, request.FILES)
logging.info('Created new formset- %s'%time.clock())

>From my logs:
2009-01-06 22:53:30,671 INFO Start - 0
2009-01-06 22:53:30,671 INFO Formset Class created- 0.000403403225829
2009-01-06 22:53:34,296 INFO Created new formset- 3.62182316468
  or later
2009-01-06 22:56:37,500 INFO Start - 186.836136716
2009-01-06 22:56:37,500 INFO Formset Class created- 186.836445135
2009-01-06 22:56:43,108 INFO Created new formset- 192.440754621


   Please note that I am running the whole thing under the django
development server in my laptop itself and not a server.

--~--~-~--~~~---~--~~
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: Recipe 534109: XML to Python data structure

2009-01-06 Thread Rock

Elementtree is now part of the python distribution. I am using it in a
Django app I created for a client to extract data from XML provided by
a web service. It works well but the documentation could be clearer.

On Jan 6, 9:27 am, "shi shaozhong"  wrote:
> I am reading in a xml from a web service.  I wish to find a Python
> script to turn the xml into a Python data array for further
> manipulation and to be saved in a .dbf file.
>
> Has anyone tried the following 
> script?http://code.activestate.com/recipes/534109/
>
> How do I use it?
>
> Regards.
>
> David
--~--~-~--~~~---~--~~
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: Circular imports between managers and models

2009-01-06 Thread Ben Eliott

Not that pretty/efficient but you could use contenttype contrib  
temporarily.
IF ClassB has a ForeignKey to Class A could you extract the Class A  
model from  a foreign key via Class B's  .meta?
Or the Class B could have a callable method which returned the  
instance of the model you want...
Not sure whether/how these will work but just throwing out some ideas.



On 6 Jan 2009, at 16:08, bruno desthuilliers wrote:

>
> on 6 jan, 14:54, Polat Tuzla  wrote:
> (snip)
>> The reason why I need to separate models and managers into different
>> files is that they have simply grown to thousands of lines.
>>
> It's indeed a very compelling reason !-)
>
> But (simple suggestion - I know nothing about your project...) don't
> you see it as a sign your app (django meaning) is getting a bit to
> big ? Perhaps refactoring it into a couple or more small apps would be
> a better move ? (once again, just my 2 cents...)
>
>
> >


--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Vitaly Babiy
Brain do you find it a little slow?

Vitaly Babiy


On Tue, Jan 6, 2009 at 12:00 PM, Brian  wrote:

>
> For Python/Django I tend to like Komodo's Editor, as I am a fan of
> auto-complete and $free.
> >
>

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



strip_tags in django admin issues

2009-01-06 Thread ChrisL

Hi everyone,

Been bashing against this one for a while now and am keen for
suggestions. I'm trying to apply custom validation to forms within
Django's default admin. First up, I want to strip out all html from a
Title field. Following the official documentation I have developed
this:



from django.contrib import admin
from django import forms
from django.utils.html import strip_tags
from queryclick.qc_news.models import *

#Custom Data Validation in the Admin Interface
class MyArticleAdminForm(forms.ModelForm):
class Meta:
model = Article

def clean_title(self):
#Remove all HTML, using strip_tags (import from 
django.utils.html
title = self.strip_tags('title')
#Always return cleaned data
return self.cleaned_data["title"]

class ArticleAdmin(admin.ModelAdmin):
list_display = ('title', 'client', 'submitted_date', 'edited_date',
'go_live_date')
list_filter = ('client', 'submitted_date', 'edited_date',
'go_live_date')
ordering = ('-submitted_date',)
search_fields = ('title','client',)
form = MyArticleAdminForm

admin.site.register(Copywriter)
admin.site.register(Client)
admin.site.register(Article, ArticleAdmin)



But get an Attribute Error: 'ArticleForm' object has no attribute
'strip_tags' from line 13:

title = self.strip_tags('title')

Any and all suggestions warmly welcomed!



--~--~-~--~~~---~--~~
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: Recipe 534109: XML to Python data structure

2009-01-06 Thread Ben Eliott

Perhaps try:
http://www.crummy.com/software/BeautifulSoup/
is awesome and has good documentation

On 6 Jan 2009, at 15:27, shi shaozhong wrote:

>
> I am reading in a xml from a web service.  I wish to find a Python
> script to turn the xml into a Python data array for further
> manipulation and to be saved in a .dbf file.
>
> Has anyone tried the following script?
> http://code.activestate.com/recipes/534109/
>
> How do I use it?
>
> Regards.
>
> David
>
> >


--~--~-~--~~~---~--~~
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: autodiscover not being called? why?

2009-01-06 Thread bongo


> In your application directory, the one created by manage.py startapp, same
> as where models.py is.

Thanks.

Thats what I thought I should put it. This is getting weirder though.
Even though I got autodiscover working it still couldn't find it. I
then decided to go with the manual method of subclassing the admin app
and manually wiring it in according to this blog.

http://oebfare.com/blog/2008/jul/20/newforms-admin-migration-and-screencast/

It still didn't work but now with an import name error.

Its seems that when I renamed the module from admin.py to
adrem_admin.py it worked without an import error!

This is crazy but it simply didn't like the module being called
admin.py!! What is going on? A naming conflict with something in my
python installation?  I assume it was trying to load the site
attribute from another module called admin somewhere.. ouch! How can I
find out what it was really finding?

This has been driving me crazy for days. I now have a manual
workaround but it means the autodiscover will never work for me..  I
need to eliminate the real problem if I am ever to use autodiscover.

--~--~-~--~~~---~--~~
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: strip_tags in django admin issues

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 12:14 PM, ChrisL <1angryc...@googlemail.com>wrote:

>
> Hi everyone,
>
> Been bashing against this one for a while now and am keen for
> suggestions. I'm trying to apply custom validation to forms within
> Django's default admin. First up, I want to strip out all html from a
> Title field. Following the official documentation I have developed
> this:
>
> 
>
> from django.contrib import admin
> from django import forms
> from django.utils.html import strip_tags
> from queryclick.qc_news.models import *
>
> #Custom Data Validation in the Admin Interface
> class MyArticleAdminForm(forms.ModelForm):
>class Meta:
>model = Article
>
>def clean_title(self):
>#Remove all HTML, using strip_tags (import from
> django.utils.html
>title = self.strip_tags('title')
>#Always return cleaned data
>return self.cleaned_data["title"]
>
> class ArticleAdmin(admin.ModelAdmin):
>list_display = ('title', 'client', 'submitted_date', 'edited_date',
> 'go_live_date')
>list_filter = ('client', 'submitted_date', 'edited_date',
> 'go_live_date')
>ordering = ('-submitted_date',)
>search_fields = ('title','client',)
>form = MyArticleAdminForm
>
> admin.site.register(Copywriter)
> admin.site.register(Client)
> admin.site.register(Article, ArticleAdmin)
>
> 
>
> But get an Attribute Error: 'ArticleForm' object has no attribute
> 'strip_tags' from line 13:
>
> title = self.strip_tags('title')
>
> Any and all suggestions warmly welcomed!
>
>
You could try:

return strip_tags(self.cleaned_data['title'])

though I have no knowledge of what that function does so I'm just assuming
it does what you want.

There are several things wrong with what you have: first, stirp_tags is a
simple function, not an object method, and not a method of ArticleForm
(hence the error when you try to call it via self.strip_tags).  Passing in
'title' will cause it to operate on the literal string 'title', whereas if
you want it to operate on the data that has been posted in the form, you
need to pass in self.cleaned_data['title'].  You assign what it turns to the
variable title but then you go ahead and return the original
self.cleaned_data['title'] that you have not modified, so even if you did
not get the error you are seeing, your clean function as written would
simply return what had been included in the form.

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: Changing tutorial radio button to drop down

2009-01-06 Thread Max

Thanks!! It works now!

Max


--~--~-~--~~~---~--~~
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: strip_tags in django admin issues

2009-01-06 Thread Alex Koshelev

Form class really doesn't have `strip_tags` method. I think you are
interested in `strip_tags` functon from `django.utils.html`(and your
comment says the same). So your method may look like this:

def clean_title(self):
   from django.utils.html import strip_tags
   title = strip_tags(self.cleaned_data["title"])
   return title


On Tue, Jan 6, 2009 at 8:14 PM, ChrisL <1angryc...@googlemail.com> wrote:
>
> Hi everyone,
>
> Been bashing against this one for a while now and am keen for
> suggestions. I'm trying to apply custom validation to forms within
> Django's default admin. First up, I want to strip out all html from a
> Title field. Following the official documentation I have developed
> this:
>
> 
>
> from django.contrib import admin
> from django import forms
> from django.utils.html import strip_tags
> from queryclick.qc_news.models import *
>
> #Custom Data Validation in the Admin Interface
> class MyArticleAdminForm(forms.ModelForm):
>class Meta:
>model = Article
>
>def clean_title(self):
>#Remove all HTML, using strip_tags (import from 
> django.utils.html
>title = self.strip_tags('title')
>#Always return cleaned data
>return self.cleaned_data["title"]
>
> class ArticleAdmin(admin.ModelAdmin):
>list_display = ('title', 'client', 'submitted_date', 'edited_date',
> 'go_live_date')
>list_filter = ('client', 'submitted_date', 'edited_date',
> 'go_live_date')
>ordering = ('-submitted_date',)
>search_fields = ('title','client',)
>form = MyArticleAdminForm
>
> admin.site.register(Copywriter)
> admin.site.register(Client)
> admin.site.register(Article, ArticleAdmin)
>
> 
>
> But get an Attribute Error: 'ArticleForm' object has no attribute
> 'strip_tags' from line 13:
>
> title = self.strip_tags('title')
>
> Any and all suggestions warmly welcomed!
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Changing tutorial radio button to drop down

2009-01-06 Thread Daniel Roseman

On Jan 6, 12:20 pm, Max  wrote:
> Hello,
>
> Using the tutorial for detail.view, I changed the radio button to a
> drop down.  I kept the view the same as the tutorial.  
> Seehttp://dpaste.com/106018/
>
> When I select the choice on the drop down, I receive the error saying
> I didn't make a choice.   I have a mistake in either the drop down
> code or I need to change the view.
>
> Can someone help?
>
> Thanks,
>
> Max

The problem is in your template. Specifically, line 7:

At this point, you don't have a variable called 'choice', as you don't
set that until the for loop in the next line. If you look at your
rendered HTML (do View Source within the browser), you'll see that
this will probably just give you this markup:

So, obviously, there's nothing to link the selected value with any key
in the POST dictionary.

Instead, you probably want this:

Note that you should really set a name as well as the id - that's the
best way of referring to form fields.

However, I have to say that the tutorial doesn't really give you the
best way of doing things here. Django has a great built-in forms
framework, which allows you to do the same thing in far less code and
much more 'Djangonically' (is that the right word?) and this bypasses
it completely. Unfortunately, the tutorial doesn't cover the forms
framework - although it is very well documented here:
http://docs.djangoproject.com/en/dev/topics/forms/

--
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: Changing tutorial radio button to drop down

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 12:20 PM, Max  wrote:

>
> Hello,
>
> Using the tutorial for detail.view, I changed the radio button to a
> drop down.  I kept the view the same as the tutorial.  See
> http://dpaste.com/106018/
>
> When I select the choice on the drop down, I receive the error saying
> I didn't make a choice.   I have a mistake in either the drop down
> code or I need to change the view.
>
> Can someone help?
>

You didn't put a name on the select element, thus its value is not included
when the form is posted:

http://www.w3schools.com/TAGS/att_select_name.asp

You are also setting the id to choice.id before you have set choice to
anything, so id will be blank I believe.

Note if you use Django forms:

http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index

you may spare yourself from having to hand-write a lot of this form stuff.
 (Though it is good to learn some basics of it anyway.)

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



Changing tutorial radio button to drop down

2009-01-06 Thread Max

Hello,

Using the tutorial for detail.view, I changed the radio button to a
drop down.  I kept the view the same as the tutorial.  See
http://dpaste.com/106018/

When I select the choice on the drop down, I receive the error saying
I didn't make a choice.   I have a mistake in either the drop down
code or I need to change the view.

Can someone help?

Thanks,

Max
--~--~-~--~~~---~--~~
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: Performance of include tag

2009-01-06 Thread Michał Moroz

On 2 Sty, 16:12, Rajesh Dhawan  wrote:

> Here's another way to solve this: Add a rendered_version field to your
> Message model and populate it at the time that the message is saved
> (perhaps by overriding the Message.save method). This way, you would
> just need to write  {{ message.rendered_version|safe }} in your
> dashboard's template loop and anywhere else you want to render that
> message.

Thanks - this method seems more reasonable than the concept of cached
templates.

> One drawback of this method is that if you want old messages to be
> rendered with updated templates, it's not straightforward. Hopefully,
> your use cases don't call for that.

For debug purposes I added template inclusion so that I can make quick
changes without rebuilding messages every time. In production
environment it will be necessary to rebuild them after template code
has changed, but codebase updates aren't a thing you do fifty times at
a day.

Michael
--~--~-~--~~~---~--~~
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: autodiscover not being called? why?

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 9:43 AM, bongo  wrote:

>
> Thanks. It is still not working but probably for another reason (maybe
> I have put the admin.py in wrong directory or something).
>
> Your tip of deleting all the pyc files now results in "Discovered!"
> being printed so I think autodiscover is actually being run now. Its
> strange but I thought modifying the urls.py source would cause a new
> pyc file to be created. I wonder why does that not happen?
>

No idea.


>
> Where does the new autodiscover actually look for relevant admin.py
> files?
>

In your application directory, the one created by manage.py startapp, same
as where models.py is.

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: Installing Django 1.0.2...

2009-01-06 Thread Karen Tracey
On Tue, Jan 6, 2009 at 7:16 AM, Jay  wrote:

>
> Karen, thanks for your comments, you are right.
> However, it turns out that the file "...\Django-1.0.2-final\django
> \utils\__init__.py" has size 0, and it seems when using winzip ( I
> just realized why 7-zip may have been required for unzipping), the 0
> size file is *not*  written out. In fact "viewing" the file causes an
> error (at least on my version winzip 7.0 SR-1). The simple work around
> is to create an empty file named __init__.py in "...\Django-1.0.2-final
> \django\utils".
>
> Now the command "setup.py install" works just fine.
>

Be aware there are many more 0-byte __init__.py files in the django
tarball.  Any tool that doesn't correctly extract them is probably not
something you want to be using.  These files are common in any Python-based
project.

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: IOError: request data read error

2009-01-06 Thread Chunlei Wu

Thanks a lot Graham. I will upgrade my modwsgi to v2.3. Looking
forward to the v3.0 to see if the fix on issue #29 will fix my problem
as well.

Chunlei

On Jan 5, 3:40 pm, Graham Dumpleton 
wrote:
> On Jan 6, 4:41 am, Chunlei  Wu  wrote:
>
> > Hi,
>
> >        We have a web app running on Django 1.0 / modwsgi 2.0 / Apache
>
> Latest mod_wsgi is 2.3, you should really think about upgrading. :-)
>
> > 2.2.3. Sparsely, about 2~3 times a week, I receive emails about
> > IOError as below:
>
> > ...
> >   File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
> > core/handlers/wsgi.py", line 69, in safe_copyfileobj
> >     buf = fsrc.read(min(length, size))
>
> > IOError: request data read error
>
> > Mostly it happens on the root URL, but there is a case from other URL.
> > I suspect that it is related to the network connection problem, but I
> > can not re-produce it. Can anybody explain what  doe this error mean
> > exactly? Thanks.
>
> It means that low level Apache functions returned an error when trying
> to read request content.
>
> Unfortunately, the particular Apache function used to get the request
> content is one that effectively looses the even lower level Apache
> error number which would be useful in qualifying what caused the
> problem. In other words, the Apache function just says there was an
> error and not what it was. Technically some different set of Apache
> functions could be used to do the same thing, without loss of the
> error code when a problem does occur, but that is a bit trickier and
> involves more work. Changing how it is done might occur, but not soon.
>
> More than likely though, it is a variation on another error that can
> come back when reading request content as described in:
>
>  http://code.google.com/p/modwsgi/issues/detail?id=29
>
> That one can occur when user/client aborts the connection. This can
> occur when they are trigger happy on the reload button.
>
> To try and reproduce it, perhaps perform a file upload and before it
> has completed keep pressing the reload button for the page.
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Unable to login (cookies not enabled?)

2009-01-06 Thread Deniz Dogan

On 5 Jan, 11:41, Deniz Dogan  wrote:
> On 5 Jan, 10:47, Deniz Dogan  wrote:
>
>
>
> > Hi
>
> > I'm having trouble when using the AuthenticationForm in Django. It
> > tells me that I haven't enabled cookies, even though I'm completely
> > sure that I have. I get this error:
>
> > "Your Web browser doesn't appear to have cookies enabled. Cookies are
> > required for logging in."
>
> > I've tried restarting Django, the browser, tried several different
> > browsers, etc. I'm completely lost. I read somewhere that the login
> > view has to be called with a GET request before it's called with a
> > POST for this to work, but it *is* called with a GET to actually view
> > the login form in the first place.
>
> > Below is the login view that I'm using.
>
> > -
>
> > def user_login(request):
>
> >     if request.user.is_authenticated():
> >         return HttpResponseRedirect('/main/')
>
> >     if request.method == 'POST':
> >         form = AuthenticationForm(request.POST)
> >         if form.is_valid():
> >             login(request, form.get_user())
> >             return HttpResponseRedirect('/main/')
> >         else:
> >             return render_to_response('login.html', { 'form' : form })
>
> >     else:
> >         form = AuthenticationForm()
> >         return render_to_response('login.html', { 'form' : form })
>
> > -
>
> > Thanks,
> > Deniz
>
> I finally managed to help the problem by doing AuthenticationForm
> (None, request.POST). I have understood that None should represent the
> HTTPRequest object so that the form can validate that cookies have
> been enabled. Passing None bypasses this check, but is there any real
> danger in doing this?
>
> Thanks again,
> Deniz

I think I got it now, so if anyone has the same problem, this is what
happens...

When the user first reaches the actual login page (by HTTP GET), you
must call request.session.set_test_cookie() which will help
AuthenticationForm later determine whether cookies are enabled on the
user's side. AuthenticationForm checks so that the test cookie has
been set in the POST request from the user and will raise
ValidationError if it's not. So to put it short, when the user reaches
the login page, do request.session.set_test_cookie(), otherwise you
cannot properly test if cookies have been enabled. Of course, if you
don't care if the user has enabled cookies (for whatever reason that
may be), you can just pass None as the first parameter to the
constructor.

Deniz
--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Brian

For Python/Django I tend to like Komodo's Editor, as I am a fan of
auto-complete and $free.
--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Vitaly Babiy
I use Gedit in gnome and some plugins
Works well.

Vitaly Babiy


On Tue, Jan 6, 2009 at 11:45 AM, Santiago wrote:

>
> i recently switched to screen + vim with omnicomplete for python and
> html...
>
> komodo edit its pretty good too
>
> 2009/1/7 martyn :
> >
> > Hi
> >
> > http://pyrox.utp.edu.co/
> >
> > Regards
> >
> > Bye.
> >
> > On Jan 6, 9:34 am, roberto  wrote:
> >> I tried them all (almost ... I think... at least the free ones).
> >> - Pyscripter is really nice but it is true, it is only for windows.
> >> (If it is developed with python it should be platform-independent,
> >> shouldn' be ?) (no support for sql queries I think)
> >> - Eclipse + PyDev (no good support for sql queries to relational db)
> >> - Ulipad (open source / excellent / very small / some issues with
> >> svn / no support for sql queries to db - django plugin to highlight
> >> templates, etc)
> >> - Netbeans (ex-NBPython) it is excellent (very good sql support - some
> >> issues with memory consume - I didn't get debugger work 100% with
> >> django)
> >> - Oracle jdeveloper. it is an excellent tool. Its support for python
> >> is still too new and I think that django support is still to come.
> >> - Eric4: screenshots are very beautiful bu I couldn't get to install
> >> it in my ubuntu box (too many precedences and too complicated for a
> >> newbie like me).
> >>
> >> Have a great year 2009 everyone !
> >>
> >> On Jan 6, 9:02 am, "Trivedi, Apaar"  wrote:
> >>
> >> > I use Eclipse with PyDev and PyDev extensions.  I really like it, but
> I
> >> > prefer the eclipse sort of IDE's.
> >>
> >> > 
> >>
> >> > From: django-users@googlegroups.com
> >> > [mailto:django-us...@googlegroups.com] On Behalf Of Damien Hou
> >> > Sent: Tuesday, January 06, 2009 8:43 AM
> >> > To: django-users@googlegroups.com
> >> > Subject: Re: Your IDE of choice
> >>
> >> > TextMate with Django and Django Templates bundles is pretty neat
> >>
> >> > On Tue, Jan 6, 2009 at 7:48 PM, HB  wrote:
> >>
> >> > Hey,
> >> > What is your favorite IDE for coding Django projects?
> >> > Any ideas about PyDev and ActiveState Komodo IDE?
> >> > Thanks.
> >>
> >> > --
> >> > Best Regards,
> >> > Damien
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread Santiago

i recently switched to screen + vim with omnicomplete for python and html...

komodo edit its pretty good too

2009/1/7 martyn :
>
> Hi
>
> http://pyrox.utp.edu.co/
>
> Regards
>
> Bye.
>
> On Jan 6, 9:34 am, roberto  wrote:
>> I tried them all (almost ... I think... at least the free ones).
>> - Pyscripter is really nice but it is true, it is only for windows.
>> (If it is developed with python it should be platform-independent,
>> shouldn' be ?) (no support for sql queries I think)
>> - Eclipse + PyDev (no good support for sql queries to relational db)
>> - Ulipad (open source / excellent / very small / some issues with
>> svn / no support for sql queries to db - django plugin to highlight
>> templates, etc)
>> - Netbeans (ex-NBPython) it is excellent (very good sql support - some
>> issues with memory consume - I didn't get debugger work 100% with
>> django)
>> - Oracle jdeveloper. it is an excellent tool. Its support for python
>> is still too new and I think that django support is still to come.
>> - Eric4: screenshots are very beautiful bu I couldn't get to install
>> it in my ubuntu box (too many precedences and too complicated for a
>> newbie like me).
>>
>> Have a great year 2009 everyone !
>>
>> On Jan 6, 9:02 am, "Trivedi, Apaar"  wrote:
>>
>> > I use Eclipse with PyDev and PyDev extensions.  I really like it, but I
>> > prefer the eclipse sort of IDE's.
>>
>> > 
>>
>> > From: django-users@googlegroups.com
>> > [mailto:django-us...@googlegroups.com] On Behalf Of Damien Hou
>> > Sent: Tuesday, January 06, 2009 8:43 AM
>> > To: django-users@googlegroups.com
>> > Subject: Re: Your IDE of choice
>>
>> > TextMate with Django and Django Templates bundles is pretty neat
>>
>> > On Tue, Jan 6, 2009 at 7:48 PM, HB  wrote:
>>
>> > Hey,
>> > What is your favorite IDE for coding Django projects?
>> > Any ideas about PyDev and ActiveState Komodo IDE?
>> > Thanks.
>>
>> > --
>> > Best Regards,
>> > Damien
> >
>

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



django-tagging help

2009-01-06 Thread nbv4

I have django-tagging installed and working fine. I have a model
called Plane, which has a few hundred objects in the database, almost
all of them with at least one tag. The tagging_tag, and the
tagging_taggeditem table in my database looks fine. All the tags are
listed there correctly. When I look at the table for the Plane model,
the tag field looks like this "tag1, tag2, tag3", yet when I try to
use the tagging utilities to get all tags for an object, this code
returns an empty list:

TaggedItem.objects.get_by_model(Plane.objects.get(pk=1), "tag2")

but this code returns what I would expect:

TaggedItem.objects.get_by_model(Plane.objects.get(pk=1), ", tag2")

How can I fix this? I want it to ignore the space and the comma. If I
change the tag field to "tag1,tag2,tag3", it works fine, but for ease
of reading, I'd like to have the space there. Is this possible with
django-tagging?
--~--~-~--~~~---~--~~
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: Shouldn't blank=True imply null=True?

2009-01-06 Thread tofergus

On 06.01-08:03, dchandek wrote:
> [ ... ]   But shouldn't this be addressed in the
> validation code?

ps: no, the validation code would exist as it currently does.  i am
only suggesting a change in convention, not the actual options or
their meanings.

--~--~-~--~~~---~--~~
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: Shouldn't blank=True imply null=True?

2009-01-06 Thread tofergus

On 06.01-08:03, dchandek wrote:
[ ... ]
>> i would be against unifying the options as i can imagine a more complex
>> environment (i.e. a database trigger or complex type not known to
>> django) where there may be a distinction and i believe the current
>> distinction is a clear one.  it may be worthwile to imply that setting
>> 'null=True' also sets 'blank=True' unless explictly overridden with
>> 'blank=False'.  however, the converse implication is faulty (i.e.
>> 'blank=True' != 'null=True') because 'blank' relates to the admin
>> interface, whereas 'null' refers to the data model.  it is correct to
>> imply the interface and formatting from the data model but not to
>> imply the data contraints from the interface. IMHO.
> 
> The only gotcha I've encountered here is that practically speaking
> null=True requires blank=True. I'm not sure I'd want that setting to
> be automatic, though. It seems silly, for example, to have to set
> blank=True in order for a non-value in a ForeignKey to validate, since
> a blank value makes no sense. But shouldn't this be addressed in the
> validation code?

i believe we are in agreement here but perhaps i may not be explaining
myself sufficiently.  you shouldn't set 'blank=True', you would set
'null=True'.  this would (by default only) set 'blank=True' such that
the validation would allow it to be blank as well as 'null'.  a user
could of course override this to set 'blank=False' if they desired.

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



autodiscover does not find my admin.py

2009-01-06 Thread bongo

After upgrading old django 0.96 app to 1.0.2 and now using the new
admin method I cannot get autodiscover to actually discover my new
admin.py

I have put print statements in my admin.py to check whether its
getting called.

What could be going on? I can't see anything I am doing that differs
from the documentation.


--~--~-~--~~~---~--~~
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: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers

on 6 jan, 14:54, Polat Tuzla  wrote:
(snip)
> The reason why I need to separate models and managers into different
> files is that they have simply grown to thousands of lines.
>
It's indeed a very compelling reason !-)

But (simple suggestion - I know nothing about your project...) don't
you see it as a sign your app (django meaning) is getting a bit to
big ? Perhaps refactoring it into a couple or more small apps would be
a better move ? (once again, just my 2 cents...)


--~--~-~--~~~---~--~~
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: Shouldn't blank=True imply null=True?

2009-01-06 Thread dchandek

> i would be against unifying the options as i can imagine a more complex
> environment (i.e. a database trigger or complex type not known to
> django) where there may be a distinction and i believe the current
> distinction is a clear one.  it may be worthwile to imply that setting
> 'null=True' also sets 'blank=True' unless explictly overridden with
> 'blank=False'.  however, the converse implication is faulty (i.e.
> 'blank=True' != 'null=True') because 'blank' relates to the admin
> interface, whereas 'null' refers to the data model.  it is correct to
> imply the interface and formatting from the data model but not to
> imply the data contraints from the interface. IMHO.

The only gotcha I've encountered here is that practically speaking
null=True requires blank=True. I'm not sure I'd want that setting to
be automatic, though. It seems silly, for example, to have to set
blank=True in order for a non-value in a ForeignKey to validate, since
a blank value makes no sense. But shouldn't this be addressed in the
validation code?

--David
--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread martyn

Hi

http://pyrox.utp.edu.co/

Regards

Bye.

On Jan 6, 9:34 am, roberto  wrote:
> I tried them all (almost ... I think... at least the free ones).
> - Pyscripter is really nice but it is true, it is only for windows.
> (If it is developed with python it should be platform-independent,
> shouldn' be ?) (no support for sql queries I think)
> - Eclipse + PyDev (no good support for sql queries to relational db)
> - Ulipad (open source / excellent / very small / some issues with
> svn / no support for sql queries to db - django plugin to highlight
> templates, etc)
> - Netbeans (ex-NBPython) it is excellent (very good sql support - some
> issues with memory consume - I didn't get debugger work 100% with
> django)
> - Oracle jdeveloper. it is an excellent tool. Its support for python
> is still too new and I think that django support is still to come.
> - Eric4: screenshots are very beautiful bu I couldn't get to install
> it in my ubuntu box (too many precedences and too complicated for a
> newbie like me).
>
> Have a great year 2009 everyone !
>
> On Jan 6, 9:02 am, "Trivedi, Apaar"  wrote:
>
> > I use Eclipse with PyDev and PyDev extensions.  I really like it, but I
> > prefer the eclipse sort of IDE's.
>
> > 
>
> > From: django-users@googlegroups.com
> > [mailto:django-us...@googlegroups.com] On Behalf Of Damien Hou
> > Sent: Tuesday, January 06, 2009 8:43 AM
> > To: django-users@googlegroups.com
> > Subject: Re: Your IDE of choice
>
> > TextMate with Django and Django Templates bundles is pretty neat
>
> > On Tue, Jan 6, 2009 at 7:48 PM, HB  wrote:
>
> > Hey,
> > What is your favorite IDE for coding Django projects?
> > Any ideas about PyDev and ActiveState Komodo IDE?
> > Thanks.
>
> > --
> > Best Regards,
> > Damien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Recipe 534109: XML to Python data structure

2009-01-06 Thread shi shaozhong

I am reading in a xml from a web service.  I wish to find a Python
script to turn the xml into a Python data array for further
manipulation and to be saved in a .dbf file.

Has anyone tried the following script?
http://code.activestate.com/recipes/534109/

How do I use it?

Regards.

David

--~--~-~--~~~---~--~~
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: Shouldn't blank=True imply null=True?

2009-01-06 Thread tofergus

On 06.01-07:38, Lee Braiden wrote:
[ ... ]
> On Tue, 2009-01-06 at 00:05 -0700, Jeff Anderson wrote:
> > Malcolm Tredinnick wrote:
> > > I don't think we'd want to get too subtle here. Either it makes
> > > sense for all non-text fields, or it doesn't.
> > Agreed I simply haven't spent any time thinking about this particular
> > problem in respect to any field other than an IntegerField. I can't
> > think of any non-text field that it may not make sense with.

i would be against unifying the options as i can imagine a more complex
environment (i.e. a database trigger or complex type not known to
django) where there may be a distinction and i believe the current
distinction is a clear one.  it may be worthwile to imply that setting
'null=True' also sets 'blank=True' unless explictly overridden with
'blank=False'.  however, the converse implication is faulty (i.e.
'blank=True' != 'null=True') because 'blank' relates to the admin
interface, whereas 'null' refers to the data model.  it is correct to
imply the interface and formatting from the data model but not to
imply the data contraints from the interface. IMHO.

--~--~-~--~~~---~--~~
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: Newb needs help with tracking variables in Templates

2009-01-06 Thread junker37

Yep, reading the documentation helps ;).

But here's how your code should look:


{% for art in my_art_list %}
{% cycle '' '' '' %}



{% cylce '' '' '' %}
   {% empty %}
You have no art pieces to view.  Would you like to add some?

   {% endfor %}


Assuming you are using a version of django that has support for the
for...empty tag, I'm not sure when that came about.  But the cycle tag
is what you want.
On Jan 5, 4:39 pm, "django_fo...@codechimp.net" 
wrote:
> I have a pretty simple template that needs to print some data in a
> bunch of table rows.  I have done something like this:
>
> 
> {% if my_art_list %}
>         {% count = 0 %}
>         {% for art in my_art_list %}
>                 {% if count%3 = 0 %}
>                 
>                 {% endif %}
>                         
>                                 
>                         
>                 {% if count%3 = 2 %}
>                 
>                 {% endif %}
>         {% endfor %}
>         
> {% else %}
>         You have no art pieces to view.  Would you like to add some?
> {% endif %}
> 
>
> However, as you probably suspect, the "count" variables cause all
> sorts of trouble.  Is there a way to have tracking variables in the
> template code?  I was under the impression that the {%  %} tags were
> just straight Python code and would execute as such, but apparently my
> understanding is a little less than adequate.
>
> Please help me sort this out...

--~--~-~--~~~---~--~~
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: autodiscover not being called? why?

2009-01-06 Thread bongo

Thanks. It is still not working but probably for another reason (maybe
I have put the admin.py in wrong directory or something).

Your tip of deleting all the pyc files now results in "Discovered!"
being printed so I think autodiscover is actually being run now. Its
strange but I thought modifying the urls.py source would cause a new
pyc file to be created. I wonder why does that not happen?

Where does the new autodiscover actually look for relevant admin.py
files?

On Jan 6, 2:31 pm, "Valts Mazurs"  wrote:
> 1. Check your settings.py if it uses the correct urls.py file. Actually at
> first check if the correct settings.py is being used
> 2. Remove .pyc and pyo files from your project's directory to be sure that
> python interpreter really takes into account changes in source files.
>
> Regards,
> --
> Valts
>
> On Tue, Jan 6, 2009 at 15:36, bongo  wrote:
>
> > I am in the process of upgrading an old django 0.96 application to
> > 1.0.2 final.
>
> > I am having real trouble getting the admin app to run with my models
> > included with the new method. After some trial an error it seems that
> > autodiscover is never being called at all in my urls.py. However, the
> > url mappings are working. Any one got an idea as to why django might
> > not be running autodiscover?
>
> > from django.contrib import admin
>
> > admin.autodiscover()
> > print "Discovered!"
>
> > urlpatterns = patterns('',
> >    (r'^admin/(.*)', admin.site.root),
> > 
>
> > Thanks
> > John
--~--~-~--~~~---~--~~
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: Your IDE of choice

2009-01-06 Thread roberto

I tried them all (almost ... I think... at least the free ones).
- Pyscripter is really nice but it is true, it is only for windows.
(If it is developed with python it should be platform-independent,
shouldn' be ?) (no support for sql queries I think)
- Eclipse + PyDev (no good support for sql queries to relational db)
- Ulipad (open source / excellent / very small / some issues with
svn / no support for sql queries to db - django plugin to highlight
templates, etc)
- Netbeans (ex-NBPython) it is excellent (very good sql support - some
issues with memory consume - I didn't get debugger work 100% with
django)
- Oracle jdeveloper. it is an excellent tool. Its support for python
is still too new and I think that django support is still to come.
- Eric4: screenshots are very beautiful bu I couldn't get to install
it in my ubuntu box (too many precedences and too complicated for a
newbie like me).

Have a great year 2009 everyone !

On Jan 6, 9:02 am, "Trivedi, Apaar"  wrote:
> I use Eclipse with PyDev and PyDev extensions.  I really like it, but I
> prefer the eclipse sort of IDE's.
>
> 
>
> From: django-users@googlegroups.com
> [mailto:django-us...@googlegroups.com] On Behalf Of Damien Hou
> Sent: Tuesday, January 06, 2009 8:43 AM
> To: django-users@googlegroups.com
> Subject: Re: Your IDE of choice
>
> TextMate with Django and Django Templates bundles is pretty neat
>
> On Tue, Jan 6, 2009 at 7:48 PM, HB  wrote:
>
> Hey,
> What is your favorite IDE for coding Django projects?
> Any ideas about PyDev and ActiveState Komodo IDE?
> Thanks.
>
> --
> Best Regards,
> Damien
--~--~-~--~~~---~--~~
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: Distinct users ordered by remote field

2009-01-06 Thread coan



On Jan 6, 12:22 am, Malcolm Tredinnick 
wrote:

> Right now, with trunk or Django 1.0, it's not particularly easy without
> using custom SQL or extra().

Ok! Thanks for clearing that up for me, I'll filter it manually.
--~--~-~--~~~---~--~~
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: autodiscover not being called? why?

2009-01-06 Thread Valts Mazurs
1. Check your settings.py if it uses the correct urls.py file. Actually at
first check if the correct settings.py is being used
2. Remove .pyc and pyo files from your project's directory to be sure that
python interpreter really takes into account changes in source files.

Regards,
--
Valts


On Tue, Jan 6, 2009 at 15:36, bongo  wrote:

>
> I am in the process of upgrading an old django 0.96 application to
> 1.0.2 final.
>
> I am having real trouble getting the admin app to run with my models
> included with the new method. After some trial an error it seems that
> autodiscover is never being called at all in my urls.py. However, the
> url mappings are working. Any one got an idea as to why django might
> not be running autodiscover?
>
> from django.contrib import admin
>
> admin.autodiscover()
> print "Discovered!"
>
> urlpatterns = patterns('',
>(r'^admin/(.*)', admin.site.root),
> 
>
>
> Thanks
> John
>
>
> >
>

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



autodiscover not being called? why?

2009-01-06 Thread bongo

I am in the process of upgrading an old django 0.96 application to
1.0.2 final.

I am having real trouble getting the admin app to run with my models
included with the new method. After some trial an error it seems that
autodiscover is never being called at all in my urls.py. However, the
url mappings are working. Any one got an idea as to why django might
not be running autodiscover?

from django.contrib import admin

admin.autodiscover()
print "Discovered!"

urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),



Thanks
John


--~--~-~--~~~---~--~~
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: Installing Django 1.0.2...

2009-01-06 Thread Jay

Karen, thanks for your comments, you are right.
However, it turns out that the file "...\Django-1.0.2-final\django
\utils\__init__.py" has size 0, and it seems when using winzip ( I
just realized why 7-zip may have been required for unzipping), the 0
size file is *not*  written out. In fact "viewing" the file causes an
error (at least on my version winzip 7.0 SR-1). The simple work around
is to create an empty file named __init__.py in "...\Django-1.0.2-final
\django\utils".

Now the command "setup.py install" works just fine.

Jay

On Dec 31 2008, 9:14 am, "Karen Tracey"  wrote:
> On Wed, Dec 31, 2008 at 3:36 AM, mic  wrote:
>
> > I am a first time python/django user
>
> > running "python setup.py install" gives me this error
>
> > Traceback (most recent call last):
> >  File "setup.py", line 69, in 
> >    version = __import__('django').get_version()
> >  File "C:\Django-1.0.2-final\django\__init__.py", line 13, in
> > get_version
> >    from django.utils.version import get_svn_revision
> > ImportError: No module named utils.version
>
> > Any help is appreciated.
>
> > Thanks for the help.
>
> That's odd. Do you have the files:
>
> C:\Django-1.0.2-final\django\utils\__init__.py
> C:\Django-1.0.2-final\django\utils\version.py
>
> If not, something has gone wrong with unpacking the 1.0.2 tarfile because
> those files are in it.
>
> If you do have those files, what version of Python are you using?
>
> 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: Circular imports between managers and models

2009-01-06 Thread Polat Tuzla

Yes, indeed! It's the models.Manager I'm talking about.
I tried to keep my example short and easily comprehensible without
code snippets, but i think I've achieved the opposite.
Sorry for any inconvenience.

Polat Tuzla

On Jan 6, 3:37 pm, bruno desthuilliers 
wrote:
> On 6 jan, 14:08, Lee Braiden  wrote:
>
>
>
> > On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote:
> > > Hi,
> > > Suppose I have two classes in "models.py", namely A and B. And there
> > > is the manager for B as BManager in "managers.py". BManager makes use
> > > of clas A.
>
> > > This situation leads to circular imports between "managers.py" and
> > > "models.py" for which I can't find a solution.
>
> > > Assuming that I need to separate models and manager into different
> > > files, so merging them is not an option, are there any best practices
> > > or do you have any other suggestions?
>
> > No expert on Django, and it's hard to tell what your GOAL is from this
> > description, but you might want I'd write something like this:
>
> > class Employee(models.Model):
> >         name = models.CharField(...)
>
> > class Manager(Employee):
> >         manager_stuff...
>
> I think the OP is talking about 
> models.Managers:http://docs.djangoproject.com/en/dev/topics/db/managers/
>
> !-)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >