Re: SQL Server Support - Does it Exist

2011-07-14 Thread Wei guangjing
2011/7/15 Python_Junkie :
> I have tried django-mssql without any luck.
>
> Could you send me the link for django-pyodbc.

Please use svn checkout the source code, and do setup.py install.

svn checkout http://django-pyodbc.googlecode.com/svn/trunk/ django-pyodbc

--
Wei guangjing

-- 
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.



getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-14 Thread Derick Felsman
Hi,

I'm brand new to django and have been having trouble setting it up
with apache and mod_wsgi on my new mac with xcode 4 installed.  All
the resources i've been able to find are either outdated or don't work
with an xcode 4 installation.  Does anyone know how to do this or know
where i would be able to get training to do this?  Thanks.

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



Re: SQL Server Support - Does it Exist

2011-07-14 Thread Python_Junkie
I have tried django-mssql without any luck.

Could you send me the link for django-pyodbc.

I was only able to find 2 downloads that say they have been
deprecated.

By the way I have been using the (sql) pyodbc for my native (MySQL)
sql connections to retrieve data.  I would rather use sql rather than
the ORM.

So, presently the syncdb is a nice to have which allows me to utilize
the admin functionality as well as the built in Forms.py
functionality.  Otherwise I could use sql server to make my calls to
the database to populate web pages and or insert or update.

Any other calls to the database I can accomplish to sql server through
pyodbc and sql.



On Jul 14, 8:42 pm, David Graves  wrote:
> https://docs.djangoproject.com/en/1.3/ref/databases/#using-a-3rd-part...
> django-mssql
>
> http://stackoverflow.com/questions/842831/using-sql-server-with-djang...
>
> I personally have used django-pyodbc in conjunction with pyodbc.
>
> On Thu, Jul 14, 2011 at 5:03 PM, bruno desthuilliers <
>
>
>
>
>
>
>
> bruno.desthuilli...@gmail.com> wrote:
>
> > On 14 juil, 23:15, Python_Junkie 
> > wrote:
> > > I have searched for the drivers to use the syncdb utility with MS SQL
> > > Server but have been unsuccessful.
>
> >https://docs.djangoproject.com/en/1.3/ref/databases/
>
> > Django doesn't support MS SQL.
>
> > --
> > 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: SQL Server Support - Does it Exist

2011-07-14 Thread Python_Junkie
I have installed django-mssql and still seem to be stuck.

What are the correct attributes that need to be set in the settings.py
file?

I am getting an error

This is how I have configured my settings.py file

DATABASE

S = {
'default': {
'NAME': 'notes',
'ENGINE': 'django.db.backends.sqlserver_ado',
'HOST': ' ',  #blank for local host
'USER': '',#blank for active directory authentication
'PASSWORD': '',
'OPTIONS' : {
'provider': 'SQLOLEDB',
'use_mars': True,
},
}
}



I am getting the following error when I attempt to syncdb

*
django.core.exceptions.ImproperlyConfigured: 'sqlserver_ado' isn't an
available
database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2',
'sqlite3'
Error was: No module named sqlserver_ado.base
***
I have MYSQL up and running, just trying to use a different database


Thanks for any assistance that you can provide


On Jul 14, 9:07 pm, Russell Keith-Magee 
wrote:
> On Fri, Jul 15, 2011 at 6:03 AM, bruno desthuilliers
>
>  wrote:
>
> > On 14 juil, 23:15, Python_Junkie 
> > wrote:
> >> I have searched for the drivers to use the syncdb utility with MS SQL
> >> Server but have been unsuccessful.
>
> >https://docs.djangoproject.com/en/1.3/ref/databases/
>
> > Django doesn't support MS SQL.
>
> Django doesn't provide *official* support MSSQL. However, we do have a
> supported backend API, and there are several third-party projects that
> implement MS SQL support [1]. I can't comment on their completeness or
> stability, but the projects exist.
>
> [1]https://docs.djangoproject.com/en/1.3/ref/databases/#using-a-3rd-part...
>
> Yours,
> Russ Magee %-)

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



Re: something about django mysql database long connection

2011-07-14 Thread Kejun He
Hi,
I will look the DBUtils imformation first.

Thank you very much

regards,
he

On Thu, Jul 14, 2011 at 11:58 AM, Jian Chang  wrote:

> Try DBUtils
> http://www.webwareforpython.org/DBUtils/Docs/UsersGuide.html
>
> 2011/7/13 Kejun He 
>
>> hi,
>> I am sorry. My English is very bad.
>>
>> Yes, i want to make persistent databases connection on each session.
>>
>>
>> and yesterday i try to modify the  code on
>> "site-packages\django\db\__init__.py"
>>
>> 
>> def close_connection(**kwargs):
>> for conn in connections.all():
>> conn.close()
>> #signals.request_finished.connect(close_connection) <---
>>
>> 
>>
>> could it work?
>>
>> regards,
>> he
>>
>>
>>
>>
>> On Mon, Jul 11, 2011 at 7:31 PM, Cal Leeming [Simplicity Media Ltd] <
>> cal.leem...@simplicitymedialtd.co.uk> wrote:
>>
>>>
>>>
>>> On Mon, Jul 11, 2011 at 4:49 AM, oops  wrote:
>>>
 hi,
 Now, i am doing a django project, and use models to do all operation
 about data in mysql db.

 and i think that it would connect to database whenever  do some
 operation like 'XXX.objects.all()' , may be it would cast much of
 resource on database connection. So i need a connection never being
 desconnected.

>>>
>>> At as best guess (as the question is somewhat broken), are you asking how
>>> to make persistent connections which are guaranteed to never time out in a
>>> single session?
>>>
>>> Could you clarify a little more on your question please?
>>>
>>> Cal
>>>
>>>

 Does django has this function?  And how to do for it??

 thank you
 rgs,
 he

 --
 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.
>>
>
>  --
> 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: SQL Server Support - Does it Exist

2011-07-14 Thread Russell Keith-Magee
On Fri, Jul 15, 2011 at 6:03 AM, bruno desthuilliers
 wrote:
>
>
> On 14 juil, 23:15, Python_Junkie 
> wrote:
>> I have searched for the drivers to use the syncdb utility with MS SQL
>> Server but have been unsuccessful.
>
> https://docs.djangoproject.com/en/1.3/ref/databases/
>
> Django doesn't support MS SQL.

Django doesn't provide *official* support MSSQL. However, we do have a
supported backend API, and there are several third-party projects that
implement MS SQL support [1]. I can't comment on their completeness or
stability, but the projects exist.

[1] 
https://docs.djangoproject.com/en/1.3/ref/databases/#using-a-3rd-party-database-backend

Yours,
Russ Magee %-)

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



[solved] virtualenv with dev server

2011-07-14 Thread Mike Dewhirst
Thank you - all four of you were on the money. Taking your advice this 
is what I did to fix it ...


C:\users\miked\py\ssds <-- root
C:\users\miked\py\ssds\Lib <-- virtualenv python installation
C:\users\miked\py\ssds\Scripts <-- virtualenv python scripts
C:\users\miked\py\ssds\src <-- project source root - contains settings.py

Created a shortcut called runserver with the following command line ...

C:\users\miked\py\ssds\Scripts\python.exe 
C:\users\miked\py\src\manage.py runserver --settings=.src.settings


... and Start in = C:\users\miked\py\ssds\src

Without needing to activate, this loads the correct python and the 
correct django. I haven't actually written any code or organised 
directories yet so it errors and exits but I can see which django is 
barfing and I'm happy.


Thanks again

Mike


On 14/07/2011 5:54pm, Mike Dewhirst wrote:
Trying to get virtualenv working for the first time for a new project 
and have stumbled somehow. I can get it working as advertised (see 
below) but django dev server doesn't notice.


Any hints appreciated ...

||| here is virtualenv being activated

C:\users\miked\py\ssds>Scripts\activate
(ssds) C:\users\miked\py\ssds>python
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit 
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.3'
>>> quit()

||| correctly showing django version 1.3 installed in virtualenv ssds
||| so now I want to start the dev server

(ssds) C:\users\miked\py\ssds>Scripts\django-admin.py runserver 
--settings=src.settings

Validating models...

0 errors found
Django version 1.4 pre-alpha SVN-16452, using settings 'src.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

||| it has used my global site-packages django 1.4 from trunk
||| just in case, here is my ssds\Scripts\django-admin.py

#!C:\users\miked\py\ssds\Scripts\python.exe
from django.core import management

if __name__ == "__main__":
management.execute_from_command_line()


Thanks

Mike



--
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: SQL Server Support - Does it Exist

2011-07-14 Thread David Graves
https://docs.djangoproject.com/en/1.3/ref/databases/#using-a-3rd-party-database-backendmentions
django-mssql

http://stackoverflow.com/questions/842831/using-sql-server-with-django-in-production

I personally have used django-pyodbc in conjunction with pyodbc.

On Thu, Jul 14, 2011 at 5:03 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
> On 14 juil, 23:15, Python_Junkie 
> wrote:
> > I have searched for the drivers to use the syncdb utility with MS SQL
> > Server but have been unsuccessful.
>
> https://docs.djangoproject.com/en/1.3/ref/databases/
>
> Django doesn't support MS SQL.
>
> --
> 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: SQL Server Support - Does it Exist

2011-07-14 Thread bruno desthuilliers


On 14 juil, 23:15, Python_Junkie 
wrote:
> I have searched for the drivers to use the syncdb utility with MS SQL
> Server but have been unsuccessful.

https://docs.djangoproject.com/en/1.3/ref/databases/

Django doesn't support MS SQL.

-- 
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.



SQL Server Support - Does it Exist

2011-07-14 Thread Python_Junkie
I have searched for the drivers to use the syncdb utility with MS SQL
Server but have been unsuccessful.

Has anyone implemented SQL server.

If you have could you point me to the links for driver downloads and
the settings.py parameters.

Thanks

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



Re: virtualenv with dev server

