Re: Validating and rendering dynamic form

2009-01-31 Thread DragonSlayre

Solved my problem - data = self.cleaned_data[dataName]  should have
been:
data = self.cleaned_data.get(dataName)


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



Apache ImportError: Could not import settings

2009-01-31 Thread DragonSlayre

Hi,

I'm at the final stage in one of my django developments, and am trying
to get my site live.

I've been following instructions on
http://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-linux-server/
but got the following error:

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 94, in __init__
raise ImportError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
e)

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


My ubuntu username is git, and the site I've made (kazbah) is at /home/
git/DjangoProjects/kazbah
My httpd.conf settings look like this:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE kazbah.settings
PythonDebug On
PythonPath "['/home/git/DjangoProjects'] + sys.path"



SetHandler None



SetHandler None



SetHandler None



Any ideas about why my settings can't be found?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 newbie

2009-01-29 Thread DragonSlayre

I'm guessing that you might have tried to do a ForeignKey(User) for
the other_invited.  If that is the case, then I think you need to add
a related_name e.g. ForeignKey(User,
related_name="group_invited_to").  You may have to do a related name
for the creator as well.

I hope that helps.

On Jan 30, 8:16 pm, Kirill  wrote:
> Hello all!
>
> I have some logic problem I really don't understand how make model
> for this task:
>
> I have registered users (i want to use User class).
> Each registered user can create project (or group or blog) where he
> can invite another users
> So, how it's better to do model ?
>
> #
>
> from django.cotrib.auth.models import User
>
> class Project_or_Group_or_Blog(models.Model):
>         creator = models.ForeignKey(User)           # many users for
> one project. How it's will be written in table ?
>         other_invited = models. ? (User) # Here should be many
> ids: first_id, second_id etc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Validating and rendering dynamic form

2009-01-29 Thread DragonSlayre

I've created a dynamic form to allow users to upload images, and I'm
trying to validate the form.  - it displays fine, but when I validate
and return a response, I get either a Key Error at the line (data =
self.cleaned_data[dataName] ) in _clean_photo or I get a render error
in my template at {{ image_form.as_table }} - I'm not too sure why
sometimes I get either of the errors.

In my view that gets posted to, i have:
  #images_submitted is a list of the names of the  submitted image
fields
  listingImages = make_image_form(images_submitted)
  image_form = listingImages(request.POST, request.FILES)

The code calls into the make_image_form  view to create the form:

