Free Comments problem...

2008-07-02 Thread [EMAIL PROTECTED]

I'm trying to use Free Comments, but coming up against a problem
displaying the form. I've followed the tutorial at djangoproject.com
(http://code.djangoproject.com/wiki/UsingFreeComment)

So I've done these things:

 - amended my urls.py to include: (r'^comments/',
include('django.contrib.comments.urls.comments')),
 - amended settings.py to include: 'django.contrib.comments', as an
installed app
 - run syncdb on this app
 - created the correct comments templates in my appname/templates/
comments/ directory
 - included {% load comments %} in my template
 - included {% free_comment_form for appname.entry object.id %}

...but the page still doesn't show a comments form.

I've been fiddling around with various things, checking syntax,
amending names, etc. for about 4-5 hours, with absolutely no results.
Searching the web for answers, it seems like everyone else has found
this so easy, there's no-one with simliar problemswhat's going
on!?!?!

I'm running Django 0.96.1 at the moment using the inbuilt dev server
(python manage.py runserver).

Many thanks for any help

Chris

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



Re: Tutorial method was_published_today() - problem

2008-07-02 Thread Collin Grady

You can use tabs, but you have to /always/ use tabs if you do so - you
can't mix tabs and spaces, or you hit issues like this :)

Especially if your editor is showing tabs as four spaces, since python
would use eight.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Client testing with custom http request referrer

2008-07-02 Thread Collin Grady

Please do not re-post your question - you already submitted this 7
hours before you posted this one, so you should just wait for replies
to that :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin functionality: someadmin.articles.models.article_genre'> instance needs to have a primary key value before a many-to-many relationship can be used.

2008-07-02 Thread [EMAIL PROTECTED]

Hi all,
  I am using django admin to show my tables.
  I used ManyToMany field, and facing this error.

 instance needs to
have a primary key value before a many-to-many relationship can be
used.

 Actually I am trying to create new record of article which has many
to many field to article_genre table...
First of all the error is wrong. Next how to over come it.
I searched the group, and could see some solutions with out using
admin interfacebut could not able to
solution in which I can still use admin interface...
  Please let me know if some one have used many to many field and
could still see their tables using django
admin..

Thanks,
Sateesh.

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



forms + UI question

2008-07-02 Thread pihentagy

Hi!

I have an auction site, the items appear in more views (and there are
more items in a view), and I would like to allow users to bid on every
view.
I have done it somehow, but I think that solution is not pretty (I
mean the code quality). I would like to use the same newforms form on
every view, if possible. The form consists of one numeric field. I
also would like to prefill the bids made before. Can anybody propose
me a solution how to organize these? Especially the Form & url part.

Thanks
Gergo

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



Re: testing login problem

2008-07-02 Thread laspal

Hi,
I have  created initial_data.xml using dumpdata and
"""manage.py loaddata initial_data.xml""" gives me no error.
but still  I am not able to login using setUp().. and this is
essential  as all my views functions required login..

here is my test file:

import unittest

from django.test import TestCase

class IndustryTest(TestCase):

def setUp(self):
self.client = Client()
response =self.client.post('/ibms/login/',
{'username':'laspal', 'passwords':'abcd'})
print response

I am still getting the error."""Your username and password didn't
match"""
Please help me out as I have to write lots of test cases for my view
functions.

Thanks

On Jul 1, 7:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> > How do I create username and password for the test database.
>
> What I do is either create a test user on SetUp(), or put that
> username inside the "initial_data" fixture, which loads automatically
> when Django creates the test DB...
>
> HTH,
>
> Carlos
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: url views problem

2008-07-02 Thread sebey

wonderful!! its works thank you!!!

On Jul 1, 3:27 pm, sebey <[EMAIL PROTECTED]> wrote:
> cool sorry i will try that out sorry for replying so late but I will
> post what the results are
>
> thanks again
>
> On Jun 26, 9:23 pm, "Emil Styrke" <[EMAIL PROTECTED]> wrote:
>
> > This line:
>
> >    query = show.objects.filter(show_feed__contains="http://";)
>
> > selects all shows that have a feed url(?) containing "http://";. The for loop
> > then loops through these items and passes each one to feedparser. If you
> > want to view only one show you have to change this to use the show ID you're
> > passing in.  So maybe replacing the query line with
>
> >   s = show.objects.get(pk=show_feed)
>
> > and getting rid of the "for s in query" line might do the trick? Then you'll
> > get only the feed for show 1 parsed when you go to /shows/1.
>
> >   /Emil
>
> > 2008/6/25 sebey <[EMAIL PROTECTED]>:
>
> > > sorry but I do not want to limit the results as I am useing a parser
> > > in the views.py but I want to get all of the urls and the first url
> > > show/1, the second url I want to give shows/2 and so on and so on
> > > On Jun 25, 1:48 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
> > > > You've now passed in the variable (which you can check by throwing a
> > > > "print show_feed" at the top of the function), but now you actually
> > > > need to *do* something with it.  I'm assuming (not really knowing what
> > > > you want out of this) that you'd want to add an order_by clause to
> > > > order your podcasts (?) by *something*, then do some slicing to limit
> > > > the results.
>
> > > > Read:
> > >http://www.djangoproject.com/documentation/db-api/#limiting-querysets
>
> > > > -Jeff
>
> > > > On Jun 25, 4:58 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > yes i have that set up it now looks like this
>
> > > > > def show_page(request,show_feed):
> > > > >     """this is where we take what we need form the rss feeds in the
> > > > > data base"""
> > > > >     query = show.objects.filter(show_feed__contains="http://";)
> > > > >     for s in query:
> > > > >         podcast = feedparser.parse(s.show_feed)
> > > > >         if  podcast.entries:
> > > > >             elements = {'show_about':
> > > > > podcast.feed.summary,'show_latest_title':
> > > > > podcast.entries[0].title,'show_latest': podcast.entries[0].summary}
> > > > >     e = elements
> > > > >     t = loader.get_template('shows/show_page_base.html')
> > > > >     return  HttpResponse(t.render(Context(e)))
>
> > > > > but it still in not working so help please thank you for trying
>
> > > > > On Jun 24, 3:07 pm, phillc <[EMAIL PROTECTED]> wrote:
>
> > > > > > you did not readhttp://
> > >www.djangoproject.com/documentation/url_dispatch/
>
> > > > > > your method, show_page, is now passed a parameter called show_feed.
> > > > > > you need to use it accordingly
>
> > > > > > On Jun 24, 10:02 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > > > either way its still the same thanks though but it still is not
> > > > > > > working
>
> > > > > > > On Jun 24, 1:44 pm, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > The regex you're using has a trailing /, so you need to have 
> > > > > > > > that
> > > in
> > > > > > > > your link as well:
> > > > > > > > /shows/1/
>
> > > > > > > > The other option is to make the trailing slash optional like so:
> > > > > > > > r'^shows/(?P\d{1})[/]?$'
>
> > > > > > > > On Jun 24, 7:09 am, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > it works but  (thanks for the tips) it still is getting the
> > > same feed
> > > > > > > > > for local/shows/1/ and local/show/2 help please
>
> > > > > > > > > everyone who has helped so far thank you
>
> > > > > > > > > On Jun 24, 12:06 pm, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > ok fixed that yeah i saw that after I posted but here is 
> > > > > > > > > > what
> > > it looks
> > > > > > > > > > like now
>
> > > > > > > > > > from django.conf.urls.defaults import *
>
> > > > > > > > > > urlpatterns = patterns('',
> > > > > > > > > >     # Example:
> > > > > > > > > >     # (r'^ubermicro/', include('ubermicro.foo.urls')),
>
> > > > > > > > > >     # Uncomment this for admin:
> > > > > > > > > >     (r'^admin/', include('django.contrib.admin.urls')),
> > > > > > > > > >     #temp only fo dev proposes
> > > > > > > > > >     (r'^shows/(?p\d{1})/
> > > > > > > > > > $','ubermicro.shows.views.show_page')
> > > > > > > > > > )
>
> > > > > > > > > > thanks some please
>
> > > > > > > > > > On Jun 24, 11:46 am, Tye <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > > > > > > > > Why does the /shows/ etc url string end with
>
> > > > > > > > > > > /s'
>
> > > > > > > > > > > ?
>
> > > > > > > > > > > Typo?
>
> > > > > > > > > > > Sent from my iPhone
>
> > > > > > > > > > > On Jun 24, 2008, at 3:23, sebey <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > > I have gotten this traceback
>
> > > > > > > > > > > > Traceback (most recent call last):
> > > > > > > > > > > > File
> > > "/Library/

Re: i18n model - tri-lingual data

2008-07-02 Thread Nebojša Đorđević

On 26 Jun 2008, at 15:22, pihentagy wrote:

> Is there a way I can tell the model about the request's language? Or,
> well, I know it is a violation of MVC, but how to solve this problem?


from django.utils.translation import get_language
lang = get_language()

-- 
Nebojša Đorđević - nesh, Studio Quattro - Niš - Serbia
http://nesh.studio-quattro.info
http://www.ohloh.net/accounts/6315 | http://www.linkedin.com/in/neshdj
Registered Linux User 282159 [http://counter.li.org]


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



Re: i18n model - tri-lingual data

2008-07-02 Thread KONTRA, Gergely
Many thanks!

Will make my views and templates definitely shorter.

On Wed, Jul 2, 2008 at 12:01 PM, Nebojša Đorđević <[EMAIL PROTECTED]> wrote:
> On 26 Jun 2008, at 15:22, pihentagy wrote:
>> Is there a way I can tell the model about the request's language? Or,
>> well, I know it is a violation of MVC, but how to solve this problem?
> from django.utils.translation import get_language
> lang = get_language()

-- 
Will Rogers  - "I don't make jokes. I just watch the government and
report the facts."

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



Re: Strange display of date

2008-07-02 Thread Evert

> Anyone?
>
> On Jun 27, 9:38 am,gumbah<[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > does anyone know what i am doing wrong when i see adatelooking like
> > this in the "change history" part of the admin app:
>
> > FriAMCDTE_261CDT02_CDT1JunE_June1218655750TrueTrue
>
> > I see this throughout the admin app (change history of users, of
> > groups etc.)

It's likely it has something to do with your localisation/
international settings. Django will try to show the date in your local
flavour (Dutch?), but somehow cannot find the appropriate translation,
and appears to mess things up.
Not sure if that helps you, but you could nail things down better if
you mention
- the Django version you're using
- What system you're on
- What Python version you're using
- What, if any and you know them, are your localisation/
internationalisation settings

Also, have a read through http://www.djangoproject.com/documentation/i18n/
, at least the beginning.
And perhaps try setting "USE_I18N = False" in your settings.py
(assuming you're using the development server, that should be picked
up immediately); that should turn internationalisation off, and if
that changes things for the better, than at least you better know
where the problem is.

Then again, I may be completely off here with my suggestions. But it's
something worth trying.

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



django+mod_python, caching or something else?

2008-07-02 Thread Mario

Hi, all!
I have a some little project that consists news list, several text
blocks and else
All worked... But after adding, for example news, it not publish on
main page while apache restart(reload). This problem haven't
regularity.

model.py:
class News(models.Model):
title = models.CharField("Заголовок", maxlength=250)
category = models.ForeignKey(NewsCategories,
verbose_name="Категория")
preview = models.TextField("Сокращенный вариант")
body = models.TextField("Полный текст")
created = models.DateTimeField("Добавлена", auto_now_add=True)
hot = models.BooleanField("Горячая новость")

views.py (example for news):
context = {
'hot_news': News.objects.filter(hot=True).order_by('-created')[0],
}
return render_to_response('index.html', context)

I try CACHE_BACKEND = 'dummy:///'
and have same result

I look at sql log - django didn't query that, but always query lists,
for example:
context["news_list"] = News.objects.filter(hot=False).order_by('-
created')[:5]

what is this? mod_python? caching?

# django-admin.py --version
0.97-pre-SVN-7810

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



Can't pickle error from development version (7825)

2008-07-02 Thread Tipan

Whilst setting up a new machine for development I took down the latest
development version of Django (7825). I am now experiencing a Pickle
error when running my existing application which has been working fine
on our production servers for a few months. The error occurs when
using the Cache.set function and passing a queryset for the purposes
of caching. It also does the same in anaother view where we're passing
a queryset into the Cache.set

I've checked the backward compatibility changes and cannot see
anything that would directly relate to it. I note that there was a fix
implented at 7773 - http://code.djangoproject.com/ticket/7506, but I'm
not sure if it is relevant.

Has anyone encountered this recently, or can anyone shed some light on
it and suggest a work round, or does it need a ticket?

The code that causes this in the view is:


comp=Compfile.objects.filter(campaign=campaign).select_related().order_by("rank")
for i in comp:
my_id=i.competition.id
strapline=i.competition.strapline
setattr(i,"my_id",my_id)
setattr(i,"strapline",strapline)
data={'comp':comp}
cache.set(cache_name,data,cache_time)

 Traceback from the error is as follows:

Environment:

Request Method: GET
Request URL: http://localhost/hive/competitions_ver2/
Django Version: 0.97-pre-SVN-7825
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.humanize',
 'hive.promotions',
 'voting']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "C:\Python25\Lib\site-packages\django-trunk\django\core\handlers
\base.py" in get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "C:/DATA/PROJECTS/hive\promotions\views.py" in
display_competitions_ver2
  6712. cache.set(cache_name,data,cache_time)
File "C:\Python25\Lib\site-packages\django-trunk\django\core\cache
\backends\db.py" in set
  41. return self._base_set('set', key, value, timeout)
File "C:\Python25\Lib\site-packages\django-trunk\django\core\cache
\backends\db.py" in _base_set
  56. encoded = base64.encodestring(pickle.dumps(value,
2)).strip()

Exception Type: PicklingError at /hive/competitions_ver2/
Exception Value: Can't pickle : attribute lookup
__builtin__.function failed

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



Re: Can't pickle error from development version (7825)

2008-07-02 Thread Malcolm Tredinnick


On Wed, 2008-07-02 at 04:47 -0700, Tipan wrote:
> Whilst setting up a new machine for development I took down the latest
> development version of Django (7825). I am now experiencing a Pickle
> error when running my existing application which has been working fine
> on our production servers for a few months. The error occurs when
> using the Cache.set function and passing a queryset for the purposes
> of caching. It also does the same in anaother view where we're passing
> a queryset into the Cache.set
> 
> I've checked the backward compatibility changes and cannot see
> anything that would directly relate to it. I note that there was a fix
> implented at 7773 - http://code.djangoproject.com/ticket/7506, but I'm
> not sure if it is relevant.
> 
> Has anyone encountered this recently, or can anyone shed some light on
> it and suggest a work round, or does it need a ticket?

I have no idea what's going on here, although I doubt r7773 will have
made things worse (since it produces less complex objects for pickling).
It will help a lot if you could narrow down a rough version where this
started to appear. Check out something from a while back where it
worked, then checkout out something halfway in between, see if it works,
etc.

You could also try reducing your example code a bit to see what is the
bit that is tripping the error. That might give us a few more hints.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django+mod_python, caching or something else?

2008-07-02 Thread Alex Koshelev

Client-side caching. Use the `never_cache` decorator

On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> Hi, all!
> I have a some little project that consists news list, several text
> blocks and else
> All worked... But after adding, for example news, it not publish on
> main page while apache restart(reload). This problem haven't
> regularity.
>
> model.py:
> class News(models.Model):
>     title = models.CharField("Заголовок", maxlength=250)
>     category = models.ForeignKey(NewsCategories,
> verbose_name="Категория")
>     preview = models.TextField("Сокращенный вариант")
>     body = models.TextField("Полный текст")
>     created = models.DateTimeField("Добавлена", auto_now_add=True)
>     hot = models.BooleanField("Горячая новость")
>
> views.py (example for news):
> context = {
>     'hot_news': News.objects.filter(hot=True).order_by('-created')[0],}
>
> return render_to_response('index.html', context)
>
> I try CACHE_BACKEND = 'dummy:///'
> and have same result
>
> I look at sql log - django didn't query that, but always query lists,
> for example:
>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> created')[:5]
>
> what is this? mod_python? caching?
>
> # django-admin.py --version
> 0.97-pre-SVN-7810
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using SQLite in production

2008-07-02 Thread David Marko

I'm just considering using SQLite in small Django project(in
production environment). I have no fear about performance but what
troubles me is whether SQLite can be used in environment like Apache
+mod_wsgi ? As SQLite is file based database, isn't there concurrency
problem?

Can someone explain?

Thanks,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django+mod_python, caching or something else?

2008-07-02 Thread James Bennett

On Wed, Jul 2, 2008 at 7:09 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Client-side caching. Use the `never_cache` decorator

No, that's not it at all.

> On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
>> I look at sql log - django didn't query that, but always query lists,
>> for example:
>> context["news_list"] = News.objects.filter(hot=False).order_by('-
>> created')[:5]
>>
>> what is this? mod_python? caching?

When launched, mod_python loads your code once and only once for each
server process, and holds it in memory afterward. This is a trade-off
made or efficiency, because reloading the code on every request would
significantly slow the server. As a result, whenever you make a change
to code that runs under mod_python, you must also restart the web
server.

In addition, any variable assigned at the module global level will
only be evaluated once, which means that any top-level variable
declaration which does a database query will only evaluate once per
server process, rather than appearing to refresh on each request.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



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

2008-07-02 Thread chefsmart

With new commits, I guess this has become a little outdated. Or am I
wrong? Is there some new code required to achieve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Make changes to model...

2008-07-02 Thread mccomas . chris

Hello all,

I'm using MySQL with Django, I setup my models and installed
everything, got into the admin panel and realized I left a field out.
I went back into my models file, added it, and it gives me an error
because while I guess the code realized it's there, that field wasn't
created in MySQL. Is there a way to do this, other than going in
through phpMyAdmin to do it?

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



Re: Make changes to model...

2008-07-02 Thread Oscar Carlsson
Unless you use django-evolution
(http://code.google.com/p/django-evolution/, which I don't know much
about) you have to make these changes yourself,
but usually it isn't that hard.

There is information on how to make these changes in the django book,
chapter 5:
http://djangobook.com/en/1.0/chapter05/ ("Making Changes to a Database
Schema")

Oscar

On Wed, Jul 2, 2008 at 2:49 PM, <[EMAIL PROTECTED]> wrote:

>
> Hello all,
>
> I'm using MySQL with Django, I setup my models and installed
> everything, got into the admin panel and realized I left a field out.
> I went back into my models file, added it, and it gives me an error
> because while I guess the code realized it's there, that field wasn't
> created in MySQL. Is there a way to do this, other than going in
> through phpMyAdmin to do it?
>
> Thnx,
> >
>

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



Re: Can't pickle error from development version (7825)

2008-07-02 Thread Tipan

Hi Malcolm,

I've been back through as you suggested and can trace the problem to
revision 7477 which is merging of the Queryset refactor branch into
the trunk. Version 7476 works fine with our application.

I'll have a play with my view code to see if I can see exactly what is
causing the problem.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django+mod_python, caching or something else?

2008-07-02 Thread Alex Koshelev

Of course. But author don't write where he create context in some view
function or in module scope.

On Jul 2, 4:42 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 2, 2008 at 7:09 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> > Client-side caching. Use the `never_cache` decorator
>
> No, that's not it at all.
>
> > On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> >> I look at sql log - django didn't query that, but always query lists,
> >> for example:
> >>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> >> created')[:5]
>
> >> what is this? mod_python? caching?
>
> When launched, mod_python loads your code once and only once for each
> server process, and holds it in memory afterward. This is a trade-off
> made or efficiency, because reloading the code on every request would
> significantly slow the server. As a result, whenever you make a change
> to code that runs under mod_python, you must also restart the web
> server.
>
> In addition, any variable assigned at the module global level will
> only be evaluated once, which means that any top-level variable
> declaration which does a database query will only evaluate once per
> server process, rather than appearing to refresh on each request.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Tutorial method was_published_today() - problem

2008-07-02 Thread bruno desthuilliers



On 2 juil, 09:48, Collin Grady <[EMAIL PROTECTED]> wrote:
> You can use tabs,

You can, but *don't*. Use spaces. 4 spaces. Always.


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



Re: django+mod_python, caching or something else?

2008-07-02 Thread Mario

I understand. Global context = {} was bad solution...
views,py:
context = {
'hot_news': News.objects.filter(hot=True).order_by('-created')[0],
'last_radio_message': VisualRadio.objects.all().order_by('-
created')[0],
'last_totals': Totals.objects.all().order_by('-created')[0],
'last_poll': Poll.objects.all().order_by('-created')[0],
}

def index(request):
context["hot_news"] = News.objects.filter(hot=True).order_by('-
created')[0]
context["news_list"] = News.objects.filter(hot=False).order_by('-
created')[:5]
return render_to_response('index.html', context)


Please, help me to write good code. I don't want repeat code in every
view...

On Jul 2, 3:42 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 2, 2008 at 7:09 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> > Client-side caching. Use the `never_cache` decorator
>
> No, that's not it at all.
>
> > On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> >> I look at sql log - django didn't query that, but always query lists,
> >> for example:
> >>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> >> created')[:5]
>
> >> what is this? mod_python? caching?
>
> When launched, mod_python loads your code once and only once for each
> server process, and holds it in memory afterward. This is a trade-off
> made or efficiency, because reloading the code on every request would
> significantly slow the server. As a result, whenever you make a change
> to code that runs under mod_python, you must also restart the web
> server.
>
> In addition, any variable assigned at the module global level will
> only be evaluated once, which means that any top-level variable
> declaration which does a database query will only evaluate once per
> server process, rather than appearing to refresh on each request.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django+mod_python, caching or something else?

2008-07-02 Thread Alex Koshelev

Brrr... Try to use context processors
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext

On Jul 2, 5:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> I understand. Global context = {} was bad solution...
> views,py:
> context = {
>     'hot_news': News.objects.filter(hot=True).order_by('-created')[0],
>     'last_radio_message': VisualRadio.objects.all().order_by('-
> created')[0],
>     'last_totals': Totals.objects.all().order_by('-created')[0],
>     'last_poll': Poll.objects.all().order_by('-created')[0],
>
> }
>
> def index(request):
>     context["hot_news"] = News.objects.filter(hot=True).order_by('-
> created')[0]
>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> created')[:5]
>     return render_to_response('index.html', context)
>
> Please, help me to write good code. I don't want repeat code in every
> view...
>
> On Jul 2, 3:42 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, Jul 2, 2008 at 7:09 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> > > Client-side caching. Use the `never_cache` decorator
>
> > No, that's not it at all.
>
> > > On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> > >> I look at sql log - django didn't query that, but always query lists,
> > >> for example:
> > >>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> > >> created')[:5]
>
> > >> what is this? mod_python? caching?
>
> > When launched, mod_python loads your code once and only once for each
> > server process, and holds it in memory afterward. This is a trade-off
> > made or efficiency, because reloading the code on every request would
> > significantly slow the server. As a result, whenever you make a change
> > to code that runs under mod_python, you must also restart the web
> > server.
>
> > In addition, any variable assigned at the module global level will
> > only be evaluated once, which means that any top-level variable
> > declaration which does a database query will only evaluate once per
> > server process, rather than appearing to refresh on each request.
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django+mod_python, caching or something else?

2008-07-02 Thread Alex Koshelev

Or may be a custom template tag for common stuff.

On Jul 2, 5:59 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Brrr... Try to use context 
> processorshttp://www.djangoproject.com/documentation/templates_python/#subclass...
>
> On Jul 2, 5:43 pm, Mario <[EMAIL PROTECTED]> wrote:
>
> > I understand. Global context = {} was bad solution...
> > views,py:
> > context = {
> >     'hot_news': News.objects.filter(hot=True).order_by('-created')[0],
> >     'last_radio_message': VisualRadio.objects.all().order_by('-
> > created')[0],
> >     'last_totals': Totals.objects.all().order_by('-created')[0],
> >     'last_poll': Poll.objects.all().order_by('-created')[0],
>
> > }
>
> > def index(request):
> >     context["hot_news"] = News.objects.filter(hot=True).order_by('-
> > created')[0]
> >     context["news_list"] = News.objects.filter(hot=False).order_by('-
> > created')[:5]
> >     return render_to_response('index.html', context)
>
> > Please, help me to write good code. I don't want repeat code in every
> > view...
>
> > On Jul 2, 3:42 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > > On Wed, Jul 2, 2008 at 7:09 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> > > > Client-side caching. Use the `never_cache` decorator
>
> > > No, that's not it at all.
>
> > > > On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> > > >> I look at sql log - django didn't query that, but always query lists,
> > > >> for example:
> > > >>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> > > >> created')[:5]
>
> > > >> what is this? mod_python? caching?
>
> > > When launched, mod_python loads your code once and only once for each
> > > server process, and holds it in memory afterward. This is a trade-off
> > > made or efficiency, because reloading the code on every request would
> > > significantly slow the server. As a result, whenever you make a change
> > > to code that runs under mod_python, you must also restart the web
> > > server.
>
> > > In addition, any variable assigned at the module global level will
> > > only be evaluated once, which means that any top-level variable
> > > declaration which does a database query will only evaluate once per
> > > server process, rather than appearing to refresh on each request.
>
> > > --
> > > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > > correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django+mod_python, caching or something else?

2008-07-02 Thread Norman Harman

Alex Koshelev wrote:
> Or may be a custom template tag for common stuff.

Or like any code anywhere just extract the common parts to a helper 
function and call that.

-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

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



Re: testing login problem

2008-07-02 Thread Norman Harman

laspal wrote:
> Hi,
> I have  created initial_data.xml using dumpdata and
> """manage.py loaddata initial_data.xml""" gives me no error.
> but still  I am not able to login using setUp().. and this is
> essential  as all my views functions required login..
> 
> here is my test file:
> 
> import unittest
> 
> from django.test import TestCase
> 
> class IndustryTest(TestCase):
> 
> def setUp(self):
> self.client = Client()
> response =self.client.post('/ibms/login/',
> {'username':'laspal', 'passwords':'abcd'})
> print response
> 
> I am still getting the error."""Your username and password didn't
> match"""
> Please help me out as I have to write lots of test cases for my view
> functions.

Test system creates a new test database from scratch every time it is 
run.  manage.py loaddata has NO effect on test.

I could be wrong but I don't believe test runner automatically loads the 
fixture initial_data.xml

You need to tell it what fixtures to load and you need to put them in 
the correct place.

http://www.djangoproject.com/documentation/testing/#fixture-loading


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

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



Re: Make changes to model...

2008-07-02 Thread TiNo
You can use the output of "python manage.py sql myapp" to see what the sql
ought to be and compare it with the curent state.

On 7/2/08, Oscar Carlsson <[EMAIL PROTECTED]> wrote:
>
> Unless you use django-evolution (
> http://code.google.com/p/django-evolution/ , which I don't know much
> about) you have to make these changes yourself, but usually it isn't that
> hard.
>
> There is information on how to make these changes in the django book,
> chapter 5:
> http://djangobook.com/en/1.0/chapter05/ ("Making Changes to a Database
> Schema")
>
> Oscar
>
> On Wed, Jul 2, 2008 at 2:49 PM, <[EMAIL PROTECTED]> wrote:
>
>>
>> Hello all,
>>
>> I'm using MySQL with Django, I setup my models and installed
>> everything, got into the admin panel and realized I left a field out.
>> I went back into my models file, added it, and it gives me an error
>> because while I guess the code realized it's there, that field wasn't
>> created in MySQL. Is there a way to do this, other than going in
>> through phpMyAdmin to do it?
>>
>> Thnx,
>>
>>
>
> >
>

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



Re: Free Comments problem...

2008-07-02 Thread Karen Tracey
On Wed, Jul 2, 2008 at 3:33 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> I'm trying to use Free Comments, but coming up against a problem
> displaying the form. I've followed the tutorial at djangoproject.com
> (http://code.djangoproject.com/wiki/UsingFreeComment)
>
> So I've done these things:
>
>  - amended my urls.py to include: (r'^comments/',
> include('django.contrib.comments.urls.comments')),
>  - amended settings.py to include: 'django.contrib.comments', as an
> installed app
>  - run syncdb on this app
>  - created the correct comments templates in my appname/templates/
> comments/ directory
>  - included {% load comments %} in my template
>  - included {% free_comment_form for appname.entry object.id %}
>
> ...but the page still doesn't show a comments form.
>

Every time I have run into something not appearing in a template like I
expect, it usually results from my adding something to a template that
extends another template, but putting whatever I'm trying to add outside of
any block defined in the parent template.  So, are you using template
inheritance and if so have you put the {% free_comment_form for
appname.entry object.id %} inside of a block defined in the parent template?

Karen

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



Re: Admin functionality: someadmin.articles.models.article_genre'> instance needs to have a primary key value before a many-to-many relationship can be used.

2008-07-02 Thread Karen Tracey
On Wed, Jul 2, 2008 at 4:01 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

>
> Hi all,
>  I am using django admin to show my tables.
>  I used ManyToMany field, and facing this error.
>
> instance needs to
> have a primary key value before a many-to-many relationship can be
> used.
>
>  Actually I am trying to create new record of article which has many
> to many field to article_genre table...
> First of all the error is wrong. Next how to over come it.
> I searched the group, and could see some solutions with out using
> admin interfacebut could not able to
> solution in which I can still use admin interface...
>  Please let me know if some one have used many to many field and
> could still see their tables using django
> admin..
>

I think the error message identifying the wrong Model has been fixed
recently (see http://code.djangoproject.com/ticket/7026).

Can't comment on the rest of the question because I don't understand it.  To
avoid this error, you have to ensure both sides of the ManyToMany
relationship have been saved (and thus have a primary key) before attempting
to save the relationship.  How do you have your models specified that this
requirement cannot be satisfied in the context of the admin app?

Karen

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



Re: CharField as text?

2008-07-02 Thread Stuart Grimshaw

On Jul 1, 9:41 pm, Brian Luft <[EMAIL PROTECTED]> wrote:
> What is your purpose in defining a form field if it won't be used for
> user input?

I wanted to try and kee things simple (and look where that got me).

I have a list of players, and want to display them, with checkboxes
next to the names. I was following this example:

http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/

and could see a way to match the two lists in the view, so i moved all
the info I needed into the form class so I only needed 1 list of
objects.

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



Form serialization

2008-07-02 Thread Alexander Pugachev

Hi.
Is there way to store bounded form for later use?
For example to put into session, then show it at another way.

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



Multiple instances of same form: how to only saved the filled in ones?

2008-07-02 Thread Berco Beute

I have multiple instances of same the form (of which all fields are
optional), but I only want to save the form in case something is
filled in. How can I test that in my view?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiple instances of same form: how to only saved the filled in ones?

2008-07-02 Thread Malcolm Tredinnick


On Wed, 2008-07-02 at 07:58 -0700, Berco Beute wrote:
> I have multiple instances of same the form (of which all fields are
> optional), but I only want to save the form in case something is
> filled in. How can I test that in my view?

After checking that the form is valid (which means each field on the
form will have to have required=False, since the form could be entirely
empty), see if form.cleaned_data.values() contains anything. This
becomes a bit easier once newforms-admin lands because we essentially
implemented just that logic in the formsets there (and, from memory,
there's even an is_empty() method to save typing).

If you want to have some fields required if and only if any data is
supplied, that's a little trickier. You still make each field optional
in the form, but then clean() method on the form can check if
cleaned_data contains anything and, if it does, check that *all* the
required fields are present.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using SQLite in production

2008-07-02 Thread Brian Luft

I don't have any firsthand experience to share with running sqlite in
a production setting.  I did choose to spend about 30 seconds scanning
the sqlite FAQ:

http://www.sqlite.org/faq.html#q5
http://www.sqlite.org/faq.html#q6

If what sqlite is saying on their FAQ is true, it sounds you can get
away with running sqlite in a production setting.  However, please
don't interpret this as a recommendation from me.

-Brian

On Jul 2, 5:20 am, David Marko <[EMAIL PROTECTED]> wrote:
> I'm just considering using SQLite in small Django project(in
> production environment). I have no fear about performance but what
> troubles me is whether SQLite can be used in environment like Apache
> +mod_wsgi ? As SQLite is file based database, isn't there concurrency
> problem?
>
> Can someone explain?
>
> Thanks,
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



URL pre-processing middleware

2008-07-02 Thread David Christiansen

Hi everyone,

I'm in the process of using Django to develop a CMS for our Web site,
and one thing that I'd like to do is to find a way to maintain
compatibility with the old URLs on the site. These old URLs are,
however, somewhat crufty. In particular, I'd like to be able to do the
following to URLs:

1. Strip certain file extensions, such as ".php" and ".asp"

2. Change them from mixed case to all lower case

Doing this will allow the majority of our legacy URLs to work well in
the new system.  It should probably be done by returning a permanent
redirect status code pointing at the new URL.

It seems to me that the best way to do this would be to write a
middleware class that works similarly to CommonMiddleware.  However,
I'm having a hard time creating one that I'm satisfied with. The
problem is that anything I create will have to essentially replicate
those URL rewrites performed by CommonMiddleware, such as adding the
trailing slash.  This is because only one middleware can return a new
response for a request.

My first plan of attack was to write a middleware class whose __init__
method took a list of functions as parameters which it would then use
as rewriters.  But it doesn't seem to look as though one can provide
init arguments to middleware classes.  I suppose it could be in a
settings.py variable though.  In any case, this middleware would also
have to reimplement the rewrites found in CommonMiddleware.

Is there somewhere I should be looking where I'm not? Some kind of
built in rewriter?

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



Re: Free Comments problem...

2008-07-02 Thread [EMAIL PROTECTED]

Yeah, so in the parent template (base.html) I've specified the usual
{% block content %} and in the child template, the call to the form is
well within the corresponding block tags. I've checked syntax about a
million times too, to make sure there's no syntax error - it's a
pretty simple project, so not much to check.

thanks for the answer though - any other ideas?

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



How do I get the value of a disabled Select widget?

2008-07-02 Thread Huuuze

I use the following code to disable a ModelForm field in a custom
__init__:

self.fields['state'] =
USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
'tabindex':'-1',}, choices=STATE_CHOICES), required=False)

Unfortunately, this presents a problem.  When I post the form with a
"disabled" Select field, the form is no longer valid since it expects
a value associated with State.  Under non-Django conditions, I'd add a
hidden field that contains the value of the Select field and give it
the same name as the Select field.  However, I'm having trouble
figuring out how to retrieve the value of the Select field to place
into a InputHidden field.  This is operating under the assumption that
there isn't a better way to do this.  :)

For the sake of argument, here is my ModelForm:

class BookForm(forms.ModelForm):
  class Meta:
  model = Book

def __init__(self, *args, **kwargs):
super(BookForm, self).__init__(*args, **kwargs)
... some other stuff happens here 
self.fields['state'] =
USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
'tabindex':'-1',}, choices=STATE_CHOICES), required=False)



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



Re: Free Comments problem...

2008-07-02 Thread Karen Tracey
On Wed, Jul 2, 2008 at 11:14 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Yeah, so in the parent template (base.html) I've specified the usual
> {% block content %} and in the child template, the call to the form is
> well within the corresponding block tags. I've checked syntax about a
> million times too, to make sure there's no syntax error - it's a
> pretty simple project, so not much to check.
>
> thanks for the answer though - any other ideas?
>

Are you absolutely sure the template being rendered is the one where you
have put the {% free_comment_form ... %}?  If you deliberately introduce an
error (like omitting the {% load comments %} or mistyping a variable name in
the comment form arguments, do you get the expected "Invalid block tag" and
"VariableDoesNotExist" errors?

Karen

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



Re: How do I get the value of a disabled Select widget?

2008-07-02 Thread Huuuze

I figured out the puzzle:

self.fields['state'] = forms.CharField(required=False,
widget=forms.HiddenInput(), initial=self.instance.state)

Still open to feedback since I'm new to Django.


On Jul 2, 11:19 am, Huuuze <[EMAIL PROTECTED]> wrote:
> I use the following code to disable a ModelForm field in a custom
> __init__:
>
> self.fields['state'] =
> USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
> 'tabindex':'-1',}, choices=STATE_CHOICES), required=False)
>
> Unfortunately, this presents a problem.  When I post the form with a
> "disabled" Select field, the form is no longer valid since it expects
> a value associated with State.  Under non-Django conditions, I'd add a
> hidden field that contains the value of the Select field and give it
> the same name as the Select field.  However, I'm having trouble
> figuring out how to retrieve the value of the Select field to place
> into a InputHidden field.  This is operating under the assumption that
> there isn't a better way to do this.  :)
>
> For the sake of argument, here is my ModelForm:
>
> class BookForm(forms.ModelForm):
>   class Meta:
>       model = Book
>
>     def __init__(self, *args, **kwargs):
>         super(BookForm, self).__init__(*args, **kwargs)
>         ... some other stuff happens here 
>         self.fields['state'] =
> USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
> 'tabindex':'-1',}, choices=STATE_CHOICES), required=False)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overriding the JOIN type in contrib.admin's search forms?

2008-07-02 Thread Paul Winkler

Followup: This bug is fully fixed on the newforms_admin branch.
Thanks for the help!



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



Re: Multiple instances of same form: how to only saved the filled in ones?

2008-07-02 Thread Berco Beute

is_empty() was indeed what I was looking for. :)
For the time being I got it working using
any(form.cleaned_data.values())

Thanks for your great help!
2B

On Jul 2, 5:02 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-07-02 at 07:58 -0700, Berco Beute wrote:
> > I have multiple instances of same the form (of which all fields are
> > optional), but I only want to save the form in case something is
> > filled in. How can I test that in my view?
>
> After checking that the form is valid (which means each field on the
> form will have to have required=False, since the form could be entirely
> empty), see if form.cleaned_data.values() contains anything. This
> becomes a bit easier once newforms-admin lands because we essentially
> implemented just that logic in the formsets there (and, from memory,
> there's even an is_empty() method to save typing).
>
> If you want to have some fields required if and only if any data is
> supplied, that's a little trickier. You still make each field optional
> in the form, but then clean() method on the form can check if
> cleaned_data contains anything and, if it does, check that *all* the
> required fields are present.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Greater than Less than

2008-07-02 Thread mike171562

hello,
I am working on a web app that pulls call logs from a database
and displays them.  I am working with the greater than and less than
functions to filter out phone numbers less than 7 digits long i.e.
internal extensions. When I use something like
call.filter(number__gte=7) however, it filters  me the value and not
the length. Does anyone know of a way to query for length of a number
and not the actual value?  thx in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Greater than Less than

2008-07-02 Thread Scott Moonen
Mike, you might try this:

call.filter(number__regex = r'^.{7,}')

That uses a regular expression that matches strings of length 7 characters
or more.

  -- Scott

On Wed, Jul 2, 2008 at 11:59 AM, mike171562 <[EMAIL PROTECTED]>
wrote:

>
> hello,
>I am working on a web app that pulls call logs from a database
> and displays them.  I am working with the greater than and less than
> functions to filter out phone numbers less than 7 digits long i.e.
> internal extensions. When I use something like
> call.filter(number__gte=7) however, it filters  me the value and not
> the length. Does anyone know of a way to query for length of a number
> and not the actual value?  thx in advance.
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Re: Free Comments problem...

2008-07-02 Thread [EMAIL PROTECTED]

: ) absolutely! It's in an entry template. I've tried the same thing
in other templates as well (a gallery page, a photo page...) and the
same.

I don't get any error messages at all. The page loads fine. If I
change the syntax of the {% free_comment_form ... %}, for example by
introducing a spelling error or something, then I get an error page,
but otherwise, Django doesn't complain.

On Jul 2, 11:27 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jul 2, 2008 at 11:14 AM, [EMAIL PROTECTED] <
>
> [EMAIL PROTECTED]> wrote:
>
> > Yeah, so in the parent template (base.html) I've specified the usual
> > {% block content %} and in the child template, the call to the form is
> > well within the corresponding block tags. I've checked syntax about a
> > million times too, to make sure there's no syntax error - it's a
> > pretty simple project, so not much to check.
>
> > thanks for the answer though - any other ideas?
>
> Are you absolutely sure the template being rendered is the one where you
> have put the {% free_comment_form ... %}?  If you deliberately introduce an
> error (like omitting the {% load comments %} or mistyping a variable name in
> the comment form arguments, do you get the expected "Invalid block tag" and
> "VariableDoesNotExist" errors?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Greater than Less than

2008-07-02 Thread mike171562

Scott,

Thanks, I'm already using long_distance =
call.exclude(number__iregex=r'^1?(281|832|713|800)')
to filter long distance numbers so, the new regex would be

something like iregex=r'^1?(281|832|713|800)^.{7,}')

does that look right?


On Jul 2, 11:04 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Mike, you might try this:
>
> call.filter(number__regex = r'^.{7,}')
>
> That uses a regular expression that matches strings of length 7 characters
> or more.
>
>   -- Scott
>
> On Wed, Jul 2, 2008 at 11:59 AM, mike171562 <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > hello,
> >I am working on a web app that pulls call logs from a database
> > and displays them.  I am working with the greater than and less than
> > functions to filter out phone numbers less than 7 digits long i.e.
> > internal extensions. When I use something like
> > call.filter(number__gte=7) however, it filters  me the value and not
> > the length. Does anyone know of a way to query for length of a number
> > and not the actual value?  thx in advance.
>
> --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Greater than Less than

2008-07-02 Thread mike171562

hey Scott, that worked perfectly thanks

On Jul 2, 11:16 am, mike171562 <[EMAIL PROTECTED]> wrote:
> Scott,
>
> Thanks, I'm already using long_distance =
> call.exclude(number__iregex=r'^1?(281|832|713|800)')
> to filter long distance numbers so, the new regex would be
>
> something like iregex=r'^1?(281|832|713|800)^.{7,}')
>
> does that look right?
>
> On Jul 2, 11:04 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
>
> > Mike, you might try this:
>
> > call.filter(number__regex = r'^.{7,}')
>
> > That uses a regular expression that matches strings of length 7 characters
> > or more.
>
> >   -- Scott
>
> > On Wed, Jul 2, 2008 at 11:59 AM, mike171562 <[EMAIL PROTECTED]>
> > wrote:
>
> > > hello,
> > >I am working on a web app that pulls call logs from a database
> > > and displays them.  I am working with the greater than and less than
> > > functions to filter out phone numbers less than 7 digits long i.e.
> > > internal extensions. When I use something like
> > > call.filter(number__gte=7) however, it filters  me the value and not
> > > the length. Does anyone know of a way to query for length of a number
> > > and not the actual value?  thx in advance.
>
> > --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Greater than Less than

