Re: form validation does not work

2008-12-30 Thread Alex Koshelev
Please post here entire view code


On Wed, Dec 31, 2008 at 8:18 AM, Chuck22  wrote:

>
> class ContactForm(forms.Form):
>  email = forms.EmailField(required=True,
> widget=forms.TextInput(attrs=
> {'size':'30'}),
>error_messages={'required':'Please fill
> out your Email'})
>  ...
>
> in my form html file:
> ...
> label for="id_full_name">Your email address
>{{ form.email.errors }}
>{{ form.email }}
> ...
>
> in my view:
> def contact(request):
>if request.method == 'POST':
>f = ContactForm(request.POST)
>if f.is_valid():
>email = f.cleaned_data['email']
>...
>return HttpResponseRedirect(reverse('contact_success'))
>
> When user submit the contact form without fill out email field, the
> form get submitted without displaying error message 'Please fill out
> your Email'. Instead, I got error: The view app.views.contact didn't
> return an HttpResponse object.
>
> it seems f.is_valud return false, which is correct. But I think form
> validation should kick in at this point and return error message to
> {{ form.email.errors }} field in template. Why doesn't the validation
> work? Did I miss anything?
> >
>

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



form validation does not work

2008-12-30 Thread Chuck22

class ContactForm(forms.Form):
  email = forms.EmailField(required=True,
 widget=forms.TextInput(attrs=
{'size':'30'}),
error_messages={'required':'Please fill
out your Email'})
  ...

in my form html file:
...
label for="id_full_name">Your email address
{{ form.email.errors }}
{{ form.email }}
...

in my view:
def contact(request):
if request.method == 'POST':
f = ContactForm(request.POST)
if f.is_valid():
email = f.cleaned_data['email']
...
return HttpResponseRedirect(reverse('contact_success'))

When user submit the contact form without fill out email field, the
form get submitted without displaying error message 'Please fill out
your Email'. Instead, I got error: The view app.views.contact didn't
return an HttpResponse object.

it seems f.is_valud return false, which is correct. But I think form
validation should kick in at this point and return error message to
{{ form.email.errors }} field in template. Why doesn't the validation
work? Did I miss anything?
--~--~-~--~~~---~--~~
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: Calendar

2008-12-30 Thread Praveen

I want a calendar on simple html page.. i do now want to use widget.
In a plain html page how we may display calendar.

Karen Tracey wrote:

> On Tue, Dec 30, 2008 at 7:51 AM, Praveen 
> wrote:
>
> >
> > Hi All,
> > I want to use calendar in my html template as the default admin
> > interface uses.
> >
>
> http://docs.djangoproject.com/en/dev/topics/forms/media/#form-media
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model fields and arrays?

2008-12-30 Thread schwim

I'm trying to build a model that will store the counts of each of 10
possible choices, e.g.:

v1 = models.IntegerField(default=0)
v2 = models.IntegerField(default=0)
v3 = models.IntegerField(default=0)
...
v10 = models.IntegerField(default=0)

I'd prefer to represent this as an array rather than 10 separate
fields.  I looked at the CommaSeparatedIntegerField as an alternative,
but I want to explicitly state that there are 10 entries available per
instance.

Any suggestions on how this can be done, or perhaps a better way to
solve this puzzle?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



specify alternative settings.py file at startup

2008-12-30 Thread dick...@gmail.com

i'm confused on the --settings option on manage.py.

if i have a project call foo, i'd have in ./foo/settings.py

to run: python manage.py runserver 8080

let's say i have a bar.settings.py which contains different values
(like test database to use or something), i'm trying to run:

python manage.py runserver --settings=bar.settings 8080 (and maybe
combintations of), but keep getting some derivations of: "Could Not
Import settings...is it on the sys.path, no module named bar.settings.

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: Looking for Django tutorial that illustrates master/detail data models

2008-12-30 Thread ldm999

Thanks for your response.

I should have been more clear. I'm looking for examples of views/forms
to manage the children of a parent child model. Eg how to add/change/
delete a book on a book list.

I don't recall the Django tutorial covering this and I just looked
again. It appears to focus more on the Django Admin than on custom
forms. And what it does cover wrt forms seems mostly focused on a form
for a stand-alone model rather than the child of a prent model where
you need the context of the parent to make sure you add a new item to
the right parent, and edit/delete the correct item based on its
parent.

I'll take another detailed look at the official tutorial to see if
this is covered.

On Dec 30, 6:02 pm, Daniel Roseman 
wrote:
> On Dec 30, 8:22 pm, ldm999  wrote:
>
> > Eg:
> > Lists (books, movies, restaurants) and multiple items per list.
>
> > Web forms would allow user to:
> > - Add/change/delete lists
> > - Add/change/delete list items
>
> > TIA
>
> Have you actually read the tutorial on the Django site? The Poll
> application covers exactly this.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: one server, multiple sites...

2008-12-30 Thread garagefan

figured out the issue was with the * not including a port :)

now, pages aren't actually working...


NameVirtualHost *:80

ServerName www.site.net

  
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/home/site'] + sys.path"


SetHandler None


SetHandler None




On Dec 30, 8:14 pm, garagefan  wrote:
> and i don't want one to access another's django installation...
>
> and the following doesn't seem to work
> NameVirtualHost *
>
> 
>     ServerNamewww.website.net
>     
>         SetHandler python-program
>         PythonHandler django.core.handlers.modpython
>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>         PythonOption django.root /mysite
>         PythonDebug On
>         PythonPath "['/home/site'] + sys.path"
>     
>     
>         SetHandler None
>     
>     
>         SetHandler None
>     
> 
>
> and this is the error i get:  VirtualHost _default_:443 -- mixing *
> ports and non-* ports with a NameVirtualHost address is not supported,
> proceeding with undefined results
--~--~-~--~~~---~--~~
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: Ordering ForeignKey lists in admin change view

2008-12-30 Thread Daniel Roseman

On Dec 30, 7:15 am, janedenone  wrote:
> Hi,
>
> this must be really simple, but all the references to ordering fields
> did not explain how to do this: How can I change the order of entries
> in foreign key lists in the admin change view?
>
> Kind regards,
> Jan

Django will just use the default ordering for the related model. You
can change it for all uses of that model by using the 'ordering'
option in the model's inner Meta class.

If you need to change the order just for a foreign key list, while
leaving the model's default order alone, you can do it by defining a
custom form for the admin change view, override the definition of the
foreign key field on that form, passing it a queryset ordered the way
you want.

For example:

class MyCustomForm(forms.ModelForm):
my_foreign_key = forms.ModelChoiceField
(queryset=MyRelatedModel.objects.order_by('my_order'))

class MyCustomAdmin(admin.ModelAdmin):
form = MyCustomForm

admin.site.register(MyModel, MyCustomAdmin)

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



Re: Getting SQL from QuerySet

2008-12-30 Thread Russell Keith-Magee

On Wed, Dec 31, 2008 at 5:11 AM, Info Cascade
 wrote:
>
> Hi --
>
> I am getting intermittent errors on certain database queries on our
> production server.
> I am having a hard time duplicating them (most of the time they run
> okay, only sometimes on the production server am I receiving exception
> messages),
> so I want to log the SQL query itself and see what it is, and why it
> might be failing.
> Is there some way of seeing what SQL statement will be executed by a
> QuerySet before actually executing it?

Yes. If you have the query:

>>> Author.objects.filter(...)

then the following:

>>> print Author.objects.filter(...).query.as_sql()

will print the SQL that results from the query.

Another approach is to inspect the query log. If debug is enabled in
your settings, then:

>>> from django.db import connection
>>> connection.queries

will print a list of all queries that have been passed to the database.

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: Getting SQL from QuerySet

2008-12-30 Thread flo...@gmail.com

I think that

>>> print my_query_set.query.as_sql()

should do the trick.

Thanks,
Eric Florenzano

On Dec 30, 12:11 pm, Info Cascade 
wrote:
> Hi --
>
> I am getting intermittent errors on certain database queries on our
> production server.
> I am having a hard time duplicating them (most of the time they run
> okay, only sometimes on the production server am I receiving exception
> messages),
> so I want to log the SQL query itself and see what it is, and why it
> might be failing.
> Is there some way of seeing what SQL statement will be executed by a
> QuerySet before actually executing it?
> I've also set up logging on the database side, so I can look there as well.
> Any other ideas for how I might debug this?  See anything wrong with the
> queries?
> I do need to know the total number of articles returned, and .count() is
> the recommended way of doing that. In most cases I'm slicing the
> QuerySet after getting the count.
>
> Any help would be very much appreciated!
>
>  ~Liam
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 
> 86, in get_response
>     response = callback(request, *callback_args, **callback_kwargs)
>
>   File "/var/www/vhosts/site.com/django/obsidian/obs/views.py", line 219, in 
> index
>     radius=radius, order_by='distance')
>
>   File "/var/www/vhosts/site.com/django/obsidian/obs/data_access.py", line 
> 551, in search
>     art_result_count = art_list.count()
>
>   File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 
> 296, in count
>     return self.query.get_count()
>
>   File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py", line 
> 237, in get_count
>     data = obj.execute_sql(SINGLE)
>
>   File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py", line 
> 1734, in execute_sql
>     cursor.execute(sql, params)
>
> InternalError: current transaction is aborted, commands ignored until end of 
> transaction block
>
> The code looks like this:
>
>  if term:
>
>             if pnt:
>
>                 art_list = Article.objects.filter(\
>
>                     status='PUBLISHED')\
>
>                     .extra(where=["title_tsv @@ plainto_tsquery(%s)"], 
> params=[term])\
>
>                     .distance(pnt)\
>                     .order_by(*order_by)
>
>             else:
>
>                 art_list = Article.objects.extra (\
>
>                     where=['title_tsv @@ plainto_tsquery(%s) AND 
> status=%s'],params=[term,'PUBLISHED'])\
>
>                     .order_by(*order_by)
>
>         elif search_origin:
>
>             try:
>
>                 art_list = Article.objects.filter(status='PUBLISHED',\
>
>                     point__distance_lte=(pnt,D(km=radius))).distance(pnt)\
>
>                     .order_by(*order_by)
>
>             except Exception, e:
>
>                 raise
>
>         else:      
>
>             raise
>
> The exception comes when I execute the query by getting the count
>
>  art_result_count = art_list.count()
>  if rows:
>      art_list = art_list[start:start+rows]
--~--~-~--~~~---~--~~
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 serializers and local/inherited model fields

2008-12-30 Thread Russell Keith-Magee

On Wed, Dec 31, 2008 at 4:27 AM, psj  wrote:
>
> Django's base serializers only serialize a model's local fields, not
> inherited ones, which seems odd at first blush (if an Employee is a
> Person, and a Person has a name, wouldn't I be likely to want to see
> the Employees' names by default?)
>
> This looks straightforward to work around, but just wondering if
> there's some gotcha I'm not thinking of here. Was this a performance
> decision?

This is one of the areas that reveals that serialization is a bit of a
'one-trick pony'. Serialization works really well for fixtures, but it
isn't particularly flexible when it comes to other serialization use
cases. In this case, the serializers are serializing exactly what the
database requires - the output is a JSON representation of the
database table contents.

The primary reason for this is the deserialization process. If you
include the 'Person' attributes on a serialized Employee, it becomes
more complex to determine whether you need to create a new Person
object when deserializing the Employee, and to disable creation of the
parent object instance when it isn't required. So - if you want to
fully serialize an Employee, you also need to serialize the underlying
Person object as well, and each model is responsible for serializing
their own attributes.

Expanding the usefulness of the serializers is something that we would
like to address. If you search the ticket database, you will find many
suggestions floating around for improving the capabilities of the
serialization process. However, it's not a trivial problem, and it
will take some serious design work. Any offers to help out in this
area would be gratefully accepted.

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: Looking for Django tutorial that illustrates master/detail data models

2008-12-30 Thread Daniel Roseman

On Dec 30, 8:22 pm, ldm999  wrote:
> Eg:
> Lists (books, movies, restaurants) and multiple items per list.
>
> Web forms would allow user to:
> - Add/change/delete lists
> - Add/change/delete list items
>
> TIA

Have you actually read the tutorial on the Django site? The Poll
application covers exactly this.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Looking for Django tutorial that illustrates master/detail data models

2008-12-30 Thread ldm999

Eg:
Lists (books, movies, restaurants) and multiple items per list.

Web forms would allow user to:
- Add/change/delete lists
- Add/change/delete list items

TIA

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



one server, multiple sites...

2008-12-30 Thread garagefan

and i don't want one to access another's django installation...

and the following doesn't seem to work
NameVirtualHost *


ServerName www.website.net

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/home/site'] + sys.path"


SetHandler None


SetHandler None



and this is the error i get:  VirtualHost _default_:443 -- mixing *
ports and non-* ports with a NameVirtualHost address is not supported,
proceeding with undefined results


--~--~-~--~~~---~--~~
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: working with shp files and geodjango

2008-12-30 Thread Justin Bronn

The numbers have different values because the shapefiles have data in
different coordinate systems.  It looks like the data for that
shapefile is actually for the 3435 SRID: 
http://spatialreference.org/ref/epsg/3435/
(3084 a NAD83 projection for all of Texas!).

Unfortunately, most shapefiles don't explicitly label their SRID in
their projection information.  However, by reading the spatial
reference text ("Layer SRS WKT"), and using spatialreference.org, one
can be quite successful in figuring out what SRID it corresponds to.
Your fortunate that this file came with projection information, as it
is not included with some shapefile datasets -- making it
significantly more difficult to determine the coordinate system.

Regards,
-Justin

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



manage.py test without using a database?

2008-12-30 Thread Bo Shi

Hi,

One of our django applications does not use django's ORM.  Is there a
way to run

./manage.py test my_app

Such that it does not perform test database setup?


Thanks,
Bo
--~--~-~--~~~---~--~~
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: Configuring mod_python and Djano on Apache2

2008-12-30 Thread Graham Dumpleton



On Dec 31, 8:41 am, tosh  wrote:
> it depends on the url structure of your site really
>
> if you don't need your django site to load from the root you could
> just do something like
>
> 
>     SetHandler None
> 

Don't need SetHandler None at root needed if mounting at sub URL. In
fact this may cause other things to stop working.

Graham

> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE Test.settings
>     PythonPath "['/home/YOUR_USERNAME/django_projects'] + sys.path"
> 
>
> On Dec 29, 2:23 pm, webhopper  wrote:
>
> > Hello,
>
> > I am a new fan of Django. Enjoying the learning process. The tutorial
> > documentation is great. Where I am stuck is on how to move my
> > development project onto my public website which sits on Ubuntu 8.10.
>
> > I was able to configure mod_python and tell it where to find my Django
> > project and templates. Found this 
> > bloghttp://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-li...
> > useful.
>
> > This is what I had in apache2.conf:
>
> > 
> >     SetHandler python-program
> >     PythonHandler django.core.handlers.modpython
> >     SetEnv DJANGO_SETTINGS_MODULE Test.settings
> >     PythonPath "['/home/YOUR_USERNAME/django_projects'] + sys.path"
> > 
>
> > This works and I can see my Django site working. But here is  the
> > problem. I have other stuff like MovableType running on same web
> > server, which I do not want to disrupt.
>
> > The way Apache gets configured if I follow instructions above seems to
> > be that EVERYTHING is seen by mon_python first and I am being required
> > to list all context roots that should NOT be handled by mod_python.
> > See for example below:
>
> > 
> >     SetHandler None
> > 
>
> > This is painful and does not scake as I consolidate more on same
> > server.
>
> > Is there a way top configure mod_python better?
>
> > Thanks in advance for any advice
>
> > Best
>
> > Sreeram
--~--~-~--~~~---~--~~
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: Configuring mod_python and Djano on Apache2

2008-12-30 Thread tosh

it depends on the url structure of your site really

if you don't need your django site to load from the root you could
just do something like


SetHandler None



SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE Test.settings
PythonPath "['/home/YOUR_USERNAME/django_projects'] + sys.path"




On Dec 29, 2:23 pm, webhopper  wrote:
> Hello,
>
> I am a new fan of Django. Enjoying the learning process. The tutorial
> documentation is great. Where I am stuck is on how to move my
> development project onto my public website which sits on Ubuntu 8.10.
>
> I was able to configure mod_python and tell it where to find my Django
> project and templates. Found this 
> bloghttp://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-li...
> useful.
>
> This is what I had in apache2.conf:
>
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE Test.settings
>     PythonPath "['/home/YOUR_USERNAME/django_projects'] + sys.path"
> 
>
> This works and I can see my Django site working. But here is  the
> problem. I have other stuff like MovableType running on same web
> server, which I do not want to disrupt.
>
> The way Apache gets configured if I follow instructions above seems to
> be that EVERYTHING is seen by mon_python first and I am being required
> to list all context roots that should NOT be handled by mod_python.
> See for example below:
>
> 
>     SetHandler None
> 
>
> This is painful and does not scake as I consolidate more on same
> server.
>
> Is there a way top configure mod_python better?
>
> Thanks in advance for any advice
>
> Best
>
> Sreeram
--~--~-~--~~~---~--~~
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: Test database is not getting created.

2008-12-30 Thread sudha

yes. there was only .pyc file . Ie for settings.py.

On Dec 30, 3:29 pm, "Karen Tracey"  wrote:
> On Tue, Dec 30, 2008 at 2:49 PM, sudha  wrote:
>
> > I'm a total newbie to django. I have to test some of ui models. When I
> > run manage.py test; Django complains as follows:
> > File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 35,
> > in defaulterrorhandler
> > _mysql_exceptions.OperationalError: (1059, "Identifier name
> > 'x_id_refs_xxx_item_display_id_45c0d1896de52687'
> > is too long")
>
> > 1. I got a sqldump using manage.py sqlall app > app.sql
> > 2.dropped the database and recreated it. Also deleted all references
> > to "" from admin.py and removed the file from models
> > directory.deleted other references too.
> > 3.Now edited all tables referring to "xx" ...(I just want this
> > work once!)
> > 4.sourced the saved sql file back to the database.
> > 5.when i reran the tests, It still complains about the "x" issue.
>
> > I even verified the settings file.
>
> > I am so totally confused. How's django creating the tables that were
> > deleted from the database, models,admin etc. defnitely there's some
> > settings issue. What am doing wrong. Can someone pls point me in the
> > right direction?
>
> > Many Thanks
>
> Sounds like:
>
> http://code.djangoproject.com/ticket/1820
>
> In the absence of a fix for that, the only way mentioned in that ticket to
> avoid the problem is to use shorter class names in your code.  It sounds
> like perhaps you tried to do that, though the fact that you are using
> 'x' in place of the presumably real names involved here makes that
> somewhat less than clear to me.  It sounds like you tried to delete all
> classes that may have had names that were too long?  Did you also delete the
> .pyc files?
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



FormWizard: Setting up a ChoiceField.choices based on previous forms,

2008-12-30 Thread Ariel Mauricio Nunez Gomez
Hello list,
Today I started using FormWizard and could not find a clean way to populate
a choices field based on previously submitted forms, I ended up overriding
the render method like this(The only changed line is the one highlited):
{{{
class CountryForm(forms.Form):
country = forms.ModelChoiceField(queryset=Country.objects.all())

class StaterForm(forms.Form):
state = forms.ChoiceField()

class LocationFormWizard(forms.Form):
  def process_step(self, request, form, step):
if step == 0 and form.is_valid():
self.state_choices= states_from_country(form.data['0-country'])

def prepare_form(self, request, form, step):
if step == 1:
form.fields['state'].choices = self.state_choices
return form

def render(self, form, request, step, context=None):
"Renders the given Form object, returning an HttpResponse."
old_data = request.POST
prev_fields = []
form = self.prepare_form(request,form, step)
if old_data:
hidden = forms.HiddenInput()
# Collect all data from previous steps and render it as HTML
hidden fields.
for i in range(step):
old_form = self.get_form(i, old_data)
hash_name = 'hash_%s' % i
prev_fields.extend([bf.as_hidden() for bf in old_form])
prev_fields.append(hidden.render(hash_name,
old_data.get(hash_name, self.security_hash(request, old_form
return self.render_template(request, form, ''.join(prev_fields),
step, context)
}}}

Is there a hook missing to do what I needed or am I missing something?

Ariel

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



building an application interface

2008-12-30 Thread Michael

hi guys

i would like to build an application interface in a given django
application using the ContentType class and GenericRelations. the
basic architecture shall be given by two tables: one organizing to be
plugged resources (Resources), i.e. tables of other apps, using a
ForeignKey(ContentType) field. this table should only be writeable to
a superuser.

whereas another table containing resource objects (ResourceObjects)
should refer to activated resources pulling the information about the
resource itself out of the Resource table and establish the
relationship between resource and any application-internal object.

doing so one had an manageable abstract application interface
separating manager and user functionalities.

but i do fail to construct the feed from the resource table to the
resourceobject table ...

does anyone understand my wish and is generously willing to help me?

thanks,
michael

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



Re: Test database is not getting created.

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 2:49 PM, sudha  wrote:

>
> I'm a total newbie to django. I have to test some of ui models. When I
> run manage.py test; Django complains as follows:
> File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 35,
> in defaulterrorhandler
> _mysql_exceptions.OperationalError: (1059, "Identifier name
> 'x_id_refs_xxx_item_display_id_45c0d1896de52687'
> is too long")
>
> 1. I got a sqldump using manage.py sqlall app > app.sql
> 2.dropped the database and recreated it. Also deleted all references
> to "" from admin.py and removed the file from models
> directory.deleted other references too.
> 3.Now edited all tables referring to "xx" ...(I just want this
> work once!)
> 4.sourced the saved sql file back to the database.
> 5.when i reran the tests, It still complains about the "x" issue.
>
> I even verified the settings file.
>
> I am so totally confused. How's django creating the tables that were
> deleted from the database, models,admin etc. defnitely there's some
> settings issue. What am doing wrong. Can someone pls point me in the
> right direction?
>
> Many Thanks
>

Sounds like:

http://code.djangoproject.com/ticket/1820

In the absence of a fix for that, the only way mentioned in that ticket to
avoid the problem is to use shorter class names in your code.  It sounds
like perhaps you tried to do that, though the fact that you are using
'x' in place of the presumably real names involved here makes that
somewhat less than clear to me.  It sounds like you tried to delete all
classes that may have had names that were too long?  Did you also delete the
.pyc files?

Karen

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



Re: Inline problem in Postgres but not MySQL

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 2:37 PM, Peter  wrote:

> > (You don't say what version of Django you are using.)
>
> Sorry - 1.0 final
>
> > What you describe
> > sounds similar to a few problems that have been reported.
>
> Ah yes. I looked. Thanks. Nasty.
>
> > but I believe the only way to
> > completely ensure you do not see this issue with PostgreSQL at present is
> to
> > include a default ordering for your inlined model.
>
> Well I have updated to 1.1 pre-alpha SVN-9692' and the issue has been
> fixed. You say to
> include a default ordering "for your inlined model". Can you show me
> on the model I supplied
> how I should do this. It does include an ordering already but I
> presume not the right one?
>
> Thanks for yur help here - an amazing list this.
>
>
Sorry, I missed that you had included an ordering for Telephone. If that
ordering provides a unique sequence (no duplicate phone_numbers) then I am
not sure you are hitting the problem I was thinking of.  If the specified
ordering can result in the same set of rows being returned by the DB in
different orders (due to duplicates in the ordering field) for different
calls, then I think to ensure you don't hit the problem you need to include
a field in ordering such as the primary key to guarantee that each time the
set is returned it is in the same order.

So, I'm not sure if you were hitting the problem I was thinking of.  If
updating to current trunk level has made it go away then you might have been
running into something entirely different that was fixed between 1.0 and
now.  Unfortunately right now I do not have time to experiment with your
models and say with any more certainty what was/is going on

Karen

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



Re: Joining models on M2M field

2008-12-30 Thread Andre P LeBlanc

I think what you're trying to do can be accomplished with the
queryset's .extra() method.
something like
Level.objects.all().extra(select={'unlocked':'count(**matching rows in
the join table**) > 0'})

-Andre
On Dec 30, 7:04 am, Deniz Dogan  wrote:
> Hi
>
> I have a user profile which has a many-to-many relationship to a model
> Level. The relationship is called "unlocked" and says which levels a
> specific user has unlocked. Now I wish to retrieve all the levels but
> "joined" with the user's unlocked levels, so that I get a QuerySet
> containing exactly Level.objects.all() but with an extra column called
> "unlocked" which is True if the user has unlocked that level and False
> otherwise.
>
> Is there any way to accomplish this without using explicit SQL?
>
> Any help appreciated,
> Deniz
--~--~-~--~~~---~--~~
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 SQL from QuerySet

2008-12-30 Thread Info Cascade

Hi --

I am getting intermittent errors on certain database queries on our
production server.
I am having a hard time duplicating them (most of the time they run
okay, only sometimes on the production server am I receiving exception
messages),
so I want to log the SQL query itself and see what it is, and why it
might be failing.
Is there some way of seeing what SQL statement will be executed by a
QuerySet before actually executing it?
I've also set up logging on the database side, so I can look there as well.
Any other ideas for how I might debug this?  See anything wrong with the
queries?
I do need to know the total number of articles returned, and .count() is
the recommended way of doing that. In most cases I'm slicing the
QuerySet after getting the count.

Any help would be very much appreciated!

 ~Liam

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 
86, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/var/www/vhosts/site.com/django/obsidian/obs/views.py", line 219, in 
index
radius=radius, order_by='distance')

  File "/var/www/vhosts/site.com/django/obsidian/obs/data_access.py", line 551, 
in search
art_result_count = art_list.count()

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 296, 
in count
return self.query.get_count()

  File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py", line 
237, in get_count
data = obj.execute_sql(SINGLE)

  File "/usr/lib/python2.4/site-packages/django/db/models/sql/query.py", line 
1734, in execute_sql
cursor.execute(sql, params)

InternalError: current transaction is aborted, commands ignored until end of 
transaction block



The code looks like this:

 if term:

if pnt:

art_list = Article.objects.filter(\

status='PUBLISHED')\

.extra(where=["title_tsv @@ plainto_tsquery(%s)"], 
params=[term])\

.distance(pnt)\
.order_by(*order_by)


else:

art_list = Article.objects.extra (\

where=['title_tsv @@ plainto_tsquery(%s) AND 
status=%s'],params=[term,'PUBLISHED'])\

.order_by(*order_by)

elif search_origin:

try:

art_list = Article.objects.filter(status='PUBLISHED',\

point__distance_lte=(pnt,D(km=radius))).distance(pnt)\

.order_by(*order_by)

except Exception, e:

raise

else:   

raise


The exception comes when I execute the query by getting the count

 art_result_count = art_list.count()
 if rows:
 art_list = art_list[start:start+rows]




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



Test database is not getting created.

2008-12-30 Thread sudha

I'm a total newbie to django. I have to test some of ui models. When I
run manage.py test; Django complains as follows:
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 35,
in defaulterrorhandler
_mysql_exceptions.OperationalError: (1059, "Identifier name
'x_id_refs_xxx_item_display_id_45c0d1896de52687'
is too long")

1. I got a sqldump using manage.py sqlall app > app.sql
2.dropped the database and recreated it. Also deleted all references
to "" from admin.py and removed the file from models
directory.deleted other references too.
3.Now edited all tables referring to "xx" ...(I just want this
work once!)
4.sourced the saved sql file back to the database.
5.when i reran the tests, It still complains about the "x" issue.

I even verified the settings file.

I am so totally confused. How's django creating the tables that were
deleted from the database, models,admin etc. defnitely there's some
settings issue. What am doing wrong. Can someone pls point me in the
right direction?

Many 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: unable to access another field in cleaned_data from clean_

2008-12-30 Thread hotani

Thanks Karen - I think that got it. At least it's looking better than
it has been. Apparently the missing field from 'cleaned_data' was
caused by the wonky way I had it set up before.
--~--~-~--~~~---~--~~
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: Inline problem in Postgres but not MySQL

2008-12-30 Thread Peter


> (You don't say what version of Django you are using.)

Sorry - 1.0 final

> What you describe
> sounds similar to a few problems that have been reported.

Ah yes. I looked. Thanks. Nasty.

> but I believe the only way to
> completely ensure you do not see this issue with PostgreSQL at present is to
> include a default ordering for your inlined model.

Well I have updated to 1.1 pre-alpha SVN-9692' and the issue has been
fixed. You say to
include a default ordering "for your inlined model". Can you show me
on the model I supplied
how I should do this. It does include an ordering already but I
presume not the right one?

Thanks for yur help here - an amazing list this.

-- Peter


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



Re: Inline problem in Postgres but not MySQL

2008-12-30 Thread Peter

Thank you Ana, I checked that out - but I don't understand how it
works (at least not without looking at the
other models).

Is Django less solid with Django than MySQL?  I mean my example is a
trivial 'text book' example
and it did not work with PostgreSQL

-- Peter

On Dec 30, 6:49 pm, Ana  wrote:
> Hello Peter,
>
> I use Postgres and have success creating a manytomany table.  See:
>
> http://dpaste.com/103824/
>
> Ana
>
> On Dec 30, 10:29 am, Peter  wrote:
>



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



Django serializers and local/inherited model fields

2008-12-30 Thread psj

Django's base serializers only serialize a model's local fields, not
inherited ones, which seems odd at first blush (if an Employee is a
Person, and a Person has a name, wouldn't I be likely to want to see
the Employees' names by default?)

This looks straightforward to work around, but just wondering if
there's some gotcha I'm not thinking of here. Was this a performance
decision?

Thanks,
psj

--~--~-~--~~~---~--~~
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: unable to access another field in cleaned_data from clean_

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 2:21 PM, hotani  wrote:

>
> -- Update --
>
> If I make the clean method for 'county', it works. I guess county
> comes after case_no so both are accessible by that time. Weird, but I
> can deal with it. However, that brings me to the 2nd issue with this
> process: Whatever is accessed in the clean method is no longer
> accessible for writing to the database.
>
> If the form clears - everything checks out and I'm ready to write the
> data, "county" is no longer available and a ValueError is returned
> because the field does not accept NULL values. I know I'm missing
> something here, and the docs are terribly sparse on this topic.
>

For multi-field validation, please read:

http://docs.djangoproject.com/en/dev/ref/forms/validation/

especially:

http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other

I do not know what this second problem you are referring to is.  If the form
passes validation than it doesn't make any sense that some of the data
"isn't accessible".  Some examples of the code you are trying may help
pinpoint what is going wrong.

Karen

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



Re: Looking for Django-Pinax developers for music production community

2008-12-30 Thread James Matthews
Thank you for your interest in Django. You may also post this job offer on
djangogigs.com

Much Success
James

On Mon, Dec 29, 2008 at 8:00 PM, Pancrazio wrote:

>
> Hi group!
>
> we are a startup working on a community-based music production
> website.
>
> We are looking for Django developers with some expertise in Pinax
> applications and Posgresql database backend.
>
> Knowledge of Ajax programming and frameworks like jQuery will be
> appreciated as well as playing any musical instrument.
>
>
> Please, send an email to j...@buskerlabel.com
>
>
> Thanks for your attention,
>
> Pancrazio and Giulio
> Buskerlabel Srl
>
>
>
>
>
>
> >
>


-- 
http://www.astorandblack.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: Django with shared host FastCGI

2008-12-30 Thread James Matthews
Which host are you using? I am on dreamhost and it works very nice. also try
searching on google your hosts name and django to see if someone created a
tutorial on it.

On Tue, Dec 30, 2008 at 12:57 AM, James Gregory  wrote:

>
> I tried using the guide here:
> http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/?from=olddocs
>
> to set up Django using FastCGI.
>
> 1. It kept just hanging with a never ending loading cursor whenever I
> tried going to the fcgi page. I eventually discovered, through immense
> trial and error, that it worked fine if I removed the line "AddHandler
> fastcgi-script .fcgi" from the htaccess file.
>
> 2. As well as adding the directory with python in to sys.path, I found
> I also had to add my project directory and also the project beneath my
> project directory (the latter I think because it is necessary to
> import mysite.settings)
>
> So Is the documentation wrong? Or have I done something wrong and
> somehow fluked getting it to work anyway? Or something else?
>
> >
>


-- 
http://www.astorandblack.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: unable to access another field in cleaned_data from clean_

2008-12-30 Thread hotani

-- Update --

If I make the clean method for 'county', it works. I guess county
comes after case_no so both are accessible by that time. Weird, but I
can deal with it. However, that brings me to the 2nd issue with this
process: Whatever is accessed in the clean method is no longer
accessible for writing to the database.

If the form clears - everything checks out and I'm ready to write the
data, "county" is no longer available and a ValueError is returned
because the field does not accept NULL values. I know I'm missing
something here, and the docs are terribly sparse on this topic.
--~--~-~--~~~---~--~~
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: Sending id to new template - beginners confusion

2008-12-30 Thread Ana

Hello Ramdas,

Thanks!  I will work on it.

Ana

On Dec 30, 10:54 am, "Ramdas S"  wrote:
> The models need to be rewritten. It might be a better idea use a DateField,
> you need to not worry about having a seperate foreignkey for month and year.
>
> Try using a slug, instead of searching based pubtitles. Check the models
> documentation, it will help you.
>
> Here are some tips, pubtitle, pubauthors can be CharField. Have an extra
> field called  slug, a slugfield which will be slugified from the title.
>
> Your view is searching for an object based on id. If you want to put it up
> based on title , which I wont recommend, you need to
>
> def search_detail(request, pubtitle):
>     p = get_object_or_404(Publication, pubtitle=pubtitle)
>     return render_to_response('search_detail.html', {'publication': p})
>
> Instead search for slug (read the docs)
>
> def search_detail(request, slug):
>
>     p = get_object_or_404(Publication,slug =slug)
>
>     return render_to_response('search_detail.html', {'publication': p})
>
> urls will be something like
>
> search_detail/(?P[0-9A-Za-z-]+)/$
>
> search_detail/my-new-story/ will give you the results you require.
>
> Anna IMHO you need to do some more reading before you code
> constructively. Just search and google there are enough examples to go
> thru
>
>
>
> On Wed, Dec 31, 2008 at 12:06 AM, Ana  wrote:
>
> > Hello Ramdas,
>
> > The model is here:  http://dpaste.com/103815/
>
> > The URL is here:  http://dpaste.com/103816/
>
> > I've got quite a mess trying to figure out how to move between
> > templates.  I'm having a very hard time finding practical examples of
> > this stage of Django.  The admin and database piece was very well
> > documented and I had that part up and running in a few days.
>
> > Thanks,
>
> > Ana
>
> > On Dec 30, 10:27 am, "Ramdas S"  wrote:
> > > fsafety/search_detail283, this does not make sense. Your regular
> > > expression in urls clearly is looking for a number. Can you dpaste the
> > > models and urls.py also
>
> > > Thanks
>
> > > Ramdas
>
> > > On Tue, Dec 30, 2008 at 11:23 PM, Ana  wrote:
>
> > > > Hello,
>
> > > > Please see the following:
>
> > > >http://dpaste.com/103798/
>
> > > > Thank you,
>
> > > > Anna
>
> > > --
> > > Ramdas S
> > > +91 9342 583 065
>
> --
> Ramdas S
> +91 9342 583 065
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



unable to access another field in cleaned_data from clean_

2008-12-30 Thread hotani

I have 2 fields I'm working with in a custom clean method:
- case_no
- county

the clean method is for case_no, so I have this:
--
def clean_case_no(self):
  d = self.cleaned_data
  form_case_no = d['case_no']
  form_county = d['county']
  ...
--

The form fails with KeyError on 'county'. How else can I access this
field for the clean method? I tried using self.is_valid() before
accessing cleaned_data but no change.

--~--~-~--~~~---~--~~
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: Sending id to new template - beginners confusion

2008-12-30 Thread Ramdas S
The models need to be rewritten. It might be a better idea use a DateField,
you need to not worry about having a seperate foreignkey for month and year.

Try using a slug, instead of searching based pubtitles. Check the models
documentation, it will help you.

Here are some tips, pubtitle, pubauthors can be CharField. Have an extra
field called  slug, a slugfield which will be slugified from the title.

Your view is searching for an object based on id. If you want to put it up
based on title , which I wont recommend, you need to


def search_detail(request, pubtitle):
p = get_object_or_404(Publication, pubtitle=pubtitle)
return render_to_response('search_detail.html', {'publication': p})

Instead search for slug (read the docs)



def search_detail(request, slug):

p = get_object_or_404(Publication,slug =slug)

return render_to_response('search_detail.html', {'publication': p})


urls will be something like

search_detail/(?P[0-9A-Za-z-]+)/$


search_detail/my-new-story/ will give you the results you require.


Anna IMHO you need to do some more reading before you code
constructively. Just search and google there are enough examples to go
thru








On Wed, Dec 31, 2008 at 12:06 AM, Ana  wrote:

>
> Hello Ramdas,
>
> The model is here:  http://dpaste.com/103815/
>
> The URL is here:  http://dpaste.com/103816/
>
> I've got quite a mess trying to figure out how to move between
> templates.  I'm having a very hard time finding practical examples of
> this stage of Django.  The admin and database piece was very well
> documented and I had that part up and running in a few days.
>
> Thanks,
>
> Ana
>
> On Dec 30, 10:27 am, "Ramdas S"  wrote:
> > fsafety/search_detail283, this does not make sense. Your regular
> > expression in urls clearly is looking for a number. Can you dpaste the
> > models and urls.py also
> >
> > Thanks
> >
> > Ramdas
> >
> > On Tue, Dec 30, 2008 at 11:23 PM, Ana  wrote:
> >
> > > Hello,
> >
> > > Please see the following:
> >
> > >http://dpaste.com/103798/
> >
> > > Thank you,
> >
> > > Anna
> >
> > --
> > Ramdas S
> > +91 9342 583 065
> >
>


-- 
Ramdas S
+91 9342 583 065

--~--~-~--~~~---~--~~
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: Inline problem in Postgres but not MySQL

2008-12-30 Thread Ana

Hello Peter,

I use Postgres and have success creating a manytomany table.  See:

http://dpaste.com/103824/

Ana

On Dec 30, 10:29 am, Peter  wrote:
> I have two models: Person and Telephone. A person can have many
> telephones but a telephone belongs to at most one person. The models
> are:
>
> class Person(models.Model):
>     name = models.CharField(max_length=50)
>
>     def __unicode__(self):
>         return self.name
>
> class Telephone(models.Model):
>     phone_number = models.IntegerField()
>     phone_type = models.CharField(max_length=50, blank=False)
>     owner = models.ForeignKey(Person, blank=True, null=True)
>     ordering = ['+phone_number',]
>
>     def __unicode__(self):
>         return unicode(self.phone_number)
>
> In admin.py I have:
>
> class TelephoneInline(admin.TabularInline):
>     model = Telephone
>
> class PersonAdmin(admin.ModelAdmin):
>     inlines = [TelephoneInline,]
>     fk_name='owner'
> admin.site.register(Person, PersonAdmin)
>
> Using PostgreSQL this allows me a single phone number for a person. I
> can chnage and delete the number. However if I add more than one phone
> number I cannot change or delete numbers.
>
> Changing from PostgreSQL to MySQL this issue disappears.
>
> There is no useful error information I can access (just the default
> ValidationError). Has anyone any idea what this might be?
>
> -- Peter
--~--~-~--~~~---~--~~
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: Inline problem in Postgres but not MySQL

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 1:29 PM, Peter  wrote:

>
> I have two models: Person and Telephone. A person can have many
> telephones but a telephone belongs to at most one person. The models
> are:
>
> [snipped]
> Using PostgreSQL this allows me a single phone number for a person. I
> can chnage and delete the number. However if I add more than one phone
> number I cannot change or delete numbers.
>
> Changing from PostgreSQL to MySQL this issue disappears.
>
> There is no useful error information I can access (just the default
> ValidationError). Has anyone any idea what this might be?
>

(You don't say what version of Django you are using.)  What you describe
sounds similar to a few problems that have been reported.  See #9006, #9076,
#9758.  You are less likely to hit the problem with the change that went in
for #9076 (I think that's included in 1.0.2) but I believe the only way to
completely ensure you do not see this issue with PostgreSQL at present is to
include a default ordering for your inlined model.

Karen

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



Re: Sending id to new template - beginners confusion

2008-12-30 Thread Ana

Hello Ramdas,

The model is here:  http://dpaste.com/103815/

The URL is here:  http://dpaste.com/103816/

I've got quite a mess trying to figure out how to move between
templates.  I'm having a very hard time finding practical examples of
this stage of Django.  The admin and database piece was very well
documented and I had that part up and running in a few days.

Thanks,

Ana

On Dec 30, 10:27 am, "Ramdas S"  wrote:
> fsafety/search_detail283, this does not make sense. Your regular
> expression in urls clearly is looking for a number. Can you dpaste the
> models and urls.py also
>
> Thanks
>
> Ramdas
>
> On Tue, Dec 30, 2008 at 11:23 PM, Ana  wrote:
>
> > Hello,
>
> > Please see the following:
>
> >http://dpaste.com/103798/
>
> > Thank you,
>
> > Anna
>
> --
> Ramdas S
> +91 9342 583 065
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Inline problem in Postgres but not MySQL

2008-12-30 Thread Peter

I have two models: Person and Telephone. A person can have many
telephones but a telephone belongs to at most one person. The models
are:

class Person(models.Model):
name = models.CharField(max_length=50)

def __unicode__(self):
return self.name

class Telephone(models.Model):
phone_number = models.IntegerField()
phone_type = models.CharField(max_length=50, blank=False)
owner = models.ForeignKey(Person, blank=True, null=True)
ordering = ['+phone_number',]

def __unicode__(self):
return unicode(self.phone_number)

In admin.py I have:

class TelephoneInline(admin.TabularInline):
model = Telephone

class PersonAdmin(admin.ModelAdmin):
inlines = [TelephoneInline,]
fk_name='owner'
admin.site.register(Person, PersonAdmin)

Using PostgreSQL this allows me a single phone number for a person. I
can chnage and delete the number. However if I add more than one phone
number I cannot change or delete numbers.

Changing from PostgreSQL to MySQL this issue disappears.

There is no useful error information I can access (just the default
ValidationError). Has anyone any idea what this might be?

-- Peter


--~--~-~--~~~---~--~~
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: Sending id to new template - beginners confusion

2008-12-30 Thread Ramdas S
fsafety/search_detail283, this does not make sense. Your regular
expression in urls clearly is looking for a number. Can you dpaste the
models and urls.py also

Thanks

Ramdas

On Tue, Dec 30, 2008 at 11:23 PM, Ana  wrote:

>
> Hello,
>
> Please see the following:
>
> http://dpaste.com/103798/
>
> Thank you,
>
> Anna
> >
>


-- 
Ramdas S
+91 9342 583 065

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



Sending id to new template - beginners confusion

2008-12-30 Thread Ana

Hello,

Please see the following:

http://dpaste.com/103798/

Thank you,

Anna
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Permissions: is something wrong with them?

2008-12-30 Thread Artem Skvira

Hi all,

I have some issues with django permissions model. Please bear in mind
that I have just started learning django so feel free to correct me if
I'm wrong :)

First of all it was hard to find how one can add a custom permission
to list of permissions of a model instance.
I ended up with a code like this:

from ... import model
...
c_type = ContentType.objects.get_for_model(model)
p = Permission.objects.get(codename=name, content_type=c_type)
user.user_permissions.add(p)

It does look like rather generic task to me, and If that is the right
way of doing that, it could be implemented as a helper function in
django, alongside with has_perm(), get_all_permissions() and others.
Or is there something like that already?

Second thing which I have problems understanding is a naming
convention for .has_perm() function parameter. Why for god's sake it
omits model name, including only package name and permission name?

Here is the quote from documentation:

has_perm(perm)
Returns True if the user has the specified permission, where 
perm is
in the format "package.codename"

It's easy to imagine a situation when one has got several custom
permissions with same name for different models within same package.
Is this going to cause some sort of conflict or wrong name resolution
when using has_perm()?

--~--~-~--~~~---~--~~
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: Calendar

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 7:51 AM, Praveen wrote:

>
> Hi All,
> I want to use calendar in my html template as the default admin
> interface uses.
>

http://docs.djangoproject.com/en/dev/topics/forms/media/#form-media

Karen

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



Re: Validate uniqueness in forms

2008-12-30 Thread Karen Tracey
On Tue, Dec 30, 2008 at 7:22 AM, janedenone wrote:

>
> Hi,
>
> I was looking for a way to customize the error message when trying to
> submit an existing value for a unique field (using a ModelForm).
> According to this request (http://code.djangoproject.com/ticket/8913),
> I am not the first one to look for such a feature, and I'm happy to
> wait for it.
>
> My current solution is quite inelegant, though:
>
> if register_form.errors.has_key('email') and (register_form._errors
> ['email'] == ['Customer with this E-Mail already exists.']):
>register_form._errors['email'] = ErrorList(['My custom error message
> goes here.'])
>
> But I also found this snippet (http://www.djangosnippets.org/snippets/
> 1228/ ), and the first
> comment confused me. I never had to pass an
> instance when instantiating the form - the is_valid() method created
> the desired error message and linked it to the appropriate field.
>
> Am I missing something?
>
>
You need instance if you are updating an already-existing object.  (From
memory, so I could be getting this slightly wrong) Django's uniqueness code
is going to query the database to see if any existing row in the DB has a
value that matches one that is declared unique.  If you are editing an
already-existing object and have not changed the value of the unique field
in question, the answer will be "yes", since the object is already in the
DB, and that "yes" answer will lead to a ValidationError since it appears
the new value being provided is not unique in the DB.   When you pass
instance in during form creation, however, then that instance in the DB will
be excluded from the check, so the query becomes "does any row besides this
one that we are in the process of updating have this value in this
column?".  This query provides the correct answer for uniqueness check when
you are dealing with an already-existing row in the DB.

Karen

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



Calendar

2008-12-30 Thread Praveen

Hi All,
I want to use calendar in my html template as the default admin
interface uses.

--~--~-~--~~~---~--~~
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: request.user is set to None

2008-12-30 Thread Roy

You might want to check if the context being passed to your template
is a regular Context or a RequestContext. Only RequestContexts have
the request.user available. Check the context_instance parameter in
render_to_response: 
http://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response

On Dec 30, 1:43 am, "Antoni Aloy"  wrote:
> 2008/12/29 madhav :
>
> >  As a part of django user authentication, when is request.user becomes
> > None?? As I have read in the docs, it will either
> > django.contrib.auth.User or AnonymousUser, but I am getting a very
> > weird error telling request.user is None. Please help me out. When I
> > am trying to call request.user.is_authenticated(), it is raising an
> > error telling request.user doesn't exist. I am using Django 1.0
> > (version:8961). Please help me out. :(
>
> Hello!
>
> If request.user  is None means that you don't have a user object, so
> you cant access to its properties.
> So double check that you have SessionMiddleware and
> AuthenticationMiddleware configured in your settings.py, and if it
> fails give more information about how you're accessing to the User
> object.
>
> Hope it helps!
>
> --
> Antoni Aloy López
> Blog:http://trespams.com
> Site:http://apsl.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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
-~--~~~~--~~--~--~---



Validate uniqueness in forms

2008-12-30 Thread janedenone

Hi,

I was looking for a way to customize the error message when trying to
submit an existing value for a unique field (using a ModelForm).
According to this request (http://code.djangoproject.com/ticket/8913),
I am not the first one to look for such a feature, and I'm happy to
wait for it.

My current solution is quite inelegant, though:

if register_form.errors.has_key('email') and (register_form._errors
['email'] == ['Customer with this E-Mail already exists.']):
register_form._errors['email'] = ErrorList(['My custom error message
goes here.'])

But I also found this snippet (http://www.djangosnippets.org/snippets/
1228/), and the first comment confused me. I never had to pass an
instance when instantiating the form - the is_valid() method created
the desired error message and linked it to the appropriate field.

Am I missing something?

Kind regards,
Jan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Ordering ForeignKey lists in admin change view

2008-12-30 Thread janedenone

Hi,

this must be really simple, but all the references to ordering fields
did not explain how to do this: How can I change the order of entries
in foreign key lists in the admin change view?

Kind regards,
Jan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Joining models on M2M field

2008-12-30 Thread Deniz Dogan

Hi

I have a user profile which has a many-to-many relationship to a model
Level. The relationship is called "unlocked" and says which levels a
specific user has unlocked. Now I wish to retrieve all the levels but
"joined" with the user's unlocked levels, so that I get a QuerySet
containing exactly Level.objects.all() but with an extra column called
"unlocked" which is True if the user has unlocked that level and False
otherwise.

Is there any way to accomplish this without using explicit SQL?

Any help appreciated,
Deniz
--~--~-~--~~~---~--~~
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: Admin form got a wrong action address via lighttpd with fastcgi.

2008-12-30 Thread khsing

I have got the reason.

just set FORCE_SCRIPT_NAME = '' in settings.py

On Tue, Dec 30, 2008 at 10:41 AM, khsing  wrote:
>
> I have done via this link 
> http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/
>
> The login form is appeared, but the action of login form is wrong.
>
> I think the action should be "/admin/", but I got "/nsman.fcgi/
> admin/". why?
>
> here is some configure files.
>
> * lighttpd.conf
>
> fastcgi.server = (
>"/nsman.fcgi" => (
>"main" => (
>"socket" => djp + "/nsman/nsman.sock",
>"check-local" => "disable",
>)
>),
> )
> alias.url = (
>"/media/" => "/usr/local/python25/lib/python2.5/site-packages/
> django/contrib/admin/media/",
> )
> url.rewrite-once = (
>"^(/media.*)$" => "$1",
>"^/favicon\.ico$" => "/media/favicon.ico",
>"^(/.*)" => "/nsman.fcgi$1"
> )
>
> * urls.py
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
> urlpatterns = patterns('',
>(r'^admin/(.*)', admin.site.root),
> )
>
> * login from section.
>
> 
> 
>  
>Username:  name="username" id="id_username" />
>  
>  
>Password:  name="password" id="id_password" />
>
>  
>  
>
>  
> 
>
> >
>



-- 
A man live in jail and want to break.
http://blog.khsing.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: select childless parents, i.e. base with no derived classes in model inheritance

2008-12-30 Thread Briel

The first query looks at the restaurant attribute in the place model,
and gets all that have a NULL value in that field. Now  I don't know
the restaurant/place setup, the docs I read uses book/auther examples.
It looks like that the restaurant field is ForeignKey, and should be
able to work the way intended. It would do a lookup for all places
that doen't have a restaurant object associate with it. But, if the
restaurant field is a BoolianField instead, then you can't use
is_null, as both True and False isn't Null.

Hope this helps, else be a little more explicit about the
relationships.

-Briel

On Dec 30, 5:23 am, pk  wrote:
> Alex,
>
> First I made a mistake in the original post. The first query returns
> *nothing*, not "all places". This is the correct "question:
>
> 1) print Place.objects.filter(restaurant__isnull=True).count()
>
> returns 0
>
> and 2) print Place.objects.filter
> (restaurant__serves_hotdog__isnull=True).count()
>
> works correctly, returning a count of all Places that is not a
> restaurant.
>
> The first query does not even join the child table. It tries to do:
>
> SELECT COUNT(*) FROM "place" WHERE "place"."id" IS NULL
>
> Where as the second query does a LEFT OUTER JOIN between parent and
> child table, then
> added a where clause to test for the hotdog field being null,
> essentially filtered out the rows
> that have no hotdog fields at all.
>
> Seems like query 1 is broken?
>
> P.K.
--~--~-~--~~~---~--~~
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 in runfcgi mode does not have log even is daemonize=false

2008-12-30 Thread Alex Koshelev
How do you put messages to log?


On Tue, Dec 30, 2008 at 7:08 AM, CG  wrote:

>
> Hi, all I am using Django 1.02 + lighttpd , and I run my django app in
> fastCGI mode using the following
>
>  runfcgi method=prefork socket=/tmp/socket.sock
> pidfile=/var/run/process.pid outlog=/var/log/lighttpd/out.log
>
> out.log is created but there is nothing inside.
>
> Later , I try with  daemonize=false, which suppose to be helpful in
> debugging
>
>  runfcgi daemonize=false method=prefork socket=/tmp/socket.sock
> pidfile=/var/run/process.pid
>
> However, even it run as foreground , it does not output anything on screen
> also.
>
>
> I have searched through the Google , and found not much info about
> this. Anybody can help ?
>
> Thanks.
>
> CG
>
> >
>

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



Django is generating requests that result in untyped binary data download in FF 3.0

2008-12-30 Thread alex kessinger

Hi,
  I am having a problem that seems like a ghost. I can find where it's
comming from. It doesn't happen all the time. But what happens is
sometimes when I go to a page. instead of loading the page, the
browsers askes me if I would like to download a file called untyped
binary data.

I am hosting the project on dreamhost. I am use fcgi.

I am starting the requests here  in a dispatch.fcgi

#!/home/mysite/opt/bin/python
import sys, os

from flup.server.fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler

# Add a custom Python path.
sys.path.insert(0, "/home/mysite/site_code")

# Switch to the directory of your project. (Optional.)
os.chdir("/home/mysite/site_code")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

WSGIServer(WSGIHandler()).run()


This is what the file looks like that it asks me to download

 

--~--~-~--~~~---~--~~
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: working with a returned object inside another class

2008-12-30 Thread Briel

Just a tip if you're not familiar with SQL, you can get django-
evolution. It works with syncdb, in that syncdb will detect when an
"evolution" of the db is needed like in the example above. It can't do
everything, but it can do a lot if things for you, with some simple
commands.

A second thing. [:1] will return a list with the first item only,
however, [1] will return not the first item, but the second item of
the list. If you want the first item, you should use [0] instead as
python like counting from 0.

On Dec 30, 5:36 am, garagefan  wrote:
> Thanks, that worked perfectly. right now i can lose the data as i'm
> still learning this all. I will have to look into editing the DB via
> the shell for future fixes
>
> On Dec 29, 11:20 pm, Daniel Roseman 
> wrote:
>
> > On Dec 29, 11:04 pm, garagefan  wrote:
>
> > > awesome... it was all in that [:1]!
>
> > > now, next issue...
>
> > > "OperationalError at /admin/galleries/gallery/
> > > (1054, "Unknown column 'galleries_gallery.status' in 'field list'")"
>
> > > i just added the status field as i wasn't worried about any of that
> > > previously... now, it appears to be causing issues. I've ran syncdb,
> > > but it doesn't seem to be adding this new column. I gather it is very
> > > very important to consider your required fields before syncing
> > > originally... how do i go about fixing this issue?
>
> > > thanks again
>
> > Syncdb doesn't modify existing tables. If you don't have any data you
> > need to keep, you can run
> > ./manage.py reset galleries
> > Note that this will completely delete and recreate your tables. If you
> > want to preserve existing data, you'll need to go into your database
> > shell (via ./manage.py dbshell) and run the SQL to modify your table
> > manually - something like
> > ALTER TABLE `galleries_gallery` ADD COLUMN `status` VARCHAR(1) NOT
> > NULL;
> > (guessing at the column definition, change as required).
>
> > --
> > DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---