def _clean_photo(self, dataName):
data = self.cleaned_data[dataName]
if data != None:
if data.size > max_photo_size:
raise forms.ValidationError("The maximum image size
allowed is 500KB")
elif data.size == 0:
raise forms.ValidationError("The image given is
empty.")
return data

def make_image_form(image_fields):
''' Takes a list of image_fields to generate image fields '''
images = SortedDict()  #a django sortedDict
#create the ImageFields for the form
for image_name in image_fields:
images[image_name] = forms.ImageField(required=False)
new_form = type('ListingImagesForm2', (forms.BaseForm,),
{'base_fields' : images})
#now we add the validation methods to the class
for image_name in image_fields:
setattr(new_form, 'clean_' + image_name, lambda self:
self._clean_photo(image_name))
#Add the _clean_photo method to the class
setattr(new_form, '_clean_photo', _clean_photo)
return new_form



The _clean_photo method only gets called once -  for the first photo.
The ListingImagesForm2 class gets created fine, and the clean_photo_1,
2, 3 methods get created fine as well.

I'm not too sure what's happening with the errors, but I think that it
must have something to do with how I'm validating.  When _clean_photo
was called,  self.cleaned_data had the image info for the first image
only, when 2 or 3 images were posted.

I hope I've provided enough information for help, any ideas as to what
might be wrong will be highly appreciated :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to change python version in ubuntu???

2009-01-27 Thread DragonSlayre

Thanks Waylan  - 
http://achinghead.com/archive/83/installing-multiple-versions-python/
is just what I needed.

Thanks Shaleh,

I appreciate the detailed explanation :)
Yes - the shell is something that I have to get more familiar with -
I've only really recently started using ubuntu for development so am
on a bit of a learning journey.

So it seems pretty easy to invoke the version of python I want to use,
and using symbolic links make sense (especially after seeing Waylan's
link).

Just a couple of questions:

I didn't quite get what you were referring to with the Django command
line tool, and Django scripts - are you talking about django-
admin.py ?
When you install a python package from the package manager or using
apt-get, is there some way to tell it to install into a specific
version of python, or does it use the python symlink /usr/bin/python,
or something else? - Waylan installed easy_install for each python
version in his example (so he could install packages for different
python versions).


Thanks a lot,

Things are becoming much clearer now.


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



Re: How to change python version in ubuntu???

2009-01-26 Thread DragonSlayre



On Jan 27, 4:11 pm, Steve Holden <holden...@gmail.com> wrote:
> DragonSlayre wrote:
>
> > On Jan 27, 3:15 pm, Steve Holden <holden...@gmail.com> wrote:
>
> >> DragonSlayre wrote:
> > How do you do this?
>
> http://www.swc.scipy.org/lec/shell02.html
>
> regards
>  Steve

WOW, that explains it all...  Looks about as good as every other thing
that I've read on the net.
Ok, so I do a set | less - hey there's no Environment variable
with PYTHON in it. - who cares though right - now I know how to use
grep... yay!!

This is what F**ks me off with most of the developers out there - so
vague in documentation (if it exists).

I know you are probably just trying to help Steve, but if you know how
to do this, is it so hard just to say how?  It's very frustrating to
spend hours and hours trying to find out how to do something so
simple, and still have no answer.  Personally - I wish there was a
radio button that I could select to switch between python versions,
but unfortunately, a radio button just isn't as superior as a
terminal.

The link provided looks like a great reference, but unfortunately it's
like giving someone a toolkit and expecting them to build a house from
it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to change python version in ubuntu???

2009-01-26 Thread DragonSlayre

RE Steve - I tried earlier to change the PYTHONHOME variable (seen in
the man pages - http://linux.die.net/man/1/python), the python path
urls changed, but they were a bit screwed up.

The way I changed it was by editing the .bashrc (hidden) file in my
home directory.  I think I wrote something like export PYTHONHOME=/usr/
lib/python2.5

I'm just hacking around as I couldn't find anything explicit enough to
say how to change the python version.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to change python version in ubuntu???

2009-01-26 Thread DragonSlayre



On Jan 27, 3:15 pm, Steve Holden <holden...@gmail.com> wrote:
> DragonSlayre wrote:
> That's most easily done by controlling your PATH so the the version you
> want to prefer is found first when python is called for.
>
> regards
>  Steve

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



Re: How to change python version in ubuntu???

2009-01-26 Thread DragonSlayre



On Jan 27, 1:41 pm,  wrote:

> Does this help? Found via google and ubuntu 
> forums.https://launchpad.net/~doko/+archive
>
> Sorry, I run Debian (which ubuntu is based on), I just apt-get install all of 
> the
> available python versions and then run /usr/bin/python to test 
> things.

The problem isn't installing python, which can be done through the
package manager or with apt-get, but the problem is for example
changing back to 2.5 once 2.6 is installed.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to change python version in ubuntu???

2009-01-26 Thread DragonSlayre

Ok, well I reinstalled ubuntu.

It'd still be good to know how to change python versions easily, if
anybody knows how to do this - it seems like it's not documented
anywhere :(
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to change python version in ubuntu???

2009-01-26 Thread DragonSlayre

Hi,

I've made a total mess of python (I installed python2.6 from source,
installed python 2.6 from an installer (http://jaredforsyth.com/
content/install-python-26-ubuntu)).  The source version installed
into /usr/local/, and the installer version installed into /usr/.

After installing python from source, I installed Django (which
installed into the correct location).  I then tried installing PIL
(python imaging library) - which didn't install into the correct
location.  That's why I thought I'd give the installer a go.

I then decided that I should try revert back to python 2.5.  So I
deleted the python2.6 files and folders from /usr/local/lib, /usr/
local/bin, /usr/lib/, /usr/bin/.

when I run python though, it still says it's python 2.6.1..

I thought that trying to reinstall python2.5 again might overwrite the
python version, but unfortunately it doesn't.

I looked up the python doc in the man pages (http://
manpages.ubuntu.com/manpages/intrepid/en/man1/python.1.html), and
searched over the internet, but haven't found out how to revert to a
previous version of python, or change the version.

The only real viable solution for me at the moment is to reinstall
ubuntu and start again - although I would consider this to be a bit of
a cheats way - as in the end, I haven't really learnt anything (apart
from the fact that I probably don't want to mess with the python
versions!)


Surely somebody must know how to setup which python version they wish
to use?



Thanks for your help,


Louis

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: sqlite3 problems setting up

2009-01-24 Thread DragonSlayre



On Jan 25, 6:04 pm, Steve Holden  wrote:
>
> When you install something by running
>
>   python setup.py install
>
> it gets installed into the python that is used to run setup.py. It looks
> like you had /usr/local/bin on your path when you installed django, but
> not when you installed PIL and pysqlite2 (or maybe you just hadn't
> installed Python 2.6 at that stage).
>
> Either way, one version of Python won't see packages installed in another.


Yes, I think this is happening - very frustrating!  I just wanted to
update python - Whenever I try install modules now though (e.g. sudo
aptitude install python-imaging), it doesn't install them in the new
folder  - why oh why

I just found this site http://jaredforsyth.com/content/install-python-26-ubuntu
that explains how to have an automatic install - which I did,  but now
my python path has got my other python 2.6 installation location. (I
now have one under /usr/lib/ and another under /usr/local/lib)

I've googled and googled and have not found out how you remove it
properly (If I were to remove it, I'd just delete the whole folder)

I don't know how to set my python path to point to the new python 2.6
folder either.


All in all, I'd rather just revert back to python 2.5 problem is
that I don't know how to do that either!!!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: sqlite3 problems setting up

2009-01-24 Thread DragonSlayre

Just doing some exploring - noticing that:

* /usr/lib/python2.5/site-packages has a pysqlite2 folder as well as a
PIL folder
* /usr/local/lib/python2.6/site-packages has just django in it

I'm not sure how the whole site-packages things work, or why python
2.5 is in /usr/lib/ and python 2.6 is in /usr/local/lib/ ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: sqlite3 problems setting up

2009-01-24 Thread DragonSlayre

Importing sqlite3 fails as well (if I type this into a python
shell)

 import sqlite3
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.6/sqlite3/__init__.py", line 24, in

from dbapi2 import *
  File "/usr/local/lib/python2.6/sqlite3/dbapi2.py", line 27, in

from _sqlite3 import *
ImportError: No module named _sqlite3

sqlite3 is definitely installed, as I made a database and tested it
out
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: sqlite3 problems setting up

2009-01-24 Thread DragonSlayre

This is my path currently:

['', '/usr/local/lib/python26.zip', '/usr/local/lib/python2.6', '/usr/
local/lib/python2.6/plat-linux2', '/usr/local/lib/python2.6/lib-tk', '/
usr/local/lib/python2.6/lib-old', '/usr/local/lib/python2.6/lib-
dynload', '/usr/local/lib/python2.6/site-packages']


On Jan 25, 3:22 pm, DragonSlayre <lssay...@gmail.com> wrote:
> I've just done a fresh install of python 2.6 and django 1.0.2, and
> sqlite3 in ubuntu, and I've cloned my repository, and tried python
> manage.py runserver, but then I get this error:
>
> File "/usr/local/lib/python2.6/site-packages/django/db/backends/
> sqlite3/base.py", line 27, in 
>     raise ImproperlyConfigured, "Error loading %s module: %s" %
> (module, exc)
> django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
> module: No module named _sqlite3
>
> The only thing I can think of is that maybe what it's looking for
> isn't on the python path or something - I just commented out the DB in
> the settings, and it complained about the PIL module (I installed this
> prior to installing django).
>
> I'm not exactly sure what's going on, any help would be appreciated :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



sqlite3 problems setting up

2009-01-24 Thread DragonSlayre

I've just done a fresh install of python 2.6 and django 1.0.2, and
sqlite3 in ubuntu, and I've cloned my repository, and tried python
manage.py runserver, but then I get this error:

File "/usr/local/lib/python2.6/site-packages/django/db/backends/
sqlite3/base.py", line 27, in 
raise ImproperlyConfigured, "Error loading %s module: %s" %
(module, exc)
django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
module: No module named _sqlite3

The only thing I can think of is that maybe what it's looking for
isn't on the python path or something - I just commented out the DB in
the settings, and it complained about the PIL module (I installed this
prior to installing django).


I'm not exactly sure what's going on, any help would be appreciated :)

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



Re: Multiple images in form

2009-01-20 Thread DragonSlayre

Yeah, I had to add a related_name to my ForeignKeys e.g:
first_photo = models.ForeignKey(Image, blank=True, null=True,
related_name="first photo")

The problem now is that with foreign keys, it generates a drop down
list to select the images - whereas, I want a browse type text box to
choose an image. - is there anyway to tell the foreignkey field to
render the items pointed to by the foreign key, rather than just
render a drop down list?

On Jan 21, 3:14 am, "Karen Tracey" <kmtra...@gmail.com> wrote:
> On Tue, Jan 20, 2009 at 2:28 AM, DragonSlayre <lssay...@gmail.com> wrote:
> > [snip details of problem]
>
> > This gives me loads of errors - i'm pretty sure it's because of the
> > ForeignKeys.
>
> Without trying it, I'm guessing you got four errors.  If they are the errors
> I think they are, the error message actually tries pretty hard to point you
> in the right direction of fixing them.  Did you try following the advice in
> the error message?  If you do not understand the error message, it would
> help if you included it with your question as well as what it is you don't
> understand in what it is trying to say, which would help people try to frame
> an answer to address whatever misunderstanding is causing the confusion.  As
> it is I'm just guessing that if you read and follow the advice in the error
> messages you can make the errors go away pretty easily.
>
> 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: Multiple images in form

2009-01-19 Thread DragonSlayre

I'm using django-thumbs (http://code.google.com/p/django-thumbs/), and
the problem with it is that you can't stick blank=True, null=True when
you declare a field in your model.

To get around this, I thought I'd wrap it in another model, and
reference it from my Posting model, which contains information for a
post (text and picture etc etc).  This works fine for one picture,
but I wanted say five - I tried to reference 5 of them by having 5
foreign key fields to the same model - but django didn't like that
very much and gave me a whole heap of errors - is there a way around
this?

My models look a bit like this:

class Image(models.Model):
photo = ImageWithThumbsField(
upload_to="static/site_images",
sizes=((thumb_widths,thumb_heights),))

class Posting(models.Model):
'''An abstract class to represent a listing '''
#main data
title = models.CharField(max_length=200)
body_text = models.TextField()

#Listing images
first_photo = models.ForeignKey(Image, blank=True, null=True)
second_photo = models.ForeignKey(Image, blank=True, null=True)
third_photo = models.ForeignKey(Image, blank=True, null=True)
fourth_photo = models.ForeignKey(Image, blank=True, null=True)
fifth_photo = models.ForeignKey(Image, blank=True, null=True)

class PostingForm(ModelForm):
class Meta:
model = Posting


This gives me loads of errors - i'm pretty sure it's because of the
ForeignKeys.


Thoughts?


On Jan 20, 5:48 pm, DragonSlayre <lssay...@gmail.com> wrote:
> Hi,
>
> I've seen some posts from a while back, but didn't find any real
> solution when searching to find out how to put multiple images (or any
> field for that matter) into a form (mainly a  ModelForm)
>
> Basically what I want to have is a form that has a one to many
> relationship from a post to images, and to allow 5 images to be
> displayed on the form.
>
> Any simple way of doing this?
>
> If not, any other ways that people can think of/have done?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Multiple images in form

2009-01-19 Thread DragonSlayre

Hi,

I've seen some posts from a while back, but didn't find any real
solution when searching to find out how to put multiple images (or any
field for that matter) into a form (mainly a  ModelForm)

Basically what I want to have is a form that has a one to many
relationship from a post to images, and to allow 5 images to be
displayed on the form.

Any simple way of doing this?

If not, any other ways that people can think of/have done?


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



Re: How do you get the time and date out of a datetimefield object?

2009-01-17 Thread DragonSlayre

Thanks for the tips, the help thing looks real - well... helpful! lol


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 you get the time and date out of a datetimefield object?

2009-01-17 Thread DragonSlayre

Hi,

As I'm relatively new to python and django, I'm unsure how to get the
date and time out of a DateTimeField.

How I usually work with this sort of thing is to 'python manage.py
shell' and then import whatever class i'm interested in and then do a
dir() on the object to find out what methods and fields it has.

My question is for the experienced programmers - if you were in my
position, how would you go about finding out how to get a date and
time out of a DateTimeField?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: MEDIA_ROOT, MEDIA_URL and upload_to confusion (~.~)

2009-01-16 Thread DragonSlayre

Yeah, that makes good sense - I tried finding out info on
djangoproject but didn't quite understand what they were for.

Thanks

On Jan 17, 7:04 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Fri, 2009-01-16 at 21:06 -0800, DragonSlayre wrote:
> > I'm using django-thumbs (http://code.google.com/p/django-thumbs/) to
> > create some thumbnails for my site:
>
> > class Image(models.Model):
> >     title = models.CharField(max_length=50, blank=True, null=True)
> >     caption = models.CharField(max_length=100, blank=True, null=True)
> >     photo = ImageWithThumbsField(
> >             upload_to="site_images",
> >             sizes=((270,150),))
>
> > And in my settings my media path is as following:
>
> > MEDIA_ROOT = os.path.abspath(os.path.join(PROJECT_DIR, 'site_media'))
> > MEDIA_URL = 'static/'
>
> > I'm trying to upload my images into the  'site_media/static/
> > site_images/' location
>
> > When I upload however, it puts the image into 'site_media/
> > site_images/'
> > The strange thing though, is that the location that gets stored in the
> > database is 'static/site_images/imageName.jpg'
>
> > I'm really not sure what's going on, and feel completely confused.
>
> The MEDIA_ROOT is the path on the storage system (the hard-drive,
> typically) where the data is saved.
>
> The MEDIA_URL is the URL used by the web browser to access the media. It
> is entirely unrelated to the location on the hard-drive. Even though
> URLs and directory paths both use '/' as a separator, they don't refer
> to the same namespace of objects. The web browser requesting the media
> is using a URL and has absolutely no idea where you might have chosen to
> store the data on the disk.
>
> However (and this is an important point), to make things a little
> simpler on the code developer, when you're using the straightforward
> file-saving operations, as you are doing, Django makes the filesystem
> layout underneath MEDIA_ROOT match the URL space layout referred to by
> URL_ROOT.
>
> I'm not familiar with the django-thumbs project, so I have no idea why
> it's putting the MEDIA_URL portion on the front of the filename it
> saves. What I will mention, though, is that Django's normal ImageField
> model field only stores "site_images/imageName.jpg" in the case you
> describe. So a template might put MEDIA_URL on the front of that to get
> the URL and something wanting to access the file directory (a cronjob or
> something similar) would prepend MEDIA_ROOT to the name in the database.
>
> Does that clear things up a bit? MEDIA_URL is the URL used by external
> things like web browsers to access the object. MEDIA_ROOT talks about
> where the image is stored on disk. They are unrelated concepts (in the
> sense that URLs are not file paths), although you would normally have to
> configure your webserver so that requests for MEDIA_URL were served by
> files under MEDIA_ROOT.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MEDIA_ROOT, MEDIA_URL and upload_to confusion (~.~)

2009-01-16 Thread DragonSlayre

Ok, I got it working, I changed:

> photo = ImageWithThumbsField(
> upload_to="site_images",
> sizes=((270,150),))

to:

 photo = ImageWithThumbsField(
 upload_to="static/site_images",
 sizes=((270,150),))

and

> MEDIA_URL = 'static/'

to:

 MEDIA_URL = '/site_media/'

I think I get it now - the media_root is where django uploads images
to, and the media_url is where the images will be linked from. -
hopefully that is what they mean :)


On Jan 17, 6:06 pm, DragonSlayre <lssay...@gmail.com> wrote:
> I'm using django-thumbs (http://code.google.com/p/django-thumbs/) to
> create some thumbnails for my site:
>
> class Image(models.Model):
>     title = models.CharField(max_length=50, blank=True, null=True)
>     caption = models.CharField(max_length=100, blank=True, null=True)
>     photo = ImageWithThumbsField(
>             upload_to="site_images",
>             sizes=((270,150),))
>
> And in my settings my media path is as following:
>
> MEDIA_ROOT = os.path.abspath(os.path.join(PROJECT_DIR, 'site_media'))
> MEDIA_URL = 'static/'
>
> I'm trying to upload my images into the  'site_media/static/
> site_images/' location
>
> When I upload however, it puts the image into 'site_media/
> site_images/'
> The strange thing though, is that the location that gets stored in the
> database is 'static/site_images/imageName.jpg'
>
> I'm really not sure what's going on, and feel completely confused.
>
> Any help will be greatly appreciated!
>
> Louis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



MEDIA_ROOT, MEDIA_URL and upload_to confusion (~.~)

2009-01-16 Thread DragonSlayre

I'm using django-thumbs (http://code.google.com/p/django-thumbs/) to
create some thumbnails for my site:

class Image(models.Model):
title = models.CharField(max_length=50, blank=True, null=True)
caption = models.CharField(max_length=100, blank=True, null=True)
photo = ImageWithThumbsField(
upload_to="site_images",
sizes=((270,150),))

And in my settings my media path is as following:

MEDIA_ROOT = os.path.abspath(os.path.join(PROJECT_DIR, 'site_media'))
MEDIA_URL = 'static/'

I'm trying to upload my images into the  'site_media/static/
site_images/' location

When I upload however, it puts the image into 'site_media/
site_images/'
The strange thing though, is that the location that gets stored in the
database is 'static/site_images/imageName.jpg'

I'm really not sure what's going on, and feel completely confused.

Any help will be greatly appreciated!


Louis
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Passing a form a user before validation

2009-01-08 Thread DragonSlayre

Thank you thank you thank you

Cheers Malcolm, you're the best!

On Jan 9, 2:31 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Thu, 2009-01-08 at 17:09 -0800, DragonSlayre wrote:
> > I'm trying to generate a form with a user's details, so that they can
> > change the details they've submitted.
>
> > One of my forms is a ModelForm, which is the profile of the User
> > object.  I also want to show the first name, last name and email from
> > the User object, so I've created a form for that which validates the
> > email (to make sure no-one else has the same email).
>
> > Here's my view code so far:
>
> > @login_required
> > def change_my_account(request):
> >     fireman = Fireman.objects.get(pk=request.user.get_profile().id)
>
> >     if request.method == 'POST':
> >         #also need to check my RegistrationFormSimple
> >         form = FiremanForm(request.POST, instance=fireman)
> >         if form.is_valid():
> >             form.save()
> >     else:
> >         form =FiremanForm(instance=fireman)
> >         data = {'first_name' : request.user.first_name,
> >                 'last_name'  : request.user.last_name,
> >                 'email'      : request.user.email}
> >         userForm = RegistrationFormSimple(data)
> >     return render_to_response('Change_account.html', {'form' : form,
> >                                                       'user_form' :
> > userForm})
>
> > This works well, except that I have a validator in my
> > RegistrationFormSimple, which needs to know who the user is, to check
> > the emails.
>
> > I'm stumped about how I give this information to my
> > RegistrationFormSimple.
>
> The validation method needs to be able to look up the user or have it
> passed in. I would pass it in. You can write an __init__ method for your
> RegistrationFormSimple class that accepts an extra parameter (preferably
> a keyword argument) that it uses in the validator. For example
>
>         class RegistrationFormSimple(forms.Form):
>            def __init__(self, *args, **kwargs):
>               self.user = kwargs.pop("user")
>               super(RegistrationFormSimple, self).__init__(*args,
>         **kwargs)
>
>            def clean_email(self):
>               # Can refer to self.user in here
>
> Then you can create this form in your view like this:
>
>         userForm = RegistrationFormSimple(data, user=request.user)
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Passing a form a user before validation

2009-01-08 Thread DragonSlayre

I'm trying to generate a form with a user's details, so that they can
change the details they've submitted.

One of my forms is a ModelForm, which is the profile of the User
object.  I also want to show the first name, last name and email from
the User object, so I've created a form for that which validates the
email (to make sure no-one else has the same email).

Here's my view code so far:

@login_required
def change_my_account(request):
fireman = Fireman.objects.get(pk=request.user.get_profile().id)

if request.method == 'POST':
#also need to check my RegistrationFormSimple
form = FiremanForm(request.POST, instance=fireman)
if form.is_valid():
form.save()
else:
form =FiremanForm(instance=fireman)
data = {'first_name' : request.user.first_name,
'last_name'  : request.user.last_name,
'email'  : request.user.email}
userForm = RegistrationFormSimple(data)
return render_to_response('Change_account.html', {'form' : form,
  'user_form' :
userForm})

This works well, except that I have a validator in my
RegistrationFormSimple, which needs to know who the user is, to check
the emails.

I'm stumped about how I give this information to my
RegistrationFormSimple.

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



Re: birth date in a model form

2009-01-05 Thread DragonSlayre

Oh, cool thanks :)