2008-07-02 Thread Scott Moonen
Aah, ok.  I think this might work:

exclude(number_iregex = r'^(1?(281|832|713|800).*|.{,6})$')

That excludes anything that matches your existing pattern or which is
exactly six characters or less.  Please be sure to test it though as this is
off the cuff. :)

  -- Scott

On Wed, Jul 2, 2008 at 12:16 PM, mike171562 <[EMAIL PROTECTED]>
wrote:

>
> Scott,
>
> Thanks, I'm already using long_distance =
> call.exclude(number__iregex=r'^1?(281|832|713|800)')
> to filter long distance numbers so, the new regex would be
>
> something like iregex=r'^1?(281|832|713|800)^.{7,}')
>
> does that look right?
>
>
> On Jul 2, 11:04 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> > Mike, you might try this:
> >
> > call.filter(number__regex = r'^.{7,}')
> >
> > That uses a regular expression that matches strings of length 7
> characters
> > or more.
> >
> >   -- Scott
> >
> > On Wed, Jul 2, 2008 at 11:59 AM, mike171562 <[EMAIL PROTECTED]>
> > wrote:
> >
> >
> >
> > > hello,
> > >I am working on a web app that pulls call logs from a database
> > > and displays them.  I am working with the greater than and less than
> > > functions to filter out phone numbers less than 7 digits long i.e.
> > > internal extensions. When I use something like
> > > call.filter(number__gte=7) however, it filters  me the value and not
> > > the length. Does anyone know of a way to query for length of a number
> > > and not the actual value?  thx in advance.
> >
> > --http://scott.andstuff.org/|http://truthadorned.org/
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Using WingIDE's shell instead of manage.py shell