2011-07-14 Thread i...@webbricks.co.uk
theres two different versions of django listed there, you're not
running the version in the virtualenv in one of those two listings.
definitely activating the virtual env? then navigating into it to the
folder manage.py is in?

Matt


On Jul 14, 8:54 am, Mike Dewhirst  wrote:
> Trying to get virtualenv working for the first time for a new project
> and have stumbled somehow. I can get it working as advertised (see
> below) but django dev server doesn't notice.
>
> Any hints appreciated ...
>
> ||| here is virtualenv being activated
>
> C:\users\miked\py\ssds>Scripts\activate
> (ssds) C:\users\miked\py\ssds>python
> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import django
>  >>> django.get_version()
> '1.3'
>  >>> quit()
>
> ||| correctly showing django version 1.3 installed in virtualenv ssds
> ||| so now I want to start the dev server
>
> (ssds) C:\users\miked\py\ssds>Scripts\django-admin.py runserver
> --settings=src.settings
> Validating models...
>
> 0 errors found
> Django version 1.4 pre-alpha SVN-16452, using settings 'src.settings'
> Development server is running athttp://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
>
> ||| it has used my global site-packages django 1.4 from trunk
> ||| just in case, here is my ssds\Scripts\django-admin.py
>
> #!C:\users\miked\py\ssds\Scripts\python.exe
> from django.core import management
>
> if __name__ == "__main__":
>      management.execute_from_command_line()
>
> Thanks
>
> Mike

-- 
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: virtualenv with dev server

2011-07-14 Thread Carles Barrobés
Try running
> python Scripts\django-admin.py runserver

On windows, the .py extension will be registered with your defaut
installation of python and that's the one it's using if you call the
script directly

Carles



On 14 Jul, 09:54, Mike Dewhirst  wrote:
> Trying to get virtualenv working for the first time for a new project
> and have stumbled somehow. I can get it working as advertised (see
> below) but django dev server doesn't notice.
>
> Any hints appreciated ...
>
> ||| here is virtualenv being activated
>
> C:\users\miked\py\ssds>Scripts\activate
> (ssds) C:\users\miked\py\ssds>python
> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import django
>  >>> django.get_version()
> '1.3'
>  >>> quit()
>
> ||| correctly showing django version 1.3 installed in virtualenv ssds
> ||| so now I want to start the dev server
>
> (ssds) C:\users\miked\py\ssds>Scripts\django-admin.py runserver
> --settings=src.settings
> Validating models...
>
> 0 errors found
> Django version 1.4 pre-alpha SVN-16452, using settings 'src.settings'
> Development server is running athttp://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
>
> ||| it has used my global site-packages django 1.4 from trunk
> ||| just in case, here is my ssds\Scripts\django-admin.py
>
> #!C:\users\miked\py\ssds\Scripts\python.exe
> from django.core import management
>
> if __name__ == "__main__":
>      management.execute_from_command_line()
>
> Thanks
>
> Mike

-- 
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 form radio input layout

2011-07-14 Thread Bill Freeman
Unless things have changed, the trouble is that the individual bound fields
aren't all in existence at the same time, but are created and discarded
one at a time as the outer widget iterates the choices.  I once uploaded
a snippet for a template tag that performed the iteration, allowing finer
styling control.  I've forgotten the details, or the pointer to my snippet,
but such a tag could let you iterate template code for each button, rendering
what you want, having recognized, say, the value of the button field that
you want to render differently in a template ifequal, or equivalent.  Of course
you are also then stuck with self rendering the whole Form, unless you put
everything else in one Form, and this in another, but all within the same
"form" tag so that they are submitted together.  Your view needs to be aware
of the two forms.  But at this point you could just separately render the list
of choices by hand, leaving the Choice field out of the Form's fields list.  I
always put my choices lists as Model attributes, so I can make them easily
accessible in the template, though a suitable iterator method on the Model
makes the template code cleaner.

I'm liking the last approach best in that things like my template tag had to
dip into Field internals, so it is fragile across Django versions,
while rendering
the special radio collection by hand fits the "explicit is better than implicit
(magic)" mantra, and doesn't use anything that is likely to change out from
under you.  (Though adding a suitable iterator method on Choice/MultiChoice
Fields to the API would not be unwelcome.)

Bill

On Thu, Jul 14, 2011 at 3:10 PM, NateB  wrote:
>
>
> CrabbyPete wrote:
>>
>> I am trying to do the same thing. Did you ever get a response?
>>
>
> I accepted an answer to the one on the stack overflow question I linked to
> in my previous email - however, it wasn't what I was *really* hoping for
> (although it definitely works).  Before asking, I spent a long time
> searching through the Django code, and I couldn't come up with a clean
> solution (but figured that it was simply my ignorance, because I considered
> that a weird oversight).  I get the impression now that there *is* no easy,
> pretty way of doing it, just a circuitous, not-so-pretty way of doing it.
> --
> View this message in context: 
> http://old.nabble.com/django-form-radio-input-layout-tp31862033p32063704.html
> Sent from the django-users mailing list archive at Nabble.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> 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: django form radio input layout

2011-07-14 Thread NateB


CrabbyPete wrote:
> 
> I am trying to do the same thing. Did you ever get a response?
> 

I accepted an answer to the one on the stack overflow question I linked to
in my previous email - however, it wasn't what I was *really* hoping for
(although it definitely works).  Before asking, I spent a long time
searching through the Django code, and I couldn't come up with a clean
solution (but figured that it was simply my ignorance, because I considered
that a weird oversight).  I get the impression now that there *is* no easy,
pretty way of doing it, just a circuitous, not-so-pretty way of doing it.
-- 
View this message in context: 
http://old.nabble.com/django-form-radio-input-layout-tp31862033p32063704.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: Raise CommandError: One or more models did not validate

2011-07-14 Thread Petey
I am just starting to do adminmodel and now I've noticed that it can be done 
by this function and not models :)
I'll work a bit more on that tomorrow :)

Thanks for help I really appreciate it.

-- 
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/-/jKY3XLCFIZoJ.
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
On Thursday, July 14, 2011 2:32:26 PM UTC-4, Petey wrote:
>
> Is there a way around?
>

This isn't really something that can/should be solved in the model itself.

You could try overwriting the formfield_for_foreignkey method in your 
ModelAdmin:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
 

-- 
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/-/HuevwqFZAnAJ.
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
You should still probably remove the user_logged_in from your default value. 
It doesn't do what you think it does, and could cause other strange things 
to happen.

-- 
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/-/lrYJBQ-5MvEJ.
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 form radio input layout

2011-07-14 Thread CrabbyPete
I am trying to do the same thing. Did you ever get a response?

On Jun 16, 11:55 am, NateB  wrote:
> Hello all,
>
> I posted this to stackoverflow a couple weeks ago, but I have yet to get any
> takers.  I was able to backburner this for a little bit, but I'd like to see
> it wrapped up.
>
> In my form class, I have a forms.ChoiceField whose widget is a
> forms.RadioSelect widget, one of whose choices needs to be presented with an
> inline text input (which is also a field in the form). I'm using custom
> validation to ignore the text field when itsradiochoice is not selected.
> When rendered, I want it to appear like below:
>
> 
>  name="rad" /> No Textbox
>  name="rad" /> One Textbox:  />
> 
>
> However, I can't simply produce this in my template, because theradio
> choices are not exposed. I can't see a way to do this without tightly
> coupling my form to my template, or alternately, putting all of the
> presentation logic in the form class. What is the right way to solve this
> problem?
>
> I'm a much better backend programmer than web designer, and I'm on this
> project alone, so maybe it's a lack of education - is what I described
> simply poor design? Should I just be designing this a different way? I'm
> really open to any suggestion here that will help me move past this.
>
> If you're a stackoverflow user, and you'd like 15 rep for 
> answering,http://stackoverflow.com/questions/6218299/django-form-radio-input-la...
> the question is here
> --
> View this message in 
> context:http://old.nabble.com/django-form-radio-input-layout-tp31862033p31862...
> Sent from the django-users mailing list archive at Nabble.com.

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



Re: Raise CommandError: One or more models did not validate

2011-07-14 Thread Petey
Sorry for multiple messages but I think that I've accidently fixed it:

from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in
import datetime

class News(models.Model):
text = models.TextField()
title = models.TextField()
date = models.DateTimeField(editable=False, 
default=datetime.datetime.now())
source_name = models.CharField(max_length=50)
created = models.ForeignKey(User, default=user_logged_in, 
related_name="news_created_set")
edited = models.ForeignKey(User, default=user_logged_in, 
related_name="news_edited_set")

  
class Meta:
verbose_name_plural = "News"
abstract = False


-- 
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/-/EYKGyLPnOmkJ.
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.



Check out my about.me profile!

2011-07-14 Thread gungorbasa
Hi django-users,

I set up my about.me splash page and want to share it with you: 
.

If you don't have an about.me splash page, you can get one for free at 
. Names are going fast so you might 
want to get yours now.

GüngörIf you would like to unsubscribe and stop receiving these emails click 
here: 
http://email.about.me/wf/unsubscribe?rp=PbcyGUPGr7r6vpKs8pDP0NgfxUMORjDXqpK3Y9Q1Ae98LIdWRX0wc%2F85rTvrsXapBEjfRybhwPwD%2BmF9meFmzA%3D%3D=vwDlxcCETXqKlH1EwbZQuA%2Fut

-- 
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.



Check out my about.me profile!

2011-07-14 Thread gungorbasa
Hi django-users,

I set up my about.me splash page and want to share it with you: 
.

If you don't have an about.me splash page, you can get one for free at 
. Names are going fast so you might 
want to get yours now.

GüngörIf you would like to unsubscribe and stop receiving these emails click 
here: 
http://email.about.me/wf/unsubscribe?rp=PbcyGUPGr7r6vpKs8pDP0NgfxUMORjDXqpK3Y9Q1Ae98LIdWRX0wc%2F85rTvrsXapBEjfRybhwPwD%2BmF9meFmzA%3D%3D=bSDyGtsDSK-LaWIWyzF9DQ%2Fut