I never went into the code part of djangoproject before, always just
the documentation.  That's great, thanks.

On Jan 6, 12:53 pm, Brot <schla...@gmail.com> wrote:
> from django import forms
> from django.forms.extras import widgets
>
> class FiremanForm(forms.ModelForm):
>     birth_date = forms.DateField(widget=widgets.SelectDateWidget())
>
> On Jan 6, 12:11 am, DragonSlayre <lssay...@gmail.com> wrote:
>
> > I've tried using it, but I'm still quite new to django - I put it into
> > my model file for now, and made my model form looks like this:
>
> > class FiremanForm(ModelForm):
> >     birth_date = models.DateField(widget=SelectDateWidget())
>
> > But I get an error "got an unexpected keyword argument 'widget' "
> > From this I gather that I must be writing the wrong thing, but I'm not
> > sure what I should be writing?
>
> > Thanks a lot
>
> > On Jan 6, 11:29 am, Brot <schla...@gmail.com> wrote:
>
> > > Hello,
>
> > > I have the same issue in my app and there is a widget. You can find it
> > > here:http://code.djangoproject.com/browser/django/trunk/django/forms/extra...
>
> > > But for me this widget misses a few features and there are open
> > > tickets with patches, but they are not in trunk yet 
> > > :-(http://code.djangoproject.com/ticket/9124http://code.djangoproject.co...
>
> > > I am working with the latest patch from #6231 and so the widget is now
> > > useful for me. But I hope that this patch find it's way into django
> > > trunk!
>
> > > ~Bernd
>
> > > On Jan 5, 11:00 pm, DragonSlayre <lssay...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I've got a ModelForm, and the model for it contains a birth date field
> > > > (as a DateField):
>
> > > > class FiremanForm(ModelForm):
> > > >     class Meta:
> > > >         model = Fireman
>
> > > > Currently a single text box is rendered to enter the date, but I'd
> > > > like to have a drop down list for day, month, year.
>
> > > > I'm guessing that lots of people have come across this, and I was
> > > > wondering what the best way is to get these drop down lists on the
> > > > page ?
>
> > > > Are there any widgets that I don't know about that I should be using,
> > > > or should I be creating my own, or should I be breaking my Fireman's
> > > > birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Does PhoneNumberField for models exist?

2009-01-05 Thread DragonSlayre

Thanks :)