2008-07-02 Thread Fernando Rodríguez

Hi,

I'd like to use WingIDE's own python shell with django, instead of the
terminal you get with manage.py shell.

However, if I try to eval a file form within Wing, I get this error:

Traceback (most recent call last):
  File "/home/fernando/", line 1, in 
  File "/var/lib/python-support/python2.5/django/db/__init__.py", line
7, in 
if not settings.DATABASE_ENGINE:
  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
28, in __getattr__
self._import_settings()
  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
53, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." %
ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
undefined.

How can I fix this?

Thanks!



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



Trouble activating the admin interface

2008-07-02 Thread Fernando Rodríguez

Hi,

I'm learning django with "the definitve guide to django". On chapter 6,
I tried to activate the admin interface fro the "books" app, by adding
django.contrib.admin to the INSTALLED_APPS and then calling manage.py
syncdb.

It failed with the following error:


 
[EMAIL PROTECTED]:~/django/mysite$ manage syncdb
Error: Couldn't install apps, because there were errors in one or more
models:
admin.logentry: 'user' has relation with model User, which has not been
installed
admin.logentry: 'content_type' has relation with model ContentType,
which has not been installed
--

The book mentions a possible error (though not that one), and the fix is
to run create_superuser.py. I tried, and it didn't work either:

--
Traceback (most recent call last):
  File "./create_superuser.py", line 8, in 
