Re: syncdb is not doing anything

2009-07-05 Thread Luc Saffre

I often got confused because when a modification in my models.py causes
it to raise an ImportError (for example you try to import a non-existing
module from your module.py), then several parts of Django (including
syncdb) simply act as if your application wasn't installed, without any
warning.
Maybe that's also your problem?
Luc

On 6.07.2009 8:17, chefsmart wrote:
> Hi,
> 
> I have been working on an app for some time now. I have been using the
> Django svn trunk.
> 
> I have a lot of data in the database. Today I modified a couple of
> fields and added a couple of fields (date and char fields) to three of
> my models. No fields have been removed from the original model
> definitions.
> 
> When I do "python manage.py sql myapp" the output shows some
> inconsistent sql that is syntactically wrong. I thought this may
> simply be a jumbled string output problem, so I ran syncdb anyway.
> However, syncdb is not doing anything. I mean no messages, no error
> outputs, nothing. It just simply exits with a blank line output. I
> checked my database (mysql) and there were no changes made. So syncdb
> is not doing anything, even though the sqlall output shows it wants to
> do a lot of sql commands.
> 
> Moreover, the manage.py sql myapp command shows that syncdb wants to
> drop and reconstruct tables that I have not modified, and that are not
> related to the modified models in any way.
> 
> What could be going on?
> 
> Regards,
> CM
> > 


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



Re: syncdb is not doing anything

2009-07-05 Thread Kenneth Gonsalves

On Monday 06 July 2009 10:47:59 chefsmart wrote:
>  have a lot of data in the database. Today I modified a couple of
> fields and added a couple of fields (date and char fields) to three of
> my models. No fields have been removed from the original model
> definitions.

syncdb does not look at changes within models - only looks for new models. 
Changing fields within models has to be done manually, or you can look at the 
various attempts at building schema evolution. The simplest way to do this is 
to save the output of sqlall before and after you change your models. Find the 
diff and make a change.sql script out of the diff.

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

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



syncdb is not doing anything

2009-07-05 Thread chefsmart

Hi,

I have been working on an app for some time now. I have been using the
Django svn trunk.

I have a lot of data in the database. Today I modified a couple of
fields and added a couple of fields (date and char fields) to three of
my models. No fields have been removed from the original model
definitions.

When I do "python manage.py sql myapp" the output shows some
inconsistent sql that is syntactically wrong. I thought this may
simply be a jumbled string output problem, so I ran syncdb anyway.
However, syncdb is not doing anything. I mean no messages, no error
outputs, nothing. It just simply exits with a blank line output. I
checked my database (mysql) and there were no changes made. So syncdb
is not doing anything, even though the sqlall output shows it wants to
do a lot of sql commands.

Moreover, the manage.py sql myapp command shows that syncdb wants to
drop and reconstruct tables that I have not modified, and that are not
related to the modified models in any way.

What could be going on?

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



syncdb is not doing anything

2009-07-05 Thread chefsmart

Hi,

I have been working on an app for some time now. I have been using the
Django svn trunk.

I have a lot of data in the database. Today I modified a couple of
fields and added a couple of fields (date and char fields) to three of
my models. No fields have been removed from the original model
definitions.

When I do "python manage.py sql myapp" the output shows some
inconsistent sql that is syntactically wrong. I thought this may
simply be a jumbled string output problem, so I ran syncdb anyway.
However, syncdb is not doing anything. I mean no messages, no error
outputs, nothing. It just simply exits with a blank line output. I
checked my database (mysql) and there were no changes made. So syncdb
is not doing anything, even though the sqlall output shows it wants to
do a lot of sql commands.

Moreover, the manage.py sql myapp command shows that syncdb wants to
drop and reconstruct tables that I have not modified, and that are not
related to the modified models in any way.

What could be going on?

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



Re: Apache with Django

2009-07-05 Thread Boštjan Jerko


On 6.7.2009, at 5:31, WilsonOfCanada wrote:

>
> Also, do I use the my LAN IP or Internet IP with which port (is it the
> same one Apache listens to)?
>

It depends how you set up the connection between Apache and Django?  
What do you use?
Usually it's just a local server IP (so 127.0.0.1).
B.

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



Re: Apache with Django

2009-07-05 Thread Kenneth Gonsalves

On Monday 06 July 2009 09:01:53 WilsonOfCanada wrote:
> When running a production server, I was wondering if I still use
> "python manage.py runserver [ip]:[port]" because the cmd says it is
> running a development server.
>
> Also, do I use the my LAN IP or Internet IP with which port (is it the
> same one Apache listens to)?

