Re: Application Name Cannot be the Same as Site Name - is this true?

2010-02-27 Thread Anthony
Their both version 1.1.1 by the way.

On Feb 27, 11:33 pm, Anthony  wrote:
> I've got my app deployed on my production server where the application
> name == site name.  (It's running fine.)
>
> I copied it down to my development machine and tried to set up the
> same thing ('python manage.py startapp [appname==sitename]'), I got
> the error message above.
>
> Did I just do something funny in my production environment that will
> bring the site down in the future?  It's running fine now, but I'm
> wondering if I should redo it for safety's sake.
>
> 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-us...@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.



Application Name Cannot be the Same as Site Name - is this true?

2010-02-27 Thread Anthony
I've got my app deployed on my production server where the application
name == site name.  (It's running fine.)

I copied it down to my development machine and tried to set up the
same thing ('python manage.py startapp [appname==sitename]'), I got
the error message above.

Did I just do something funny in my production environment that will
bring the site down in the future?  It's running fine now, but I'm
wondering if I should redo it for safety's sake.

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-us...@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: update query set with a limit

2010-02-27 Thread James Bennett
On Sat, Feb 27, 2010 at 10:07 PM, Harley Bussell  wrote:
> Hi, id like to know if any one has found a work around to use limits
> when updating a query set.

This is unlikely to be supported by Django; "UPDATE ... LIMIT" is
non-standard, non-portable and MySQL is the only DB supporting it out
of the box.


-- 
"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-us...@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.



update query set with a limit

2010-02-27 Thread Harley Bussell
Hi, id like to know if any one has found a work around to use limits
when updating a query set.

I'm trying to lock a number of the oldest rows in a table.
update job set lock='lockid' where lock ='' order by created limit 10;

Ideally id like to do something like this:
Job.objects.filter(lock='').order_by('created').update(lock='lockid')
[0:10]

Now i'm just using raw sql to lock which is fine but it would be great
if there was a way to do it with the orm.

Appreciate any advice
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-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Karen Tracey
On Sat, Feb 27, 2010 at 9:23 PM, piz...@gmail.com  wrote:

> Yes Karen, that's what I thought from the beginning, something is broken in
> my Python installation, I'll explain it better. I'm currently using django
> dev server and it doesn't update the .pyc files, let's say I just change a
> line in the models, I have to delete the models.pyc file because python
> doesn't update i, if it helps, timestamps difer just seconds (I make quick
> changes).
>
> This happens to me even on other programs where every change I make, I have
> to delete manually the .pyc file. As someone said before is like
> head-banging. How can I track down this problem? I'm not a programmer, this
> is just a hobby.
>
>
I'd ask in someplace like comp.lang.python. It's not behavior I've
experienced nor seen reported before.

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



Re: How can I apply ordering through a M2M join model?

2010-02-27 Thread Prabhu
What is wrong with gallery.photos.all().order_by('name') ?

On Feb 27, 4:49 pm, Kyle Fox  wrote:
> I'm wondering if it's possible to apply ordering to a ManyToMany
> relationship by using a `position` attribute on the join model.  A
> classic example (photo gallery) is probably the best way to illustrate
> this:
>
> class Photo(models.Model):
>     image = models.ImageField(upload_to="photos")
>
> class Gallery(models.Model):
>     name = models.CharField(max_length=100)
>     photos = models.ManyToManyField(Photo, through='GalleryPhoto')
>
> class GalleryPhoto(models.Model):
>     gallery = models.ForeignKey(Gallery)
>     photo = models.ForeignKey(Photo)
>     position = models.IntegerField(default=0)
>
>     class Meta:
>         ordering = ('position',)
>
> (Also athttp://dpaste.com/hold/165618/)
>
> I want to attach photos with a gallery, like this:
>
> >>> GalleryPhoto.objects.create(photo=photo1, gallery=some_gallery, 
> >>> position=1)
> >>> GalleryPhoto.objects.create(photo=photo2, gallery=some_gallery, 
> >>> position=2)
>
> And then have the photos retrievable through the gallery *according to
> the position attribute* on the GalleryPhoto, like so:
>
> >>> gallery.photos.all()
>
> [photo1, photo2]
>
> The simplest fix would be to add create a `get_photos` method on the
> Gallery which does a query for it's photos, but I'd rather stick to
> straight Django models if at all possible.
>
> 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-us...@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: Handling input of external urls

2010-02-27 Thread Prabhu
If you use URLField it should do the trick. Just prefix http:// if it
doesn't exist already using javascript.

On Feb 26, 9:37 pm, russianbandit  wrote:
> This is a fairly general question, but what is the best way to handle
> and verify user entry of external urls? For example, if the user types
> in "google.com", django will try to render "http://localhost:8000/
> users/google.com". That is obviously not what I want. I know that if
> the user types in "http://google.com; the request will be forwarded
> correctly to Google. Thus my question is, what is the right/best way
> to handle user input of external urls?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Prabhu
Did you check ROOT_URLCONF in settings.py?

On Feb 27, 8:34 pm, Rodrigo  wrote:
> If I update any line on the urls.py, this doesn't reflect on the
> server. I can even DELETE the file, and all the urls are still
> working. I've tried restarting runserver many times, even restarting
> the computer, and nothing happens.
>
> The last test I did was deleting settings.py, to see if there was some
> kind of problem of other type, but the settings.py does get read,
> since runserver gave me this error:
> $ python manage.py runserver
> Error: Can't find the file 'settings.py' in the directory containing
> 'manage.py'. It appears you've customized things.
> You'll have to run django-admin.py, passing it your settings module.
> (If the file settings.py does indeed exist, it's causing an
> ImportError somehow.)
>
> So, I restored settings.py and with urls.py deleted, the server keeps
> resolving old urls.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread piz...@gmail.com

El 28/02/2010, a las 1:03, Karen Tracey wrote:


If you are routinely needing to delete .pyc files after making code  
changes in the corresponding .py files, something is broken. The  
post I responded to stated: "Python generates a compiled version
of the file, and if you don't delete it, it never get's updated."  
That is not commonly true. Python compares the modification date/ 
time of the .pyc file to same info for the .py file and if the .pyc  
file is out of date the existing .pyc file is ignored and a new one  
is regenerated from the current source. If this mechanism is not  
working on some system, it would be a good idea to track down why,  
because having to remember to delete .pyc files when changing code  
is bound to lead to headaches.


The only times I have to manually delete .pyc files are when I have  
deleting the corresponding .py files, or done a major restructuring  
and moved things around. I've never had to delete .pyc files for  
simple code changes. Running under a webserver or not makes no  
difference in this. Where running under a web server may make a  
difference is in the need to restart the server to get it to see  
changes. You generally don't need to do that for runserver, but  
usually do for production setups. You do not, however, need to  
delete .pyc files -- you just need to restart the server.


Karen



Yes Karen, that's what I thought from the beginning, something is  
broken in my Python installation, I'll explain it better. I'm  
currently using django dev server and it doesn't update the .pyc  
files, let's say I just change a line in the models, I have to delete  
the models.pyc file because python doesn't update i, if it helps,  
timestamps difer just seconds (I make quick changes).


This happens to me even on other programs where every change I make,  
I have to delete manually the .pyc file. As someone said before is  
like head-banging. How can I track down this problem? I'm not a  
programmer, this is just a hobby.


I'll test this on other python installation I have on my mac, just in  
case. Thanks everybody, and forgive my bad english ;)


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: Banned from the #django irc channel

2010-02-27 Thread Jeremy
I've run into this recently as well when I wasn't registered with
Nickserv. You might try registering/authenticating before joining the
channel.

On Feb 26, 8:39 pm, Matías Iturburu  wrote:
> Hi guys, Sorry to bring such an off topic, but I've notice that I'm banned
> on the django irc channel (at least I'm receaving #django :Cannot send to
> channel any time I want to talk there, my nick name is *tutuca*).
> I don't think I've ever been disrespectful or, in any other way, rude in the
> channel, so I would like to know why I've been banned, or if there is any
> way I can know the reason of this.
> The irc is a great way of having a quick feedback about roadblocks so I'm
> very annoyed of this (at least from my part) un understable situation.
>
> Hope somebody can give me a pointer.
> Thanks in advance
>
> --
> Matías Iturburuhttp://www.linkedin.com/in/miturburu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Can't get Uploaded File into DictReader

2010-02-27 Thread jeff
Thanks for the feedback.  The bit about it being iterable put me on
the right track and it turned out to be pretty simple.  For the
benefit of others, here's the basic code to select a CSV file on the
local machine and process it on the server using DictReader to manage
the columns:


FORM:
class ImportFileForm( forms.Form ):

filename  = forms.FileField(
label='Select File',
required=True,
help_text="Click Browse to find the file on your computer",
)

(Template is just a standard form display)

VIEW:

def import_from_csv( request ):

# =
# Select File
# =
if request.POST:
form = ImportFileForm( request.POST, request.FILES )
if form.is_valid():
pass# Fall through to process the file

else:
form = ImportFileForm()
return render_to_response('admin_import_from_csv.html', {'form':
form,}, RequestContext(request) )

errors = [] # List

# =
# Upload From File
# =
reader = csv.DictReader( request.FILES['filename'] )
try:
for row in reader:
group_name = str.strip( row['Group Name'] )
try:
job_name = str.strip( row['Job Name'] )
except KeyError:
job_name = ''
try:
shift_location = str.strip( row['Shift 
Location'] )
except KeyError:
shift_location = ''
try:
shift_date = str.strip( row['Shift Date'] )
except KeyError:
shift_date = ''
try:
start_time = str.strip( row['Start Time'] )
except KeyError:
start_time = ''
try:
end_time = str.strip( row['End Time'] )
except KeyError:
end_time = ''
try:
min_volunteers = str.strip( row['Min 
Volunteers'] )
except KeyError:
min_volunteers = ''
try:
max_volunteers = str.strip( row['Max 
Volunteers'] )
except KeyError:
max_volunteers = ''
try:
shift_notes = str.strip( row['Shift Notes'] )
except KeyError:
shift_notes = ''

# Do something with the row values here.

except Exception, e:
errors += [( reader.line_num, "Serious Error Importing File: " +
str( e ) )]

# Done!  Render a success screen or ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Kenneth Loafman
Karen Tracey wrote:
> On Sat, Feb 27, 2010 at 6:31 PM, Kenneth Loafman
> > wrote:
> 
> Karen Tracey wrote:
> > On Sat, Feb 27, 2010 at 4:05 PM, piz...@gmail.com
> 
> > >
>   >>
> > wrote:
> >
> > Did you delete the .pyc files? Python generates a compiled version
> > of the file, and if you don't delete it, it never get's
> updated. At
> > least it's the problem I have. So  if you update views.py and
> don't
> > delete the old view.pyc file, it will work as the old version.
> >
> >
> > You should not have to manually delete .pyc files when you update the
> > corresponding .py file -- Python should automatically notice the
> > modification date/time of the files do not match and re-generate the
> > .pyc file based on the new contents of the .py file.
> >
> > It's only when you flat-out delete a .py file that you need to
> remember
> > to delete its .pyc file as well, because in that case Python can still
> > see the module as existing even though the .py file is gone.
> 
> That's the way it *should* work, however, if you are running under a web
> server (runserver, Apache, Lighttpd), you need to manually delete the
> .pyc files and restart the server.
> 
> 
> If you are routinely needing to delete .pyc files after making code
> changes in the corresponding .py files, something is broken. The post I
> responded to stated: "Python generates a compiled version
> of the file, and if you don't delete it, it never get's updated." That
> is not commonly true. Python compares the modification date/time of the
> .pyc file to same info for the .py file and if the .pyc file is out of
> date the existing .pyc file is ignored and a new one is regenerated from
> the current source. If this mechanism is not working on some system, it
> would be a good idea to track down why, because having to remember to
> delete .pyc files when changing code is bound to lead to headaches.

Forget headaches, think full-on head-banger migraines!  ;-)

> The only times I have to manually delete .pyc files are when I have
> deleting the corresponding .py files, or done a major restructuring and
> moved things around. I've never had to delete .pyc files for simple code
> changes. Running under a webserver or not makes no difference in this.
> Where running under a web server may make a difference is in the need to
> restart the server to get it to see changes. You generally don't need to
> do that for runserver, but usually do for production setups. You do not,
> however, need to delete .pyc files -- you just need to restart the server.

I listed runserver above, but its not normally a problem.

The problem only appears when you do an update of the .py files while
either Apache or Lighttpd are running.  For some reason, even a restart
of the servers will not always catch the modification of the .py file.
Not sure why this is, but I've run into this on multiple Linux distros,
multiple versions of Python and Django, and multiple versions of web
servers.

...Ken

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Karen Tracey
On Sat, Feb 27, 2010 at 6:31 PM, Kenneth Loafman
wrote:

> Karen Tracey wrote:
> > On Sat, Feb 27, 2010 at 4:05 PM, piz...@gmail.com
> >  >
> > wrote:
> >
> > Did you delete the .pyc files? Python generates a compiled version
> > of the file, and if you don't delete it, it never get's updated. At
> > least it's the problem I have. So  if you update views.py and don't
> > delete the old view.pyc file, it will work as the old version.
> >
> >
> > You should not have to manually delete .pyc files when you update the
> > corresponding .py file -- Python should automatically notice the
> > modification date/time of the files do not match and re-generate the
> > .pyc file based on the new contents of the .py file.
> >
> > It's only when you flat-out delete a .py file that you need to remember
> > to delete its .pyc file as well, because in that case Python can still
> > see the module as existing even though the .py file is gone.
>
> That's the way it *should* work, however, if you are running under a web
> server (runserver, Apache, Lighttpd), you need to manually delete the
> .pyc files and restart the server.
>

If you are routinely needing to delete .pyc files after making code changes
in the corresponding .py files, something is broken. The post I responded to
stated: "Python generates a compiled version
of the file, and if you don't delete it, it never get's updated." That is
not commonly true. Python compares the modification date/time of the .pyc
file to same info for the .py file and if the .pyc file is out of date the
existing .pyc file is ignored and a new one is regenerated from the current
source. If this mechanism is not working on some system, it would be a good
idea to track down why, because having to remember to delete .pyc files when
changing code is bound to lead to headaches.

The only times I have to manually delete .pyc files are when I have deleting
the corresponding .py files, or done a major restructuring and moved things
around. I've never had to delete .pyc files for simple code changes. Running
under a webserver or not makes no difference in this. Where running under a
web server may make a difference is in the need to restart the server to get
it to see changes. You generally don't need to do that for runserver, but
usually do for production setups. You do not, however, need to delete .pyc
files -- you just need to restart the server.

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-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Kenneth Loafman
Karen Tracey wrote:
> On Sat, Feb 27, 2010 at 4:05 PM, piz...@gmail.com
>  >
> wrote:
> 
> Did you delete the .pyc files? Python generates a compiled version
> of the file, and if you don't delete it, it never get's updated. At
> least it's the problem I have. So  if you update views.py and don't
> delete the old view.pyc file, it will work as the old version.
> 
> 
> You should not have to manually delete .pyc files when you update the
> corresponding .py file -- Python should automatically notice the
> modification date/time of the files do not match and re-generate the
> .pyc file based on the new contents of the .py file.
> 
> It's only when you flat-out delete a .py file that you need to remember
> to delete its .pyc file as well, because in that case Python can still
> see the module as existing even though the .py file is gone.

That's the way it *should* work, however, if you are running under a web
server (runserver, Apache, Lighttpd), you need to manually delete the
.pyc files and restart the server.

...Ken

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Karen Tracey
On Sat, Feb 27, 2010 at 4:05 PM, piz...@gmail.com  wrote:

> Did you delete the .pyc files? Python generates a compiled version of the
> file, and if you don't delete it, it never get's updated. At least it's the
> problem I have. So  if you update views.py and don't delete the old view.pyc
> file, it will work as the old version.
>
>
You should not have to manually delete .pyc files when you update the
corresponding .py file -- Python should automatically notice the
modification date/time of the files do not match and re-generate the .pyc
file based on the new contents of the .py file.

It's only when you flat-out delete a .py file that you need to remember to
delete its .pyc file as well, because in that case Python can still see the
module as existing even though the .py file is gone.

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-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread piz...@gmail.com
Did you delete the .pyc files? Python generates a compiled version of  
the file, and if you don't delete it, it never get's updated. At  
least it's the problem I have. So  if you update views.py and don't  
delete the old view.pyc file, it will work as the old version.



El 27/02/2010, a las 21:34, Rodrigo escribió:


If I update any line on the urls.py, this doesn't reflect on the
server. I can even DELETE the file, and all the urls are still
working. I've tried restarting runserver many times, even restarting
the computer, and nothing happens.

The last test I did was deleting settings.py, to see if there was some
kind of problem of other type, but the settings.py does get read,
since runserver gave me this error:
$ python manage.py runserver
Error: Can't find the file 'settings.py' in the directory containing
'manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
(If the file settings.py does indeed exist, it's causing an
ImportError somehow.)

So, I restored settings.py and with urls.py deleted, the server keeps
resolving old urls.

--
You received this message because you are subscribed to the Google  
Groups "Django users" group.

To post to this group, send email to django-us...@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.




--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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 not reading the URLConf (urls.py)

2010-02-27 Thread Rodrigo
If I update any line on the urls.py, this doesn't reflect on the
server. I can even DELETE the file, and all the urls are still
working. I've tried restarting runserver many times, even restarting
the computer, and nothing happens.

The last test I did was deleting settings.py, to see if there was some
kind of problem of other type, but the settings.py does get read,
since runserver gave me this error:
$ python manage.py runserver
Error: Can't find the file 'settings.py' in the directory containing
'manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
(If the file settings.py does indeed exist, it's causing an
ImportError somehow.)

So, I restored settings.py and with urls.py deleted, the server keeps
resolving old urls.

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



Re: Django 1.0 admin - no "select all" checkbox

2010-02-27 Thread Ramiro Morales
On Sat, Feb 27, 2010 at 1:11 PM, Carlos Ricardo Santos
 wrote:
> Anyone noticed that django 1.0 admin has no "select all" checkbox in every
> model object view?\

That's because the actions feature (as it is known) was added in version 1.1
and is being enhanced for  version 1.2.

If you are following the docs make sure you are reading the correct ones
form the Django release you are using (in the case of  the docs published at the
djangoproject.com site, look for a header at the top of the pages that
link to docs
of other releases).

-- 
Ramiro Morales  |  http://rmorales.net

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



How can I apply ordering through a M2M join model?

2010-02-27 Thread Kyle Fox
I'm wondering if it's possible to apply ordering to a ManyToMany
relationship by using a `position` attribute on the join model.  A
classic example (photo gallery) is probably the best way to illustrate
this:

class Photo(models.Model):
image = models.ImageField(upload_to="photos")

class Gallery(models.Model):
name = models.CharField(max_length=100)
photos = models.ManyToManyField(Photo, through='GalleryPhoto')

class GalleryPhoto(models.Model):
gallery = models.ForeignKey(Gallery)
photo = models.ForeignKey(Photo)
position = models.IntegerField(default=0)

class Meta:
ordering = ('position',)

(Also at http://dpaste.com/hold/165618/)

I want to attach photos with a gallery, like this:

>>> GalleryPhoto.objects.create(photo=photo1, gallery=some_gallery, position=1)
>>> GalleryPhoto.objects.create(photo=photo2, gallery=some_gallery, position=2)

And then have the photos retrievable through the gallery *according to
the position attribute* on the GalleryPhoto, like so:

>>> gallery.photos.all()
[photo1, photo2]


The simplest fix would be to add create a `get_photos` method on the
Gallery which does a query for it's photos, but I'd rather stick to
straight Django models if at all possible.

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-us...@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 1.0 admin - no "select all" checkbox

2010-02-27 Thread Carlos Ricardo Santos
Anyone noticed that django 1.0 admin has no "select all" checkbox in every
model object view?\
Do i have to clear objects in shell if I need to clean them all?

-- 
Carlos Ricardo Santos

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: "Illegal mix of collations": how to handle that?

2010-02-27 Thread Karen Tracey
On Sat, Feb 27, 2010 at 7:06 AM, jul  wrote:

> hi,
>
> when submitting some characters in a charfield of a django form I get
> the following error (e.g. when submitting 'ś')
>
> (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
> (utf8_general_ci,COERCIBLE) for operation '='")
>
> It seems that the character I'm submitting is not part of my database
> character set. How can I handle that? Should I first check in the
> clean function of the field whether all characters are included in my
> database charset ? Is this not handled by django (I would expect some
> error before submitting the data to the database)?
>

Django assumes you have set up your database so that it is capable of
storing whatever data you attempt to store in it. Here you apparently have
latin1-encoded tables and are trying to store a character that has no
representation in the latin1 charset. The easiest fix is to change your
tables to use utf8 encoding (ALTER TABLE with CONVERT TO CHARSET). If for
some reason you really want to restrict your DB to only latin1 data, then
you'll need to ensure, before saving any character data, that it can be
encoded in latin1.

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-us...@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: "Illegal mix of collations": how to handle that?

2010-02-27 Thread Nick Arnett
On Sat, Feb 27, 2010 at 4:06 AM, jul  wrote:

> hi,
>
> when submitting some characters in a charfield of a django form I get
> the following error (e.g. when submitting 'ś')
>
> (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
> (utf8_general_ci,COERCIBLE) for operation '='")
>
> It seems that the character I'm submitting is not part of my database
> character set. How can I handle that? Should I first check in the
> clean function of the field whether all characters are included in my
> database charset ? Is this not handled by django (I would expect some
> error before submitting the data to the database)?


You probably need to fix this in your database, which I'm guessing is
MySQL.  Change all your tables and columns to UTF8 and this should
disappear.  Solving it on the Python side will probably drive you crazy.
Nick

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



"Illegal mix of collations": how to handle that?

2010-02-27 Thread jul
hi,

when submitting some characters in a charfield of a django form I get
the following error (e.g. when submitting 'ś')

(1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
(utf8_general_ci,COERCIBLE) for operation '='")

It seems that the character I'm submitting is not part of my database
character set. How can I handle that? Should I first check in the
clean function of the field whether all characters are included in my
database charset ? Is this not handled by django (I would expect some
error before submitting the data to the database)?

thanks

jul


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Banned from the #django irc channel

2010-02-27 Thread Kenneth Gonsalves
On Saturday 27 Feb 2010 12:38:16 pm James Purser wrote:
> On Fri, 2010-02-26 at 22:17 -0500, Shawn Milochik wrote:
> > I asked in the IRC, but nobody answered. There seemed to be almost no  
> > activity at all, though. Maybe someone who's associated with the room  
> > will see this thread and help.
> > 
> > Shawn 
> 
> You could always ask in #freenode to see if you have been banned.
> 

as already mentioned, if he was banned he would get a big notice saying 'you 
are banned from this channel on trying to join'. He is joining the channel, 
but since he is not authenticated, he cannot speak on the channel. That's all. 
It is a non-issue.
-- 
regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS
http://certificate.nrcfoss.au-kbc.org.in

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: search_field doesn't work ?

2010-02-27 Thread Daniel Roseman
On Feb 27, 12:03 pm, "mendes.rich...@gmail.com" 
wrote:
> Hello Django Users,
>
> I have the following problem,
> In some of my models i have search_fields listed, and for some reason
> these are not working anymore ( they previously did ).
>
> the syntax i used to get the search field is the following.
> search_fields = ('labcode')

Should be:
 search_fields = ('labcode',)

--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Passing RequestContext as dict vs. context_instance=RequestContext

2010-02-27 Thread Jesaja Everling
Hi Bruno,
Hi Alex,

thank you very much for your helpful responses.
I will do as you suggested and use RequestContext as it is supposed to
be used or via Alex' generic view trick.

Best Regards,

Jesaja Everling

On Feb 25, 3:27 pm, Alex Robbins 
wrote:
> If you get tired of forgetting to add theRequestContextyou can use
> direct_to_template[1] instead. (I almost always forget it the first
> time)
>
> It is almost exactly like render_to_response, you'd use it like this:
>
> def index(request):
>     return direct_to_template(request, 'index.html', {
>         'extra_context_var': value,
>         })
>
> Alex
>
> [1]http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-...
>
> On Feb 24, 6:00 am, Jesaja Everling  wrote:
>
> > Hi all!
>
> > Is there any difference between these two ways of using
> >RequestContext?
> > I'm asking because I usually use the first approach, but I want to
> > make sure that there are no subtle differences.
>
> > 1)
> > def index(request):
> >     return render_to_response('index.html',
> >                              RequestContext(request,
> >                                              {}
> >                                              ))
>
> > 2)
> > def index(request):
> >     return render_to_response('index.html',
> >                              {},
> >                              context_instance=
> >RequestContext(request))
>
> > Thanks!
>
> > Jesaja Everling

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



search_field doesn't work ?

2010-02-27 Thread mendes.rich...@gmail.com
Hello Django Users,

I have the following problem,
In some of my models i have search_fields listed, and for some reason
these are not working anymore ( they previously did ).

the syntax i used to get the search field is the following.
search_fields = ('labcode')

The url i get when i execute a search is
serveradress/admin/system/participation/?e=1

When i look at the log from the database the following query is run:
SELECT
"system_participation"."participation","system_participation"."user_id","system_participation"."module_id","system_user"."username","system_user"."password","system_user"."labcode_id","system_clients"."labcode","system_clients"."invoiceNr","system_clients"."sponsor_id","system_clients"."method_id","system_sponsor"."sponsor","system_sponsor"."sponsorName","system_submitmethod"."method","system_submitmethod"."methodName","system_module"."module","system_module"."moduleName","system_module"."endDate","system_module"."path"
FROM "system_participation" , "system_user", "system_clients",
"system_sponsor", "system_submitmethod", "system_module" WHERE
"system_participation"."user_id" = "system_user"."username" AND
"system_user"."labcode_id" = "system_clients"."labcode" AND
"system_clients"."sponsor_id" = "system_sponsor"."sponsor" AND
"system_clients"."method_id" = "system_submitmethod"."method" AND
"system_participation"."module_id" = "system_module"."module"

When i do the same thing for the user from the auth model it works
like it should and the query that is ran is:
SELECT
"auth_user"."id","auth_user"."username","auth_user"."first_name","auth_user"."last_name","auth_user"."email","auth_user"."password","auth_user"."is_staff","auth_user"."is_active","auth_user"."is_superuser","auth_user"."last_login","auth_user"."date_joined"
FROM "auth_user" WHERE ((("auth_user"."username" ILIKE E'%richard%' OR
"auth_user"."first_name" ILIKE E'%richard%' OR "auth_user"."last_name"
ILIKE E'%richard%' OR "auth_user"."email" ILIKE E'%richard%'))) ORDER
BY "auth_user"."username" ASC

It seems like the value that i gave in the search box didn't come
through, at least i don't see a ILIKE E%'value' in the query that is
ran.
The syntax in the auth model i exactly the same as the syntax in my
system model.

Does anyone know the fix for this problem or point me in the right
direction ?
Another thing is in which class from the django system is the search
being dealt with.

regards,

Richard Mendes

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Handling input of external urls

2010-02-27 Thread rebus_
On 27 February 2010 02:17, russianbandit  wrote:
> Sorry for being sort of a newb when it comes to regex. But what
> exactly does that line do?
>
> On Feb 26, 3:59 pm, "ge...@aquarianhouse.com"
>  wrote:
>> Check it with regex?
>>
>> re.compile("[a-z0-9]\.[a-z]{2,6}$", re.I)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

well this regex would translate to:

any lowercase letter in range from a to z or digit appearing once
([a-z0-9]) followed by a literal dot (.) and then followed by 2 to 6
occurrences of any lowercase letter in range from a to z followed by
the end of the string.

But this regex doesn't seem all that useful, and it is not a raw string.

You could just check to see if the protocol was specified and based on
that append it or not.

r'^http:\\'

Google search for "url regex" gives:
http://www.geekzilla.co.uk/view2D3B0109-C1B2-4B4E-BFFD-E8088CBC85FD.htm

Learn more about regular expressions:
http://www.regular-expressions.info/reference.html

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: to_field connected to field in UserProfile

2010-02-27 Thread django_is
Yeah I understand that. But it makes no sense to link the payment
field in my Orders model to the CustomerProfile.
In the end I want to save one payment method from the methods that are
available for one specific user in my record for one order. I'm just
confused on how to achieve that. From a user perspective I'd like to
get a dropdown when adding one order in the backend which allows me to
select one payment method from the methods that got added to the one
specific user. (the same applies to a form field for the frontend)

It would be awesome if you could help me in that point. Thank you very
much!

On Feb 24, 7:10 pm, Timothy Kinney  wrote:
> When you include the to_field, it tells Django that you want the foreignkey
> to be the to_field on the CustomerProfile. It then looks for a field called
> payment_id (following the foreignKey relationship). This is normal.
>
> If you remove the to_field, it will choose the primary key of
> CustomerProfile which is probably an AutoField. Then it will look for
> CustomerProfile_id which is a field that DOES exist.
>
> The point of the ForeignKey option is to link one model to another one *via
> the primary key*. You don't link to a random field in the model, you always
> link to the primary key.
>
> Does that make sense?
>
> -Tim
>
> On Tue, Feb 23, 2010 at 11:23 AM, django_is 
> wrote:
>
> > Thank you for your response. But how would the Orders model field for
> > payment look like?
>
> > Should it look like that:
>
> > payment = models.ForeignKey(CustomerProfile,
> > related_name="order_customer_payment",verbose_name='Zahlungsart')
>
> > I don't understand how that should work. At the moment I am quite
> > confused about what you mean.
>
> > Regards
>
> > On 23 Feb., 16:00, Daniel Roseman  wrote:
> > > On Feb 23, 11:56 am, django_is  wrote:
>
> > > > Hmm ok. Assuming the use case above what would be the correct way to
> > > > solve this problem? Especially to have the possibility to have one
> > > > field in the Orders table that allows me to select one payment method
> > > > of the methods which got added to the one specific user. Adding
> > > > payment methods to each user happens in the CustomerProfile with the
> > > > M2M relationship between the CustomerProfile model and the Payment
> > > > model.
>
> > > > Here is the M2M relationship defined in the CustomerProfile:
>
> > > > payment = models.ManyToManyField(Payment, verbose_name='Zahlungsart')
>
> > > > This M2M relationship is working as expected. I just don't know how to
> > > > get the payment methods inside the Orders model.
>
> > > > It would be great if you could help me with this.
>
> > > > Thank you very much.
>
> > > > Regards
>
> > > I don't know how I can make what I said in the previous message it any
> > > clearer: you don't need the to_field.
> > > --
> > > DR.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: convert mysql database to django model

2010-02-27 Thread Sven Richter
Wow, this is cool. Django is so cool! I love it more and more every day!


Greetings and thanks
Sven

On Sat, Feb 27, 2010 at 11:49 AM, rebus_  wrote:
> On 27 February 2010 11:46, Sven Richter  wrote:
>> Hi everybody,
>>
>> i am wondering if there is a tool which converts existing mysql
>> databases with table structure into a django model?
>>
>>
>> Greetings
>> Sven Richter
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@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.
>>
>>
>
> http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdb
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>



-- 
Sven Richter
Dipl.-Inf. (FH)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: convert mysql database to django model

2010-02-27 Thread rebus_
On 27 February 2010 11:46, Sven Richter  wrote:
> Hi everybody,
>
> i am wondering if there is a tool which converts existing mysql
> databases with table structure into a django model?
>
>
> Greetings
> Sven Richter
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdb

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: convert mysql database to django model

2010-02-27 Thread ge...@aquarianhouse.com
Hi

just use ./manage.py inspectdb ;)

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



convert mysql database to django model

2010-02-27 Thread Sven Richter
Hi everybody,

i am wondering if there is a tool which converts existing mysql
databases with table structure into a django model?


Greetings
Sven Richter

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