On Jan 6, 12:46 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:
> On Mon, Jan 5, 2009 at 5:33 PM, DragonSlayre <lssay...@gmail.com> wrote:
>
> >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> > This lists PhoneNumberField as being a field type, but in the models
> > documentation,
> >http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fi...
> > there is no such field.
>
> > Does anybody know if this field exists? I'd quite like to use it.
>
> It's in the US localflavor, just as the associated formfield is:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/localflavor/#django
>
> (Moving that and the US state field out of the general fields and into the
> appropriate localflavor looks to have been a fairly late fixup for 1.0,
> which is probably why mention of it is leftover in the general docs.)
>
> 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: birth date in a model form

2009-01-05 Thread DragonSlayre

I've tried using it, but I'm still quite new to django - I put it into
my model file for now, and made my model form looks like this:

class FiremanForm(ModelForm):
birth_date = models.DateField(widget=SelectDateWidget())

But I get an error "got an unexpected keyword argument 'widget' "
>From this I gather that I must be writing the wrong thing, but I'm not
sure what I should be writing?


Thanks a lot

On Jan 6, 11:29 am, Brot <schla...@gmail.com> wrote:
> Hello,
>
> I have the same issue in my app and there is a widget. You can find it
> here:http://code.djangoproject.com/browser/django/trunk/django/forms/extra...
>
> But for me this widget misses a few features and there are open
> tickets with patches, but they are not in trunk yet 
> :-(http://code.djangoproject.com/ticket/9124http://code.djangoproject.com/ticket/6231
>
> I am working with the latest patch from #6231 and so the widget is now
> useful for me. But I hope that this patch find it's way into django
> trunk!
>
> ~Bernd
>
> On Jan 5, 11:00 pm, DragonSlayre <lssay...@gmail.com> wrote:
>
> > Hi,
>
> > I've got a ModelForm, and the model for it contains a birth date field
> > (as a DateField):
>
> > class FiremanForm(ModelForm):
> >     class Meta:
> >         model = Fireman
>
> > Currently a single text box is rendered to enter the date, but I'd
> > like to have a drop down list for day, month, year.
>
> > I'm guessing that lots of people have come across this, and I was
> > wondering what the best way is to get these drop down lists on the
> > page ?
>
> > Are there any widgets that I don't know about that I should be using,
> > or should I be creating my own, or should I be breaking my Fireman's
> > birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Does PhoneNumberField for models exist?

2009-01-05 Thread DragonSlayre

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

This lists PhoneNumberField as being a field type, but in the models
documentation, 
http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields
there is no such field.

Does anybody know if this field exists? I'd quite like to use it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



birth date in a model form

2009-01-05 Thread DragonSlayre

Hi,

I've got a ModelForm, and the model for it contains a birth date field
(as a DateField):

class FiremanForm(ModelForm):
class Meta:
model = Fireman

Currently a single text box is rendered to enter the date, but I'd
like to have a drop down list for day, month, year.

I'm guessing that lots of people have come across this, and I was
wondering what the best way is to get these drop down lists on the
page ?

Are there any widgets that I don't know about that I should be using,
or should I be creating my own, or should I be breaking my Fireman's
birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: MultiValueDictKeyError when accessing POST items

2008-12-23 Thread DragonSlayre

Cheers :)