from django.core import validators
  File "/var/lib/python-support/python2.5/django/core/validators.py",
line 13, in 
from django.utils.translation import gettext, gettext_lazy, ngettext
  File
"/var/lib/python-support/python2.5/django/utils/translation/__init__.py", line 
3, in 
if settings.USE_I18N:
  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
28, in __getattr__
self._import_settings()
  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
53, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." %
ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
undefined.
[EMAIL PROTECTED]:/usr/share/python-support/python-django/django/contrib
--

Any suggestions? O:-)

Thanks!



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



ImageField error

2008-07-02 Thread Molly

I added ImageField to my models like this:


photo = models.ImageField("Photograph", upload_to='media/images',
blank=True,null=True)


I "import Image" in my imports, and in my models I:


from django.db.models import ImageField


Everything works.. it shows up on my site, I upload it and it is
there. When I open the picture, i get this error:


error: (10061, 'Connection refused')


I would appreciate any help!

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



Accessing URL Parameters in Django Templates

2008-07-02 Thread Sameer Maggon

Hi All,

Is there a standard way to access the URL parameters in the Django
templates? I can write a template tag to do that, but I was hoping I
could avoid it.

Thanks,
Sameer.
--
http://www.maggon.com

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



Re: Accessing URL Parameters in Django Templates

2008-07-02 Thread Scott Moonen
Sameer, if you are using the RequestContext object to produce the template
context, then you should be able to access the URL parameters in your
template as request.GET.*parametername*.  In this case, request.GET is a
QueryDict object (see
http://www.djangoproject.com/documentation/request_response/#querydict-objects
).

  -- Scott


On Wed, Jul 2, 2008 at 1:52 PM, Sameer Maggon <[EMAIL PROTECTED]> wrote:

>
> Hi All,
>
> Is there a standard way to access the URL parameters in the Django
> templates? I can write a template tag to do that, but I was hoping I
> could avoid it.
>
> Thanks,
> Sameer.
> --
> http://www.maggon.com
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Re: Trouble activating the admin interface

2008-07-02 Thread Brian Luft

Do you have 'django.contrib.auth' and 'django.contrib.contenttypes' in
your INSTALLED_APPS setting?

On Jul 2, 10:20 am, Fernando Rodríguez <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm learning django with "the definitve guide to django". On chapter 6,
> I tried to activate the admin interface fro the "books" app, by adding
> django.contrib.admin to the INSTALLED_APPS and then calling manage.py
> syncdb.
>
> It failed with the following error:
>
> 
> [EMAIL PROTECTED]:~/django/mysite$ manage syncdb
> Error: Couldn't install apps, because there were errors in one or more
> models:
> admin.logentry: 'user' has relation with model User, which has not been
> installed
> admin.logentry: 'content_type' has relation with model ContentType,
> which has not been installed
> --
>
> The book mentions a possible error (though not that one), and the fix is
> to run create_superuser.py. I tried, and it didn't work either:
>
> --
> Traceback (most recent call last):
>   File "./create_superuser.py", line 8, in 
>     from django.core import validators
>   File "/var/lib/python-support/python2.5/django/core/validators.py",
> line 13, in 
>     from django.utils.translation import gettext, gettext_lazy, ngettext
>   File
> "/var/lib/python-support/python2.5/django/utils/translation/__init__.py", 
> line 3, in 
>     if settings.USE_I18N:
>   File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> 28, in __getattr__
>     self._import_settings()
>   File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> 53, in _import_settings
>     raise EnvironmentError, "Environment variable %s is undefined." %
> ENVIRONMENT_VARIABLE
> EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
> undefined.
> [EMAIL PROTECTED]:/usr/share/python-support/python-django/django/contrib
> --
>
> Any suggestions? O:-)
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble activating the admin interface

2008-07-02 Thread Richard Dahl
Also ensure that you have imported those models into your apps models.py

from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType

os some such import statement should be at the top of your models.py
-richard


On 7/2/08, Brian Luft <[EMAIL PROTECTED]> wrote:
>
>
> Do you have 'django.contrib.auth' and 'django.contrib.contenttypes' in
> your INSTALLED_APPS setting?
>
> On Jul 2, 10:20 am, Fernando Rodríguez <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm learning django with "the definitve guide to django". On chapter 6,
> > I tried to activate the admin interface fro the "books" app, by adding
> > django.contrib.admin to the INSTALLED_APPS and then calling manage.py
> > syncdb.
> >
> > It failed with the following error:
> >
> >
> 
> > [EMAIL PROTECTED]:~/django/mysite$ manage syncdb
> > Error: Couldn't install apps, because there were errors in one or more
> > models:
> > admin.logentry: 'user' has relation with model User, which has not been
> > installed
> > admin.logentry: 'content_type' has relation with model ContentType,
> > which has not been installed
> >
> --
> >
> > The book mentions a possible error (though not that one), and the fix is
> > to run create_superuser.py. I tried, and it didn't work either:
> >
> >
> --
> > Traceback (most recent call last):
> >   File "./create_superuser.py", line 8, in 
> > from django.core import validators
> >   File "/var/lib/python-support/python2.5/django/core/validators.py",
> > line 13, in 
> > from django.utils.translation import gettext, gettext_lazy, ngettext
> >   File
> > "/var/lib/python-support/python2.5/django/utils/translation/__init__.py",
> line 3, in 
> > if settings.USE_I18N:
> >   File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> > 28, in __getattr__
> > self._import_settings()
> >   File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> > 53, in _import_settings
> > raise EnvironmentError, "Environment variable %s is undefined." %
> > ENVIRONMENT_VARIABLE
> > EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
> > undefined.
> > [EMAIL PROTECTED]
> :/usr/share/python-support/python-django/django/contrib
> >
> --
> >
> > Any suggestions? O:-)
> >
> > Thanks!
> >
>

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



deleting a session

2008-07-02 Thread Bobby Roberts

i can't find a way to delete session data (other than user removing
their cookie perhaps?) in the django docs.  Is there an easy way to do
this like in ASP?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Newforms Admin - Overriding the Save Method of an Inline Model