you do not, repeat not use runserver in production.
-- 
regards
kg
http://lawgon.livejournal.com

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



Apache with Django

2009-07-05 Thread WilsonOfCanada

Hellos,

When running a production server, I was wondering if I still use
"python manage.py runserver [ip]:[port]" because the cmd says it is
running a development server.

Also, do I use the my LAN IP or Internet IP with which port (is it the
same one Apache listens to)?

Thanks

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



Re: Model for "Global Options"

2009-07-05 Thread dvainsencher

On Jul 5, 9:21 pm, dvainsencher  wrote:
> On Jul 5, 10:12 am, thornomad  wrote:
>
>
>
> > Hi Daniel -
>
> > Okay ... so, it looks like I could do this two ways (maybe more).
> > After reading:http://docs.djangoproject.com/en/dev/ref/templates/api/
>
> > 1. I could create my own context process and define it in
> > TEMPLATE_CONTEXT_PROCESSORS -
>
> > 2. (maybe more straightforward) I could create a function in a view
> > that returns a dictionary of all the items (value/key pairs) in a
> > particular Model ... then pass that to the view when it gets process.
> > Then I could add/remove value/key pairs form the admin as needed.
>
> > I think I may try out option 2, and see how it goes.  Sounds easier,
> > anyway.
>
> Good search, Damon.
> The implementation with context processor is not so hard than in view
> one.
> If you want to use global anywhere i think it's a better approach.
>

s/anywhere/everywhere

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



Re: Model for "Global Options"

2009-07-05 Thread dvainsencher

On Jul 5, 10:12 am, thornomad  wrote:
> Hi Daniel -
>
> Okay ... so, it looks like I could do this two ways (maybe more).
> After reading:http://docs.djangoproject.com/en/dev/ref/templates/api/
>
> 1. I could create my own context process and define it in
> TEMPLATE_CONTEXT_PROCESSORS -
>
> 2. (maybe more straightforward) I could create a function in a view
> that returns a dictionary of all the items (value/key pairs) in a
> particular Model ... then pass that to the view when it gets process.
> Then I could add/remove value/key pairs form the admin as needed.
>
> I think I may try out option 2, and see how it goes.  Sounds easier,
> anyway.
>

Good search, Damon.
The implementation with context processor is not so hard than in view
one.
If you want to use global anywhere i think it's a better approach.

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



Re: problem with manage.py runfcgi and the pidfile parameter

2009-07-05 Thread aaron smith

Just as another illustration of the problem. I'm using the example in
the help docs for the runfcgi command - even that doesn't work.

$>python manage.py runfcgi socket=/tmp/fcgi.sock method=prefork
daemonize=true pidfile=/var/run/django-fcgi.pid

It doesn't write out the pid file, and it doesn't start the process.
No errors thrown either.

However, if you take out the pidfile parameter, it does work.

$>python manage.py runfcgi socket=/tmp/fcgi.sock method=prefork daemonize=true

This seems like a problem right? I'm running mac os x 10.5

Thanks for any help.