Damn, I must have been a bit tired coding that up lol

Here's my working code (incase anyone else is as stupid as me):


  Login:
  Username: 
  
  Password:
  
  


On Dec 23, 4:23 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote:
> > I've created my own form:
>
> > 
> >   Login:
> >   Username: 
> >   
> >   Password:
> >   
> >   
> > 
>
> > I am mappying /accounts/login/ to a view of mine, which is then
> > calling:
>
> > if request.method == 'POST':
> >         username = request.POST['login_username']
>
> > I have no idea why I'm getting the error - "Key 'login_username' not
> > found in ".
>
> > What am I doing wrong?
>
> login_username is the value of the id attribute on the label, not on the
> form input element. Basically, your HTML isn't correct for the type of
> form you're after. You need to identify the form input elements, rather
> than the label elements. Compare the output from a Django form to what
> you have an you should see the difference fairly quickly.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MultiValueDictKeyError when accessing POST items

2008-12-22 Thread DragonSlayre

I've created my own form:


  Login:
  Username: 
  
  Password:
  
  


I am mappying /accounts/login/ to a view of mine, which is then
calling:

if request.method == 'POST':
username = request.POST['login_username']

I have no idea why I'm getting the error - "Key 'login_username' not
found in ".

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



Re: Problem saving a User object to a profile