2008-07-02 Thread John Boxall

Hey everyone -

I'm running into a bit of a problem with NFA.

I would like to override the save method of an inline model.

For example -
I have a Poll which many Options.
In the admin panel I would be able to edit the Options while editing
the Poll so I declare the Poll to have the Options as an inline.

Now, when the Save button is pressed the Poll is saved and the Options
are saved - however I would like to add some custom behavior when each
individual Option is saved.

Lllama's NFA guide talks about custom validation:
http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIaddcustomvalidation

I've implemented a similiar approach, setting the ModelAdmin to point
to a custom ModelForm and defining a ``clean`` method. This method
always runs on each of the Options whenever the Poll form (with the
Options inline) is saved.

However the ``save`` method I've declared is never run.

Any thoughts?

Cheers,

John

---

class OptionModelForm(forms.ModelForm):

class Meta:
model = Option

def save(self, commit=True):
# Will -NEVER- run
assert False

def clean(self):
# Will -ALWAYS- run
assert False

...

class OptionInline(admin.TabularInline):
model = Option
form = PollModelForm

class PollAdmin(admin.ModelAdmin):
model = Poll
inlines = [OptionInline]


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



Re: Newforms Admin - Overriding the Save Method of an Inline Model

2008-07-02 Thread Brian Rosner


On Jul 2, 2008, at 12:22 PM, John Boxall wrote:

> class OptionModelForm(forms.ModelForm):
>
>   class Meta:
>   model = Option
>
>   def save(self, commit=True):
>   # Will -NEVER- run
>   assert False
>
>   def clean(self):
>   # Will -ALWAYS- run
>   assert False
>
> ...
>
> class OptionInline(admin.TabularInline):
>   model = Option
>   form = PollModelForm
>
> class PollAdmin(admin.ModelAdmin):
>   model = Poll
>   inlines = [OptionInline]
>
>
Ok, based on the wrongly posted thread on django-developers, you  
mentioned it was a form on a ModelAdmin /not/ an inline. Right now  
save is not called on a ModelForm from an inline. I am still not sure  
if it ever will. It might end up being a documentation fix. Check into  
how model formsets work. It might help you uncover why this is.

> >

Brian Rosner
http://oebfare.com




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



Re: Make changes to model...

2008-07-02 Thread mccomas . chris

Thanks guys. I know how to do it via the admin, wasn't sure if I was
"missing" something within Django to handle it :)

Kind of off topic, but say myapp is named myapp, then in the heading
the admin will be displayed Myapp with the model items below it. Other
than customizing the admin template is there a way to change that?


On Jul 2, 10:27 am, TiNo <[EMAIL PROTECTED]> wrote:
> You can use the output of "python manage.py sql myapp" to see what the sql
> ought to be and compare it with the curent state.
>
> On 7/2/08, Oscar Carlsson <[EMAIL PROTECTED]> wrote:
>
>
>
> > Unless you use django-evolution (
> >http://code.google.com/p/django-evolution/, which I don't know much
> > about) you have to make these changes yourself, but usually it isn't that
> > hard.
>
> > There is information on how to make these changes in the django book,
> > chapter 5:
> >http://djangobook.com/en/1.0/chapter05/("Making Changes to a Database
> > Schema")
>
> > Oscar
>
> > On Wed, Jul 2, 2008 at 2:49 PM, <[EMAIL PROTECTED]> wrote:
>
> >> Hello all,
>
> >> I'm using MySQL with Django, I setup my models and installed
> >> everything, got into the admin panel and realized I left a field out.
> >> I went back into my models file, added it, and it gives me an error
> >> because while I guess the code realized it's there, that field wasn't
> >> created in MySQL. Is there a way to do this, other than going in
> >> through phpMyAdmin to do it?
>
> >> Thnx,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: deleting a session

2008-07-02 Thread Juanjo Conti

You mean in the views?

del request.session['somedata']

2008/7/2 Bobby Roberts <[EMAIL PROTECTED]>:
>
> i can't find a way to delete session data (other than user removing
> their cookie perhaps?) in the django docs.  Is there an easy way to do
> this like in ASP?
> >
>



-- 
Juanjo Conti

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



Re: deleting a session

2008-07-02 Thread Bobby Roberts

> On Jul 2, 2:50 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote:
> You mean in the views?
>
> del request.session['somedata']

Well If i have 15 session variables I don't want to have to do it for
each variable.

Is there something like del request.session.sessionid or something
that will kill all session variables at one time?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newforms Admin - Overriding the Save Method of an Inline Model

2008-07-02 Thread Richard Dahl
You may be able to do what you want to by overriding the save() function
within the model. If you need any information from the form or related
object you could pass them as kwargs to save.
http://www.djangoproject.com/documentation/model-api/
-richard



On 7/2/08, Brian Rosner <[EMAIL PROTECTED]> wrote:
>
>
>
> On Jul 2, 2008, at 12:22 PM, John Boxall wrote:
>
> > class OptionModelForm(forms.ModelForm):
> >
> >   class Meta:
> >   model = Option
> >
> >   def save(self, commit=True):
> >   # Will -NEVER- run
> >   assert False
> >
> >   def clean(self):
> >   # Will -ALWAYS- run
> >   assert False
> >
> > ...
> >
> > class OptionInline(admin.TabularInline):
> >   model = Option
> >   form = PollModelForm
> >
> > class PollAdmin(admin.ModelAdmin):
> >   model = Poll
> >   inlines = [OptionInline]
> >
> >
> Ok, based on the wrongly posted thread on django-developers, you
> mentioned it was a form on a ModelAdmin /not/ an inline. Right now
> save is not called on a ModelForm from an inline. I am still not sure
> if it ever will. It might end up being a documentation fix. Check into
> how model formsets work. It might help you uncover why this is.
>
> > >
>
> Brian Rosner
> http://oebfare.com
>
>
>
>
> >
>

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



Re: deleting a session

2008-07-02 Thread Juanjo Conti

I am just guessing, but try:

request.session.clear()

2008/7/2 Bobby Roberts <[EMAIL PROTECTED]>:
>
>> On Jul 2, 2:50 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote:
>> You mean in the views?
>>
>> del request.session['somedata']
>
> Well If i have 15 session variables I don't want to have to do it for
> each variable.
>
> Is there something like del request.session.sessionid or something
> that will kill all session variables at one time?
> >
>



-- 
Juanjo Conti

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



Adding groups to groups

2008-07-02 Thread Dan Lazewatsky

Is there any way to add a group to another group, similarly to how you 
would add a user to a group. For example, let's say I have four groups: 
Undergraduates, Grad Students, Faculty and Staff, and there are a bunch 
of permissions that will always be the same for Undergraduates and Grad 
Students - so it would be nice to be able to add Undergraduates and Grad 
Students to a sort of meta-group called Students where I can manage all 
of the permissions they have in common.

I haven't been able to find an obvious or clean way of doing this, so 
any thoughts would be appreciated.

Thanks,
-Dan

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



Re: Newforms Admin - Overriding the Save Method of an Inline Model

2008-07-02 Thread John Boxall

Hey Brian - I wasn't sure that the fact that it was inline would have
an effect - I see now that it does - sorry for the incomplete first
post.
I just found it odd that what I was doing worked for ``clean`` but not
``save``.
I'll look into Formsets.

Richard - I'm sure I could do it that way - but I'd rather not to ...

The Poll model is generic and I would be putting application specific
logic inside that generic class.
Then again, maybe it's best just to do that and avoid the headache :)

Cheers,

John


On Jul 2, 11:53 am, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
> You may be able to do what you want to by overriding the save() function
> within the model. If you need any information from the form or related
> object you could pass them as kwargs to 
> save.http://www.djangoproject.com/documentation/model-api/
> -richard
>
> On 7/2/08, Brian Rosner <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Jul 2, 2008, at 12:22 PM, John Boxall wrote:
>
> > > class OptionModelForm(forms.ModelForm):
>
> > >       class Meta:
> > >               model = Option
>
> > >       def save(self, commit=True):
> > >               # Will -NEVER- run
> > >               assert False
>
> > >       def clean(self):
> > >               # Will -ALWAYS- run
> > >               assert False
>
> > > ...
>
> > > class OptionInline(admin.TabularInline):
> > >       model = Option
> > >       form = PollModelForm
>
> > > class PollAdmin(admin.ModelAdmin):
> > >       model = Poll
> > >       inlines = [OptionInline]
>
> > Ok, based on the wrongly posted thread on django-developers, you
> > mentioned it was a form on a ModelAdmin /not/ an inline. Right now
> > save is not called on a ModelForm from an inline. I am still not sure
> > if it ever will. It might end up being a documentation fix. Check into
> > how model formsets work. It might help you uncover why this is.
>
> > Brian Rosner
> >http://oebfare.com

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



Flatpages and base template translations

2008-07-02 Thread shadfc

Let me preface that this is not a question about translating flatpage
content.

I have a project created in english and I've had someone create
Romanian translations for the necessary strings.  Most of these are
just menu text, titles, etc -- all of the actual content on the site
will be created by a Romanian in Romanian.

So the setup here is that base.html has menus and things that use {%
trans "strings strings" %}.  I have a template called
introduction.html which extends from base.html.  When I render this
template (direct_to_template), all of the translations in base.html
for the menus and such work great.  However, when I do the exact same
thing with a flatpage, nothing gets translated in the base template.
The introduction.html and flatpages/default.html are nearly the same,
except that my page_title and content blocks are actual content in
introduction.html and filled by the flatpage context variable
attributes in flatpages/default.html.

Is this a known issue (I couldn't find anything on it)? I can
workaround it by just making templates out of the content instead of
flatpages, but thats a crappy solution.

I am using svn-7774.  I am also using the Modify Headers add on for
Firefox 3 extension to set Accept-Language to ro for testing.

thanks
Jay Wineinger

Please CC me directly on any replies

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



Re: Accessing URL Parameters in Django Templates

2008-07-02 Thread Sameer Maggon

That worked!

Thanks,
Sameer

On Jul 2, 10:57 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Sameer, if you are using the RequestContext object to produce the template
> context, then you should be able to access the URL parameters in your
> template as request.GET.*parametername*.  In this case, request.GET is a
> QueryDict object 
> (seehttp://www.djangoproject.com/documentation/request_response/#querydic...
> ).
>
>   -- Scott
>
> On Wed, Jul 2, 2008 at 1:52 PM, Sameer Maggon <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
>
> > Is there a standard way to access the URL parameters in the Django
> > templates? I can write a template tag to do that, but I was hoping I
> > could avoid it.
>
> > Thanks,
> > Sameer.
> > --
> >http://www.maggon.com
>
> --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ManyToManyField in Admin list_display

2008-07-02 Thread urukay


Hi,

right now I'm working on one model and it looks like this

class Area(models.Model):
   
region = models.CharField(max_length = 2, choices =
SLOVAK_REGION_CHOICES, radio_admin = True, db_index = True, blank = True,
null = True)
city = models.CharField(max_length = 4, choices =
SLOVAK_DISTRICT_CHOICES, db_index = True)
   
def __str__(self):
return '%s:' '%s' %(self.region, self.city)
   
class Admin:
list_display = ('region', 'city')

class JobOffer(ATag):
   
created = models.DateTimeField(_('created'), default =
datetime.datetime.now)
changed = models.DateTimeField(_('changed'), default =
datetime.datetime.now)
name = models.CharField(_('name'), max_length=80, core = True)
company = models.ForeignKey(Company)
loc = models.ManyToManyField(Area)

  ...

And I wanna display field "loc" in Admin's list_display (region and also
city field for created model), but that's impossible because it's
ManyToManyField and only way to do that is to write down proper method...and
that's the problem. Just can't figure it out :(
Can anybody please help me?

Thanks a lot!!!

-- 
View this message in context: 
http://www.nabble.com/ManyToManyField-in-Admin-list_display-tp18245816p18245816.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: ManyToManyField in Admin list_display

2008-07-02 Thread urukay


solved



urukay wrote:
> 
> Hi,
> 
> right now I'm working on one model and it looks like this
> 
> class Area(models.Model):
>
> region = models.CharField(max_length = 2, choices =
> SLOVAK_REGION_CHOICES, radio_admin = True, db_index = True, blank = True,
> null = True)
> city = models.CharField(max_length = 4, choices =
> SLOVAK_DISTRICT_CHOICES, db_index = True)
>
> def __str__(self):
> return '%s:' '%s' %(self.region, self.city)
>
> class Admin:
> list_display = ('region', 'city')
> 
> class JobOffer(ATag):
>
> created = models.DateTimeField(_('created'), default =
> datetime.datetime.now)
> changed = models.DateTimeField(_('changed'), default =
> datetime.datetime.now)
> name = models.CharField(_('name'), max_length=80, core = True)
> company = models.ForeignKey(Company)
> loc = models.ManyToManyField(Area)
> 
>   ...
> 
> And I wanna display field "loc" in Admin's list_display (region and also
> city field for created model), but that's impossible because it's
> ManyToManyField and only way to do that is to write down proper
> method...and that's the problem. Just can't figure it out :(
> Can anybody please help me?
> 
> Thanks a lot!!!
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ManyToManyField-in-Admin-list_display-tp18245816p18246133.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: Adding groups to groups

2008-07-02 Thread Milan Andric

On Wed, Jul 2, 2008 at 2:23 PM, Dan Lazewatsky <[EMAIL PROTECTED]> wrote:
>
> Is there any way to add a group to another group, similarly to how you
> would add a user to a group. For example, let's say I have four groups:
> Undergraduates, Grad Students, Faculty and Staff, and there are a bunch
> of permissions that will always be the same for Undergraduates and Grad
> Students - so it would be nice to be able to add Undergraduates and Grad
> Students to a sort of meta-group called Students where I can manage all
> of the permissions they have in common.
>

Just wondering why you wouldn't just create the "meta" group called
Students and assign a user to more than one group?  So a grad student
would be in Student and Grad Student.  Just one extra click for an
admin and would probably save you a bunch of work.

Not an answer to your question but it would provide the functionality.
 I know nothing about adding a group to a group unfortunately.

--
Milan

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



Re: testing login problem

2008-07-02 Thread [EMAIL PROTECTED]

You can check my dump of manage.py test (ran as root) here;
http://dpaste.com/60433/

As you can see the fixture load runs OK... and I even got a couple of
errors on the load process! That sure confirms the fixtures load ;-)
Tests run fine though.