On Sun, Jul 5, 2009 at 3:55 PM, aaron
smith wrote:
> Hey all, I'm running into something that I'm not sure if it's a
> problem, or something I might be doing wrong. What I'm working on is
> some deployment scripting, and using pid files to kill processes. I'm
> having problems with the pidfile attribute.
>
> When I run manage.py like this, the pidfile is written as expected
> (I'm testing out tcp and unix sockets just to for good measure):
>
> python manage.py runfcgi host=127.0.0.1 port=8024 daemonize=false
> pidfile=serve/fcgi/port_8024.pid
> python manage.py runfcgi socket=/tmp/fcgi.sock daemonize=false
> pidfile=serve/fcgi/port_8024.pid
>
> After each of those, I run this:
>
> $>more serve/fcgi/port_8024.pid
>
> It correctly has the pid in it.
>
> Then I delete the pid file:
>
> $>rm serve/fcgi/port_8024.pid
>
> Now I try running it daemonized:
>
> python manage.py runfcgi host=127.0.0.1 port=8024 daemonize=true
> pidfile=serve/fcgi/port_8024.pid
> python manage.py runfcgi socket=/tmp/fcgi.sock daemonize=true
> pidfile=serve/fcgi/port_8024.pid
>
> After doing that, it hasn't created the port_8024.pid file.
>
> This is where it gets interesting.  I'm noticing that for some reason
> the fcgi isn't spawning either - when I have the pidfile=xxx parameter
> specified.
>
> When I run `ps -ax` I don't see the process there.
>
> But, when I run it again, without the pidfile:
>
> python manage.py runfcgi host=127.0.0.1 port=8024 daemonize=true
> python manage.py runfcgi socket=/tmp/fcgi.sock daemonize=true
>
> Now the process actually spawns, and I see it in `ps -ax`
>
> Anyone have any idea what's going on? Is this a bug?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with manage.py runfcgi and the pidfile parameter

2009-07-05 Thread aaron smith

Hey all, I'm running into something that I'm not sure if it's a
problem, or something I might be doing wrong. What I'm working on is
some deployment scripting, and using pid files to kill processes. I'm
having problems with the pidfile attribute.

When I run manage.py like this, the pidfile is written as expected
(I'm testing out tcp and unix sockets just to for good measure):

python manage.py runfcgi host=127.0.0.1 port=8024 daemonize=false
pidfile=serve/fcgi/port_8024.pid
python manage.py runfcgi socket=/tmp/fcgi.sock daemonize=false
pidfile=serve/fcgi/port_8024.pid

After each of those, I run this:

$>more serve/fcgi/port_8024.pid

It correctly has the pid in it.

Then I delete the pid file:

$>rm serve/fcgi/port_8024.pid

Now I try running it daemonized:

python manage.py runfcgi host=127.0.0.1 port=8024 daemonize=true
pidfile=serve/fcgi/port_8024.pid
python manage.py runfcgi socket=/tmp/fcgi.sock daemonize=true
pidfile=serve/fcgi/port_8024.pid

After doing that, it hasn't created the port_8024.pid file.

This is where it gets interesting.  I'm noticing that for some reason
the fcgi isn't spawning either - when I have the pidfile=xxx parameter
specified.

When I run `ps -ax` I don't see the process there.

But, when I run it again, without the pidfile:

python manage.py runfcgi host=127.0.0.1 port=8024 daemonize=true
python manage.py runfcgi socket=/tmp/fcgi.sock daemonize=true

Now the process actually spawns, and I see it in `ps -ax`

Anyone have any idea what's going on? Is this a bug?

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



using modelformsets

2009-07-05 Thread Eric Abrahamsen

I'm somehow failing to use modelformsets, this is the relevant view  
and error traceback:

http://dpaste.org/evHq/

I'm validating a whole bunch of forms at the same time, but I don't  
see how that could cause the formset failure. Sample is a model with a  
ForeignKey to Author (though the ForeignKey field itself is called  
'translator', stupid naming practice). I'm hoping there's something  
obviously wrong with what I'm doing there, but I can provide more  
details if necessary...

TIA,
Eric

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



user passes test or is owner

2009-07-05 Thread Streamweaver

I'm new to decorators but using them in their basic form fine in
Django so far.

My problem is this.  I have two model edit forms, each has an owner
field that is a FK to a user.

I also have some groups with permissions to edit the models.

What I want to do is setup a 'is_owner_or_has_perm' decorator but I'm
not sure how to handle the OR part of it all.  It seems like I'd have
to pass the decorator both the user and the object I wanted to edit
and I"m not sure how to do 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin of an Admin for an E-Commerce Page

2009-07-05 Thread Nick

I'm looking to write an e-commerce page with very minimal admin
functionality, but which also has an extended admin that would
facilitate the rest of the basic admin tasks.  For example, the basic
admin could add products but shouldn't have to know any html or meta-
language to do so.  They just import a few pictures, add a
description, a few tags, and a price, amount in stock, along with
maybe a category and type of layout, then hit the 'add' button.  The
extended admin, would be responsible for creating the different
layouts to be chosen from, along with adding additional categories,
adjusting SEO meta info, portlets, etc...  The default admin module in
Django, along with a few Django e-commerce options I have looked into,
all seem to lump everything into the same admin area.  Is there
anything out there that separates this functionality or should I look
into rolling my own?  And if the answer is roll my own, do you have
any tips as to where to start?  I'm pretty new to python & django so
pardon me if I'm missing something obvious.

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



Re: ChoiceField, TypedChoiceField, ModelChoiceField and empty_label

2009-07-05 Thread zweb

I also agree this is a needed feature.

On Jul 3, 5:17 pm, maplye  wrote:
> I also agree that
>
> 2009/7/3 ristretto.rb :
>
>
>
> > Hello,
>
> > I have stepped through code, and cruised the django docs, forums, and
> > internet in general looking for how to setup an empty label with
> > TypedChoiceField (or ChoiceField.)  I suspected it would be done
> > similar to the way it is done with ModelChoiceField.
>
> > With ModelChoiceField, we can specify anempty_label.  But, with
> > TypeChoice and Choice you have to put an empty field in our choices
> > list.  And, None doesn't work, it has to be ''.
>
> > I have code that is working fine.  But, my question is...  Is there
> > any design reasonempty_labelwas not included in the other Choice
> > fields?
>
> > thanks
> > ristretto
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: extracting MySQL-python-1.2.3c1.tar.gz

2009-07-05 Thread Nikola Pavlović

On Sun, Jul 05, 2009 at 06:47:10AM -0700, mikel wrote:
> 
> Setting up Django is going fine until configuring MySQL. It requires
> MySQLdb, which I downloaded from sourceforge as MySQL-
> python-1.2.3c1.tar.gz (and MySQL-python-1.2.2.tar.gz) on Mac OS X,
> Redhat, and Windows. When I try decompressing then extracting the file
> returns error: "tar: This does not look like a tar archive". I've
> never had this problem with gzip/tar files and not sure where to look
> next. Any help on getting MySQLdb so I can move forward with Django
> would be great. Thanks!
> 

It's not really a Django question... ;)

I just tried with 1.2.2 from SourceForge and it's fine. This is maybe a
dumb question, but have you tried downloading it again? And, at least
for Red Hat, why don't you just use the distro's package? RH surely has
to have something as common as this in repository?


-- 
"I must have a prodigious quantity of mind; it takes me as much as a
week sometimes to make it up."
-- Mark Twain, "The Innocents Abroad"


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



Re: Using a dynamically created ImageField filename prior to save?

2009-07-05 Thread Mirat Can Bayrak

I have another question. You are naming images as hash of random number. There 
is a small chance to produce same name i think. It is not good way to give name 
ha?

-- 
Mirat Can Bayrak 

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



Re: Problem with Reverse

2009-07-05 Thread Karen Tracey
On Sat, Jul 4, 2009 at 11:44 PM, tam...@gmail.com  wrote:

>
> Hi,
>
> I am trying to decouple my views.py with respect to my url.py but I
> have a problem.
>
> -I do have a principal url.py which contains and include to a second
> url.py:
> urlpatterns = patterns('',
> (r'^users/', include('myapp.users.urls'))
> .
>
> -Thus the second url.py contains:
> url(regex='^edit/(?P\w+)/$', prefix='myapp.users',
> view='views.edit_user_profile', name='users_edit'),
>
> -In my views.py (in signup function) I try to call:
> url = reverse('users_edit', kwargs={'username':user.username})
> return HttpResponseRedirect(url)
>
> -But instead of being correctly redirected I have got the following
> error:
> ViewDoesNotExist at /users/signup/
> Tried select in module myapp.users.views. Error was: 'module' object
> has no attribute 'select'
>
> Any hint? :-(


Are you sure you are even getting to your signup view?  From the error
message it does not sound like it -- you are getting ViewDoesNotExist for
/users/signup.  What is the urlpattern for your signup view?  It appears to
be referencing a view named 'select', which isn't being found.

Karen

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



Re: Using email as username for django auth

2009-07-05 Thread Michael
On Sat, Jul 4, 2009 at 8:09 PM, zweb  wrote:

>
> i just increased the size of username in auth_user table to 100 and I
> enter email as user name from my register user web page.
>

Just for the record this is unsupported in Django (due to the constaints
django.contrib.auth.models.User.username), and I will guarantee this
behavior will break in the future  when model validation hits (currently a
GSOC project).

The reason e-mail isn't used as a username is due to, I assume, the way it
was initially created. There are a lot of sites that would prefer to have a
username instead of an e-mail available to the users. So a decision was made
a long time ago and released for us to use. And for me, and a lot of other
people who use Django, and even for your use case with the e-mail
authentication, it works well.

That said the custom auth backend and reading from a field named e-mail
directly, as I showed in the links, is really simple and the code is already
written for you. The only tricky part is creating a username, which you can
do by parsing the email address and placing it in the username field. Simple
really, only you need to know that is what is happening.

My recommendation is to extend the auth module a touch by adding less than
40 LOC to your code base. You could also rewrite the auth module if you
would like. I would not recommend relying on the undocumented behavior.

Michael

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



Re: Easy way to include Request Context always?

2009-07-05 Thread Streamweaver

Thanks for the reply.  I thought that might be the case but wanted to
check.

There is a very good blogpost about this very topic at Liconln Loop

http://lincolnloop.com/blog/2008/may/10/getting-requestcontext-your-templates/

but it was made last year and I hoped there was a setting we could
change or set to make it global.

Thanks again.

On Jul 5, 5:23 am, Ronghui Yu  wrote:
> I had the same problem. I didn't find a built-in way to solve this. But
> I think you can implement a custom render_to_response, which calls the
> built-in one in turn.
> Then what you need to do is just importing your custome one.
>
> Streamweaver ??:
>
>
>
> > I'm still struggling a bit with template contexts
>
> > What I want to do is put a code snippet in the header of my site base
> > template that either presents the user with a small login form if they
> > aren't authenticated or display a "Welcome! user" where user is linked
> > to their profile.
>
> > It seems I have to pass RequestContext(request) everytime I call
> > render_to_response but I'm sure there's an easier way I'm missing.
> > I've read through the docs and apologize if I'm missing it but can
> > someone help with some advice?
>
> > Thanks in advance.
>
> --
> Ronghui Yu 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django and its caching system help

2009-07-05 Thread Ryan K

Greetings,

I am designing an application that includes a menu with a many to many
relationship with links. These menus will hardly ever change. What is
the best way to cache these pages? Should I use the messaging system
to create an html file to use when the menu is changed? Is database
access quicker than disk access? Do I even need to do this considering
Django has a cache system? Any help would be greatly appreciated.

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



Re: Global custom tags

2009-07-05 Thread diogobaeder

Thanks, Yu, it was a lack of attention of mine, not just a typo... I
corrected the file name, now the module is being found, thanks! :-)

Diogo



On Jul 5, 6:32 am, Ronghui Yu  wrote:
> _init_.py should be
>
> __init__.py
>
> or just a typo error in the mail?
>
> diogobaeder ??:
>
>
>
> > Koen,
>
> > I tried to make an initial template tag, just to test and learn, but
> > it's not working. I followed the instructions here
> >http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howt...
> > and registered the compilation function, but it's not finding the
> > module, like stated here in this stack trace, even though I've saved
> > the _init_.py file:
> >http://dpaste.com/63306/
>
> > The code I used to test it is here:
> >http://dpaste.com/63308/
>
> > Any ideas?
>
> > Thanks again!
>
> > Diogo
>
> > On Jul 3, 3:10 am, koenb  wrote:
>
> >> On 3 jul, 04:59, diogobaeder  wrote:
>
> >>> But where do I put the custom template, than? If I load it from an app
> >>> template, I must create it under /templatetags/, and what if I
> >>> want to call it from the base template? /templatetags/?
>
> >>> Thanks!
>
> >>> Diogo
>
> >> I think you are missing something here: there really is no app
> >> namespacing in templatetags: if you try to load a tag library, django
> >> will search the templatetags folders located underneath all installed
> >> apps. If it finds one that matches, it will use that one. This means
> >> that you can use a tag library from app X in any template you use (no
> >> matter where it is located), as long as app X is in the installed
> >> apps. The downside of this is that you need to name your tag libraries
> >> wisely, because tags.py in app X and tags.py in app Y will conflict.
>
> >> Koen
>
> --
> Ronghui Yu 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem displaying application data

2009-07-05 Thread Robert

I ran into a similar problem. It was solved when I corrected the
indentation of "class admin" in models.py of the app.

Cheers.

Robert

On 18 Jun, 18:49, Francis  wrote:
> Hi,
>
> In my project, theadmininterface is not able to display tables
> content of one application. The other application table listing works
> fine. I did change the SITE_ID for some test, but now I'm screw an 
> Ican'tfindany solution to make it works again.
>
> Is there someone with any idea to solve my problem?
>
> Thank you
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Efficiency of getting attribute values in templates

2009-07-05 Thread Rajesh D



On Jul 4, 9:28 pm, TechnicalBard  wrote:
> But the admin app does - it defines the labels from the attribute
> names and just puts them all in a table or list.
>
> How does one do that?

Actually, you tell it which fields you want to display through the
list_display attribute on your Admin class.

  Analogous to iterating through a list of
> objects, is it possible to iterate through the attributes of a single
> object?

The _meta object of a model instance has a method that can give you
all the field names:

your_model_instance._meta.get_all_field_names()

There are several other methods and properties like this available on
the _meta[1] object (for example, get_field(), .fields,..) Once you
learn what they do, you will be able to deduce the field names you
need and then call getattr(your_model_instance, field_name) on them.
You will probably also want to distinguish between local fields and
related fields such as foreign keys and m2m fields. You can't do much
of this in the template. You will have to do all this introspection in
your view and then pass on suitable context variables to your template
which can be fairly generic.

Martin Alchin's book Pro Django[2] is a must-read if you want to dive
into this kinda of stuff.

[1] 
http://code.djangoproject.com/browser/django/trunk/django/db/models/options.py
[2] http://www.amazon.com/Pro-Django-Experts-Voice-Development/dp/1430210478

-RD


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



Re: Django and chat

2009-07-05 Thread Juanjux (Google)

Hi Ivan,

It's not based on Django, but it's easily embedable on any site and
works pretty well:

https://blueimp.net/ajax/

On Jul 3, 8:20 am, Ivan Uemlianin  wrote:
> Xiong
>
> Thanks for your comment.  Good questions.
>
> I envisage a social networking website, based on Django.  The website
> will provide a chat facility for users who are logged in: multi-user
> chatrooms and private chat (I has been thinking of 1-to-1 as a special
> case of multi-user).  Django-integration because certain chat
> functions might have to access Django-centric information (eg
> different types of user displayed differently; perhaps a django
> moderation module).
>
> If there is a standard embeddable thingamajig, that may well be the
> way to go.  Can you recommend any that would fit the above usage?
>
> Best
>
> Ivan
>
>
>
> > Are you looking for a multi-user chatroom, or private chat?  I'm
> > guessing you want the first, but you included a jabber client in there
> > as well, which, to my knowledge, only supports 1-to-1 conversations.
>
> > The approach I've seen for most sites is to have a web interface to an
> > irc room, so that you can chat without having an irc client, or with
> > one, if you prefer.  I know that Rizon just announced an embeddable
> > client for their network, and a quick google finds all sorts of
> > different embeddable clients.  What specifically do you need Django-
> > integration for, as opposed to a standard java/javascript embeddable
> > thingamajig?

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



extracting MySQL-python-1.2.3c1.tar.gz

2009-07-05 Thread mikel

Setting up Django is going fine until configuring MySQL. It requires
MySQLdb, which I downloaded from sourceforge as MySQL-
python-1.2.3c1.tar.gz (and MySQL-python-1.2.2.tar.gz) on Mac OS X,
Redhat, and Windows. When I try decompressing then extracting the file
returns error: "tar: This does not look like a tar archive". I've
never had this problem with gzip/tar files and not sure where to look
next. Any help on getting MySQLdb so I can move forward with Django
would be great. Thanks!

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



Re: Django and chat

2009-07-05 Thread Juanjux (Google)

Not Django, but it can be easily integrated on any site:

https://blueimp.net/ajax/

On Jul 3, 8:20 am, Ivan Uemlianin  wrote:
> Xiong
>
> Thanks for your comment.  Good questions.
>
> I envisage a social networking website, based on Django.  The website
> will provide a chat facility for users who are logged in: multi-user
> chatrooms and private chat (I has been thinking of 1-to-1 as a special
> case of multi-user).  Django-integration because certain chat
> functions might have to access Django-centric information (eg
> different types of user displayed differently; perhaps a django
> moderation module).
>
> If there is a standard embeddable thingamajig, that may well be the
> way to go.  Can you recommend any that would fit the above usage?
>
> Best
>
> Ivan
>
>
>
> > Are you looking for a multi-user chatroom, or private chat?  I'm
> > guessing you want the first, but you included a jabber client in there
> > as well, which, to my knowledge, only supports 1-to-1 conversations.
>
> > The approach I've seen for most sites is to have a web interface to an
> > irc room, so that you can chat without having an irc client, or with
> > one, if you prefer.  I know that Rizon just announced an embeddable
> > client for their network, and a quick google finds all sorts of
> > different embeddable clients.  What specifically do you need Django-
> > integration for, as opposed to a standard java/javascript embeddable
> > thingamajig?

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



Re: Model for "Global Options"

2009-07-05 Thread thornomad

Here is what I tried - is working.  Not sure if it's as clever as it
could be, but it works.

# models.py

class GlobalOptions(models.Model):
key = models.SlugField(max_length=30,unique=True)
value = models.TextField()

# views.py

def global_options():
dict = {}
for go in GlobalOptions.objects.all():
dict[go.key] = go.value
return dict

def my_view(request, template_name):
# ...
return render_to_response('template.html', { 'global':
global_options() })

# template.html

key_name =  {{ global.key_name }}

I can add additional keys, as needed, and just have to reference them
in the template (don't have to change any of the python).

Thoughts ?

Damon

On Jul 5, 9:12 am, thornomad  wrote:
> Hi Daniel -
>
> Okay ... so, it looks like I could do this two ways (maybe more).
> After reading:http://docs.djangoproject.com/en/dev/ref/templates/api/
>
> 1. I could create my own context process and define it in
> TEMPLATE_CONTEXT_PROCESSORS -
>
> 2. (maybe more straightforward) I could create a function in a view
> that returns a dictionary of all the items (value/key pairs) in a
> particular Model ... then pass that to the view when it gets process.
> Then I could add/remove value/key pairs form the admin as needed.
>
> I think I may try out option 2, and see how it goes.  Sounds easier,
> anyway.
>
> Thanks!  I will report back when/if I get it working.
>
> Damon
>
> On Jul 4, 11:36 pm, dvainsencher  wrote:
>
> > On Jul 4, 9:27 am, Damon Timm  wrote:
>
> > > Hello everyone -
>
> > > I wondered if anyone had insight on a Model for site-wide "global"
> > > options.  I am thinking of a place to store: site title, site meta,
> > > site description, specific global links (twitter, facebook, etc),
> > > support contact email, etc ... The model itself doesn't seem too
> > > complicated, maybe:
>
> > > class GlobalOptions(models.Model):
> > >     opiton = models.SlugField('Machine Readable Option
> > > Name',max_length=50,unique=True)
> > >     value = models.TextField('Option Value')
> > >     # more fields could be included, of course (date_created, 
> > > description, blah)
>
> > > My question, though, is about how to easily get these new "options"
> > > into a template tag.  So that I could simply do:
>
> > > {{ globaloptions.optionname }}
>
> > > And it would return the value for that option or, if the option didn't
> > > exist, it would return nothing.  I have been looking around for a way
> > > to do this and coming up blank -- I am new to both Python and Django,
> > > so I'm sure the answer is there, I just don't know where/how to look
> > > for it.
>
> > > Any insight would be great!
>
> > > Damon
>
> > You can set a globaloptions dictionary in the response context with
> > option attribute as key and value attribute as value.
>
> > []s
> > daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model for "Global Options"

2009-07-05 Thread thornomad

Hi Daniel -

Okay ... so, it looks like I could do this two ways (maybe more).
After reading: http://docs.djangoproject.com/en/dev/ref/templates/api/

1. I could create my own context process and define it in
TEMPLATE_CONTEXT_PROCESSORS -

2. (maybe more straightforward) I could create a function in a view
that returns a dictionary of all the items (value/key pairs) in a
particular Model ... then pass that to the view when it gets process.
Then I could add/remove value/key pairs form the admin as needed.

I think I may try out option 2, and see how it goes.  Sounds easier,
anyway.

Thanks!  I will report back when/if I get it working.

Damon

On Jul 4, 11:36 pm, dvainsencher  wrote:
> On Jul 4, 9:27 am, Damon Timm  wrote:
>
>
>
> > Hello everyone -
>
> > I wondered if anyone had insight on a Model for site-wide "global"
> > options.  I am thinking of a place to store: site title, site meta,
> > site description, specific global links (twitter, facebook, etc),
> > support contact email, etc ... The model itself doesn't seem too
> > complicated, maybe:
>
> > class GlobalOptions(models.Model):
> >     opiton = models.SlugField('Machine Readable Option
> > Name',max_length=50,unique=True)
> >     value = models.TextField('Option Value')
> >     # more fields could be included, of course (date_created, description, 
> > blah)
>
> > My question, though, is about how to easily get these new "options"
> > into a template tag.  So that I could simply do:
>
> > {{ globaloptions.optionname }}
>
> > And it would return the value for that option or, if the option didn't
> > exist, it would return nothing.  I have been looking around for a way
> > to do this and coming up blank -- I am new to both Python and Django,
> > so I'm sure the answer is there, I just don't know where/how to look
> > for it.
>
> > Any insight would be great!
>
> > Damon
>
> You can set a globaloptions dictionary in the response context with
> option attribute as key and value attribute as value.
>
> []s
> daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with mysql like operator with Django

2009-07-05 Thread newbie

Hi,

 In my view, I connected to the mysql server using the cursor object.

 I tried to execute the following query:

select pincode from pincode where state='Andhra Pradesh' and
district='Nellore' and area LIKE '%road%' or '%item%';

The above query is perfectly working when i give it on the mysql
command prompt. But Django is giving me the exception "not enough
arguments for format string" and its location as "usr/lib/python2.5/
site-packages/django/db/backends/__init__.py in last_executed_query,
line 173"

I think it is misinterpreting the '%' symbol for formatting. Can
anyone help me out of this problem??

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



Re: Global custom tags

2009-07-05 Thread Ronghui Yu
_init_.py should be

__init__.py

or just a typo error in the mail?

diogobaeder ??:
> Koen,
>
> I tried to make an initial template tag, just to test and learn, but
> it's not working. I followed the instructions here
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags
> and registered the compilation function, but it's not finding the
> module, like stated here in this stack trace, even though I've saved
> the _init_.py file:
> http://dpaste.com/63306/
>
> The code I used to test it is here:
> http://dpaste.com/63308/
>
> Any ideas?
>
> Thanks again!
>
> Diogo
>
>
>
> On Jul 3, 3:10 am, koenb  wrote:
>   
>> On 3 jul, 04:59, diogobaeder  wrote:
>>
>> 
>>> But where do I put the custom template, than? If I load it from an app
>>> template, I must create it under /templatetags/, and what if I
>>> want to call it from the base template? /templatetags/?
>>>   
>>> Thanks!
>>>   
>>> Diogo
>>>   
>> I think you are missing something here: there really is no app
>> namespacing in templatetags: if you try to load a tag library, django
>> will search the templatetags folders located underneath all installed
>> apps. If it finds one that matches, it will use that one. This means
>> that you can use a tag library from app X in any template you use (no
>> matter where it is located), as long as app X is in the installed
>> apps. The downside of this is that you need to name your tag libraries
>> wisely, because tags.py in app X and tags.py in app Y will conflict.
>>
>> Koen
>> 
> >
>
>   

-- 
Ronghui Yu 

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



Re: Easy way to include Request Context always?

2009-07-05 Thread Ronghui Yu
I had the same problem. I didn't find a built-in way to solve this. But 
I think you can implement a custom render_to_response, which calls the 
built-in one in turn.
Then what you need to do is just importing your custome one.

Streamweaver ??:
> I'm still struggling a bit with template contexts
>
> What I want to do is put a code snippet in the header of my site base
> template that either presents the user with a small login form if they
> aren't authenticated or display a "Welcome! user" where user is linked
> to their profile.
>
> It seems I have to pass RequestContext(request) everytime I call
> render_to_response but I'm sure there's an easier way I'm missing.
> I've read through the docs and apologize if I'm missing it but can
> someone help with some advice?
>
> Thanks in advance.
> >
>
>   

-- 
Ronghui Yu 

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



Problem with Reverse

2009-07-05 Thread tam...@gmail.com

Hi,

I am trying to decouple my views.py with respect to my url.py but I
have a problem.

-I do have a principal url.py which contains and include to a second
url.py:
urlpatterns = patterns('',
(r'^users/', include('myapp.users.urls'))
.

-Thus the second url.py contains:
url(regex='^edit/(?P\w+)/$', prefix='myapp.users',
view='views.edit_user_profile', name='users_edit'),

-In my views.py (in signup function) I try to call:
url = reverse('users_edit', kwargs={'username':user.username})
return HttpResponseRedirect(url)

-But instead of being correctly redirected I have got the following
error:
ViewDoesNotExist at /users/signup/
Tried select in module myapp.users.views. Error was: 'module' object
has no attribute 'select'

Any hint? :-(
Thanks


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



How do I display custom error messages to users?

2009-07-05 Thread Rex

There are situations on my site where I'd like to show the a page
telling them what they did wrong: their browser doesn't support
cookies, they erroneously try to re-submit a form, and so on.

However, I want to be notified by email whenever a user encounters one
of these errors, since I want to monitor that these errors don't
happen too frequently.

I see two options for doing this:

(1) Throw a 404/500 error whenever this occurs, and include a custom
error message in the template (e.g. "You weren't supposed to resubmit
the form."). I already have email error reporting turned on. However,
it doesn't look like there's built-in support for passing custom
strings to 404/500 templates (although I think I could just stick it
somewhere in the request object, which I can pass to the 404/500
template).

(2) Instead of throwing an error, just write a function called
report_error that emails an alert to the admin, like this:

report_error('ad...@mysite.com', request)

And then render a template to the user:

render_to_response('my_error_page.html', 'you weren't supposed to
resubmit the form')

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