2008-12-19 Thread DragonSlayre

Actually, it seems a bit redundant doesn't it?  I see there is a
get_profile, but nothing to set it anyway.  I guess it's derived
information from the database Yay! such simple solutions, I'm so
happy to be able to register.

On Dec 20, 9:42 am, DragonSlayre <lssay...@gmail.com> wrote:
> You are gods - thank you.  I did try something like this before, but
> being so noob at the technology, didn't assign the form to a new
> variable.
>
> Will i have to assign the profile in the user object as well?  I
> assume I will.
>
> On Dec 20, 9:38 am, Daniel Roseman <roseman.dan...@googlemail.com>
> wrote:
>
> > On Dec 19, 8:28 pm, nbv4 <cp368...@ohio.edu> wrote:> On Dec 19, 3:15 pm, 
> > DragonSlayre <lssay...@gmail.com> wrote:
>
> > > > profile_form.user = user;
> > > > profile_form.save()
>
> > > The problem is that you can't assign fields in forms directly like
> > > this. The only way to input data into a form is when you initially
> > > create the form object ala:
>
> > > profile_form = ProfileForm(request.POST)
>
> > > If theres another way I'd love to know too, because I ran into this
> > > problem earlier and my only solution was to manually create an hidden
> > > textbox with the user_id.
>
> > 
>
> > The easiest way is to do it like this:
> > new_profile = profile_form.save(commit=False)
> > new_profile.user = request.user
> > new_profile.save()
> > --
> > DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem saving a User object to a profile

2008-12-19 Thread DragonSlayre

You are gods - thank you.  I did try something like this before, but
being so noob at the technology, didn't assign the form to a new
variable.

Will i have to assign the profile in the user object as well?  I
assume I will.

On Dec 20, 9:38 am, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Dec 19, 8:28 pm, nbv4 <cp368...@ohio.edu> wrote:> On Dec 19, 3:15 pm, 
> DragonSlayre <lssay...@gmail.com> wrote:
>
> > > profile_form.user = user;
> > > profile_form.save()
>
> > The problem is that you can't assign fields in forms directly like
> > this. The only way to input data into a form is when you initially
> > create the form object ala:
>
> > profile_form = ProfileForm(request.POST)
>
> > If theres another way I'd love to know too, because I ran into this
> > problem earlier and my only solution was to manually create an hidden
> > textbox with the user_id.
>
> 
>
> The easiest way is to do it like this:
> new_profile = profile_form.save(commit=False)
> new_profile.user = request.user
> new_profile.save()
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem saving a User object to a profile

2008-12-19 Thread DragonSlayre

Ok - I'm digging deeper, and I realise that my form doesn't have a
user, as it's excluded from the form using exclude = ('user').

I'll carry on looking...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 saving a User object to a profile

2008-12-19 Thread DragonSlayre

I've got a profile model which has a django.contrib.auth.models.User
as a foreign key.

I am trying to assign the User object to my profile model after I've
checked that the user is valid and that the profile contents are also
valid.

Once I've saved my user object, I then call

profile_form.user = user;
profile_form.save()

In my database, the user and profile have been created, but the
profile's foreign key to the user hasn't been created.

I'm guessing that I'm not calling the right thing on the profile_form,
but am not sure what I should be calling?

Thanks for your 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
-~--~~~~--~~--~--~---



Re: passing extra parameters with named urls

2008-12-18 Thread DragonSlayre

url(r'^register/$',
   register,
   {'extra_context' : {'currentmaintab' :
'account'}},
   name='registration_register',
   ),

It would have been nice if you could have told me straight up.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



passing extra parameters with named urls

2008-12-18 Thread DragonSlayre

Hi,

I'm currently working with django-registration, and have the following
url pattern (it's included from my other url pattern):

 url(r'^register/$',
   register,
   name='registration_register',
   ),

This calls a view:

def register(request, success_url=None,
 form_class=RegistrationForm, profile_callback=None,
 template_name='registration/registration_form.html',
 extra_context=None):

My Question is, how do I pass the register method the extra_context ?

What I'm trying to do is something like this:
 url(r'^register/$',
   register,
   name='registration_register',
   extra_context = {'section' : 'main'},
   ),

But this gives me an error 'url() got an unexpected keyword argument
'extra_context'.  This seems like it'd be a simple little thing, but I
haven't seen any examples online about how you pass in the extra
parameters with named urls.

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



Re: coercing to Unicode: need string or buffer, tuple found

2008-12-09 Thread DragonSlayre

Oh ok, thanks a lot!!

Yes, I'm learning python too at the same time as django...

On Dec 10, 4:35 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-12-09 at 19:23 -0800, DragonSlayre wrote:
> > Hi,
>
> > I've just made a new 'Student' model, and was trying to create a new
> > Student in the admin interface, and I got the following error:
>
> > Environment:
>
> > Request Method: POST
> > Request URL:http://localhost:8000/admin/student/student/add/
> > Django Version: 1.0.2 final
> > Python Version: 2.5.2
> > Installed Applications:
> > ['django.contrib.auth',
> >  'django.contrib.contenttypes',
> >  'django.contrib.sessions',
> >  'django.contrib.sites',
> >  'django.contrib.admin',
> >  'mysite.student']
> > Installed Middleware:
> > ('django.middleware.common.CommonMiddleware',
> >  'django.contrib.sessions.middleware.SessionMiddleware',
> >  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> > Traceback:
> > File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> > in get_response
> >   86.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > in root
> >   157.                 return self.model_page(request, *url.split('/',
> > 2))
> > File "/usr/lib/python2.5/site-packages/django/views/decorators/
> > cache.py" in _wrapped_view_func
> >   44.         response = view_func(request, *args, **kwargs)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
> > in model_page
> >   176.         return admin_obj(request, rest_of_url)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in __call__
> >   191.             return self.add_view(request)
> > File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
> > _commit_on_success
> >   238.                 res = func(*args, **kw)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in add_view
> >   499.                 self.log_addition(request, new_object)
> > File "/usr/lib/python2.5/site-packages/django/contrib/admin/
> > options.py" in log_addition
> >   294.             object_repr     = force_unicode(object),
> > File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
> > force_unicode
> >   49.                 s = unicode(s)
>
> > Exception Type: TypeError at /admin/student/student/add/
> > Exception Value: coercing to Unicode: need string or buffer, tuple
> > found
>
> > My model looks like this:
> > class Student(models.Model):
>
> [...]
>
> >     def __unicode__(self):
> >         return self.user.username, ", ", self.user.first_name, " ",
> > self.user.last_name
>
> You are returning a tuple here and you must return a unicode object. If
> you want to concatenate strings, do it with "+", or use format markers
> like so:
>
>         return u"%s, %s %s" % (self.user.username, self.user.first_name, 
> self.user.last_name)
>
> Using commas to separate objects, even without the surrounding
> parentheses, is how you specify a tuple in Python.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



coercing to Unicode: need string or buffer, tuple found

2008-12-09 Thread DragonSlayre

Hi,

I've just made a new 'Student' model, and was trying to create a new
Student in the admin interface, and I got the following error:

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/student/student/add/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'mysite.student']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in root
  157. return self.model_page(request, *url.split('/',
2))
File "/usr/lib/python2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/sites.py"
in model_page
  176. return admin_obj(request, rest_of_url)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in __call__
  191. return self.add_view(request)
File "/usr/lib/python2.5/site-packages/django/db/transaction.py" in
_commit_on_success
  238. res = func(*args, **kw)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in add_view
  499. self.log_addition(request, new_object)
File "/usr/lib/python2.5/site-packages/django/contrib/admin/
options.py" in log_addition
  294. object_repr = force_unicode(object),
File "/usr/lib/python2.5/site-packages/django/utils/encoding.py" in
force_unicode
  49. s = unicode(s)

Exception Type: TypeError at /admin/student/student/add/
Exception Value: coercing to Unicode: need string or buffer, tuple
found




My model looks like this:

from django.db import models
from django.contrib.auth.models import User

GENDER_CHOICES = (
('m', 'male'),
('f', 'female'),
)


# Create your models here.
class Student(models.Model):

# This is the only required field
user = models.ForeignKey(User, unique=True)

# Being nosey
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
birth_date = models.DateField()

# Addressing details
street_address = models.CharField(max_length=50, blank=False)
suburb = models.CharField(max_length=20, blank=True)
city = models.CharField(max_length=20, blank=False)
post_code = models.PositiveSmallIntegerField(blank=False)

# Contact details
contact_phone = models.CharField(max_length=11, blank=False)
cell_phone = models.CharField(max_length=11, blank=True)

def __unicode__(self):
return self.user.username, ", ", self.user.first_name, " ",
self.user.last_name


I'm quite new to Django, so aren't sure about what's going on at all.
I appreciate any help people can give,


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



Re: Really easy DateTimeField question

2008-12-09 Thread DragonSlayre

Thanks a lot !

On Dec 10, 1:24 pm, friggstad <[EMAIL PROTECTED]> wrote:
> It is the human-friendly name used in the admin.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Really easy DateTimeField question

2008-12-09 Thread DragonSlayre

Hi,
I've seen some code with the following in, but can't find what the
string 'date added' is representing in the documentation.

What is the string for?

models.DateTimeField('date added')



Thank you!

I know it's easy, but it'd take me forever to find out.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django is changing my html!

2008-12-04 Thread DragonSlayre

yes, this fixed the problem. I should change my original title to
"Firefox is changing my html!"

Thanks for the speedy responses... I was trying to do things *right*
using xhtml standards, but I guess that it's more trouble than it's
worth.

On Dec 5, 4:10 pm, "Dj Gilcrease" <[EMAIL PROTECTED]> wrote:
> Actually it looks like he is just getting extra links, which seems to
> remind me of a Safari issue and the Doc type that is set. If I
> remember correctly I ran into an issue similar to this where Safari
> was attempting to fix my HTML to fit my specified Doc-Type. So if I
> had to guess I would say that what ever Doc-Type you are setting does
> not allow  to be a child of the  tag. Try moving your link
> inside the  and see if it still produced unexpected results.
>
> Dj Gilcrease
> OpenRPG Developer
> ~~http://www.openrpg.com
>
> On Thu, Dec 4, 2008 at 7:58 PM, Malcolm Tredinnick
>
> <[EMAIL PROTECTED]> wrote:
>
> > On Thu, 2008-12-04 at 18:49 -0800, DragonSlayre wrote:
> >> Hi,
>
> >> for some reason my hyperlink is not coming out as I expect it to.
> >> Here is my code in my template:
>
> >> 
> >>  {% for category in categories %}
> >>    
> >>        {{ category.name }}
> >>    
> >>  {% endfor %}
> >> 
>
> >> The outcome is the following html code:
>
> >> 
> >>    
> >>   
> >>   Books
> >>   
> >>    
> >> 
>
> >> I've checked and I only have one 'little' category - the Books
> >> category.
> >> I'm expecting the html to appear as the following:
>
> >> 
> >>   
> >>     Books
> >>   
> >> 
>
> >> Does anybody know what might be going on?
>
> > Doesn't seem to be any Django problem here, but you'll want to look at
> > carefully at your view function, or possible your model definition.
>
> > It seems that category.name is not returning what you think it should.
> > Since that is the only thing your template is inserting insider the "li"
> > element, and since the output shows a URL in there, that is what
> > category.name must be returning.
>
> > You haven't shown us what "categories" contains or what the "category"
> > object is, so I can only go on what you've pasted. But the thing between
> > the  and  tags is indicative of the problem. You are actually
> > seeing exactly the right template output for one item in the list (one
> > link outside the "li" element and something inside the "li" element),
> > but the inserted content -- the non-template stuff -- is not what
> > expected. Since that's the portion that is generated by your own code
> > and data, that's the place to start looking.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django is changing my html!

2008-12-04 Thread DragonSlayre


If the problem is inside my view, shouldn't the output generated look
more like this though:


  

  
  
  Books
  
  

  


What i don't understand, is how 1) ' ' is showing up, and 2) why it doesn't have the 
tags inside.
For 1, I can understand how the problem might be in my view, but for 2
- I just don't get why the html would be rendered in the way that it
is?

If I take out the anchor tag in my template, and display the dynamic
content as follows:

 {% for category in categories %}
   
   {% url category-listing category.name|lower %}
   
   
   {{ category.name }}
   
 {% endfor %}


I get the following html output:

 /listings/category/books/ 
 Books 


So I'm pretty sure that it's not the dynamic content that's causing
the problem.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django is changing my html!

2008-12-04 Thread DragonSlayre

Hi,

for some reason my hyperlink is not coming out as I expect it to.
Here is my code in my template:


 {% for category in categories %}
   
   {{ category.name }}
   
 {% endfor %}


The outcome is the following html code:


   
  
  Books
  
   


I've checked and I only have one 'little' category - the Books
category.
I'm expecting the html to appear as the following:


  
Books
  


Does anybody know what might be going on?


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



Re: Best IDE for Django and python?

2008-11-25 Thread DragonSlayre

Well maybe the problem is that the answer is not obvious

On Nov 25, 3:42 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On Tuesday 25 November 2008 01:57:09 pm DragonSlayre wrote:
>
> > How do you develop your django projects, and where do you go when you
> > need to find documentation?
>
> why do you not check the archives of this list? You are the 10,000th person to
> ask this same idiotic question
>
> --
> regards
> KGhttp://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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Best IDE for Django and python?

2008-11-25 Thread DragonSlayre

Hey, I'm getting started with a friend in developing a site with
Django, and we're both new to this, so I am wondering what people use
to manage all their files, and for looking at documentation etc.

Having come from a Java background, I'm used to great documentation,
and suspect that Java is very much the leader in doc, and not the
standard.

I've used the pydev plugin for eclipse, but it seems extremely
limited.

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



Re: Import error exception "No module named urls" when running from eclipse

2008-10-21 Thread DragonSlayre

Thanks for your help,

It turns out that it was a problem to do with the renaming
functionality not working properly in eclipse.  I tried renaming my
package - and that doesn't work for some reason, and then my hack
around caused a problem when I created a new package, which ultimately
stuffed up which package eclipse was looking in when launching the
app.

Is it *normal* for rename to not work properly for the packages in
eclipse using pydev?

My solution to this was to create a new project, with the package name
I wanted, and to import the code I was previously using.  If it's just
my version, then I should probably find out why my version doesn't
support rename.


Louis

On Oct 22, 2:03 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> DragonSlayre wrote:
> > Hi, I'm new to django/python, and I'm testing out eclipse for
> > development.
>
> > I'm using pydev, and managed to run my app, but then when I go to the
> > web page, I get:
>
> > ImportError at /time/
> > No module named urls
>
> You'll need to include the code for the view that is being called, and
> possibly your urls.py
> Do you have a urls.py in your project?
>
> Jeff Anderson
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Import error exception "No module named urls" when running from eclipse

2008-10-21 Thread DragonSlayre

Hi, I'm new to django/python, and I'm testing out eclipse for
development.

I'm using pydev, and managed to run my app, but then when I go to the
web page, I get:

ImportError at /time/
No module named urls
Request Method: GET
Request URL:http://localhost:8080/time/
Exception Type: ImportError
Exception Value:
No module named urls
Exception Location: C:\python25\lib\site-packages\django\core
\urlresolvers.py in _get_urlconf_module, line 197
Python Executable:  C:\Python25\python.exe
Python Version: 2.5.2


I'm guessing that I probably need to include a library in eclipse or
something like that - any ideas???

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