On Jul 2, 4:14 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> laspal wrote:
> > Hi,
> > I have  created initial_data.xml using dumpdata and
> > """manage.py loaddata initial_data.xml""" gives me no error.
> > but still  I am not able to login using setUp().. and this is
> > essential  as all my views functions required login..
>
> > here is my test file:
>
> > import unittest
>
> > from django.test import TestCase
>
> > class IndustryTest(TestCase):
>
> >     def setUp(self):
> >         self.client = Client()
> >         response =self.client.post('/ibms/login/',
> > {'username':'laspal', 'passwords':'abcd'})
> >         print response
>
> > I am still getting the error."""Your username and password didn't
> > match"""
> > Please help me out as I have to write lots of test cases for my view
> > functions.
>
> Test system creates a new test database from scratch every time it is
> run.  manage.py loaddata has NO effect on test.
>
> I could be wrong but I don't believe test runner automatically loads the
> fixture initial_data.xml
>
> You need to tell it what fixtures to load and you need to put them in
> the correct place.
>
> http://www.djangoproject.com/documentation/testing/#fixture-loading
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> You've got fun!  Check out Austin360.com for all the entertainment
> info you need to live it up in the big city!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



choices

2008-07-02 Thread urukay


is there a way how to create choices in Models in specific way, that some
choices are not selectable (they only group and describe choices below)?

e.g.:

CHOICES = (
 ('0', 'Basic Colors'),
 ('1', 'Red'),
 ('2', 'Green'),
 ('3', 'Blue'),
 ('4', 'Other Colors'),
 ('5', 'Brown'),
.
)

and I want "Basic Colors" and "Other Colors" not selectable when displaying
CHOICES in model. Is it possible?

Thanks


Radovan
-- 
View this message in context: 
http://www.nabble.com/choices-tp18246312p18246312.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: ImageField error

2008-07-02 Thread Milan Andric

On Wed, Jul 2, 2008 at 12:21 PM, Molly <[EMAIL PROTECTED]> wrote:
>
> I added ImageField to my models like this:
>
> 
> photo = models.ImageField("Photograph", upload_to='media/images',
> blank=True,null=True)
> 
>
> I "import Image" in my imports, and in my models I:
>
> 
> from django.db.models import ImageField
> 
>
> Everything works.. it shows up on my site, I upload it and it is
> there. When I open the picture, i get this error:
>
> 
> error: (10061, 'Connection refused')
> 
>
> I would appreciate any help!
>
> Thank you!!

Molly,

Are you doing this in your dev. environment with the built in
webserver or on a production setup?  Just wondering about the
connection error, never heard of it.  Is that a mod_python error?
Maybe you can post the entire stack trace if you have it at
http://dpaste.com/ ?

If you are serving static media, you should be able to copy an image
in your media dir and manually type in the URL to get it.

Also  have a look here, many people use this type of setup in their
dev environment to serve static media using django.views.static.serve.

http://www.djangoproject.com/documentation/static_files/#limiting-use-to-debug-true

--
Milan

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



Re: Using WingIDE's shell instead of manage.py shell

2008-07-02 Thread Milan Andric

On Wed, Jul 2, 2008 at 11:30 AM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'd like to use WingIDE's own python shell with django, instead of the
> terminal you get with manage.py shell.
>
> However, if I try to eval a file form within Wing, I get this error:
>
> Traceback (most recent call last):
>  File "/home/fernando/", line 1, in 
>  File "/var/lib/python-support/python2.5/django/db/__init__.py", line
> 7, in 
>if not settings.DATABASE_ENGINE:
>  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> 28, in __getattr__
>self._import_settings()
>  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> 53, in _import_settings
>raise EnvironmentError, "Environment variable %s is undefined." %
> ENVIRONMENT_VARIABLE
> EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
> undefined.
>
> How can I fix this?

You need to set the environment variable in wingIDE somehow .  Not
sure how that's done but i'm sure google knows. In bash it would be :

export DJANGO_SETTINGS_MODULE='myproject.settings'

--
Milan

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



Re: deleting a session

2008-07-02 Thread J. Cliff Dyer

On Wed, 2008-07-02 at 11:52 -0700, Bobby Roberts wrote:
> > On Jul 2, 2:50 pm, "Juanjo Conti" <[EMAIL PROTECTED]> wrote:
> > You mean in the views?
> >
> > del request.session['somedata']
> 
> Well If i have 15 session variables I don't want to have to do it for
> each variable.
> 

for key in request.session:
del request.session[key]


> Is there something like del request.session.sessionid or something
> that will kill all session variables at one time?
> > 


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



Fwd: Re: Inputting Date/Time in a Django Form

2008-07-02 Thread Tim Sawyer

Sorry, I don't understand where I have to put the attrs bit.

Can you give me an example?

delivery_datetime = forms.SplitDateTimeField(attrs={'class':'vDateField'}) 
doesn't work, is that what you meant?

Thanks,

Tim.

On Sunday 29 Jun 2008, TiNo wrote:
> add:
>
> 
> >
>
>  type="text/javascript" >
>  type="text/javascript" >
>
> to your template, use SplitDateTimeField and pass the fields:
>
> attrs={'class':'vDateField'}
>
> That way you have the same date and time input as the admin interface.
>
> TiNo
>
> On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer <[EMAIL PROTECTED]>
>
> wrote:
> > Hi Folks,
> >
> > What's the simplest approach for me to have a form that makes it easy for
> > the
> > user to enter a Date/Time combination?
> >
> > I have my form class specified (the field in question is a
> > forms.DateTimeField()), but I need to make it easy for users of the site
> > to enter a date/time pair for the field.
> >
> > Is there a simple way to do this?  I'm using jQuery for javascript on the
> > site
> > if that's relevant.
> >
> > Thanks,
> >
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Re: Inputting Date/Time in a Django Form

2008-07-02 Thread TiNo
Sorry, I was a little too quick. I used it like this:
date =
forms.DateField(label=_("Date"),widget=forms.DateTimeInput(attrs={'class':'vDateField'}))

I am not sure on how to do this on a SplitDateTimeField though.

On Wed, Jul 2, 2008 at 10:52 PM, Tim Sawyer <[EMAIL PROTECTED]>
wrote:

>
> Sorry, I don't understand where I have to put the attrs bit.
>
> Can you give me an example?
>
> delivery_datetime = forms.SplitDateTimeField(attrs={'class':'vDateField'})
> doesn't work, is that what you meant?
>
> Thanks,
>
> Tim.
>
> On Sunday 29 Jun 2008, TiNo wrote:
> > add:
> >
> >  >
> > >
> >
> >  > type="text/javascript" >
> >  > type="text/javascript" >
> >
> > to your template, use SplitDateTimeField and pass the fields:
> >
> > attrs={'class':'vDateField'}
> >
> > That way you have the same date and time input as the admin interface.
> >
> > TiNo
> >
> > On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer <[EMAIL PROTECTED]
> >
> >
> > wrote:
> > > Hi Folks,
> > >
> > > What's the simplest approach for me to have a form that makes it easy
> for
> > > the
> > > user to enter a Date/Time combination?
> > >
> > > I have my form class specified (the field in question is a
> > > forms.DateTimeField()), but I need to make it easy for users of the
> site
> > > to enter a date/time pair for the field.
> > >
> > > Is there a simple way to do this?  I'm using jQuery for javascript on
> the
> > > site
> > > if that's relevant.
> > >
> > > Thanks,
> > >
> > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inputting Date/Time in a Django Form

2008-07-02 Thread Tim Sawyer

Thanks.

I've got the class in the html but not the buttons for the date or time popup.  
I also have two date popups and I think I should have one that has the class 
vTimeField not vDateField.