-- 
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.



Check out my about.me profile!

2011-07-14 Thread gungorbasa
Hi django-users,

I set up my about.me splash page and want to share it with you: 
.

If you don't have an about.me splash page, you can get one for free at 
. Names are going fast so you might 
want to get yours now.

GüngörIf you would like to unsubscribe and stop receiving these emails click 
here: 
http://email.about.me/wf/unsubscribe?rp=PbcyGUPGr7r6vpKs8pDP0NgfxUMORjDXqpK3Y9Q1Ae98LIdWRX0wc%2F85rTvrsXapBEjfRybhwPwD%2BmF9meFmzA%3D%3D=JjhJPdyKTmatPbgdUmJ8Lw%2Fut

-- 
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Petey
Is there a way around?

-- 
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/-/ZcWJm3heIOgJ.
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Petey
The target of this is to automatically fill fields without users having to 
chose "user".

-- 
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/-/nDHuq-HmLNcJ.
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
I just noticed that you had the default value set to the "user_logged_in" 
signal method. That's not going to work at all. You probably want to remove 
that from the field definition.

-- 
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/-/Ti1WjbvA_IUJ.
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Petey
I got an error even after removing my modifications to the source:
*ValueError at /admin/news/news/add/* 

*invalid literal for int() with base 10: ''

*

-- 
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/-/zUKAViUvGpoJ.
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: 'RawQuerySet' object has no attribute 'get'

2011-07-14 Thread zdenulo
Thanks a lot for advice, it works.
Regards,
Zdenko



On 14 čnc, 12:40, Tom Evans  wrote:
> On Thu, Jul 14, 2011 at 10:56 AM, zdenulo  wrote:
> > Greetings to everybody,
> > I have a problem for which I didn't find solution on internet,
> > therefore  I am posting context:
>
> > simplified models.py for application testapp (django 1.3):
>
> > class Menu(models.Model):
> >    parent_menu = models.ForeignKey('Menu', blank=True, null=True)
>
> ForeignKeys to themselves should use 'self' as the target model, eg:
>
> parent_menu = models.ForeignKey('self', blank=True, null=True)
>
>
>
>
>
>
>
>
>
> >    title = models.CharField(max_length=30)
> >    def __unicode__(self):
> >        return self.title
>
> > class Page(models.Model):
> >    menu = models.ForeignKey('Menu', blank = True, null=True)
>
> > file admin.py
>
> > from testapp.models import Page, Menu
> > from django.contrib import admin
>
> > class PageAdmin(admin.ModelAdmin):
> >    def formfield_for_foreignkey(self, db_field, request, **kwargs):
> >        if db_field.name == "menu":
> >            kwargs["queryset"] = Menu.objects.raw('select * from
> > testapp_menu where not id in (select distinct parent_menu_id from
> > testapp_menu where parent_menu_id is not null)')
> >            kwargs["queryset"].all = kwargs["queryset"].__iter__
> >        return super(PageAdmin,
> > self).formfield_for_foreignkey(db_field, request, **kwargs)
>
> That just made me weep.
>
>
>
>
>
>
>
>
>
>
>
> > class MenuAdmin(admin.ModelAdmin):
> >    pass
>
> > admin.site.register(Menu, MenuAdmin)
> > admin.site.register(Page, PageAdmin)
>
> > some explanation:
> > When I am creating Page, I want to have in a list all Menu instances
> > which either don't have parent menu or don't have "child
> > menu" (inverse relationship as defined in model). Now I didn't find
> > any suitable query using Django syntax, that's why I used raw query.
> > It filters Menu objects as I expect, but when I want to save Page
> > instance, I get following error 'RawQuerySet' object has no attribute
> > 'get'
>
> > problem is in method \django\forms\models.py to_python
> >  972.             value = self.queryset.get(**{key: value})
>
> > I don't know how to bypass this error and I didn't find anywhere
> > discussion about this case, so every help and advice is much
> > appreciated.
>
> Don't do crazy monkey patching of queryset classes?
>
> Your query is quite expressible in the ORM:
>
> p_menu_ids = 
> Menu.objects.filter(parent_menu__isnull=False).order_by('parent_menu').dist 
> inct().values_list('parent_menu')
> qs = Menu.objects.exclude(id__in=p_menu_ids)
>
> 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: Managing objects spred among several tables/databases.

2011-07-14 Thread Andre Terra
> far better is to do what was suggested to you long ago: do the tutorial.
>
> before you finish it, you'll see why your questions are unanswerable,
> and if you like Django or not.
>
>
This cannot be stressed enough.

And do read the wiki guide on posting to the mailing list, as most of your
posts were too vague and simply devoid of a real *Django* question.

I don't mean to sound crass, but spamming the list like that is exactly the
reason why we can't answer every question immediately.



Regards,
André Terra / airstrike

-- 
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: Raise CommandError: One or more models did not validate

2011-07-14 Thread Tim Shaffer
When you do this:

created = models.ForeignKey(User, default=user_logged_in, editable=False
)

It's going to create a method on the user instance called "news_set".

Then when you then do this:

edited = models.ForeignKey(User, default=user_logged_in, editable=False)

It's going to try to create *another* method on the user instance called 
"news_set". Obviously that clashes with the first one created, and you get 
the error.

To get around this, you can give "created" and "edited" a distinct 
related_name that will be used instead of "news_set"

created = models.ForeignKey(User, default=user_logged_in, editable=False, 
related_name="news_created_set")
edited = models.ForeignKey(User, default=user_logged_in, editable=False, 
related_name="news_edited_set")

This is mentioned in the documentation here:

https://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name

-- 
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/-/9kDTS-kvga8J.
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.



Raise CommandError: One or more models did not validate

2011-07-14 Thread Petey
Hey

I'am working on my models page and this is my code:
http://pastebin.com/eAyzzZuY

which returns an error:
django.core.management.base.CommandError: One or more models did not 
validate:
news.news: Accessor for field 'created' clashes with related field 
'User.news_se
t'. Add a related_name argument to the definition for 'created'.
news.news: Accessor for field 'edited' clashes with related field 
'User.news_set
'. Add a related_name argument to the definition for 'edited'.

I know that without "edited" part it works perfectly. I dont really 
understand why it cant work with an additional "edited" field.

How do I fix this this? What should I look for?

-- 
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/-/5y3sWlMRLZUJ.
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: Managing objects spred among several tables/databases.

2011-07-14 Thread Javier Guerra Giraldez
On Thu, Jul 14, 2011 at 12:06 PM, Hummingbird  wrote:
> All right Tom.
> Let me look into admin.
> Then perhaps I would require the help from list.

I (like everybody else here) don't want to sound rude; but i don't
think you'll get anywhere with this approach.

Django is a big framework, just reading random doc sections won't tell
you about the 'big picture'.  without a good idea of what is there,
how parts fit and how to approach your problem(s), you won't be able
to ask the right questions.

far better is to do what was suggested to you long ago: do the tutorial.

before you finish it, you'll see why your questions are unanswerable,
and if you like Django or not.

-- 
Javier

-- 
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: Managing objects spred among several tables/databases.

2011-07-14 Thread Hummingbird
All right Tom.
Let me look into admin.
Then perhaps I would require the help from list.

Cheers.

On Jul 14, 10:01 pm, Tom Evans  wrote:
> On Thu, Jul 14, 2011 at 5:34 PM, Hummingbird  wrote:
> > I am presently using web2py.
> > Before getting the feet wet in django, I am trying to assess whether
> > the functionality I mentioned in earlier reply is already built-in in
> > django, by consulting the list-users.
> > If this is doable, I would happily dive into django.
> > That's why I did not go into actual coding with django, but asking
> > questions like "can I do thing-1, thing-2, etc."
>
> > Thanks.
>
> Let me answer all of them up front:
>
> thing-1: yes
> thing-2: yes
> thing-3: yes
> thing-N: yes
>
> As I often tell my boss, this is software development, we can do anything*.
>
> Developing a prototype, even spending just an hour defining the models
> and playing around in the admin (so no real coding) would tell you
> whether to proceed or not. But it's your choice, I guess we'll have
> another two weeks of 'interesting' questions.
>
> Tom
>
> * (given enough time and resource)

-- 
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: Managing objects spred among several tables/databases.

2011-07-14 Thread Tom Evans
On Thu, Jul 14, 2011 at 5:34 PM, Hummingbird  wrote:
> I am presently using web2py.
> Before getting the feet wet in django, I am trying to assess whether
> the functionality I mentioned in earlier reply is already built-in in
> django, by consulting the list-users.
> If this is doable, I would happily dive into django.
> That's why I did not go into actual coding with django, but asking
> questions like "can I do thing-1, thing-2, etc."
>
> Thanks.
>

Let me answer all of them up front:

thing-1: yes
thing-2: yes
thing-3: yes
thing-N: yes

As I often tell my boss, this is software development, we can do anything*.

Developing a prototype, even spending just an hour defining the models
and playing around in the admin (so no real coding) would tell you
whether to proceed or not. But it's your choice, I guess we'll have
another two weeks of 'interesting' questions.

Tom

* (given enough time and resource)

-- 
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: Managing objects spred among several tables/databases.

2011-07-14 Thread Hummingbird
I am presently using web2py.
Before getting the feet wet in django, I am trying to assess whether
the functionality I mentioned in earlier reply is already built-in in
django, by consulting the list-users.
If this is doable, I would happily dive into django.
That's why I did not go into actual coding with django, but asking
questions like "can I do thing-1, thing-2, etc."

Thanks.

On Jul 14, 9:26 pm, Tom Evans  wrote:
> On Thu, Jul 14, 2011 at 5:11 PM, Hummingbird  wrote:
> > What I want to accomplish from these tables is as given below.
>
> > All the customer data can be maintained in a single table.
> > i.e. customer(custid, custname, groupid, address, tel, mobile, city)
>
> > In the course of normalising the database, we arrived at defining 2
> > tables.
> > "customer" table maintaining basic data like name, group, etc.
> > "custdetl" table containing other details of customer.
>
> > A row in custdetl will be created only if there is any data like
> > address, tel, etc. for a customer.
> > (of course, I need not dive into normalisation concept here).
>
> > As I said earlier, there are much complex examples of "single form :
> > many tables" in my actual project
>
> > Thanks.
>
> All of this easily doable in django.
>
> Typically when handling forms for editing models, you would create a
> ModelForm, which represents one specific model/table. However, you can
> include as many ModelForms as you want within one .
>
> A good (and complex) example of this is django's admin system which
> allows you to include other models 'inline' when editing a related
> model. I think an earlier respondent alluded to this.
>
> Did you have specific questions? Django is quite easy to use and quick
> to prototype in, perhaps you should try implementing a prototype in
> django to see if it does suit your needs, asking questions on here
> when you get stuck.
>
> Cheers
>
> Tom- Hide quoted text -
>
> - Show quoted text -

-- 
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: Managing objects spred among several tables/databases.

2011-07-14 Thread Tom Evans
On Thu, Jul 14, 2011 at 5:11 PM, Hummingbird  wrote:
> What I want to accomplish from these tables is as given below.
>
> All the customer data can be maintained in a single table.
> i.e. customer(custid, custname, groupid, address, tel, mobile, city)
>
> In the course of normalising the database, we arrived at defining 2
> tables.
> "customer" table maintaining basic data like name, group, etc.
> "custdetl" table containing other details of customer.
>
> A row in custdetl will be created only if there is any data like
> address, tel, etc. for a customer.
> (of course, I need not dive into normalisation concept here).
>
> As I said earlier, there are much complex examples of "single form :
> many tables" in my actual project
>
> Thanks.
>

All of this easily doable in django.

Typically when handling forms for editing models, you would create a
ModelForm, which represents one specific model/table. However, you can
include as many ModelForms as you want within one .

A good (and complex) example of this is django's admin system which
allows you to include other models 'inline' when editing a related
model. I think an earlier respondent alluded to this.

Did you have specific questions? Django is quite easy to use and quick
to prototype in, perhaps you should try implementing a prototype in
django to see if it does suit your needs, asking questions on here
when you get stuck.

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: Managing objects spred among several tables/databases.

2011-07-14 Thread Hummingbird
Thanks Michal & other friends for sharing your time for this.

I gather from this thread that I need to write my own class for this.
It is a bit like manufacturing an axe myself before cutting the wood.
But, continuing the python philosophy, let me look at the briter side
of it.
If I write the class myself, I can cater to my needs exactly; no
problem of "unsupported/dead project; others can benefit from my work.

Cheers.

On Jul 14, 8:12 pm, Michal Petrucha  wrote:
> On Thu, Jul 14, 2011 at 07:20:12AM -0700, Hummingbird wrote:
> > Maybe, I didn't explain the condition properely.
>
> > As you say, in this case,
> > "UPDATE custdetl SET tel = NULL, address = , CITY =  > city>
> > WHERE custid = "
> > is fine in this simplified version.
>
> > Suppose when a user removes address, tel, city from table 'custdetl'.
> > When fields are not nullable (not null=true),
> > Then update won't do the job.
> > We NEED to delete the row.
>
> Maybe it is just me, but still, if the fields are not nullable, then
> the user cannot clear his phone number while keeping the rest of his
> info there -- either you delete his entire row or you keep something
> in each column. Either way, you won't be able to accomplish what you
> wrote in the previous e-mail.
>
> > Similarly regarding inserts.
> > If there is no row in 'custdetl' previously, then user interacts the
> > form & adds the details, then we NEED insert statement.
>
> This all depends on the primary key of the table -- if there is no row
> with the specified primary key, Django INSERTs one, otherwise it does
> an UPDATE.
>
> In your case I can imagine having custid as the primary key. That way,
> if you fill out a form for a customer whose details are not in the
> table, they get inserted; otherwise they are updated.
>
> > In actual project, I have individual forms handling as many as >10
> > linked tables.
> > I need to issue insert/update/delete statements to different tables.
> > Any idea how to go about it?
>
> This should be perfectly achievable using formsets. The Django admin
> implements this via a mechanism called "InlineAdmin" which is in fact
> just a bit of sugar around regular formsets.
>
> > (p.s. : If you want, I will post one elaborate example.)
>
> Dunno, that might help; from the one you supplied thus far it is
> really not clear what you want to accomplish.
>
> Michal
>
>  signature.asc
> < 1KViewDownload

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



Re: Managing objects spred among several tables/databases.

2011-07-14 Thread Hummingbird
What I want to accomplish from these tables is as given below.

All the customer data can be maintained in a single table.
i.e. customer(custid, custname, groupid, address, tel, mobile, city)

In the course of normalising the database, we arrived at defining 2
tables.
"customer" table maintaining basic data like name, group, etc.
"custdetl" table containing other details of customer.

A row in custdetl will be created only if there is any data like
address, tel, etc. for a customer.
(of course, I need not dive into normalisation concept here).

As I said earlier, there are much complex examples of "single form :
many tables" in my actual project

Thanks.

On Jul 14, 8:12 pm, Michal Petrucha  wrote:
> On Thu, Jul 14, 2011 at 07:20:12AM -0700, Hummingbird wrote:
> > Maybe, I didn't explain the condition properely.
>
> > As you say, in this case,
> > "UPDATE custdetl SET tel = NULL, address = , CITY =  > city>
> > WHERE custid = "
> > is fine in this simplified version.
>
> > Suppose when a user removes address, tel, city from table 'custdetl'.
> > When fields are not nullable (not null=true),
> > Then update won't do the job.
> > We NEED to delete the row.
>
> Maybe it is just me, but still, if the fields are not nullable, then
> the user cannot clear his phone number while keeping the rest of his
> info there -- either you delete his entire row or you keep something
> in each column. Either way, you won't be able to accomplish what you
> wrote in the previous e-mail.
>
> > Similarly regarding inserts.
> > If there is no row in 'custdetl' previously, then user interacts the
> > form & adds the details, then we NEED insert statement.
>
> This all depends on the primary key of the table -- if there is no row
> with the specified primary key, Django INSERTs one, otherwise it does
> an UPDATE.
>
> In your case I can imagine having custid as the primary key. That way,
> if you fill out a form for a customer whose details are not in the
> table, they get inserted; otherwise they are updated.
>
> > In actual project, I have individual forms handling as many as >10
> > linked tables.
> > I need to issue insert/update/delete statements to different tables.
> > Any idea how to go about it?
>
> This should be perfectly achievable using formsets. The Django admin
> implements this via a mechanism called "InlineAdmin" which is in fact
> just a bit of sugar around regular formsets.
>
> > (p.s. : If you want, I will post one elaborate example.)
>
> Dunno, that might help; from the one you supplied thus far it is
> really not clear what you want to accomplish.
>
> Michal
>
>  signature.asc
> < 1KViewDownload

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



Re: Managing objects spred among several tables/databases.

2011-07-14 Thread Michal Petrucha
On Thu, Jul 14, 2011 at 07:20:12AM -0700, Hummingbird wrote:
> Maybe, I didn't explain the condition properely.
> 
> As you say, in this case,
> "UPDATE custdetl SET tel = NULL, address = , CITY =  city>
> WHERE custid = "
> is fine in this simplified version.
> 
> Suppose when a user removes address, tel, city from table 'custdetl'.
> When fields are not nullable (not null=true),
> Then update won't do the job.
> We NEED to delete the row.

Maybe it is just me, but still, if the fields are not nullable, then
the user cannot clear his phone number while keeping the rest of his
info there -- either you delete his entire row or you keep something
in each column. Either way, you won't be able to accomplish what you
wrote in the previous e-mail.

> Similarly regarding inserts.
> If there is no row in 'custdetl' previously, then user interacts the
> form & adds the details, then we NEED insert statement.

This all depends on the primary key of the table -- if there is no row
with the specified primary key, Django INSERTs one, otherwise it does
an UPDATE.

In your case I can imagine having custid as the primary key. That way,
if you fill out a form for a customer whose details are not in the
table, they get inserted; otherwise they are updated.

> In actual project, I have individual forms handling as many as >10
> linked tables.
> I need to issue insert/update/delete statements to different tables.
> Any idea how to go about it?

This should be perfectly achievable using formsets. The Django admin
implements this via a mechanism called "InlineAdmin" which is in fact
just a bit of sugar around regular formsets.

> (p.s. : If you want, I will post one elaborate example.)

Dunno, that might help; from the one you supplied thus far it is
really not clear what you want to accomplish.


Michal


signature.asc
Description: Digital signature


Re: Linking to Django Admin from 1.3

2011-07-14 Thread eric.frederich
Nevermind... this was my bad.  I removed (.*) from my urls.py
This is now working... thanks a bunch.

This is what I get for developing an app that works and then not touching it 
for over a year.
I really need to keep up with these things.

-- 
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/-/MfVJRaK0OwsJ.
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: Linking to Django Admin from 1.3

2011-07-14 Thread eric.frederich
Well... two people replied with the same answer so rather than picking 
favorites I'll just reply to myself.

This seems to work but looks a bit quirky.

When I use {% url admin:index %} the link that gets generated actually has 
"admin/(.*)" in it.
This even shows up in the url when I click on it.

Is this okay... is it a bug?

-- 
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/-/OfQ60Wy260oJ.
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: old app fails tests, runs ok

2011-07-14 Thread Javier Guerra Giraldez
Ok, error fixed.

the issue was documented on ticket #12720, it was a change on Python's
SimpleCookie implementation between 2.6.2 and 2.6.4 that broke the way
the test client creates requests.

updating to 1.1.4 (instead of naïvely asking for 1.1) restored sanity
into the world.

and i learned a few lessons on software curating.

cheers,

-- 
Javier

-- 
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: Linking to Django Admin from 1.3

2011-07-14 Thread rebus_
On 14 July 2011 16:35, eric.frederich  wrote:
> Hello,
>
> I am moving from 1.0.2 to 1.3 and am having problems linking to the
> admin site from within a template.
> I used to have this in my template...
>
>    Django Admin
>
> And I used to have this in my urls.py
>
>    url(r'^admin/(.*)'      , admin.site.root, name='the-django-
> admin'),
>
> I'm sure this was hacky even back in 1.0.2
> How should I link to the admin site's index from within a template?
>
> I cannot hard code it to /admin because while this would work on
> development, on production it needs to be /apps/admin
> So I need to use the URL resoving mechanism so that the prefix gets
> picked up based on which environment it is on.
>
> So... simple question.  How do I link to the Django admin site from
> within a template?
>
> Thanks,
> ~Eric
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

Try:

{% url admin:index %}

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls

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



Re: Linking to Django Admin from 1.3

2011-07-14 Thread Alasdair Nicol

From the django docs on url namespaces [1]

Namespaced URLs are specified using the : operator. For example, the 
main index page of the admin application is referenced using 
admin:index. This indicates a namespace of admin, and a named URL of 
index.


So you link to the admin index in your template using:

{% url admin:index %}

For Django 1.3, the documented way [2] to include the admin site is:

*url(r'^admin/', include(admin.site.urls)),*


Regards,
Alasdair Nicol

[1] https://docs.djangoproject.com/en/dev/topics/http/urls/#url-namespaces
[2] https://docs.djangoproject.com/en/1.3/intro/tutorial02/


On 14/07/11 15:35, eric.frederich wrote:

Hello,

I am moving from 1.0.2 to 1.3 and am having problems linking to the
admin site from within a template.
I used to have this in my template...

 Django Admin

And I used to have this in my urls.py

 url(r'^admin/(.*)'  , admin.site.root, name='the-django-
admin'),

I'm sure this was hacky even back in 1.0.2
How should I link to the admin site's index from within a template?

I cannot hard code it to /admin because while this would work on
development, on production it needs to be /apps/admin
So I need to use the URL resoving mechanism so that the prefix gets
picked up based on which environment it is on.

So... simple question.  How do I link to the Django admin site from
within a template?

Thanks,
~Eric




--
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.



Linking to Django Admin from 1.3

2011-07-14 Thread eric.frederich
Hello,

I am moving from 1.0.2 to 1.3 and am having problems linking to the
admin site from within a template.
I used to have this in my template...

Django Admin

And I used to have this in my urls.py

url(r'^admin/(.*)'  , admin.site.root, name='the-django-
admin'),

I'm sure this was hacky even back in 1.0.2
How should I link to the admin site's index from within a template?

I cannot hard code it to /admin because while this would work on
development, on production it needs to be /apps/admin
So I need to use the URL resoving mechanism so that the prefix gets
picked up based on which environment it is on.

So... simple question.  How do I link to the Django admin site from
within a template?

Thanks,
~Eric

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



Re: Managing objects spred among several tables/databases.

2011-07-14 Thread Hummingbird
Maybe, I didn't explain the condition properely.

As you say, in this case,
"UPDATE custdetl SET tel = NULL, address = , CITY = 
WHERE custid = "
is fine in this simplified version.

Suppose when a user removes address, tel, city from table 'custdetl'.
When fields are not nullable (not null=true),
Then update won't do the job.
We NEED to delete the row.

Similarly regarding inserts.
If there is no row in 'custdetl' previously, then user interacts the
form & adds the details, then we NEED insert statement.

In actual project, I have individual forms handling as many as >10
linked tables.
I need to issue insert/update/delete statements to different tables.
Any idea how to go about it?

Thanks.

(p.s. : If you want, I will post one elaborate example.)


On Jul 14, 6:35 pm, Michal Petrucha  wrote:
> On Thu, Jul 14, 2011 at 06:00:38AM -0700, Hummingbird wrote:
> > Table names (field names) are are under--
>
> > customer (custid, custname, groupid),
> > custdetl (custid, address, tel, mobile, city)
> > group  (groupid, groupname)
>
> > There is a single form for handling tables "customer" and "custdetl".
> > Consider that a user wants to edit customer details in this form.
>
> > He changes groupid,
> > deletes phone number,
> > changes address,
> > adds city (earlier, it was left blank by user).
>
> > In effect, "customer" table should receive an update statement,
> > "custdetl" table should receive delete, update & insert statements.
>
> This is the part I have trouble keeping up. Why should it need one
> DELETE, one UPDATE and one INSERT? All of that can be done with one
> single UPDATE statement in terms of
> UPDATE custdetl SET tel = NULL, address = , CITY = 
> WHERE custid = ;
> Why on earth would you delete a row and then insert a row again? By
> issuing a DELETE you don't clear the value of a single column, you
> remove entire rows from the table. Same with INSERT.
>
> So either you just use one single UPDATE (which is perfectly fine with
> Django and if you use a ModelForm it is as easy as calling
> my_form.save()) or we're not talking about three tables with columns
> as you described but something much more complicated.
>
> Michal
>
>  signature.asc
> < 1KViewDownload- Hide quoted text -
>
> - Show quoted text -

-- 
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: virtualenv with dev server

2011-07-14 Thread Bill Freeman
How are you starting the dev server?  I'm mostly familiar with *nix usage, but,
in a nutshell, the only thing that python code needs to use the
virtual environment
is to be run with the correct python.  On *nix, pretty much the only
significant thing
that activate is to tweak the environment's path such that typing
"python" starts
the one from the virtual environment's bin directory, rather than the
system python,
which python has the virtual environment's lib/python2.x/site-packages
first on it's
sys.path.  You don't actually have to activate the VE so long as you
use that python
to run manage.py.

Probably what you need is a script, say, manage.bat, which cd's to the directory
containing manage.py, then invokes it using an explicit path to the
correct python.exe,
plus whatever you have to do in batch files to pass the arguments that
you give to
manage.bat on along to:

\path\to\virtual\environment\bin\python.exe manage.py %something_that_gets_args%

Then, with this on you path, you can just say "manage runserver".

But, as I say, I don't really do Windows, and I'm assuming that .bat
files work like they
used to, so you may have extra research to do.

Bill

On Thu, Jul 14, 2011 at 3:54 AM, Mike Dewhirst  wrote:
> Trying to get virtualenv working for the first time for a new project and
> have stumbled somehow. I can get it working as advertised (see below) but
> django dev server doesn't notice.
>
> Any hints appreciated ...
>
> ||| here is virtualenv being activated
>
> C:\users\miked\py\ssds>Scripts\activate
> (ssds) C:\users\miked\py\ssds>python
> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
 import django
 django.get_version()
> '1.3'
 quit()
>
> ||| correctly showing django version 1.3 installed in virtualenv ssds
> ||| so now I want to start the dev server
>
> (ssds) C:\users\miked\py\ssds>Scripts\django-admin.py runserver
> --settings=src.settings
> Validating models...
>
> 0 errors found
> Django version 1.4 pre-alpha SVN-16452, using settings 'src.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
>
> ||| it has used my global site-packages django 1.4 from trunk
> ||| just in case, here is my ssds\Scripts\django-admin.py
>
> #!C:\users\miked\py\ssds\Scripts\python.exe
> from django.core import management
>
> if __name__ == "__main__":
>    management.execute_from_command_line()
>
>
> Thanks
>
> Mike
>
> --
> 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: Managing objects spred among several tables/databases.

2011-07-14 Thread Michal Petrucha
On Thu, Jul 14, 2011 at 06:00:38AM -0700, Hummingbird wrote:
> Table names (field names) are are under--
> 
> customer (custid, custname, groupid),
> custdetl (custid, address, tel, mobile, city)
> group  (groupid, groupname)
> 
> There is a single form for handling tables "customer" and "custdetl".
> Consider that a user wants to edit customer details in this form.
> 
> He changes groupid,
> deletes phone number,
> changes address,
> adds city (earlier, it was left blank by user).
> 
> In effect, "customer" table should receive an update statement,
> "custdetl" table should receive delete, update & insert statements.

This is the part I have trouble keeping up. Why should it need one
DELETE, one UPDATE and one INSERT? All of that can be done with one
single UPDATE statement in terms of
UPDATE custdetl SET tel = NULL, address = , CITY = 
WHERE custid = ;
Why on earth would you delete a row and then insert a row again? By
issuing a DELETE you don't clear the value of a single column, you
remove entire rows from the table. Same with INSERT.

So either you just use one single UPDATE (which is perfectly fine with
Django and if you use a ModelForm it is as easy as calling
my_form.save()) or we're not talking about three tables with columns
as you described but something much more complicated.

Michal


signature.asc
Description: Digital signature


Re: Some more curious performance issues between MySQL and Django ORM

2011-07-14 Thread Cal Leeming [Simplicity Media Ltd]
On Thu, Jul 14, 2011 at 2:17 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On 14 juil, 02:24, "Cal Leeming [Simplicity Media Ltd]"
>  wrote:
> > On 14 Jul 2011 00:13, "bruno desthuilliers" <
> bruno.desthuilli...@gmail.com>
> > wrote:
> >> And FWIW, did you try the obvious:
> >
> >> return Session.objects.filter(
> >>member__username=self.username,
> >>is_fake = 0
> >> ).order_by("-id")
> >
> > If you look at the original query i pasted, you'll see that this
> > modification wouldn't have been any better (as they both would have
> > generated the same query).
>
> Your original code used a subquery, this one should use a couple inner
> join, ie something like :
>
> select * from session s inner join member m on s.member_id = m.id
> inner join user u on m.user_id = u.id where u.username='%s' and
> s.is_fake=0 order by s.id desc;
>

Oh right, I didn't realise. Tell you what, I'll try it out later and let you
know :) Thanks for the heads up on this!


>
> (sorry, don't have any django project at hand ATM so I can't check the
> exact SQL Django would generate here).
>
>
> Now that still doesn't mean you'd get better performances... :-/
>
> --
> 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: virtualenv with dev server

2011-07-14 Thread Leonidas Tsampros
Mike Dewhirst  writes:
> Trying to get virtualenv working for the first time for a new project
> and have stumbled somehow. I can get it working as advertised (see
> below) but django dev server doesn't notice.
>
> Any hints appreciated ...
>
> ||| here is virtualenv being activated
>
> C:\users\miked\py\ssds>Scripts\activate
> (ssds) C:\users\miked\py\ssds>python
> Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
 import django
 django.get_version()
> '1.3'
 quit()
>
> ||| correctly showing django version 1.3 installed in virtualenv ssds
> ||| so now I want to start the dev server
>
> (ssds) C:\users\miked\py\ssds>Scripts\django-admin.py runserver
> --settings=src.settings
> Validating models...
>
> 0 errors found
> Django version 1.4 pre-alpha SVN-16452, using settings 'src.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
>

Try running python manage.py runserver from within the root of your
project while having trun the activate script of your virtualenv.


> ||| it has used my global site-packages django 1.4 from trunk
> ||| just in case, here is my ssds\Scripts\django-admin.py
>
> #!C:\users\miked\py\ssds\Scripts\python.exe
> from django.core import management
>
> if __name__ == "__main__":
> management.execute_from_command_line()
>
>
> Thanks
>
> Mike

-- 
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: Proxy Model and casting

2011-07-14 Thread Tom Evans
On Thu, Jul 14, 2011 at 2:09 PM, tom  wrote:
> Hello,
>
> I have following proxy model
>
> class UserForSubdomain(User):
>    """
>    This Model acts as a proxy to the django model:``User`` and
>    allows to store the subdomain with the username to support
>    the same usernames with different subdomains.
>    The username is split with the first '.'. The first part is the
>    subdomain, everything that follows is the username.
>    """
>    class Meta:
>        proxy = True
>
>    def get_username(self):
>        domain = u_name = None
>        try:
>            domain, u_name = self.username.split('.', 1)
>        except ValueError:
>            #return the username if there is no . in the username
>            u_name = self.username
>        logger.debug('Full username for id %s is "%s". Split is:
> "%s"."%s"' % (self.id, self.username, domain, u_name))
>        return u_name
>
>    def __unicode__(self):
>        if self.first_name and self.last_name:
>            return self.get_full_name()
>        else:
>            return self.get_username()
>
> When I cast a ``User`` object to a ``UserForSubdomain`` object,
> somehow the values of the properties are not available anymore. I do
> this
>
 user = User.objects.get(username = 'xyz.tstagl')
 print user
> xyz.tstagl
 s_user = UserForSubdomain(user)
 print s_user
>
 print s_user.get_username()
>

>
> Has someone an idea what I am doing wrong here? I think I am missing
> something obvious, but I can't find out what.
>
> Many thanks for your help!
>
> regards, tom
>

You're missing that there is no such thing as casting in python.
"UserForSubdomain(user)" attempts to construct a new UserForSubdomain
object by calling __init__ with a User object as the first positional
parameter.

If you want a UserForSubdomain from a User, the simplest way is to
fetch it from the database, using the user id.

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: Some more curious performance issues between MySQL and Django ORM

2011-07-14 Thread bruno desthuilliers
On 14 juil, 02:24, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> On 14 Jul 2011 00:13, "bruno desthuilliers" 
> wrote:
>> And FWIW, did you try the obvious:
>
>> return Session.objects.filter(
>>            member__username=self.username,
>>            is_fake = 0
>>         ).order_by("-id")
>
> If you look at the original query i pasted, you'll see that this
> modification wouldn't have been any better (as they both would have
> generated the same query).

Your original code used a subquery, this one should use a couple inner
join, ie something like :

select * from session s inner join member m on s.member_id = m.id
inner join user u on m.user_id = u.id where u.username='%s' and
s.is_fake=0 order by s.id desc;

(sorry, don't have any django project at hand ATM so I can't check the
exact SQL Django would generate here).


Now that still doesn't mean you'd get better performances... :-/

-- 
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.



Proxy Model and casting

2011-07-14 Thread tom
Hello,

I have following proxy model

class UserForSubdomain(User):
"""
This Model acts as a proxy to the django model:``User`` and
allows to store the subdomain with the username to support
the same usernames with different subdomains.
The username is split with the first '.'. The first part is the
subdomain, everything that follows is the username.
"""
class Meta:
proxy = True

def get_username(self):
domain = u_name = None
try:
domain, u_name = self.username.split('.', 1)
except ValueError:
#return the username if there is no . in the username
u_name = self.username
logger.debug('Full username for id %s is "%s". Split is:
"%s"."%s"' % (self.id, self.username, domain, u_name))
return u_name

def __unicode__(self):
if self.first_name and self.last_name:
return self.get_full_name()
else:
return self.get_username()

When I cast a ``User`` object to a ``UserForSubdomain`` object,
somehow the values of the properties are not available anymore. I do
this

>>> user = User.objects.get(username = 'xyz.tstagl')
>>> print user
xyz.tstagl
>>> s_user = UserForSubdomain(user)
>>> print s_user

>>> print s_user.get_username()

>>>

Has someone an idea what I am doing wrong here? I think I am missing
something obvious, but I can't find out what.

Many thanks for your help!

regards, 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.



AW: Managing objects spred among several tables/databases.

2011-07-14 Thread Szabo, Patrick (LNG-VIE)
Hi, 

Are those tables somehow related to each other per FK ?!
In that case i think you might be able to use a model form for that purpose. 

I'm not really good with django myself so i might be talking bs.


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Hummingbird
Gesendet: Donnerstag, 14. Juli 2011 15:01
An: Django users
Betreff: Re: Managing objects spred among several tables/databases.

Hi again !
I went through the docs of django again, but still could not find what
I was looking for.

Definition of my problem (simplified version to keep this post short):

Table names (field names) are are under--

customer (custid, custname, groupid),
custdetl (custid, address, tel, mobile, city)
group  (groupid, groupname)

There is a single form for handling tables "customer" and "custdetl".
Consider that a user wants to edit customer details in this form.

He changes groupid,
deletes phone number,
changes address,
adds city (earlier, it was left blank by user).

In effect, "customer" table should receive an update statement,
"custdetl" table should receive delete, update & insert statements.

Beforehand, we do not have any means to know what all interactions the
user will make.

My question is:--
Is there any generic way to do this in django?
OR
Is there any third party class (which can be imported in django)
available for catering to such a need?

( I googled to find 2 such classes.
1) "PyBackend" http://pybackend.sourceforge.net/,
2) "Modeling" by Sébastien Bigaret http://modeling.sourceforge.net/main.html
)

But these projects are not active and therefore are not supported.
Also some issues are there in installing them.

Can anybody pl. help?
Thanks.


On Jul 9, 8:53 am, Hummingbird  wrote:
> Although I have gone through the docs of Django ORM, let me re-read
> it.
> Then I will come back to this thread with specific question.
>
> Thanks for your reply.
>
> On Jul 8, 8:57 pm, Tom Evans  wrote:
>
>
>
> > On Fri, Jul 8, 2011 at 4:01 PM, Hummingbird  
> > wrote:
> > > @Cal,
> > > My apologies if my post has hurted you.
> > > I didn't mean that.
> > > I understand that all these open source projects are run by people who
> > > don't get paid for it.
>
> > > My point was quite different. It was about knowledge sharing.
> > > We can re-phrase the question if nobody understands what we mean to
> > > ask.
> > > Actually, we are not asking for any exact code or any spoon-feeding.
> > > We are asking whether anybody has developed a solution similar to
> > > CursorAdaptor in VFP
> > > Ed Leafe & Paul McNett have done marvelous work in this area (DABO
> > > desktop framework).
>
> > > Instead of making this post very long by giving details of what is a
> > > CursorAdaptor, pl. refer to --
> > >http://msdn.microsoft.com/en-us/library/d993hde7(v=vs.80).aspx
>
> > > Regarding your remark of "Don't expect an instant answer"--
> > > -- OP was dated 30th June.
> > > Today is 8th July (an instant???)
>
> > > Again, pl. excuse me if I have said anything wrong.
> > > @qMax:  Have you got any way around your question?
>
> > > ---Vineet
>
> > Hi Vineet
>
> > The problem both you and the OP have is that you asked extremely vague
> > questions. I've re-read the OPs post a number of times, and all I can
> > see is some extremely vague discussion on how the ORM represents
> > tables as model instances. I still don't see a question there, or at
> > least one I can answer.
>
> > Your question is only vaguely related to the OPs (in that it deals
> > with the ORM). On mailing lists, some people find replying to another
> > thread with a different question of your own almost as rude as TYPING
> > IN ALL CAPS. It is best to start a new thread rather than hijacking
> > someone elses. Secondly, continually bumping a thread each day is also
> > very annoying. Both of these things will dissuade people from replying
> > to you, so bear that in mind.
>
> > Netiquette apart, your question is vague. You describe a system where
> > by you can update various tables, updating the ones you want. This is
> > a basic feature of ORMs - have you read the tutorial or any of the
> > documentation on django's ORM?
>
> > I think the basic point is that you are far too vague about what you
> > want. You can't just point at us at some MS relational layer
> > documentation from 2005 and expect us to wade through it, work out
> > what you are currently doing, work out if that is applicable to
> > Django's ORM and formulate a plan for you. You are going to need to do
> > some of the work yourself.
>
> > There are more ORMs out there than you can imagine. You need to work
> > out what you want from a 

Re: Managing objects spred among several tables/databases.

2011-07-14 Thread Hummingbird
Hi again !
I went through the docs of django again, but still could not find what
I was looking for.

Definition of my problem (simplified version to keep this post short):

Table names (field names) are are under--

customer (custid, custname, groupid),
custdetl (custid, address, tel, mobile, city)
group  (groupid, groupname)

There is a single form for handling tables "customer" and "custdetl".
Consider that a user wants to edit customer details in this form.

He changes groupid,
deletes phone number,
changes address,
adds city (earlier, it was left blank by user).

In effect, "customer" table should receive an update statement,
"custdetl" table should receive delete, update & insert statements.

Beforehand, we do not have any means to know what all interactions the
user will make.

My question is:--
Is there any generic way to do this in django?
OR
Is there any third party class (which can be imported in django)
available for catering to such a need?

( I googled to find 2 such classes.
1) "PyBackend" http://pybackend.sourceforge.net/,
2) "Modeling" by Sébastien Bigaret http://modeling.sourceforge.net/main.html
)

But these projects are not active and therefore are not supported.
Also some issues are there in installing them.

Can anybody pl. help?
Thanks.


On Jul 9, 8:53 am, Hummingbird  wrote:
> Although I have gone through the docs of Django ORM, let me re-read
> it.
> Then I will come back to this thread with specific question.
>
> Thanks for your reply.
>
> On Jul 8, 8:57 pm, Tom Evans  wrote:
>
>
>
> > On Fri, Jul 8, 2011 at 4:01 PM, Hummingbird  
> > wrote:
> > > @Cal,
> > > My apologies if my post has hurted you.
> > > I didn't mean that.
> > > I understand that all these open source projects are run by people who
> > > don't get paid for it.
>
> > > My point was quite different. It was about knowledge sharing.
> > > We can re-phrase the question if nobody understands what we mean to
> > > ask.
> > > Actually, we are not asking for any exact code or any spoon-feeding.
> > > We are asking whether anybody has developed a solution similar to
> > > CursorAdaptor in VFP
> > > Ed Leafe & Paul McNett have done marvelous work in this area (DABO
> > > desktop framework).
>
> > > Instead of making this post very long by giving details of what is a
> > > CursorAdaptor, pl. refer to --
> > >http://msdn.microsoft.com/en-us/library/d993hde7(v=vs.80).aspx
>
> > > Regarding your remark of "Don't expect an instant answer"--
> > > -- OP was dated 30th June.
> > > Today is 8th July (an instant???)
>
> > > Again, pl. excuse me if I have said anything wrong.
> > > @qMax:  Have you got any way around your question?
>
> > > ---Vineet
>
> > Hi Vineet
>
> > The problem both you and the OP have is that you asked extremely vague
> > questions. I've re-read the OPs post a number of times, and all I can
> > see is some extremely vague discussion on how the ORM represents
> > tables as model instances. I still don't see a question there, or at
> > least one I can answer.
>
> > Your question is only vaguely related to the OPs (in that it deals
> > with the ORM). On mailing lists, some people find replying to another
> > thread with a different question of your own almost as rude as TYPING
> > IN ALL CAPS. It is best to start a new thread rather than hijacking
> > someone elses. Secondly, continually bumping a thread each day is also
> > very annoying. Both of these things will dissuade people from replying
> > to you, so bear that in mind.
>
> > Netiquette apart, your question is vague. You describe a system where
> > by you can update various tables, updating the ones you want. This is
> > a basic feature of ORMs - have you read the tutorial or any of the
> > documentation on django's ORM?
>
> > I think the basic point is that you are far too vague about what you
> > want. You can't just point at us at some MS relational layer
> > documentation from 2005 and expect us to wade through it, work out
> > what you are currently doing, work out if that is applicable to
> > Django's ORM and formulate a plan for you. You are going to need to do
> > some of the work yourself.
>
> > There are more ORMs out there than you can imagine. You need to work
> > out what you want from a framework, and evaluate the frameworks out
> > there to find the suitable one for your project. We can help by
> > telling you about the Django one, but you need to help by telling us
> > what you want to do with it (consider creating, reading, updating and
> > deleting items as something that all the frameworks will do).
>
> > I think you will find people here will be willing and responsive to
> > help you, once you figure out what it is that you want from Django,
> > and start asking precise questions about what Django can support.
>
> > Cheers
>
> > Tom- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 

Re: urls

2011-07-14 Thread jocke khazad
http://127.0.0.1:8000/ is the same as / .

To hit the following url:

url(r'^$', 'person.views.home', name='home')

use: HttpResponseRedirect('/')


/Joakim

On Thu, Jul 14, 2011 at 10:49 AM, Massimiliano della Rovere <
massimiliano.dellarov...@gmail.com> wrote:

> I think your case is #2 in
> https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect
>
> 
> skype: masdero, icq: 473891447, yim: mas_dero, msn: mas_d...@hotmail.com
> 
> Mi scriva in italiano; Write me in English; Skribu al mi Esperante!
>
>
> On Thu, Jul 14, 2011 at 10:13, NISA BALAKRISHNAN
>  wrote:
> > i am new to django.
> >
> > i have a very simple question.
> > wht is the url  i need to give to httpresponseredirect()  to load my
> > home page with url  http://127.0.0.1:8000/
> > my urls.py looks like dis:
> >
> > urlpatterns = patterns('',
> ># Examples:
> >url(r'^$', 'person.views.home', name='home'),
> >url(r'^edit/$', 'person.views.edit', name='edit'),
> >
> >#url(r'^persons/$', 'person.views.index', name='index'),
> ># url(r'^mysite/', include('mysite.foo.urls')),
> >
> ># Uncomment the admin/doc line below to enable admin
> > documentation:
> ># url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
> >
> ># Uncomment the next line to enable the admin:
> >url(r'^admin/', include(admin.site.urls)),
> >
> >
> > )
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> 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: middleware

2011-07-14 Thread Calvin Spealman
You should use Django Debug Toolbar. It can handle this sort of thing,
and many other things, for you.

On Thu, Jul 14, 2011 at 1:34 AM, NISA BALAKRISHNAN
 wrote:
> how to write a middleware that that stores all database requests.
> How can i store all database requests?
>
> pls 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.
>
>



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy

-- 
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: 'RawQuerySet' object has no attribute 'get'

2011-07-14 Thread Cal Leeming [Simplicity Media Ltd]
On 14 Jul 2011 11:41, "Tom Evans"  wrote:
>
> On Thu, Jul 14, 2011 at 10:56 AM, zdenulo  wrote:
> > Greetings to everybody,
> > I have a problem for which I didn't find solution on internet,
> > therefore  I am posting context:
> >
> > simplified models.py for application testapp (django 1.3):
> >
> > class Menu(models.Model):
> >parent_menu = models.ForeignKey('Menu', blank=True, null=True)
>
> ForeignKeys to themselves should use 'self' as the target model, eg:
>
> parent_menu = models.ForeignKey('self', blank=True, null=True)
>
> >title = models.CharField(max_length=30)
> >def __unicode__(self):
> >return self.title
> >
> > class Page(models.Model):
> >menu = models.ForeignKey('Menu', blank = True, null=True)
> >
> >
> > file admin.py
> >
> > from testapp.models import Page, Menu
> > from django.contrib import admin
> >
> > class PageAdmin(admin.ModelAdmin):
> >def formfield_for_foreignkey(self, db_field, request, **kwargs):
> >if db_field.name == "menu":
> >kwargs["queryset"] = Menu.objects.raw('select * from
> > testapp_menu where not id in (select distinct parent_menu_id from
> > testapp_menu where parent_menu_id is not null)')
> >kwargs["queryset"].all = kwargs["queryset"].__iter__
> >return super(PageAdmin,
> > self).formfield_for_foreignkey(db_field, request, **kwargs)
>
>
> That just made me weep.

Lmao. That was just the laugh I needed to wake up to :P Kudos to the OP for
attempting this though :)

>
> >
> >
> > class MenuAdmin(admin.ModelAdmin):
> >pass
> >
> > admin.site.register(Menu, MenuAdmin)
> > admin.site.register(Page, PageAdmin)
> >
> > some explanation:
> > When I am creating Page, I want to have in a list all Menu instances
> > which either don't have parent menu or don't have "child
> > menu" (inverse relationship as defined in model). Now I didn't find
> > any suitable query using Django syntax, that's why I used raw query.
> > It filters Menu objects as I expect, but when I want to save Page
> > instance, I get following error 'RawQuerySet' object has no attribute
> > 'get'
> >
> > problem is in method \django\forms\models.py to_python
> >  972. value = self.queryset.get(**{key: value})
> >
> > I don't know how to bypass this error and I didn't find anywhere
> > discussion about this case, so every help and advice is much
> > appreciated.
> >
>
> Don't do crazy monkey patching of queryset classes?
>
> Your query is quite expressible in the ORM:
>
> p_menu_ids =
Menu.objects.filter(parent_menu__isnull=False).order_by('parent_menu').distinct().values_list('parent_menu')
> qs = Menu.objects.exclude(id__in=p_menu_ids)
>
> 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.
>

-- 
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: 'RawQuerySet' object has no attribute 'get'

2011-07-14 Thread Tom Evans
On Thu, Jul 14, 2011 at 10:56 AM, zdenulo  wrote:
> Greetings to everybody,
> I have a problem for which I didn't find solution on internet,
> therefore  I am posting context:
>
> simplified models.py for application testapp (django 1.3):
>
> class Menu(models.Model):
>    parent_menu = models.ForeignKey('Menu', blank=True, null=True)

ForeignKeys to themselves should use 'self' as the target model, eg:

parent_menu = models.ForeignKey('self', blank=True, null=True)

>    title = models.CharField(max_length=30)
>    def __unicode__(self):
>        return self.title
>
> class Page(models.Model):
>    menu = models.ForeignKey('Menu', blank = True, null=True)
>
>
> file admin.py
>
> from testapp.models import Page, Menu
> from django.contrib import admin
>
> class PageAdmin(admin.ModelAdmin):
>    def formfield_for_foreignkey(self, db_field, request, **kwargs):
>        if db_field.name == "menu":
>            kwargs["queryset"] = Menu.objects.raw('select * from
> testapp_menu where not id in (select distinct parent_menu_id from
> testapp_menu where parent_menu_id is not null)')
>            kwargs["queryset"].all = kwargs["queryset"].__iter__
>        return super(PageAdmin,
> self).formfield_for_foreignkey(db_field, request, **kwargs)


That just made me weep.

>
>
> class MenuAdmin(admin.ModelAdmin):
>    pass
>
> admin.site.register(Menu, MenuAdmin)
> admin.site.register(Page, PageAdmin)
>
> some explanation:
> When I am creating Page, I want to have in a list all Menu instances
> which either don't have parent menu or don't have "child
> menu" (inverse relationship as defined in model). Now I didn't find
> any suitable query using Django syntax, that's why I used raw query.
> It filters Menu objects as I expect, but when I want to save Page
> instance, I get following error 'RawQuerySet' object has no attribute
> 'get'
>
> problem is in method \django\forms\models.py to_python
>  972.             value = self.queryset.get(**{key: value})
>
> I don't know how to bypass this error and I didn't find anywhere
> discussion about this case, so every help and advice is much
> appreciated.
>

Don't do crazy monkey patching of queryset classes?

Your query is quite expressible in the ORM:

p_menu_ids = 
Menu.objects.filter(parent_menu__isnull=False).order_by('parent_menu').distinct().values_list('parent_menu')
qs = Menu.objects.exclude(id__in=p_menu_ids)

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: Some more curious performance issues between MySQL and Django ORM

2011-07-14 Thread Cal Leeming [Simplicity Media Ltd]
On 14 Jul 2011 03:11, "Andre Terra"  wrote:
>
> PostgreSQL or bust.

Hehe, a lot of people have suggested using PostgreSQL, and in all fairness I
do now understand some of the arguments in the MySQL vs debate.. Until i
find something really really wrong with mysql, ill probably 'stay with the
devil i know' lol.

>
> 
>
> On Wed, Jul 13, 2011 at 9:24 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:
>>
>>
>> On 14 Jul 2011 00:13, "bruno desthuilliers" <
bruno.desthuilli...@gmail.com> wrote:
>> >
>> > On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]"
>> >  wrote:
>> >
>> > > _users = map(lambda x: x.get('memberid'),
Members.objects.filter(
>> > > username = self.username
>> > > ).values('memberid'))
>> >
>> > What's wrong with values_list ?
>> >
>> > member_ids = Members.objects.filter(
>> > username = self.username
>> > ).values_list('memberid', flat=True)
>>
>> I didn't know about values_list(), thanks for this :)
>>
>> >
>> >
>> > And FWIW, did you try the obvious:
>> >
>> > return Session.objects.filter(
>> >member__username=self.username,
>> >is_fake = 0
>> > ).order_by("-id")
>>
>> If you look at the original query i pasted, you'll see that this
modification wouldn't have been any better (as they both would have
generated the same query). The problem is that mysql does strange ass things
when it comes to nested lookups or w/e its called. But tbh, ive come across
so many times when its faster to perform operations outside of mysql, than
it is inside.. the more i use mysql, the more i see how flawed it is :X
>>
>> >
>> > (not that it might necessarily be faster - depending on your dataset,
>> > indexes, hardware and whatnot).
>> >
>> > --
>> > 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.

-- 
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.



'RawQuerySet' object has no attribute 'get'

2011-07-14 Thread zdenulo
Greetings to everybody,
I have a problem for which I didn't find solution on internet,
therefore  I am posting context:

simplified models.py for application testapp (django 1.3):

class Menu(models.Model):
parent_menu = models.ForeignKey('Menu', blank=True, null=True)
title = models.CharField(max_length=30)
def __unicode__(self):
return self.title

class Page(models.Model):
menu = models.ForeignKey('Menu', blank = True, null=True)


file admin.py

from testapp.models import Page, Menu
from django.contrib import admin

class PageAdmin(admin.ModelAdmin):
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == "menu":
kwargs["queryset"] = Menu.objects.raw('select * from
testapp_menu where not id in (select distinct parent_menu_id from
testapp_menu where parent_menu_id is not null)')
kwargs["queryset"].all = kwargs["queryset"].__iter__
return super(PageAdmin,
self).formfield_for_foreignkey(db_field, request, **kwargs)


class MenuAdmin(admin.ModelAdmin):
pass

admin.site.register(Menu, MenuAdmin)
admin.site.register(Page, PageAdmin)

some explanation:
When I am creating Page, I want to have in a list all Menu instances
which either don't have parent menu or don't have "child
menu" (inverse relationship as defined in model). Now I didn't find
any suitable query using Django syntax, that's why I used raw query.
It filters Menu objects as I expect, but when I want to save Page
instance, I get following error 'RawQuerySet' object has no attribute
'get'

problem is in method \django\forms\models.py to_python
 972. value = self.queryset.get(**{key: value})

I don't know how to bypass this error and I didn't find anywhere
discussion about this case, so every help and advice is much
appreciated.

zdenulo

-- 
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 simple mailbox

2011-07-14 Thread ikatanda
have you created your views and added the url to point to the app
mailbox page?

On Jul 14, 7:36 am, bahare hoseini  wrote:
> hi there,
> as my first project i'm going to create a simple mail box to recieve or
> delete Emails,
> i made my models in my application, could you please tell me the next steps?
>
> thanks.

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



Re: Add attributes (css-class) to formfield

2011-07-14 Thread Tom Evans
On Wed, Jul 13, 2011 at 6:41 PM, Andreas Pfrengle  wrote:
> Hello,
>
> I know about assigning attributes to widgets, like shown here:
>  widget-instances>
> or here:
>  forms>
>
> However, I want to assign an additional attribute to a formfield,
> since we want a css class for a div that is wrapped around the
> presentation of a field. I've tried to assign an attribute in the
> form's __init__, like:
>
>    self.fields['my_field'].div_css = "test"
>
> If I try to fetch it in the template however, it resolves to an empty
> string (supposedly the attribute doesn't exist):
>    {% for field in form.visible_fields %}
>        
>        
>        
>    {% endfor %}
>
> Any help or explanation what goes on inside Django is appreciated.
>
> Regards,
> Andreas


All these replies, and none of them have mentioned why your original
approach doesn't work.

When iterating through a form in your template, each field instance
returned is not a field from form.fields, it is a BoundField that
represents the corresponding field from form.fields.

The original field object is available in bfield.field . Therefore,
with your original code, you can do this in the template:

   {% for bfield in form.visible_fields %}
       
       
       
   {% endfor %}

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: urls

2011-07-14 Thread Massimiliano della Rovere
I think your case is #2 in
https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect


skype: masdero, icq: 473891447, yim: mas_dero, msn: mas_d...@hotmail.com

Mi scriva in italiano; Write me in English; Skribu al mi Esperante!


On Thu, Jul 14, 2011 at 10:13, NISA BALAKRISHNAN
 wrote:
> i am new to django.
>
> i have a very simple question.
> wht is the url  i need to give to httpresponseredirect()  to load my
> home page with url  http://127.0.0.1:8000/
> my urls.py looks like dis:
>
> urlpatterns = patterns('',
>    # Examples:
>    url(r'^$', 'person.views.home', name='home'),
>    url(r'^edit/$', 'person.views.edit', name='edit'),
>
>    #url(r'^persons/$', 'person.views.index', name='index'),
>    # url(r'^mysite/', include('mysite.foo.urls')),
>
>    # Uncomment the admin/doc line below to enable admin
> documentation:
>    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>    # Uncomment the next line to enable the admin:
>    url(r'^admin/', include(admin.site.urls)),
>
>
> )
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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.



urls

2011-07-14 Thread NISA BALAKRISHNAN
i am new to django.

i have a very simple question.
wht is the url  i need to give to httpresponseredirect()  to load my
home page with url  http://127.0.0.1:8000/
my urls.py looks like dis:

urlpatterns = patterns('',
# Examples:
url(r'^$', 'person.views.home', name='home'),
url(r'^edit/$', 'person.views.edit', name='edit'),

#url(r'^persons/$', 'person.views.index', name='index'),
# url(r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below to enable admin
documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),


)

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



Re: database requests

2011-07-14 Thread NISA BALAKRISHNAN
thx

On Thu, Jul 14, 2011 at 11:26 AM, Jirka Vejrazka
wrote:

> > how can i get the queries being passed while a page is being
> > requested? i mean when a view is requested the database queries being
> > sent.
>
> Hi,
>
>  it's difficult to figure out what you need from your question, but
> I'll make a wild guess that you need this:
>
>
> https://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running
>
>  HTH
>
>Jirka
>
> --
> 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.
>
>


-- 
Thanks & Regards,

Nisa Balakrishnan,
SHARJAH, UAE.

-- 
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.



virtualenv with dev server

2011-07-14 Thread Mike Dewhirst
Trying to get virtualenv working for the first time for a new project 
and have stumbled somehow. I can get it working as advertised (see 
below) but django dev server doesn't notice.


Any hints appreciated ...

||| here is virtualenv being activated

C:\users\miked\py\ssds>Scripts\activate
(ssds) C:\users\miked\py\ssds>python
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit 
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.3'
>>> quit()

||| correctly showing django version 1.3 installed in virtualenv ssds
||| so now I want to start the dev server

(ssds) C:\users\miked\py\ssds>Scripts\django-admin.py runserver 
--settings=src.settings

Validating models...

0 errors found
Django version 1.4 pre-alpha SVN-16452, using settings 'src.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

||| it has used my global site-packages django 1.4 from trunk
||| just in case, here is my ssds\Scripts\django-admin.py

#!C:\users\miked\py\ssds\Scripts\python.exe
from django.core import management

if __name__ == "__main__":
management.execute_from_command_line()


Thanks

Mike

--
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: database requests

2011-07-14 Thread Jirka Vejrazka
> how can i get the queries being passed while a page is being
> requested? i mean when a view is requested the database queries being
> sent.

Hi,

  it's difficult to figure out what you need from your question, but
I'll make a wild guess that you need this:

https://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running

  HTH

Jirka

-- 
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.



database requests

2011-07-14 Thread NISA BALAKRISHNAN
how can i get the queries being passed while a page is being
requested? i mean when a view is requested the database queries being
sent.

-- 
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.