Re: CSS reference to Media folder

2012-02-16 Thread Leonardo Giordani
I think it is better for you to keep CSS images in /static folder too.
/media is better suited as a folder to host user-loaded content.

If you keep CSS and images in /static you can just refer to them with
a relative path.

I think that probably (but I'm not sure) CSS can only address relative
paths from their location.

Regards

Leo

2012/2/15 Kolbe :
> Hi all,
>
> I have a .css file in the /static/ folder where I keep all my styles.
>
> Now when I want to refer to images that I use in my CSS that are
> stored in the /media/ folder, how do I reference that?
>
>
> e.g. background-image:url('gradient2.png');
>
> gradient2.png is stored in ~/media/ and my css is in ~/static/
>
> Is there a way to define the path to gradient2.png?
>
> Cheers!
> Max
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google 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.



G+ API library

2012-02-16 Thread Timothy Makobu
Hi all,

Is there a completely bare bones script out there for G+?
Something that takes the client_id and client_secret and returns a handle
to G+; something like python-twitter?

-- 
You received this message because you are subscribed to the Google 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.



connection.cursor()

2012-02-16 Thread MikeKJ
I got these imported tables from an external source so I need to
access the data using connection.

The problem I have is getting at the data in more than 1 table with
one dict the pure sql call would be something like

select * from yw_basics ywb left join yw_next ywn on ywb.id = ywn.id
where ywn.field = 0

def dictfetchall(cursor):
desc = cursor.description
return [
dict(zip([col[0] for col in desc], row))
for row in cursor.fetchall()
]

def secondhand(request):
from django.db import connection, transaction
cursor = connection.cursor()
cursor.execute("SELECT * from yw_basics")
stuff = dictfetchall(cursor)

I tried adding the sql call above into the cusor.execute and failed
miserably so any clues would be gratefully received.


-- 
You received this message because you are subscribed to the Google 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: CSS reference to Media folder

2012-02-16 Thread MikeKJ
background-image: url(/media/images/base/gradient2.png)

eg

On Feb 15, 12:37 pm, Kolbe  wrote:
> Hi all,
>
> I have a .css file in the /static/ folder where I keep all my styles.
>
> Now when I want to refer to images that I use in my CSS that are
> stored in the /media/ folder, how do I reference that?
>
> e.g. background-image:url('gradient2.png');
>
> gradient2.png is stored in ~/media/ and my css is in ~/static/
>
> Is there a way to define the path to gradient2.png?
>
> Cheers!
> Max

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



Re: [ANN]: FeinCMS v1.5.0.rc1

2012-02-16 Thread Matthias Kestenholz
On Thu, Feb 16, 2012 at 07:52, Mark Renton  wrote:
> Great news! Happy to see the new version comes out ASAP. However, with the
> deprecate of old style patch of 3rd app URL reverse, is that means I must
> rewrite views and template codes of my app to fit this upgrade? And should I
> to do so if I wanna use others' app?
>

Yes, that's correct. It's recommended to set
"FEINCMS_REVERSE_MONKEY_PATCH = False" as soon as possible
(especially in new projects.)

Btw, if we want to upgrade several (old) FeinCMS sites we are runnning this
will cause a lot of pain for us too. On the other hand we finally have explicit
instead of fragile behavior, so I think the pain is still worth it
(besides being
a better citizen in the Django ecosystem, because now we do not rely on any
monkey-patching of Django proper anymore.)


Best regards
Matthias

-- 
You received this message because you are subscribed to the Google 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: [ANN]: FeinCMS v1.5.0.rc1

2012-02-16 Thread Martin J. Laubach
Well for now you don't NEED to change anything. You'll get those pesky 
deprecation warnings, but everything should continue to work fine for now, 
so there's no need to rush things, you can change your code as you go along.

mjl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dT-lPvVmS6cJ.
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: Creating a hospital erp (hospital management) in Django

2012-02-16 Thread Saadat
Hello All
I created a view today and I could access the database values usi

On Feb 14, 8:07 am, Python_Junkie 
wrote:
> Now that you have your file >>models.py   place this file in the
> app folder after creating your app
>
> 1.  python manage.py start app  My_Erp (for example)
> 2.  a blank models.py file will be created, overwrite this with your
> models.py
> 3. run the command to sync the database, assuming that your set up the
> settings.py file has been set up correctly to connect to the database
> of your choice.
>
> python manage.py syncdb
>
> Let me know if this works for you
>
> On Feb 13, 3:56 pm,Saadat wrote:
>
> > Thank you Python_junkie
> > I've created the poll app and I'm working on this Hospital ERP thing.
> > I've also created the database schema and put some dummy values for
> > testing. Then I created the models using 'inspected' command and saved
> > the models in models.py file. Now I'm confused where to put the
> > models.py file and what to with it. Guide me please.
>
> > Thanks a lot.
> >Saadat
>
> > On Feb 10, 6:18 pm, Python_Junkie 
> > wrote:
>
> > > Not sure from your post, which piece you are stuck on.
>
> > > 1. Have you used Django before?
> > > If not start with the tutorial
>
> > >https://www.djangoproject.com/
>
> > > 2. If you have a basic understanding of Django, have you been able to
> > > set up a basic project /app and connect run syncdb.
> > > One can always connect to the sqllite database, because it is built
> > > in, but getting some other database to connect can be a time consuming
> > > process if the procedure has not been established on your machine.
>
> > > 3. If you have done the above 2 items then you should move in a
> > > parallel path.
>
> > > a. Start defining your database model to support the business and the
> > > workflow that you intend to create.
> > > b. Use some sort of wire frame (framework) to lay out your web pages
> > > to support and interact step 3 a.
>
> > > On Feb 10, 8:06 am, adesantoas...@gmail.com wrote:
>
> > > > Hello, nice thread.
>
> > > > **tagged to keep following..
>
> > > > +adesst
>
> > > > -Original Message-
> > > > From:Saadat
>
> > > > Sender: django-users@googlegroups.com
> > > > Date: Fri, 10 Feb 2012 02:58:16
> > > > To: Django users
> > > > Reply-To: django-users@googlegroups.com
> > > > Subject: Creating a hospital erp (hospital management) in Django
>
> > > > Hello All,
> > > > I'm in my final year of computer science engineering and for my final
> > > > year project, i'm creating a hospital erp. I'm a bit confused about
> > > > where to start from. Any sort of help will be appreciated. Thanks a
> > > > lot.
>
> > > > Cheers
> > > >Saadat
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > 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 
> > > > athttp://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-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: Creating a hospital erp (hospital management) in Django

2012-02-16 Thread Saadat
Hi all, I created a view today and I could access the database
contents using Templates. Now I wish to create a listbox that would
have the names of doctors. When an item from the list is selected, an
sql query should be sent which will return all the details of that
doctor, where doc_id is the primary key? how do we create buttons? do
we need to use html or django can handle them also?

Thanks a lot people.
Saadat

On Feb 16, 4:12 pm, Saadat  wrote:
> Hello All
> I created a view today and I could access the database values usi
>
> On Feb 14, 8:07 am, Python_Junkie 
> wrote:
>
>
>
>
>
>
>
> > Now that you have your file >>models.py   place this file in the
> > app folder after creating your app
>
> > 1.  python manage.py start app  My_Erp (for example)
> > 2.  a blank models.py file will be created, overwrite this with your
> > models.py
> > 3. run the command to sync the database, assuming that your set up the
> > settings.py file has been set up correctly to connect to the database
> > of your choice.
>
> > python manage.py syncdb
>
> > Let me know if this works for you
>
> > On Feb 13, 3:56 pm,Saadat wrote:
>
> > > Thank you Python_junkie
> > > I've created the poll app and I'm working on this Hospital ERP thing.
> > > I've also created the database schema and put some dummy values for
> > > testing. Then I created the models using 'inspected' command and saved
> > > the models in models.py file. Now I'm confused where to put the
> > > models.py file and what to with it. Guide me please.
>
> > > Thanks a lot.
> > >Saadat
>
> > > On Feb 10, 6:18 pm, Python_Junkie 
> > > wrote:
>
> > > > Not sure from your post, which piece you are stuck on.
>
> > > > 1. Have you used Django before?
> > > > If not start with the tutorial
>
> > > >https://www.djangoproject.com/
>
> > > > 2. If you have a basic understanding of Django, have you been able to
> > > > set up a basic project /app and connect run syncdb.
> > > > One can always connect to the sqllite database, because it is built
> > > > in, but getting some other database to connect can be a time consuming
> > > > process if the procedure has not been established on your machine.
>
> > > > 3. If you have done the above 2 items then you should move in a
> > > > parallel path.
>
> > > > a. Start defining your database model to support the business and the
> > > > workflow that you intend to create.
> > > > b. Use some sort of wire frame (framework) to lay out your web pages
> > > > to support and interact step 3 a.
>
> > > > On Feb 10, 8:06 am, adesantoas...@gmail.com wrote:
>
> > > > > Hello, nice thread.
>
> > > > > **tagged to keep following..
>
> > > > > +adesst
>
> > > > > -Original Message-
> > > > > From:Saadat
>
> > > > > Sender: django-users@googlegroups.com
> > > > > Date: Fri, 10 Feb 2012 02:58:16
> > > > > To: Django users
> > > > > Reply-To: django-users@googlegroups.com
> > > > > Subject: Creating a hospital erp (hospital management) in Django
>
> > > > > Hello All,
> > > > > I'm in my final year of computer science engineering and for my final
> > > > > year project, i'm creating a hospital erp. I'm a bit confused about
> > > > > where to start from. Any sort of help will be appreciated. Thanks a
> > > > > lot.
>
> > > > > Cheers
> > > > >Saadat
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google 
> > > > > 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 
> > > > > athttp://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-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 loading integer data into database using fixture

2012-02-16 Thread Gchorn
Hello All,

I'm attempting to provide initial data for my database using a fixture
file (like this: 
https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-initial-data-with-fixtures),
but I'm running into the following error:

Problem installing fixture '/home/guillaume/NBA/players/fixtures/
player_data.yaml': Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/
commands/loaddata.py", line 169, in handle
for obj in objects:
  File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
pyyaml.py", line 54, in Deserializer
for obj in PythonDeserializer(yaml.load(stream), **options):
  File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
python.py", line 122, in Deserializer
data[field.attname] =
field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/
__init__.py", line 471, in to_python
raise exceptions.ValidationError(self.error_messages['invalid'])
ValidationError: [u'This value must be an integer.']

Here is a sample from the YAML fixture file I'm attempting to use:

- model: players.player
  pk: 2
  fields:
team: DEN
first_name: Arron
last_name: Afflalo
age: 26
pos:  SG
gp: 25
mp: 754
fg: 98
fga: 227
ft: 62
fta: 78
three_pointers: 31
threes_attempted: 81
orb: 15
drb: 51
ast: 39
stl: 15
blk: 6
tov: 33
pf: 55
pts: 289

Isn't what I have there mostly integers?  I've already checked my
models.py file to make sure I didn't accidentally use an
"IntegerField" for "team", "first_name", "last_name", or "pos."  Do I
need to include some other kind of formatting information in my YAML
file to indicate that the numbers are integers?

thanks,
Guillaume

-- 
You received this message because you are subscribed to the Google 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: connection.cursor()

2012-02-16 Thread bruno desthuilliers
On Feb 16, 10:29 am, MikeKJ  wrote:
> I got these imported tables from an external source so I need to
> access the data using connection.

Not necessarily - if there's no compound primary key, you can build
django models from the tables using manage.py inspectdb (be sure to
add the managed=False and set the correct tablename in the generated
model's Meta).


> The problem I have is getting at the data in more than 1 table with
> one dict the pure sql call would be something like
>
> select * from yw_basics ywb left join yw_next ywn on ywb.id = ywn.id
> where ywn.field = 0

"select * " is usually a bad idea.

> def dictfetchall(cursor):
>     desc = cursor.description
>     return [
>         dict(zip([col[0] for col in desc], row))
>         for row in cursor.fetchall()
>     ]

You'd be better using lazy evaluation:

def dictfetchall(cursor):
# avoid reexecuting constant code in a loop
desc = col[0] for col in cursor.description
for row in cursor:
yield dict(zip(desc, row))


> def secondhand(request):
>     from django.db import connection, transaction

Please avoid imports in functions.

>     cursor = connection.cursor()
>     cursor.execute("SELECT * from yw_basics")
>     stuff = dictfetchall(cursor)
>
> I tried adding the sql call above into the cusor.execute and failed
> miserably so any clues would be gratefully received.

First clue : "failed miserably" is about the most useless possible
description of the problem, specially if you hope to get any help. At
the very least explain what happens (and if you get an exception post
the full traceback).

-- 
You received this message because you are subscribed to the Google 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: load settings on database

2012-02-16 Thread bruno desthuilliers


On Feb 16, 4:55 am, Anderson Borges  wrote:
> Hey guys
> I am learning django and I have a question
> I have a table in my database call SettingsUser so how can I load this table 
> to all views on my application?

I just don't understand what "loading a table" is supposed to mean. If
you want to make some object (model instance or whatever) available to
all your templates, a context processor will do the job. If you want
to make it available to all your views, you can use a middleware and
attach the relevant object(s) to the request object.

Now given the name ("settingsuser") I suspect it's a kind of "per-user
settings" stuff. If so, the SettingsUser model should have a
foreignkey on User, and then you can just follow the reversed
relationship, ie:


# youmodels.py
class UserSetting(models.Model):
user = models.ForeignKey(User, related_name="settings")
parrot_is_dead = models.BooleanField(u"Is user's parrot dead ?",
default=True)


# yourviews.py


def something(request, *args, **kw):
print request.user.settings.all()

HTH

-- 
You received this message because you are subscribed to the Google 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: [ANN]: FeinCMS v1.5.0.rc1

2012-02-16 Thread Mark Renton
Great news! Happy to see the new version comes out ASAP. However, with the 
deprecate of old style patch of 3rd app URL reverse, is that means I must 
rewrite views and template codes of my app to fit this upgrade? And should 
I to do so if I wanna use others' app?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/b9ILvaoh6x8J.
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.



Model.delete() was not called.

2012-02-16 Thread SomeoneToIgnore
Hello. I'm using Django 1.3.1.

I've got some strange behaviour while deleting an object in admin
panel.

Here's the code from models.py:

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')

def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
was_published_today.short_description = 'Published today?'

def __unicode__(self):
return self.question

def delete(self, using=None):
print "Deleted"
super(Poll, self).delete(using)

It is just the code from django tutorial with delete() method
overriden.

There was an issue:
https://code.djangoproject.com/ticket/11022

If I open the object's properties page and delete an object using
Delete button on that page everything works fine and message displays
in the console.

But if I check the object's checkoxes (insted of opening their
property list pages), select "Delete selected polls" action and press
the Go button, the Delete multiple objects page opens.
Then I press "Yes, I'm sure button" and objects are successfully
deleted.

But their delete() method are not triggered so i don't get the message
"Deleted" in the console.
It does not matter if I choose one or multiply objects - the message
still does not appear in the console.

Should I consider this behaviour as a bug or I am doing something
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: Logging from multiple processes

2012-02-16 Thread JC


On Feb 15, 7:57 am, bruno desthuilliers
 wrote:
> On Feb 14, 6:23 pm, JC  wrote:
>
> > Hey guys,
>
> > Does Django 1.3.1 handle logging from multiple processes or I have to
> > have some special consideration?
>
> Not really a django-specific problem - the problem exists as soon as
> you have concurrent write access on a same file. The solution is of
> course to NOT log to a file.
>
Thanks! Maybe I wasn't clear, I know this is not a django-specific
problem, but since it had implemented logging integration I wanted to
know if django had worked around this issue.

> > This document may be 
> > related:https://code.djangoproject.com/wiki/LoggingProposalbutits two years
> > old so I was wondering maybe Django now supports this?
>
> https://docs.djangoproject.com/en/1.3/topics/logging/
>
> IOW : learn to use the standard python logging module. If you're using
> mod_wsgi the simplest thing is to use a streamhandler on sys.stderr
> and let apache do the dirty work.

I've read about this, I'll give it a try!

Thanks!

JC

-- 
You received this message because you are subscribed to the Google 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: connection.cursor()

2012-02-16 Thread MikeKJ
Actually Bruno thats great, it put me on the right track and I have
now solved the error, my bad really I forgot how to properly construct
a join sql statment... Cheers

-- 
You received this message because you are subscribed to the Google 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.delete() was not called.

2012-02-16 Thread Alasdair Nicol

Hi,

On 16/02/12 10:53, SomeoneToIgnore wrote:

Hello. I'm using Django 1.3.1.

I've got some strange behaviour while deleting an object in admin
panel.

Here's the code from models.py:

class Poll(models.Model):
 question = models.CharField(max_length=200)
 pub_date = models.DateTimeField('date published')

 def was_published_today(self):
 return self.pub_date.date() == datetime.date.today()
 was_published_today.short_description = 'Published today?'

 def __unicode__(self):
 return self.question

 def delete(self, using=None):
 print "Deleted"
 super(Poll, self).delete(using)

It is just the code from django tutorial with delete() method
overriden.

There was an issue:
https://code.djangoproject.com/ticket/11022

If I open the object's properties page and delete an object using
Delete button on that page everything works fine and message displays
in the console.

But if I check the object's checkoxes (insted of opening their
property list pages), select "Delete selected polls" action and press
the Go button, the Delete multiple objects page opens.
Then I press "Yes, I'm sure button" and objects are successfully
deleted.

But their delete() method are not triggered so i don't get the message
"Deleted" in the console.
It does not matter if I choose one or multiply objects - the message
still does not appear in the console.

Should I consider this behaviour as a bug or I am doing something
wrong?



The delete select action uses the queryset's delete method [1], which 
means the model's delete method is not called.


It's not a bug, the behaviour is documented on the admin actions page. [2]

Cheers,
Alasdair

[1]: 
https://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects
[2]: 
https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#admin-actions


--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, 
Surrey, GU2 7YD, UK.

--
You received this message because you are subscribed to the Google 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.delete() was not called.

2012-02-16 Thread SomeoneToIgnore

>
> >The delete select action uses the queryset's delete method [1], which 
> >means the model's delete method is not called.
>
> >It's not a bug, the behaviour is documented on the admin actions page. [2]
>
> >Cheers,
> >Alasdair
>
> >[1]: 
> >https://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects
> >[2]: 
>
> >https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#admin-actions
>
> >-- 
> >Alasdair Nicol
> >Developer, MEMSET
>
> >mail: alasd...@memset.com
>  > web: http://www.memset.com/
>
> >Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, 
> Guildford, Surrey, GU2 7YD, UK
>


Oh my, looks like I should read the documentation more carefully.

Thank you very much for the help. 

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



Re: Django Location- Does anyone know about this?

2012-02-16 Thread Derek
http://geodjango.org/ ?

On Feb 15, 6:18 pm, coded kid  wrote:
> Hi Guys, Does anyone knows about any good django package for maps? or
> for locating of areas, states, streets? Please kindly answer if you
> do. Thanks.
>
> BTW: I've tried using Django easy_maps but it's not working. If you've
> used easy_maps before, kindly comment below. Just want to ask you a
> few questions.

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



Re: Django Location- Does anyone know about this?

2012-02-16 Thread Addy Yeow
Not exactly a Django package but it's implemented in Django and uses
MaxMind geoip database:
http://dazzlepod.com/ip/
You could use the API for free, e.g. http://dazzlepod.com/ip/8.8.8.8.json

On Thu, Feb 16, 2012 at 10:03 PM, Derek  wrote:

> http://geodjango.org/ ?
>
> On Feb 15, 6:18 pm, coded kid  wrote:
> > Hi Guys, Does anyone knows about any good django package for maps? or
> > for locating of areas, states, streets? Please kindly answer if you
> > do. Thanks.
> >
> > BTW: I've tried using Django easy_maps but it's not working. If you've
> > used easy_maps before, kindly comment below. Just want to ask you a
> > few questions.
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

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



Re: import problem

2012-02-16 Thread Scott Macri
DrBloodmoney I not sure what you mean by circular imports.  datetime
is the only import I have in this file.

Yes Furbeenator it is a 'datetime' is not defined error.

I'll post the entire error message tonight when I get home.

My website directory is mn and my app directory is hcp.  I'm trying to
do the import on a file in the hcp app directory.  The imports of my
classes (ie from mn.hcp import something) work just fine.  The issue
seems to be with python specific imports.

Thanks.

On Wed, Feb 15, 2012 at 11:11 PM, Furbee  wrote:
> Can you reply with the actual NameError Exception? Like: NameError: global
> name 'datetime' is not defined, or whatever it is. From the module that is
> throwing this error are you importing anything else that is importing an
> overridden date method or datetime object?
>
> You can also try this (instead of "import datetime"):
>
> from datetime import date
>
> On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:
>>
>> Hello,
>> I'm having a strange issue and have already spent an hour trying to
>> figure it out.
>>
>> I created a python app called mn.  Then I setup all my models and
>> stuff to work under mn.hcp.  Everything has been working fine until I
>> tried to use date time in a py file in the hcp directory.
>>
>> I've imported datetime, with import date time at the top of my py
>> file.  Then within the file I have a class with an internal method
>> trying to use some date functions.
>>
>> datetime.date(2003,11,11)
>>
>> For some reason I am getting a NameError on the datetime object.  I
>> don't understand why this is happening after I've imported datetime.
>> Any help would be appreciated.  Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google 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.



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

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



Re: import problem

2012-02-16 Thread Scott Macri
Oh, the other thing is that if I run the exact same code in my idle
shell within the hcp app all the imports work fine.

On Thu, Feb 16, 2012 at 9:20 AM, Scott Macri  wrote:
> DrBloodmoney I not sure what you mean by circular imports.  datetime
> is the only import I have in this file.
>
> Yes Furbeenator it is a 'datetime' is not defined error.
>
> I'll post the entire error message tonight when I get home.
>
> My website directory is mn and my app directory is hcp.  I'm trying to
> do the import on a file in the hcp app directory.  The imports of my
> classes (ie from mn.hcp import something) work just fine.  The issue
> seems to be with python specific imports.
>
> Thanks.
>
> On Wed, Feb 15, 2012 at 11:11 PM, Furbee  wrote:
>> Can you reply with the actual NameError Exception? Like: NameError: global
>> name 'datetime' is not defined, or whatever it is. From the module that is
>> throwing this error are you importing anything else that is importing an
>> overridden date method or datetime object?
>>
>> You can also try this (instead of "import datetime"):
>>
>> from datetime import date
>>
>> On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:
>>>
>>> Hello,
>>> I'm having a strange issue and have already spent an hour trying to
>>> figure it out.
>>>
>>> I created a python app called mn.  Then I setup all my models and
>>> stuff to work under mn.hcp.  Everything has been working fine until I
>>> tried to use date time in a py file in the hcp directory.
>>>
>>> I've imported datetime, with import date time at the top of my py
>>> file.  Then within the file I have a class with an internal method
>>> trying to use some date functions.
>>>
>>> datetime.date(2003,11,11)
>>>
>>> For some reason I am getting a NameError on the datetime object.  I
>>> don't understand why this is happening after I've imported datetime.
>>> Any help would be appreciated.  Thanks.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>
>
>
> --
> Scott A. Macri
> www.ScottMacri.com
> (571) 234-1581



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

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



Re: import problem

2012-02-16 Thread scott macri
DrBloodmoney I not sure what you mean by circular imports.  datetime
is the only import I have in this file.

Yes Furbeenator it is a 'datetime' is not defined error.

I'll post the entire error message tonight when I get home.

My website directory is mn and my app directory is hcp.  I'm trying to
do the import on a file in the hcp app directory.  The imports of my
classes (ie from mn.hcp import something) work just fine.  The issue
seems to be with python specific imports.

Thanks.

Oh, the other thing is that if I run the exact same code in my idle
shell within the hcp app all the imports work fine.

On Wed, Feb 15, 2012 at 11:11 PM, Furbee  wrote:
> Can you reply with the actual NameError Exception? Like: NameError: global
> name 'datetime' is not defined, or whatever it is. From the module that is
> throwing this error are you importing anything else that is importing an
> overridden date method or datetime object?
>
> You can also try this (instead of "import datetime"):
>
> from datetime import date
>
> On Wed, Feb 15, 2012 at 7:48 PM, Scott  wrote:
>>
>> Hello,
>> I'm having a strange issue and have already spent an hour trying to
>> figure it out.
>>
>> I created a python app called mn.  Then I setup all my models and
>> stuff to work under mn.hcp.  Everything has been working fine until I
>> tried to use date time in a py file in the hcp directory.
>>
>> I've imported datetime, with import date time at the top of my py
>> file.  Then within the file I have a class with an internal method
>> trying to use some date functions.
>>
>> datetime.date(2003,11,11)
>>
>> For some reason I am getting a NameError on the datetime object.  I
>> don't understand why this is happening after I've imported datetime.
>> Any help would be appreciated.  Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google 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.

-- 
You received this message because you are subscribed to the Google 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: best example/tutorial for AJAX + Django

2012-02-16 Thread Sushirod
Take a look into Pyjamas as well.
http://pyjs.org/

On Feb 15, 5:32 pm, "H.T. Wei"  wrote:
> Hi,
>
> I am new to Django and searched around for a good example/tutorial about
> AJAX + Django but most of them were not considered as complete.
> Can anyone suggest if there is a good (complete) example for learning AJAX
> + Django? Thanks in advance!
>
> --

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



Sharing users db

2012-02-16 Thread Evgenii Belykh
Hi folks!

I've trying to use sharing db via technique proposed by Dustin at
http://dfcode.com/
(available at
http://webcache.googleusercontent.com/search?q=cache:ukYEYwoaJtYJ:dfcode.com/blog/2011/5/sharing-django-users-and-sessions-across-projects/+sharing+users+django&cd=1&hl=ru&ct=clnk&gl=ru&client=opera)


it works untill I've trying to exclude /admin from routing via the
following code:
import threading


# Object to hold request data
request_cfg = threading.local()


class RouterMiddleware(object):
"""
Sets a flag if we are accessing Django admin to prevent database
rerouting
for the auth model.  Removes the flag once the request has been
processed.
"""

def process_view(self, request, view_func, args, kwargs):
if request.path.startswith('/admin'):
request_cfg.admin = True

def process_response(self, request, response):
if hasattr(request_cfg, 'admin'):
del request_cfg.admin
--
Accessing site root get an error:
TypeError at /

argument of type 'NoneType' is not iterable
Exception Location: /home/alexey/sites/django/http/utils.py in
fix_location_header, line 19:
if 'Location' in response and request.get_host():
response['Location'] =
request.build_absolute_uri(response['Location'])
return response

-
Any help much appreciated.
PS.Maybe smth wrong in RouterMiddleware since it does not return a
response?



-- 
You received this message because you are subscribed to the Google 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: Logging from multiple processes

2012-02-16 Thread Alexey Luchko

Hi!

We are using TimedRotatingFileHandler with overridden stream with a class
that opens log file for append on every write.

--
Regards,
Alex.

--
You received this message because you are subscribed to the Google 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: Sharing users db

2012-02-16 Thread Tom Evans
On Thu, Feb 16, 2012 at 4:00 PM, Evgenii Belykh  wrote:
> Hi folks!
>
> I've trying to use sharing db via technique proposed by Dustin at
> […]
>    def process_view(self, request, view_func, args, kwargs):
>        if request.path.startswith('/admin'):
>            request_cfg.admin = True
>
>    def process_response(self, request, response):
>        if hasattr(request_cfg, 'admin'):
>            del request_cfg.admin
>[…]
> -
> Any help much appreciated.
> PS.Maybe smth wrong in RouterMiddleware since it does not return a
> response?
>

Asked and answered yourself!

Yes, that is exactly why it is failing. process_response(), if it
exists, must always return a response.

See:

https://docs.djangoproject.com/en/1.3/topics/http/middleware/#process-response

Cheers

Tom

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



Re: import problem

2012-02-16 Thread DrBloodmoney
On Thu, Feb 16, 2012 at 9:20 AM, Scott Macri  wrote:
> DrBloodmoney I not sure what you mean by circular imports.  datetime
> is the only import I have in this file.

Here are examples of circular import problems [1][2]

I am forever getting bitten by them, so it's become one of the first
things that I think about when weird things/bugs happen in Python.

[1] http://effbot.org/zone/import-confusion.htm#circular-imports
[2] 
http://stackoverflow.com/questions/1556387/circular-import-dependency-in-python

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



Re: best example/tutorial for AJAX + Django

2012-02-16 Thread H.T. Wei
Thank you.

On Thu, Feb 16, 2012 at 7:45 AM, Sushirod  wrote:

> Take a look into Pyjamas as well.
> http://pyjs.org/
>
> On Feb 15, 5:32 pm, "H.T. Wei"  wrote:
> > Hi,
> >
> > I am new to Django and searched around for a good example/tutorial about
> > AJAX + Django but most of them were not considered as complete.
> > Can anyone suggest if there is a good (complete) example for learning
> AJAX
> > + Django? Thanks in advance!
> >
> > --
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
" stay hungry, stay foolish"

-- 
You received this message because you are subscribed to the Google 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 loading integer data into database using fixture

2012-02-16 Thread Bill Freeman
Well, I don't know yaml, but if you are in a place where you don't
have to quote:

   Arron

then I'd expect everything to be strings.

Is there a yaml.dump that you can apply to a model with strings and
integers to see how it thinks they are distinguished?


On 2/16/12, Gchorn  wrote:
> Hello All,
>
> I'm attempting to provide initial data for my database using a fixture
> file (like this:
> https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-initial-data-with-fixtures),
> but I'm running into the following error:
>
> Problem installing fixture '/home/guillaume/NBA/players/fixtures/
> player_data.yaml': Traceback (most recent call last):
>   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
> commands/loaddata.py", line 169, in handle
> for obj in objects:
>   File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
> pyyaml.py", line 54, in Deserializer
> for obj in PythonDeserializer(yaml.load(stream), **options):
>   File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
> python.py", line 122, in Deserializer
> data[field.attname] =
> field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/
> __init__.py", line 471, in to_python
> raise exceptions.ValidationError(self.error_messages['invalid'])
> ValidationError: [u'This value must be an integer.']
>
> Here is a sample from the YAML fixture file I'm attempting to use:
>
> - model: players.player
>   pk: 2
>   fields:
> team: DEN
> first_name: Arron
> last_name: Afflalo
> age: 26
> pos:  SG
> gp: 25
> mp: 754
> fg: 98
> fga: 227
> ft: 62
> fta: 78
> three_pointers: 31
> threes_attempted: 81
> orb: 15
> drb: 51
> ast: 39
> stl: 15
> blk: 6
> tov: 33
> pf: 55
> pts: 289
>
> Isn't what I have there mostly integers?  I've already checked my
> models.py file to make sure I didn't accidentally use an
> "IntegerField" for "team", "first_name", "last_name", or "pos."  Do I
> need to include some other kind of formatting information in my YAML
> file to indicate that the numbers are integers?
>
> thanks,
> Guillaume
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Sharing users db

2012-02-16 Thread Evgenii Belykh
it rocks Tom!!


On Feb 16, 7:30 pm, Tom Evans  wrote:
> On Thu, Feb 16, 2012 at 4:00 PM, Evgenii Belykh  wrote:
> > Hi folks!
>
> > I've trying to use sharing db via technique proposed by Dustin at
> > […]
> >    def process_view(self, request, view_func, args, kwargs):
> >        if request.path.startswith('/admin'):
> >            request_cfg.admin = True
>
> >    def process_response(self, request, response):
> >        if hasattr(request_cfg, 'admin'):
> >            del request_cfg.admin
> >[…]
> > -
> > Any help much appreciated.
> > PS.Maybe smth wrong in RouterMiddleware since it does not return a
> > response?
>
> Asked and answered yourself!
>
> Yes, that is exactly why it is failing. process_response(), if it
> exists, must always return a response.
>
> See:
>
> https://docs.djangoproject.com/en/1.3/topics/http/middleware/#process...
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google 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.



Help on forms.py

2012-02-16 Thread Stanwin Siow
Hello,

I'm trying to modify the default registration forms.py by adding in more fields.

Currently it's like that:

=
keyword_info = {
"queryset" : Keyword.objects.all(),
}

class RegistrationForm(forms.Form):
   
username = forms.RegexField(regex=r'^\w+$',
max_length=30,
widget=forms.TextInput(attrs=attrs_dict),
label=_(u'username'))
email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
   maxlength=75)),
 label=_(u'email address'))
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, 
render_value=False),
label=_(u'password'))
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, 
render_value=False),
label=_(u'password (again)'))
keywords = forms.ChoiceField(choices=keyword_info)
label=_(u'keyword'))


=

The thing is i would like keywords to be a drop down menu of keywords which are 
derived from the keyword database table.

Can someone check if what i'm doing is correct?

Thank you!


Best Regards,

Stanwin Siow



-- 
You received this message because you are subscribed to the Google 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: Help on forms.py

2012-02-16 Thread Alasdair Nicol

Hi Stanwin,

On 16/02/12 17:43, Stanwin Siow wrote:

Hello,

I'm trying to modify the default registration forms.py by adding in 
more fields.


Currently it's like that:

=
*keyword_info = {*
*"queryset" : Keyword.objects.all(),*
*}*

class RegistrationForm(forms.Form):

*keywords = forms.ChoiceField(choices=keyword_info)*
*label=_(u'keyword'))*


You're using a ChoiceField, which requires a list of 2-tuples, for example:

   choices = [('keyword1', 'keyword1'), ('keyword1', 'keyword1')]

What you probably want is a ModelChoiceField [1], which takes a queryset 
argument.


keywords = forms.ModelChoiceField(queryset=Keyword.objects.all())

[1]: 
https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield


cheers,

Alasdair

--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, 
Surrey, GU2 7YD, UK.

--
You received this message because you are subscribed to the Google 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: Help on forms.py

2012-02-16 Thread Stanwin Siow
Awesome!

Thank you and have a great Weekend! :D

Best Regards,

Stanwin Siow



On Feb 17, 2012, at 1:50 AM, Alasdair Nicol wrote:

> Hi Stanwin,
> 
> On 16/02/12 17:43, Stanwin Siow wrote:
>> Hello,
>> 
>> I'm trying to modify the default registration forms.py by adding in more 
>> fields.
>> 
>> Currently it's like that:
>> 
>> =
>> keyword_info = {
>> "queryset" : Keyword.objects.all(),
>> }
>> 
>> class RegistrationForm(forms.Form):
>>
>> keywords = forms.ChoiceField(choices=keyword_info)
>> label=_(u'keyword'))
>> 
> You're using a ChoiceField, which requires a list of 2-tuples, for example:
> 
>choices = [('keyword1', 'keyword1'), ('keyword1', 'keyword1')]
> 
> What you probably want is a ModelChoiceField [1], which takes a queryset 
> argument.
> 
> keywords = forms.ModelChoiceField(queryset=Keyword.objects.all())
> 
> [1]: https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield
> 
> cheers,
> 
> Alasdair
> -- 
> Alasdair Nicol
> Developer, MEMSET
> 
> mail: alasd...@memset.com 
>  web: http://www.memset.com/ 
> 
> Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, 
> Guildford, Surrey, GU2 7YD, UK.
> 
> -- 
> You received this message because you are subscribed to the Google 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.

-- 
You received this message because you are subscribed to the Google 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 valuesfor keyword arguement 'prefix'

2012-02-16 Thread Phil
Hi,

I have a basic django blog built and am now trying to use generic views in 
it but am getting the following error, I'm not sure where I am going wrong:


Environment:


Request Method: GET
Request URL: http://127.0.0.1:8080/blog/

Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.formtools',
 'django.contrib.admindocs',
 'tagging',
 'blog']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
in get_response
  101. request.path_info)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in resolve
  252. sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in resolve
  250. for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in _get_url_patterns
  279. patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in _get_urlconf_module
  274. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in 
import_module
  35. __import__(name)
File "/home/phil/mydev/projects/job/blog/urls.py" in 
  15. 
(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/(?P[-\w]+)/$', 
'object_detail', entry_info_dict, 'blog_entry_detail', {'template_name': 
'blog/detail.html'}),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/defaults.py" 
in patterns
  24. t = url(prefix=prefix, *t)

Exception Type: TypeError at /blog/
Exception Value: url() got multiple values for keyword argument 'prefix'


**

my 'urls.py':


from django.conf.urls.defaults import *
from blog.models import Entry

entry_info_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
}

urlpatterns = patterns('django.views.generic.date_based',
(r'^$', 'archive_index', entry_info_dict, 'blog_entry_archive_index', 
{'template_name': 'blog/index.html'}),
(r'^(?P\d{4})/$', 'archive_year', entry_info_dict, 
'blog_entry_archive_year'),
(r'^(?P\d{4})/(?P\w{3})/$', 'archive_month', 
entry_info_dict, 'blog_entry_archive_month'),
(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/$', 'archive_day', 
entry_info_dict, 'blog_entry_archive_day'),

(r'^(?P\d{4})/(?P\w{3})/(?P\d{2})/(?P[-\w]+)/$', 
'object_detail', entry_info_dict, 'blog_entry_detail', {'template_name': 
'blog/detail.html'}),
)



*

end of 'Entry' in models.py:

"""
def get_absolute_url(self):
return ('blog_entry_detail', (), {'year': 
self.pub_date.strftime("%Y"),
'month': 
self.pub_date.strftime("%b").lower(),
'day': self.pub_date.strftime("%d"),
'slug': self.slug})
get_absolute_url = models.permalink(get_absolute_url)

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



Re: Django 1.4 beta 1 released

2012-02-16 Thread victoria
I just wanted to let you know that we have also released a new version
of BitNami DjangoStack 1.4b1 which bundles Django 1.4b1. I hope that
will make easier to test this new version without conflicting with
your current stable environment.

http://bitnami.org/stack/djangostack


On Thu, Feb 16, 2012 at 5:27 AM, James Bennett  wrote:
> Hot off the presses, it's the first Django 1.4 beta! Blog post with
> more information is here:
> https://www.djangoproject.com/weblog/2012/feb/15/14-beta-1/
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: import problem

2012-02-16 Thread Scott Macri
I don't believe I have any circular imports in my code.  I have a
simple file dosomething.py, with a simple class containing a simple
function.
dosomething.py
def somefunction(some_date)

At the tope of dosomething I have:
import datetime

in the somefunction def I have:
start_date = 
datetime.date(int(some_date[0:4]),int(some_date[5:7]),int(some_date[8:10]))

As soon as the code gets to the line containing start_date it fails.

On Thu, Feb 16, 2012 at 11:38 AM, DrBloodmoney  wrote:
> On Thu, Feb 16, 2012 at 9:20 AM, Scott Macri  wrote:
>> DrBloodmoney I not sure what you mean by circular imports.  datetime
>> is the only import I have in this file.
>
> Here are examples of circular import problems [1][2]
>
> I am forever getting bitten by them, so it's become one of the first
> things that I think about when weird things/bugs happen in Python.
>
> [1] http://effbot.org/zone/import-confusion.htm#circular-imports
> [2] 
> http://stackoverflow.com/questions/1556387/circular-import-dependency-in-python
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

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



Re: import problem

2012-02-16 Thread Furbee
He said he would do that later tonight.

Furbee

On Thu, Feb 16, 2012 at 2:04 PM, Dennis Lee Bieber wrote:

> On Thu, 16 Feb 2012 13:41:32 -0500, Scott Macri 
> wrote:
>
> >I don't believe I have any circular imports in my code.  I have a
> >simple file dosomething.py, with a simple class containing a simple
> >function.
>
> You have yet to show (at least, in the history I've seen) the exact
> traceback of the error.
>
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google 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 loading integer data into database using fixture

2012-02-16 Thread Gchorn
Thanks very much for the reply.  I went ahead and created a model
instance using the API, and then tried to get a yaml dump of this.
However, I'm running into another (newb) problem.  The database I'm
using is under a different username (I'm doing all of this in Ubuntu
Linux 11.10), which I understood to be good practice.  However, when I
do a python manage.py shell I have to already be in one user name or
another.  The database username gives me access to the database
through the API, but then I can't create a data dump file because I
don't have file write access under that username.  I can't be under
both usernames at once can I?  Do I just need to give write-access to
the database username as well?  If so how do I do that (I know we're
veering away from Django here, sorry)?

On Feb 17, 1:13 am, Bill Freeman  wrote:
> Well, I don't know yaml, but if you are in a place where you don't
> have to quote:
>
>    Arron
>
> then I'd expect everything to be strings.
>
> Is there a yaml.dump that you can apply to a model with strings and
> integers to see how it thinks they are distinguished?
>
> On 2/16/12, Gchorn  wrote:
>
>
>
>
>
>
>
> > Hello All,
>
> > I'm attempting to provide initial data for my database using a fixture
> > file (like this:
> >https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-i...),
> > but I'm running into the following error:
>
> > Problem installing fixture '/home/guillaume/NBA/players/fixtures/
> > player_data.yaml': Traceback (most recent call last):
> >   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
> > commands/loaddata.py", line 169, in handle
> >     for obj in objects:
> >   File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
> > pyyaml.py", line 54, in Deserializer
> >     for obj in PythonDeserializer(yaml.load(stream), **options):
> >   File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
> > python.py", line 122, in Deserializer
> >     data[field.attname] =
> > field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
> >   File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/
> > __init__.py", line 471, in to_python
> >     raise exceptions.ValidationError(self.error_messages['invalid'])
> > ValidationError: [u'This value must be an integer.']
>
> > Here is a sample from the YAML fixture file I'm attempting to use:
>
> > - model: players.player
> >   pk: 2
> >   fields:
> >     team: DEN
> >     first_name: Arron
> >     last_name: Afflalo
> >     age: 26
> >     pos:  SG
> >     gp: 25
> >     mp: 754
> >     fg: 98
> >     fga: 227
> >     ft: 62
> >     fta: 78
> >     three_pointers: 31
> >     threes_attempted: 81
> >     orb: 15
> >     drb: 51
> >     ast: 39
> >     stl: 15
> >     blk: 6
> >     tov: 33
> >     pf: 55
> >     pts: 289
>
> > Isn't what I have there mostly integers?  I've already checked my
> > models.py file to make sure I didn't accidentally use an
> > "IntegerField" for "team", "first_name", "last_name", or "pos."  Do I
> > need to include some other kind of formatting information in my YAML
> > file to indicate that the numbers are integers?
>
> > thanks,
> > Guillaume
>
> > --
> > You received this message because you are subscribed to the Google 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.

-- 
You received this message because you are subscribed to the Google 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 loading integer data into database using fixture

2012-02-16 Thread Bill Freeman
The database user and *nix user are (typically) unrelated.  The
database user is specified in settings.py and there is also a password
if necessary.  Since one usually communicates with database servers
using network connections (even on the same box), it doesn't really
know what user a connection came from.

Unless you are using sqlite3 as your database, in which case you just
need to copy and change the ownership of the database file (may
require sudo).


On 2/16/12, Gchorn  wrote:
> Thanks very much for the reply.  I went ahead and created a model
> instance using the API, and then tried to get a yaml dump of this.
> However, I'm running into another (newb) problem.  The database I'm
> using is under a different username (I'm doing all of this in Ubuntu
> Linux 11.10), which I understood to be good practice.  However, when I
> do a python manage.py shell I have to already be in one user name or
> another.  The database username gives me access to the database
> through the API, but then I can't create a data dump file because I
> don't have file write access under that username.  I can't be under
> both usernames at once can I?  Do I just need to give write-access to
> the database username as well?  If so how do I do that (I know we're
> veering away from Django here, sorry)?
>
> On Feb 17, 1:13 am, Bill Freeman  wrote:
>> Well, I don't know yaml, but if you are in a place where you don't
>> have to quote:
>>
>>    Arron
>>
>> then I'd expect everything to be strings.
>>
>> Is there a yaml.dump that you can apply to a model with strings and
>> integers to see how it thinks they are distinguished?
>>
>> On 2/16/12, Gchorn  wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Hello All,
>>
>> > I'm attempting to provide initial data for my database using a fixture
>> > file (like this:
>> >https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-i...),
>> > but I'm running into the following error:
>>
>> > Problem installing fixture '/home/guillaume/NBA/players/fixtures/
>> > player_data.yaml': Traceback (most recent call last):
>> >   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
>> > commands/loaddata.py", line 169, in handle
>> >     for obj in objects:
>> >   File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
>> > pyyaml.py", line 54, in Deserializer
>> >     for obj in PythonDeserializer(yaml.load(stream), **options):
>> >   File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
>> > python.py", line 122, in Deserializer
>> >     data[field.attname] =
>> > field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
>> >   File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/
>> > __init__.py", line 471, in to_python
>> >     raise exceptions.ValidationError(self.error_messages['invalid'])
>> > ValidationError: [u'This value must be an integer.']
>>
>> > Here is a sample from the YAML fixture file I'm attempting to use:
>>
>> > - model: players.player
>> >   pk: 2
>> >   fields:
>> >     team: DEN
>> >     first_name: Arron
>> >     last_name: Afflalo
>> >     age: 26
>> >     pos:  SG
>> >     gp: 25
>> >     mp: 754
>> >     fg: 98
>> >     fga: 227
>> >     ft: 62
>> >     fta: 78
>> >     three_pointers: 31
>> >     threes_attempted: 81
>> >     orb: 15
>> >     drb: 51
>> >     ast: 39
>> >     stl: 15
>> >     blk: 6
>> >     tov: 33
>> >     pf: 55
>> >     pts: 289
>>
>> > Isn't what I have there mostly integers?  I've already checked my
>> > models.py file to make sure I didn't accidentally use an
>> > "IntegerField" for "team", "first_name", "last_name", or "pos."  Do I
>> > need to include some other kind of formatting information in my YAML
>> > file to indicate that the numbers are integers?
>>
>> > thanks,
>> > Guillaume
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > 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.
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

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



Re: import problem

2012-02-16 Thread Scott Macri
WEIRD.  There must have been something messed up in my environment.  I
closed IDLE, deleted the dosomething.pyc file and reran the code.  It
seems to be working now.  I didn't make any code changes so maybe
something was in memory, who knows.  I tried deleting the pyc file
before and it didn't do anything.

Do I need to close IDLE every time I modify one of my object classes
being accessed?  I've just been recreating the object in IDLE and not
closing the window.  Any thoughts on this?  Thanks.

On Thu, Feb 16, 2012 at 5:12 PM, Furbee  wrote:
> He said he would do that later tonight.
>
> Furbee
>
>
> On Thu, Feb 16, 2012 at 2:04 PM, Dennis Lee Bieber 
> wrote:
>>
>> On Thu, 16 Feb 2012 13:41:32 -0500, Scott Macri 
>> wrote:
>>
>> >I don't believe I have any circular imports in my code.  I have a
>> >simple file dosomething.py, with a simple class containing a simple
>> >function.
>>
>>        You have yet to show (at least, in the history I've seen) the exact
>> traceback of the error.
>>
>> --
>>        Wulfraed                 Dennis Lee Bieber         AF6VN
>>        wlfr...@ix.netcom.com    HTTP://wlfraed.home.netcom.com/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google 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.



-- 
Scott A. Macri
www.ScottMacri.com
(571) 234-1581

-- 
You received this message because you are subscribed to the Google 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.



serving files on shared server cause extra proccesses

2012-02-16 Thread Itai
Hi all!

I have a big problem, and after reading tons of web pages I'm still
stuck.


IN SHORT:
I'm on a shared server hosting with fastCGI (=no apache access) with
no mod_xsendfile. I need to serve mp3 files of 2-3 minutes length
after authentication. That view generates extra proccesses that never
die, and maybe it timesout and creates new proccesses (???).


THE DETAILS:

My django app is on a share server, so I'm forced to use fastCGI. I
don't have access to apache settings.
Lately I've been having lots of proccesses named "/usr/bin/python
index.fcgi" that suddenly appeared and just stayed there forever.

After a lot of headache, I figured out their source was an HTML page
with JPlayer plugin (a JQuery plugin to play music - http://jplayer.org).
As the HTML page loads, Jplayer loads and calls my server with the URL
of the music file to play.
This request goes to this django view (needed for authentication of
request):

def serveMusicFile(request,filename):
my_auth_check(request)
from django.conf import settings
file = open('/my/private/file/location/'+filename)
response = HttpResponse(file.read(), mimetype="audio/mpeg")
response['Accept-Ranges'] = 'bytes'
response['Content-Length'] = os.path.getsize('/my/private/file/
location/'+filename)
response['Content-Disposition'] = 'filename='+filename
return response


So,
Why does the fastCGI create new threads for these music file
requests?
Why don't they die eventualy?
**What can I do??**

Thanks guys!

-- 
You received this message because you are subscribed to the Google 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: Creating a hospital erp (hospital management) in Django

2012-02-16 Thread Alec Taylor
ModelForm

On Thu, Feb 16, 2012 at 10:18 PM, Saadat  wrote:
> Hi all, I created a view today and I could access the database
> contents using Templates. Now I wish to create a listbox that would
> have the names of doctors. When an item from the list is selected, an
> sql query should be sent which will return all the details of that
> doctor, where doc_id is the primary key? how do we create buttons? do
> we need to use html or django can handle them also?
>
> Thanks a lot people.
> Saadat
>
> On Feb 16, 4:12 pm, Saadat  wrote:
>> Hello All
>> I created a view today and I could access the database values usi
>>
>> On Feb 14, 8:07 am, Python_Junkie 
>> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Now that you have your file >>models.py   place this file in the
>> > app folder after creating your app
>>
>> > 1.  python manage.py start app  My_Erp (for example)
>> > 2.  a blank models.py file will be created, overwrite this with your
>> > models.py
>> > 3. run the command to sync the database, assuming that your set up the
>> > settings.py file has been set up correctly to connect to the database
>> > of your choice.
>>
>> > python manage.py syncdb
>>
>> > Let me know if this works for you
>>
>> > On Feb 13, 3:56 pm,Saadat wrote:
>>
>> > > Thank you Python_junkie
>> > > I've created the poll app and I'm working on this Hospital ERP thing.
>> > > I've also created the database schema and put some dummy values for
>> > > testing. Then I created the models using 'inspected' command and saved
>> > > the models in models.py file. Now I'm confused where to put the
>> > > models.py file and what to with it. Guide me please.
>>
>> > > Thanks a lot.
>> > >Saadat
>>
>> > > On Feb 10, 6:18 pm, Python_Junkie 
>> > > wrote:
>>
>> > > > Not sure from your post, which piece you are stuck on.
>>
>> > > > 1. Have you used Django before?
>> > > > If not start with the tutorial
>>
>> > > >https://www.djangoproject.com/
>>
>> > > > 2. If you have a basic understanding of Django, have you been able to
>> > > > set up a basic project /app and connect run syncdb.
>> > > > One can always connect to the sqllite database, because it is built
>> > > > in, but getting some other database to connect can be a time consuming
>> > > > process if the procedure has not been established on your machine.
>>
>> > > > 3. If you have done the above 2 items then you should move in a
>> > > > parallel path.
>>
>> > > > a. Start defining your database model to support the business and the
>> > > > workflow that you intend to create.
>> > > > b. Use some sort of wire frame (framework) to lay out your web pages
>> > > > to support and interact step 3 a.
>>
>> > > > On Feb 10, 8:06 am, adesantoas...@gmail.com wrote:
>>
>> > > > > Hello, nice thread.
>>
>> > > > > **tagged to keep following..
>>
>> > > > > +adesst
>>
>> > > > > -Original Message-
>> > > > > From:Saadat
>>
>> > > > > Sender: django-users@googlegroups.com
>> > > > > Date: Fri, 10 Feb 2012 02:58:16
>> > > > > To: Django users
>> > > > > Reply-To: django-users@googlegroups.com
>> > > > > Subject: Creating a hospital erp (hospital management) in Django
>>
>> > > > > Hello All,
>> > > > > I'm in my final year of computer science engineering and for my final
>> > > > > year project, i'm creating a hospital erp. I'm a bit confused about
>> > > > > where to start from. Any sort of help will be appreciated. Thanks a
>> > > > > lot.
>>
>> > > > > Cheers
>> > > > >Saadat
>>
>> > > > > --
>> > > > > You received this message because you are subscribed to the Google 
>> > > > > 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 
>> > > > > athttp://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-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.
>

-- 
You received this message because you are subscribed to the Google 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.



Access denied - hostname is percent character ('%')?

2012-02-16 Thread Ishmael
I'm trying to follow the intro tutorial.
I am able to log in to my database from the command line (and via
MySQL Workbench) sans problem:
However, after changing my settings file to the correct values, I get:

_mysql_exceptions.OperationalError: (1044, "Access denied for user
'myuser'@'%' to database 'Mydatabase'")

My settings file contains:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'Mydatabase',  # Or path to
database file if using sqlite3.
'USER': 'myuser',  # Not used with
sqlite3.
'PASSWORD': 'mypassword',  # Not used with
sqlite3.
'HOST': 'my.url.com',  # Set to empty
string for localhost. Not used with sqlite3.
'PORT': '3306',  # Set to empty string for
default. Not used with sqlite3.
}
}

How do I get rid of the '%' percent symbol for the local hostname?

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: CSS reference to Media folder

2012-02-16 Thread Kolbe
Thanks guys for the valuable recommendations.

I tried this one before > background-image: url(/media/images/base/
gradient2.png)

Didn't work then, will give it a try later.

*am loving django.

Cheers!
Max

On Feb 16, 5:54 pm, MikeKJ  wrote:
> background-image: url(/media/images/base/gradient2.png)
>
> eg
>
> On Feb 15, 12:37 pm, Kolbe  wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I have a .css file in the /static/ folder where I keep all my styles.
>
> > Now when I want to refer to images that I use in my CSS that are
> > stored in the /media/ folder, how do I reference that?
>
> > e.g. background-image:url('gradient2.png');
>
> > gradient2.png is stored in ~/media/ and my css is in ~/static/
>
> > Is there a way to define the path to gradient2.png?
>
> > Cheers!
> > Max

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



"DatabaseError: can't adapt type 'NavigableString'" when using psycopg2 and Django 1.3

2012-02-16 Thread Matt Cotterell
Hi guys! New poster here and django newbie, though I'm starting to get
a handle on it now.

One issue though which is preventing release of my project is a truely
bizarre bug pertaining *purely* to postgres. I'm running Django
(1.3.1) with psycopg2 (2.2.1) and despite everything working on the
development 'runserver' server using SQLite, at some point during this
project the 'production' server running on mod_python no longer works.

The fault specifically pertains to a custom authentication module
which gets XML data over an HTTP call with pycurl. When logged in as a
regular 'ModelBackend' user, everything works fine. However when
trying to create a new User object as such:

...
except User.DoesNotExist:
# Create a new user. Note that setting the password really doesn't
mean anything.
user = User(
username=username,
email=username,
password='',
first_name=user_firstname,
last_name=user_lastname
)
user.save()
...

...I get the following Exception when calling save():

Exception Type: DatabaseError
Exception Value: can't adapt type 'NavigableString'
(traceback: http://dpaste.com/704253/)

The local variables at the time of exception are:

username:   u'matt...@example.com'
c: 
password: u'x'
user_firstname: u'Matthew'
user_lastname: u'Cotterell'
self: 
storage: 
user: 
url_string: 'https://auth.example.com:8181/ExternalAuthentication/
Login?username=matt...@example.com&password=x'

And seem to have been caused by psycopg2 here:

/usr/local/lib/python2.6/dist-packages/django/db/backends/
postgresql_psycopg2/base.py in execute

"""
def __init__(self, cursor):
self.cursor = cursor
def execute(self, query, args=None):
try:
   return self.cursor.execute(query, args) ...
except Database.IntegrityError, e:
raise utils.IntegrityError,
utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
except Database.DatabaseError, e:
raise utils.DatabaseError, utils.DatabaseError(*tuple(e)),
sys.exc_info()[2]
def executemany(self, query, args):

query: 'INSERT INTO "auth_user" ("username", "first_name",
"last_name", "email", "password", "is_staff", "is_active",
"is_superuser", "last_login", "date_joined") VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s, %s)'
self: 
args: (u'matt...@example.com',
 u'Matthew',
 u'Cotterell',
 u'matt...@example.com',
 u' ',
 False,
 True,
 False,
 u'2012-02-17 15:34:59.735209',
 u'2012-02-17 15:34:59.735222')
e: ProgrammingError("can't adapt type 'NavigableString'",)

So I know everything on my end is at least getting filled in properly.
Oddly enough, if I comment out the first_name and last_name lines, it
goes through (and causes a similar exception a few lines ahead on a
similar 'object creation' section of code. So maybe it's somethign to
do with those two lines?

It's just bizzare, I'm creating objects for other areas of the
projects perfectly fine, it's just here that it's being stubborn.
Googling the issue only highlights the fact it's likely a psycopg2
issue, but not much else.

Thanks so much to anyone who can help me here, I'm completely stumped
as to why such a simple operation can go so wrong...

Matt

-- 
You received this message because you are subscribed to the Google 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: "DatabaseError: can't adapt type 'NavigableString'" when using psycopg2 and Django 1.3

2012-02-16 Thread kenneth gonsalves
On Thu, 2012-02-16 at 20:08 -0800, Matt Cotterell wrote:
> project the 'production' server running on mod_python no longer works.

mod_python is deprecated - use mod_wsgi
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google 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 loading integer data into database using fixture

2012-02-16 Thread Gchorn
Unfortunately, that doesn't seem to be the case.  I have the database
user and password in my settings.py file, but I still have to do a
"sudo su postgres" to switch to postgres in the terminal before I can
access my PostgreSQL database through the Django database API.
Otherwise when I try to access it through my normal username
"guillaume", I get:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
query.py", line 69, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
query.py", line 84, in __len__
self._result_cache.extend(self._iter)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/
query.py", line 273, in iterator
for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/
compiler.py", line 734, in execute_sql
cursor = self.connection.cursor()
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/
__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/
postgresql_psycopg2/base.py", line 140, in _cursor
self.connection = Database.connect(**conn_params)
OperationalError: FATAL:  Peer authentication failed for user
"postgres"

However, I found a way around the "out" file issue I mentioned
earlier; I did a search for my yaml file and changed the write
permission on it to all users, so I was then able to access it while
in the API under the postgres username.  After I did so and attempted
to write serialized data to it, I got the following error:

>>> yaml_serializer.serialize(Player.objects.all(),stream=out)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
base.py", line 55, in serialize
return self.getvalue()
  File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/
pyyaml.py", line 44, in getvalue
return self.stream.getvalue()
AttributeError: 'file' object has no attribute 'getvalue'

It does seem to have written to the yaml output file.  In that, I got:

- fields: {age: 25, ast: 1, blk: 2, drb: 17, fg: 7, fga: 16,
first_name: Jeff, ft: 7,
fta: 12, gp: 8, last_name: Adrien, mp: 63, orb: 5, pf: 13, pos:
SF, pts: 21, stl: 0,
team: 1, three_pointers: 0, threes_attempted: 0, tov: 2}
  model: players.player
  pk: 1

But now I'm wondering what the error the API kicked was about...anyone
know?

thanks,
Guillaume



On Feb 17, 7:50 am, Bill Freeman  wrote:
> The database user and *nix user are (typically) unrelated.  The
> database user is specified in settings.py and there is also a password
> if necessary.  Since one usually communicates with database servers
> using network connections (even on the same box), it doesn't really
> know what user a connection came from.
>
> Unless you are using sqlite3 as your database, in which case you just
> need to copy and change the ownership of the database file (may
> require sudo).
>
> On 2/16/12, Gchorn  wrote:
>
>
>
>
>
>
>
> > Thanks very much for the reply.  I went ahead and created a model
> > instance using the API, and then tried to get a yaml dump of this.
> > However, I'm running into another (newb) problem.  The database I'm
> > using is under a different username (I'm doing all of this in Ubuntu
> > Linux 11.10), which I understood to be good practice.  However, when I
> > do a python manage.py shell I have to already be in one user name or
> > another.  The database username gives me access to the database
> > through the API, but then I can't create a data dump file because I
> > don't have file write access under that username.  I can't be under
> > both usernames at once can I?  Do I just need to give write-access to
> > the database username as well?  If so how do I do that (I know we're
> > veering away from Django here, sorry)?
>
> > On Feb 17, 1:13 am, Bill Freeman  wrote:
> >> Well, I don't know yaml, but if you are in a place where you don't
> >> have to quote:
>
> >>    Arron
>
> >> then I'd expect everything to be strings.
>
> >> Is there a yaml.dump that you can apply to a model with strings and
> >> integers to see how it thinks they are distinguished?
>
> >> On 2/16/12, Gchorn  wrote:
>
> >> > Hello All,
>
> >> > I'm attempting to provide initial data for my database using a fixture
> >> > file (like this:
> >> >https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-i...),
> >> > but I'm running into the following error:
>
> >> > Problem installing fixture '/home/guillaume/NBA/players/fixtures/
> >> > player_data.yaml': Traceback (most recent call last):
> >> >   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
> >> > commands/loadda