collection_datetime = 
forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget({'class':'vDateField 
required'}))

in my form is generating:

Collection 
datetime:

in my html.

Any ideas?

Cheers,

Tim.

On Wednesday 02 Jul 2008, TiNo wrote:
> Sorry, I was a little too quick. I used it like this:
> date =
> forms.DateField(label=_("Date"),widget=forms.DateTimeInput(attrs={'class':'
>vDateField'}))
>
> I am not sure on how to do this on a SplitDateTimeField though.
>
> On Wed, Jul 2, 2008 at 10:52 PM, Tim Sawyer <[EMAIL PROTECTED]>
>
> wrote:
> > Sorry, I don't understand where I have to put the attrs bit.
> >
> > Can you give me an example?
> >
> > delivery_datetime =
> > forms.SplitDateTimeField(attrs={'class':'vDateField'}) doesn't work, is
> > that what you meant?
> >
> > Thanks,
> >
> > Tim.
> >
> > On Sunday 29 Jun 2008, TiNo wrote:
> > > add:
> > >
> > >  > >
> > > >
> > >
> > >  > > type="text/javascript" >
> > >  > > type="text/javascript" >
> > >
> > > to your template, use SplitDateTimeField and pass the fields:
> > >
> > > attrs={'class':'vDateField'}
> > >
> > > That way you have the same date and time input as the admin interface.
> > >
> > > TiNo
> > >
> > > On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer
> > > <[EMAIL PROTECTED]
> > >
> > > wrote:
> > > > Hi Folks,
> > > >
> > > > What's the simplest approach for me to have a form that makes it easy
> >
> > for
> >
> > > > the
> > > > user to enter a Date/Time combination?
> > > >
> > > > I have my form class specified (the field in question is a
> > > > forms.DateTimeField()), but I need to make it easy for users of the
> >
> > site
> >
> > > > to enter a date/time pair for the field.
> > > >
> > > > Is there a simple way to do this?  I'm using jQuery for javascript on
> >
> > the
> >
> > > > site
> > > > if that's relevant.
> > > >
> > > > Thanks,
> > > >
> > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Regex

2008-07-02 Thread Ross Dakin

> If you have the ability to change your Call model, you should consider
> adding a new BooleanField called "is_long_distance" to Call. Then, you
> only have to compute it (in Call.save()) when you save or change a
> number. That will make your query very simple and efficient.
>
> -Rajesh D

I would disagree here. The database should only be used to store raw
data; the database should not know anything about this data (the
database should not be "smart").

Determining whether or not a number qualifies as "long distance" is a
job for the domain / controller / view layer (pick your jargon).

Here's why. Suppose the company moves, or the geographical scope of
one area code is changed. Now you have a different set of rules that
determine what qualifies a number as being "long distance." Would you
rather change the rule with one line of code in your view, or
construct and run some SQL that finds and updated all matching phone
numbers? (Note: this is meant to be a rhetorical question but could
very well be debated.)

Sorry for the tangent. I'm a stickler for best practices.

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



Re: Inputting Date/Time in a Django Form

2008-07-02 Thread TiNo
Have a look at the source (widgets.py in newforms):
class SplitDateTimeWidget(MultiWidget):
"""
A Widget that splits datetime input into two  boxes.
"""
def __init__(self, attrs=None):
widgets = (TextInput(attrs=attrs), TextInput(attrs=attrs))
super(SplitDateTimeWidget, self).__init__(widgets, attrs)

So maybe:

collection_datetime =
forms.SplitDateTimeField(

widget=forms.SplitDateTimeWidget(

widgets=(TextInput({'class':'vDateField required'}),

TextInput({'class':'vTimeField'}

will work?


On Wed, Jul 2, 2008 at 11:03 PM, Tim Sawyer <[EMAIL PROTECTED]>
wrote:

>
> Thanks.
>
> I've got the class in the html but not the buttons for the date or time
> popup.
> I also have two date popups and I think I should have one that has the
> class
> vTimeField not vDateField.
>
> collection_datetime =
>
> forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget({'class':'vDateField
> required'}))
>
> in my form is generating:
>
> Collection
> datetime: class="vDateField required" name="collection_datetime_0" /> id="id_collection_datetime_1" type="text" class="vDateField required"
> name="collection_datetime_1" />
>
> in my html.
>
> Any ideas?
>
> Cheers,
>
> Tim.
>
> On Wednesday 02 Jul 2008, TiNo wrote:
> > Sorry, I was a little too quick. I used it like this:
> > date =
> >
> forms.DateField(label=_("Date"),widget=forms.DateTimeInput(attrs={'class':'
> >vDateField'}))
> >
> > I am not sure on how to do this on a SplitDateTimeField though.
> >
> > On Wed, Jul 2, 2008 at 10:52 PM, Tim Sawyer <[EMAIL PROTECTED]>
> >
> > wrote:
> > > Sorry, I don't understand where I have to put the attrs bit.
> > >
> > > Can you give me an example?
> > >
> > > delivery_datetime =
> > > forms.SplitDateTimeField(attrs={'class':'vDateField'}) doesn't work, is
> > > that what you meant?
> > >
> > > Thanks,
> > >
> > > Tim.
> > >
> > > On Sunday 29 Jun 2008, TiNo wrote:
> > > > add:
> > > >
> > > >  type="text/javascript"
> > > >
> > > > >
> > > >
> > > >  > > > type="text/javascript" >
> > > >  > > > type="text/javascript" >
> > > >
> > > > to your template, use SplitDateTimeField and pass the fields:
> > > >
> > > > attrs={'class':'vDateField'}
> > > >
> > > > That way you have the same date and time input as the admin
> interface.
> > > >
> > > > TiNo
> > > >
> > > > On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer
> > > > <[EMAIL PROTECTED]
> > > >
> > > > wrote:
> > > > > Hi Folks,
> > > > >
> > > > > What's the simplest approach for me to have a form that makes it
> easy
> > >
> > > for
> > >
> > > > > the
> > > > > user to enter a Date/Time combination?
> > > > >
> > > > > I have my form class specified (the field in question is a
> > > > > forms.DateTimeField()), but I need to make it easy for users of the
> > >
> > > site
> > >
> > > > > to enter a date/time pair for the field.
> > > > >
> > > > > Is there a simple way to do this?  I'm using jQuery for javascript
> on
> > >
> > > the
> > >
> > > > > site
> > > > > if that's relevant.
> > > > >
> > > > > Thanks,
> > > > >
> > > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Regex

2008-07-02 Thread Rajesh Dhawan

Hi Ross,

> I would disagree here. The database should only be used to store raw
> data; the database should not know anything about this data (the
> database should not be "smart").
>
> Determining whether or not a number qualifies as "long distance" is a
> job for the domain / controller / view layer (pick your jargon).
>
> Here's why. Suppose the company moves, or the geographical scope of
> one area code is changed. Now you have a different set of rules that
> determine what qualifies a number as being "long distance." Would you
> rather change the rule with one line of code in your view, or
> construct and run some SQL that finds and updated all matching phone
> numbers? (Note: this is meant to be a rhetorical question but could
> very well be debated.)
>
> Sorry for the tangent. I'm a stickler for best practices.

That's fair...and although, you meant that as a rhetorical question, I
would indeed debate that and would further argue with your definition
of what constitutes best practices as implied by your post.

Best practices don't exist in one dimension and they are not written
in stone. You can have best practices for high performance, highly
scalable applications that are different from best practices for
"regular" applications. Today's scalability needs demand that
developers keep an open mind on what's best for the application and
it's performance/scalability requirements. Most of the time, this is
not a problem as theory usually converges with practice for a lot of
applications. But not for all.

When, for example, a regex based query is very expensive and your app
has many places where it wants to pull up phone numbers based on their
"is_long_distance" value, it certainly makes sense to store this
attribute in a precomputed form and refreshed it in a batch
computation if/when the rules for it change at all in future.

Another example, if you have a model with a purchase order with child
items that represent each purchased item, it does make sense to store
the order total in the purchase order master record, even though you
could derive it from the sum of individual item totals every time you
need it.

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



filling in AutoField

2008-07-02 Thread Grzegorz Dostatni
I'm writing a django application (postgresql db) that needs to deal with
input both from GUI (webserver) and commandline (parsing text input).

I've got a model defined where I explicitly define the id field using:

id = models.AutoField(primary_key = True)

When I'm creating a new entry, is there a method available to find the next
value in the sequence? I know the sql for that, I'm trying to see if there
is a function within django that does it. I'd rather not have sql statements
with hardcoded values (sequence name) included in my python code (unless I
absolutely have to).

Thanks,

Greg

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



Re: Regex

2008-07-02 Thread Ross Dakin

Followup to clarify.

If you DON'T use a is_longdistance flag in the model, then you use a
set of rules to determine if a number is long distance when you get
the number out of the db.

You can avoid this by using a is_longdistance flag in the model, but
you're going to have to do the same thing to determine whether or not
to set the flag when you insert a number into the database. And you
have the added pain of updating the db is these rules change, which
you don't have to do if you just check for long-distance-ness upon
retrieval.

We could even argue that the flag is wasted space in the db.

But if we get that nit picky, one could counter-argue that running the
is-long-distance logic once upon insertion is more efficient than
running it on each retrieval in a read-intensive system. However, I
prefer and human-efficient practices over computer-efficient
practices; computers get faster, humans don't.

Thus, the cleanliness and (IMHO) elegance of simply doing the check
upon retrieval and thereby avoiding potential manual updates to the db
and introducing a new table field beats the alternative.

Sorry again: huge tangent.

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



Re: Regex

2008-07-02 Thread Ross Dakin

Hi Rajesh,

Certainly, best practices are subject to your goals: code
maintainability, storage efficiency, execution efficiency, etc.

I agree, there are times when it makes sense to store calculated
values in a database. I would argue, however, that this inhibits
scalability. As a system grows, the potential for inconsistencies due
to this redundant data also grows.

We have this issue at my current job right now. Our systems have grown
organically over five years and we have various pools of redundant
data that have been the sources of some scaling issues.

Ross


On Jul 2, 2:27 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi Ross,
>
>
>
> > I would disagree here. The database should only be used to store raw
> > data; the database should not know anything about this data (the
> > database should not be "smart").
>
> > Determining whether or not a number qualifies as "long distance" is a
> > job for the domain / controller / view layer (pick your jargon).
>
> > Here's why. Suppose the company moves, or the geographical scope of
> > one area code is changed. Now you have a different set of rules that
> > determine what qualifies a number as being "long distance." Would you
> > rather change the rule with one line of code in your view, or
> > construct and run some SQL that finds and updated all matching phone
> > numbers? (Note: this is meant to be a rhetorical question but could
> > very well be debated.)
>
> > Sorry for the tangent. I'm a stickler for best practices.
>
> That's fair...and although, you meant that as a rhetorical question, I
> would indeed debate that and would further argue with your definition
> of what constitutes best practices as implied by your post.
>
> Best practices don't exist in one dimension and they are not written
> in stone. You can have best practices for high performance, highly
> scalable applications that are different from best practices for
> "regular" applications. Today's scalability needs demand that
> developers keep an open mind on what's best for the application and
> it's performance/scalability requirements. Most of the time, this is
> not a problem as theory usually converges with practice for a lot of
> applications. But not for all.
>
> When, for example, a regex based query is very expensive and your app
> has many places where it wants to pull up phone numbers based on their
> "is_long_distance" value, it certainly makes sense to store this
> attribute in a precomputed form and refreshed it in a batch
> computation if/when the rules for it change at all in future.
>
> Another example, if you have a model with a purchase order with child
> items that represent each purchased item, it does make sense to store
> the order total in the purchase order master record, even though you
> could derive it from the sum of individual item totals every time you
> need it.
>
> -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inputting Date/Time in a Django Form

2008-07-02 Thread Tim Sawyer

Sorry, still not working.  I get:

__init__() got an unexpected keyword argument 'widgets'

Is that because widgets isn't a parameter to __init__ ? (I'm still getting to 
grips with python, it's so much more expressive than the Java I'm used to!)

My code is:

 collection_datetime = forms.SplitDateTimeField(widget=
   
forms.SplitDateTimeWidget(widgets=
 (
  
forms.TextInput({'class':'vDateField required'}), 
  
forms.TextInput({'class':'vTimeField required'})
  )
)
   )

ta,

Tim.

On Wednesday 02 Jul 2008, TiNo wrote:
> Have a look at the source (widgets.py in newforms):
> class SplitDateTimeWidget(MultiWidget):
> """
> A Widget that splits datetime input into two  boxes.
> """
> def __init__(self, attrs=None):
> widgets = (TextInput(attrs=attrs), TextInput(attrs=attrs))
> super(SplitDateTimeWidget, self).__init__(widgets, attrs)
>
> So maybe:
>
> collection_datetime =
> forms.SplitDateTimeField(
>
> widget=forms.SplitDateTimeWidget(
>
> widgets=(TextInput({'class':'vDateField required'}),
>
> TextInput({'class':'vTimeField'}
>
> will work?
>
>
> On Wed, Jul 2, 2008 at 11:03 PM, Tim Sawyer <[EMAIL PROTECTED]>
>
> wrote:
> > Thanks.
> >
> > I've got the class in the html but not the buttons for the date or time
> > popup.
> > I also have two date popups and I think I should have one that has the
> > class
> > vTimeField not vDateField.
> >
> > collection_datetime =
> >
> > forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget({'class':'vDate
> >Field required'}))
> >
> > in my form is generating:
> >
> > Collection
> > datetime: > type="text" class="vDateField required" name="collection_datetime_0"
> > />
> >
> > in my html.
> >
> > Any ideas?
> >
> > Cheers,
> >
> > Tim.
> >
> > On Wednesday 02 Jul 2008, TiNo wrote:
> > > Sorry, I was a little too quick. I used it like this:
> > > date =
> >
> > forms.DateField(label=_("Date"),widget=forms.DateTimeInput(attrs={'class'
> >:'
> >
> > >vDateField'}))
> > >
> > > I am not sure on how to do this on a SplitDateTimeField though.
> > >
> > > On Wed, Jul 2, 2008 at 10:52 PM, Tim Sawyer
> > > <[EMAIL PROTECTED]>
> > >
> > > wrote:
> > > > Sorry, I don't understand where I have to put the attrs bit.
> > > >
> > > > Can you give me an example?
> > > >
> > > > delivery_datetime =
> > > > forms.SplitDateTimeField(attrs={'class':'vDateField'}) doesn't work,
> > > > is that what you meant?
> > > >
> > > > Thanks,
> > > >
> > > > Tim.
> > > >
> > > > On Sunday 29 Jun 2008, TiNo wrote:
> > > > > add:
> > > > >
> > > > >  >
> > type="text/javascript"
> >
> > > > > >
> > > > >
> > > > >  > > > > type="text/javascript" >
> > > > >  > > > > type="text/javascript" >
> > > > >
> > > > > to your template, use SplitDateTimeField and pass the fields:
> > > > >
> > > > > attrs={'class':'vDateField'}
> > > > >
> > > > > That way you have the same date and time input as the admin
> >
> > interface.
> >
> > > > > TiNo
> > > > >
> > > > > On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer
> > > > > <[EMAIL PROTECTED]
> > > > >
> > > > > wrote:
> > > > > > Hi Folks,
> > > > > >
> > > > > > What's the simplest approach for me to have a form that makes it
> >
> > easy
> >
> > > > for
> > > >
> > > > > > the
> > > > > > user to enter a Date/Time combination?
> > > > > >
> > > > > > I have my form class specified (the field in question is a
> > > > > > forms.DateTimeField()), but I need to make it easy for users of
> > > > > > the
> > > >
> > > > site
> > > >
> > > > > > to enter a date/time pair for the field.
> > > > > >
> > > > > > Is there a simple way to do this?  I'm using jQuery for
> > > > > > javascript
> >
> > on
> >
> > > > the
> > > >
> > > > > > site
> > > > > > if that's relevant.
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Regex

2008-07-02 Thread John Boxall

You might want to refer to this recent article at Coding Horror:
http://www.codinghorror.com/blog/archives/001016.html

I would stick to what you have.

(and I would also only do the calculation once and store it as a
boolean field in the database as suggested : )

John

On Jun 30, 7:13 am, mike171562 <[EMAIL PROTECTED]> wrote:
> Hello,
>    I am working on a django that querys long distance numbers from a
> mysql database. I am currently using the django API, that goes
> something like this.
>
> long_distance =
> Call.objects.filter(dest_num__startswith='1').filter(dest_num__gt=6).exclude(dest_num__startswith='18').exclude(dest_num__startswith='1281').exclude(dest_num__startswith='1832').exclude(dest_num__startswith='1713')
>
> I was hoping to consolidate all of my .filter excludes into one regex.
> is this possible and would it be more efficient? Basically any number
> that doesnt start with 281,713,832 or 1281,1713,or 1832 is long
> distance any help would be appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Regex

2008-07-02 Thread Rajesh Dhawan



On Jul 2, 5:33 pm, Ross Dakin <[EMAIL PROTECTED]> wrote:
> Followup to clarify.
>
> If you DON'T use a is_longdistance flag in the model, then you use a
> set of rules to determine if a number is long distance when you get
> the number out of the db.

Sure. Now what if the set of rules you need to use don't fit in
"naturally" into the RDBMS layer? For example, a regex search in a
field is, obviously, not the most efficient way to determine long
distance-ness of a phone number record if you have say a million phone
numbers. RegEx searches tend to be CPU-intensive and having to perform
them over and over to determine the value of an important/frequently
needed attribute is not necessarily the best design choice.

>
> You can avoid this by using a is_longdistance flag in the model, but
> you're going to have to do the same thing to determine whether or not
> to set the flag when you insert a number into the database.

Yes, but you would need to do it only once per record insert/update.
It's typical for most systems to perform far more DB record retrievals
than DB record updates. So, a modestly expensive operation when
repeated millions of times does call out for a proper design choice
(compute on retrieval vs. compute on save.)

>  And you
> have the added pain of updating the db is these rules change, which
> you don't have to do if you just check for long-distance-ness upon
> retrieval.

Again, the pain is relative to the design of the application and DB.
You could, for example, have a DB trigger update that flag for you
transparently. You could, for example, also establish an architecture
where DB updates go through a stored procedure or a framework's ORM
layer and hook in any pre-computations there.

>
> We could even argue that the flag is wasted space in the db.

Arguing that would be wasted usenet space in today's day and age :)

>
> But if we get that nit picky, one could counter-argue that running the
> is-long-distance logic once upon insertion is more efficient than
> running it on each retrieval in a read-intensive system. However, I
> prefer and human-efficient practices over computer-efficient
> practices; computers get faster, humans don't.
>
> Thus, the cleanliness and (IMHO) elegance of simply doing the check
> upon retrieval and thereby avoiding potential manual updates to the db
> and introducing a new table field beats the alternative.

You would be right if this were a simple check that's naturally
efficient in SQL. But a regex check doesn't fall in that category
especially a regex check that has many different OR conditions and
especially one that might be run over millions of phone records.

>
> Sorry again: huge tangent.

I don't think it is.


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



Re: Free Comments problem...

2008-07-02 Thread Milan Andric

Can you paste your template at http://dpaste.com so we can have a look?

On Wed, Jul 2, 2008 at 11:10 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> : ) absolutely! It's in an entry template. I've tried the same thing
> in other templates as well (a gallery page, a photo page...) and the
> same.
>
> I don't get any error messages at all. The page loads fine. If I
> change the syntax of the {% free_comment_form ... %}, for example by
> introducing a spelling error or something, then I get an error page,
> but otherwise, Django doesn't complain.
>
> On Jul 2, 11:27 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>> On Wed, Jul 2, 2008 at 11:14 AM, [EMAIL PROTECTED] <
>>
>> [EMAIL PROTECTED]> wrote:
>>
>> > Yeah, so in the parent template (base.html) I've specified the usual
>> > {% block content %} and in the child template, the call to the form is
>> > well within the corresponding block tags. I've checked syntax about a
>> > million times too, to make sure there's no syntax error - it's a
>> > pretty simple project, so not much to check.
>>
>> > thanks for the answer though - any other ideas?
>>
>> Are you absolutely sure the template being rendered is the one where you
>> have put the {% free_comment_form ... %}?  If you deliberately introduce an
>> error (like omitting the {% load comments %} or mistyping a variable name in
>> the comment form arguments, do you get the expected "Invalid block tag" and
>> "VariableDoesNotExist" errors?
>>
>> Karen
> >
>

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



Re: streaming upload

2008-07-02 Thread umrzyk

On 29 Cze, 22:15, umrzyk <[EMAIL PROTECTED]> wrote:
> hi there,
> i would like to give my users ability to upload a huge (i.e. 10-20 MB)
> files, mostly images. standard uploading using django newforms and
> FileField is at the moment not an option. it kills my
> server immediately. recently i read about streaming upload, and.. wow,
> that's it! so i patched my django sources with 2070-r7728.patch (no
> conflicts) and gave it a try. here are the problems:
>
> - for small files (i didn't check what is a small file, i guess it's
> something < 2.5MB as mentioned in doc) i got a validation message:
> "the
> submitted file is empty"
>
> - for larger files (i tried 11MB) i got an error from server: "413
>   Request Entity Too Large"
>
> i'm sure i'm doing something wrong, actually i'm the beginner. could
> you
> suggest where should i start searching? Or could you help me with a
> sample snippet that would upload the file in a given directory?
>
> running server is nginx 0.7.1 with mod_wsgi
>
> thanks,
> jm.


guys,
i have just set up apache (with mod_wsgi) to verify this issue and it
occured that django complains about empty submitted file independently
from running server. so I guess somethig is wrong with either my code
(most probably...) or with the patch.
Once again, the problem is that i cannot upload small files (request
body hold in memory). form validator returns immediately "the
submitted file is empty" message in this case. large files upload
without any problems.
my form code:

class ArticleForm(forms.Form):
title = forms.CharField(max_length=100)
content = forms.FileField()

def save(self,commit = True,user=None,f=None):
article = Article(created=user, content=f)
if commit:
article.save()
return article

view code:

def workspace(request):
if request.method == 'POST':
form = ArticleForm(request.POST, request.FILES)
if form.is_valid():
article =
form.save(user=request.user,f=request.FILES['content'])
else:
form = ArticleForm()
return render_to_response('workspace.html', {'user': request.user,
'form': form})

and models code:

class Article(models.Model):
title = models.CharField(max_length=100)
content = models.FileField(upload_to="articles")


any suggestions what is wrong here?

thanks,
jm.

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



Re: GeoDjango/GoogleMaps: No support for points/markers

2008-07-02 Thread tlpinney

Hi Ludwig,

Can you create a ticket on the trac and attach the patch?

Thanks,
Travis




On Jul 1, 4:05 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I  noticed that the automatic Google Map creation in the Django GIS
> branch does not support the display of point features, only polylines
> and polygons.
>
> Unless there was a specific reason not to include this, I have a
> patch  that will include points as GMarkers on maps, which I could
> contribute.
>
> Maybe the reason is that there is not consensus whether Google Maps
> should be in the core Django offering?
>
> Ludwig
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using SQLite in production

2008-07-02 Thread phillc

are you forced to use sqlite?


http://www.sqlite.org/limits.html

On Jul 2, 11:09 am, Brian Luft <[EMAIL PROTECTED]> wrote:
> I don't have any firsthand experience to share with running sqlite in
> a production setting.  I did choose to spend about 30 seconds scanning
> the sqlite FAQ:
>
> http://www.sqlite.org/faq.html#q5http://www.sqlite.org/faq.html#q6
>
> If what sqlite is saying on their FAQ is true, it sounds you can get
> away with running sqlite in a production setting.  However, please
> don't interpret this as a recommendation from me.
>
> -Brian
>
> On Jul 2, 5:20 am, David Marko <[EMAIL PROTECTED]> wrote:
>
> > I'm just considering using SQLite in small Django project(in
> > production environment). I have no fear about performance but what
> > troubles me is whether SQLite can be used in environment like Apache
> > +mod_wsgi ? As SQLite is file based database, isn't there concurrency
> > problem?
>
> > Can someone explain?
>
> > Thanks,
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: filling in AutoField

2008-07-02 Thread Rajesh Dhawan

Hi Greg,

On Jul 2, 5:29 pm, "Grzegorz Dostatni" <[EMAIL PROTECTED]> wrote:
> I'm writing a django application (postgresql db) that needs to deal with
> input both from GUI (webserver) and commandline (parsing text input).
>
> I've got a model defined where I explicitly define the id field using:
>
>     id = models.AutoField(primary_key = True)
>
> When I'm creating a new entry, is there a method available to find the next
> value in the sequence? I know the sql for that, I'm trying to see if there
> is a function within django that does it. I'd rather not have sql statements
> with hardcoded values (sequence name) included in my python code (unless I
> absolutely have to).

The idea behind an AutoField is that the database assigns that field
the next value from a sequence upon INSERT. You don't have to set that
value yourself and normally shouldn't have to care what that value is
going to be prior to the object being saved to the DB.

Can you describe the use-case that requires you to know the next value
in the sequence before you save a new instance of your object?

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



Re: django+mod_python, caching or something else?

2008-07-02 Thread phillc

i was going to say state a question, but found my answer...

for anyone else:

http://www.djangoproject.com/documentation/db-api/#querysets-are-lazy

On Jul 2, 10:09 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Alex Koshelev wrote:
> > Or may be a custom template tag for common stuff.
>
> Or like any code anywhere just extract the common parts to a helper
> function and call that.
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> You've got fun!  Check out Austin360.com for all the entertainment
> info you need to live it up in the big city!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: choices

2008-07-02 Thread Rajesh Dhawan



On Jul 2, 4:40 pm, urukay <[EMAIL PROTECTED]> wrote:
> is there a way how to create choices in Models in specific way, that some
> choices are not selectable (they only group and describe choices below)?
>
> e.g.:
>
> CHOICES = (
>      ('0', 'Basic Colors'),
>      ('1', 'Red'),
>      ('2', 'Green'),
>      ('3', 'Blue'),
>      ('4', 'Other Colors'),
>      ('5', 'Brown'),
>         .
> )
>
> and I want "Basic Colors" and "Other Colors" not selectable when displaying
> CHOICES in model. Is it possible?

If you want to do this in your own template, you could use the
OPTGROUP HTML tag when rendering that formfield:

http://www.w3schools.com/tags/tag_optgroup.asp


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



Re: forms + UI question

2008-07-02 Thread phillc

look up context processors

On Jul 2, 4:31 am, pihentagy <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I have an auction site, the items appear in more views (and there are
> more items in a view), and I would like to allow users to bid on every
> view.
> I have done it somehow, but I think that solution is not pretty (I
> mean the code quality). I would like to use the same newforms form on
> every view, if possible. The form consists of one numeric field. I
> also would like to prefill the bids made before. Can anybody propose
> me a solution how to organize these? Especially the Form & url part.
>
> Thanks
> Gergo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: URL pre-processing middleware

2008-07-02 Thread Rajesh Dhawan

Hi,

>
> Is there somewhere I should be looking where I'm not? Some kind of
> built in rewriter?

Have you considered using Apache mod_rewrite instead of trying to
solve this at the application layer?

http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html

Lighttpd and nginx also have similar modules.

-Rajesh


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



Re: testing login problem

2008-07-02 Thread Russell Keith-Magee

On Wed, Jul 2, 2008 at 10:14 PM, Norman Harman <[EMAIL PROTECTED]> wrote:
>
> Test system creates a new test database from scratch every time it is
> run.  manage.py loaddata has NO effect on test.
>
> I could be wrong but I don't believe test runner automatically loads the
> fixture initial_data.xml

You are wrong. initial_data is automatically loaded whenever syncdb is
run; syncdb is used to set up the test database, so all initial_data
will be present in a test database.

However, the rest of your analysis is correct - data manually loaded
with loaddata won't be present in the test database. You need to
either define a fixture in your django.test.TestCase, or call the
loaddata management as part of the test case itself.

Yours,
Russ Magee %-)

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



Re: Stability of trunk and 1.0 target: experience, testimonials?

2008-07-02 Thread J Meier

Thank you, everyone. That was exactly what I needed. It looks like
we'll be starting a prototype on Django trunk targeting 1.0 this week.

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



Re: choices

2008-07-02 Thread urukay


thanks, but i was wondering if it's possible to do that in MODEL?

Rajesh Dhawan wrote:
> 
> 
> 
> 
> On Jul 2, 4:40 pm, urukay <[EMAIL PROTECTED]> wrote:
>> is there a way how to create choices in Models in specific way, that some
>> choices are not selectable (they only group and describe choices below)?
>>
>> e.g.:
>>
>> CHOICES = (
>>  ('0', 'Basic Colors'),
>>  ('1', 'Red'),
>>  ('2', 'Green'),
>>  ('3', 'Blue'),
>>  ('4', 'Other Colors'),
>>  ('5', 'Brown'),
>> .
>> )
>>
>> and I want "Basic Colors" and "Other Colors" not selectable when
>> displaying
>> CHOICES in model. Is it possible?
> 
> If you want to do this in your own template, you could use the
> OPTGROUP HTML tag when rendering that formfield:
> 
> http://www.w3schools.com/tags/tag_optgroup.asp
> 
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/choices-tp18246312p18249595.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: Make changes to model...

2008-07-02 Thread Malcolm Tredinnick


On Wed, 2008-07-02 at 11:49 -0700, [EMAIL PROTECTED] wrote:
> Thanks guys. I know how to do it via the admin, wasn't sure if I was
> "missing" something within Django to handle it :)
> 
> Kind of off topic, but say myapp is named myapp, then in the heading
> the admin will be displayed Myapp with the model items below it. Other
> than customizing the admin template is there a way to change that?

Yes. Read about the Meta inner-class in the model-api documentation.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >