Possible to use raw_admin_fields with inlineformset_factory for a create page?

2008-12-03 Thread Paul Childs

Hi folks,

I am a newforms newbie who is currently porting a .96 project over to
1.0

I have been trying to coerce the examples in the Django documentation
to
accommodate creating a "Document" .

I have three models:
Document, DocPart --> These are in the doc module. DocPart is an
intermediary
Part --> This is in the ipl module. There are hundreds of thousands of
parts.

<><><><><><><><><><>
Simplified models
--
class Document(models.Model):
number = models.CharField(max_length=30)
title = models.CharField(max_length=30)

class DocPart(models.Model):
part = models.ForeignKey(mysite.ipl.models.Part)
document = models.ForeignKey(Document)

# in mysite.ipl.models
class Part(models.Model):
number = models.CharField(max_length=30)
description = models.CharField(max_length=30)

<><><><><><><><><>
Forms
-
DocumentForm(ModelForm):
class Meta:
model = Document

<><><><><><><><><><><>
If the user visits the document create page for the first time, in the
view I use:

form = DocumentForm()
DocPartFormset = inlineformset_factory(Document, DocPart)
formset = DocPartFormset()
.
.
.
return render_to_response('document_form.html','form':form,
'formset':formset)

<><><><><><><><><><><>
As expected the page takes a very long time to load since each select
for the DocPart is filled with hundreds of thousands of part numbers.

Since the raw_id_admin has been separated out of the model in 1.0 how
do I get the inlineformset_factory to understand that I want to use
raw_admin_field for part?





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



Getting Form Field Values in a template

2008-12-12 Thread Paul Childs

I am converting from .96 to 1.0.

In a template using 0.96, if I wanted to get the value that a
particular field was holding I would use:
{{ form.data.field_name }}

This doesn't work anymore and is breaking my code.

I have tried a number of other ways (guessing mostly), consulted the
docs and browsed the Django source and still can't figure it out.

Can anyone help me out here?

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: Getting Form Field Values in a template

2008-12-12 Thread Paul Childs

Found answer here:
http://groups.google.com/group/django-users/browse_thread/thread/99f6fa5ce32dd824/460a1c563a3a851b?lnk=gst&q=template+form+values#460a1c563a3a851b

form.data.fieldname (this is pre-cleaned bound data)  ---> Did not
work
form.cleaned_data.fieldname (post clean if valid) ---> Didn't apply so
I didn't try it
form.initial.fieldname (values set for initial) ---> WORKED!!! Thank
you Doug B

On Dec 12, 12:47 pm, Paul Childs  wrote:
> I am converting from .96 to 1.0.
>
> In a template using 0.96, if I wanted to get the value that a
> particular field was holding I would use:
> {{ form.data.field_name }}
>
> This doesn't work anymore and is breaking my code.
>
> I have tried a number of other ways (guessing mostly), consulted the
> docs and browsed the Django source and still can't figure it out.
>
> Can anyone help me out here?
>
> 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
-~--~~~~--~~--~--~---



Session Object Dropping Key Value Pairs

2008-09-04 Thread Paul Childs

Django 0.96 / mySQL / Apache2 / Ubuntu 8.04

I have created a "wizard" for data input. Rather than have one huge
form I have spread it out over a number of views/templates. After the
user submits data and it has been validated, each view places the
"new_data" into the request.session and redirects the user to the next
form. On submission of the last form, all the data is retrieved from
session, objects are built and then saved.

The code works flawlessly but every so often it will start to
consistently throwing a KeyError exception on one of the following
lines:

data1 = request.session['new_data_1']
data3 = request.session['new_data_3']
data4 = request.session['new_data_4']

Each of the above should be there. I haven't seen this exception
thrown on my development machine, or the development server. Only on
our production box.

The exception is not always consistent. It could be a KeyError for any
of the keys. This was tested with the same data each time.

If I restart the web server and reenter the data it will work. The
problem seems to go away but will resurfaces after (in one case) 15
data entry sessions. This leads me to think that it might be a
hardware issue.

Can anybody suggest how I can pin down the cause of this?

Thanks in advance.


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



Getting Access to form.data from a template

2008-01-04 Thread Paul Childs

I am trying to get all the values from 'tail_number' in the form data
that gets passed to a template...

form.data (printed in view before response is sent back):


I know that if I want access to the tail numbers in a view I can just
do this:
form.data.getlist('tail_number')

I have tried a number of things like:

{% form.tail_number %}

and

{% for tn in form.data.tail_number %}
{{ tn }}
{% endfor %}

I always get '3' since I am just getting back a string.

Does anyone know how 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: An easier way to do this Pagination in a template?

2008-01-10 Thread Paul Childs

Take a look here too...

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



Re: Where's HttpRequest?

2008-02-14 Thread Paul Childs

Try reading these

http://www.djangoproject.com/documentation/request_response/
http://www.djangoproject.com/documentation/forms/

On Feb 14, 8:55 am, "Hanne Moa" <[EMAIL PROTECTED]> wrote:
> I'm writing an authentication-backend and need to check if a cookie
> already exists. But: how do I get ahold of the HttpRequest?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Testing Django App Running on Dev Server with Selenium

2007-03-08 Thread Paul Childs

I have Selenium RC running and I was wondering if someone might be
able to nudge me in the right direction. I am trying to at least get
my local web site, running on the Django dev server, to display in the
browser without an error, nothing more. Any help would be appreciated.

The following are the steps that I took while following along with the
Selenium tutorial.
http://www.openqa.org/selenium-rc/tutorial.html

I launch Selenium in the interactive mode

I open my website
cmd=getNewBrowserSession&1=*iexplore&2=http://127.0.0.1:8000
---> Requesting 
http://localhost:/selenium-server/driver?cmd=getNewBrowserSession&1=*iexplore&2=
http://127.0.0.1:8000
queryString = cmd=getNewBrowserSession&1=*iexplore&2=http://
127.0.0.1:8000
Modifying registry settings...
Launching Internet Explorer...
Got result: OK,1173381355673

I try to open the home page
cmd=open&1=http://127.0.0.1:8000/idms/&sessionId=1173381355673
---> Requesting 
http://localhost:/selenium-server/driver?cmd=open&1=http://127.0.0.1:8000/idms/&;
sessionId=1173381355673
queryString = cmd=open&1=http://127.0.0.1:8000/idms/
&sessionId=1173381355673
Got result: OK

Then I get this Django Error message in the browser...

TypeError at http://127.0.0.1:8000/idms/
unpack non-sequence
Request Method: GET
Request URL: http://127.0.0.1:8000http://127.0.0.1:8000/idms/   <
THIS IS INTERESTING
Exception Type: TypeError
Exception Value: unpack non-sequence
Exception Location: C:\Python24\lib\site-packages\django\core\handlers
\base.py in get_response, line 68

Traceback (most recent call last):
File "C:\Python24\lib\site-packages\django\core\handlers\base.py" in
get_response
  68. callback, callback_args, callback_kwargs =
resolver.resolve(request.path)

  TypeError at http://127.0.0.1:8000/idms/
  unpack non-sequence

I tried the following and still got the same error as above..
cmd=open&1=/idms/&sessionId=1173381355673
---> Requesting 
http://localhost:/selenium-server/driver?cmd=open&1=/idms/&sessionId=11733813556
73
queryString = cmd=open&1=/idms/&sessionId=1173381355673
Got result: OK


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



Re: Testing Django App Running on Dev Server with Selenium

2007-03-09 Thread Paul Childs

Thanks for the response Malcom...

> Does the same URL work if you aren't using Selenium? I'm trying to trim
> down the problem to something smaller.
When I type http://127.0.0.1:8000/idms/ into the address bar I do not
get a Django error and the proper page is rendered.

> I *suspect* there is a problem in your URL configuration and you have
> made a typo there. But that would mean that the URL would not work even
> if you accessed it directly in the browser, without being under
> Selenium's control, too.

Here is my URL config...
#--
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^doc/', include('idms.doc.urls')),
(r'^ipl/', include('idms.ipl.urls')),
(r'^ssi/', include('idms.ssi.urls')),

(r'^idms/',"idms.general.views.idms" ),

(r'^admin/', include('django.contrib.admin.urls')),
(r'^media/(.*)$', 'django.views.static.serve', {'document_root':
'C:\\idms_project\\idms\\media\\'}),

# authentication
(r'^logout/$', 'django.contrib.auth.views.logout'),
(r'^$', 'django.contrib.auth.views.login'),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
)
#--

I dug a little deeper into the Selenium RC forum and found out that
the *proper* way to access my local server should be done using the
following commands (which I had already tried among my many attempts)

cmd=getNewBrowserSession&1=*iexplore&2=http://127.0.0.1:8000
...
Got result: OK,117398765
cmd=open&1=/idms/&sessionId=117398765

I still get the Django error.

In my Django admin my site's domain name is set to 127.0.0.1:8000.

I tried the tutorial, which accesses Google's search page and I had no
problems.


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



Re: Testing Django App Running on Dev Server with Selenium

2007-03-09 Thread Paul Childs

Thanks again Malcolm.

It looks like this is starting to get beyond my comfort level. Given
that and my time constraints, it looks like Selenium is a non-starter.
I guess I'll just have to rely on humans to do that part of the
testing. The Selenium IDE worked fine but unfortunately it's not
possible to record results.

Cheers,
/Paul

On Mar 9, 9:06 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-03-09 at 12:59 +, Paul Childs wrote:
> > Thanks for the response Malcom...
>
> > > Does the same URL work if you aren't using Selenium? I'm trying to trim
> > > down the problem to something smaller.
> > When I typehttp://127.0.0.1:8000/idms/into the address bar I do not
> > get a Django error and the proper page is rendered.
>
> Then, unfortunately, I have no idea what the problem is, because it's
> something introduced by the Selenium process. I'm not a big Selenium
> user, so unsure of what it's doing.
>
> Sounds like you need some way of seeing the URL(s) that Selenium is
> requesting from your server so that you can isolate the one that is
> causing problems.
>
> At a very low-level, you might be able to do this using tcpdump or
> ethereal or something like that (ethereal/wireshark, even better) -- if
> Selenium is talking to the browser over the local network -- and
> extracting all the HTTP-type packets to look at the requests. There's
> probably an easier way, though, since somebody must have to debug the
> Selenium interactions at some point.
>
> Regards,
> Malcolm


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



Re: Testing Django App Running on Dev Server with Selenium

2007-03-09 Thread Paul Childs

Thanks Jeremy.

> I think, since the idms pattern is not being handled by an include,
> you may want this:
> (r'^idms/$',"idms.general.views.idms" ),
> (note the "$" at the end of the pattern).

I made the change and tried again but it didn't make a difference.

Cheers,
/Paul


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



Re: Testing Django App Running on Dev Server with Selenium

2007-03-11 Thread Paul Childs

Thanks for the suggestion Grig.
I'll give it a shot on Monday.
/Paul

On 3/10/07, Grig <[EMAIL PROTECTED]> wrote:
>
> Paul -- have you tried running the Selenium RC server non-
> interactively, then interacting with it via one of the languages it
> supports? Python for example, since you're doing Django development.
> Look in the python sub-directory of the selenium-rc distribution, and
> modify the test_google.py script so that it goes to your Django site.
>
> It might be easier if you run the Selenium RC server on a different
> box than your Django server, because SelRC uses a proxy to get around
> the Javascript security issues. The proxy might interfere with your
> Django server running on port 8000.
>
> Grig

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



raw_id_admin and newforms

2007-03-29 Thread Paul Childs

My searching hasn't yielded much so here it goes...

I understand that raw_admin_id is being removed and it will only be
available as part of the Admin inner class in a model. Does this make
it unaccessible to custom forms?

If this is the case, does anyone know how to duplicate the
raw_admin_id behaviour with newforms?

We have thousands of parts that we must choose from when creating
repairs so I have been using raw_admin_id in my models and duplicating
the behaviour found in the admin (pop up a search window and select a
system ID) with my custom create and update forms. It looks like we
can't make the move to newforms because of this but we would like to.

Thanks


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



newforms gurus: Forms With Multiple Inline Objects?

2007-03-31 Thread Paul Childs

I am trying to make the switch to new forms with little success. I
have searched the news group, looked over examples (found this to be
very good  http://www.djangoproject.com/documentation/models/model_forms/)
and looked at some suggested tutorials.

The reason for the lack of success is that a lot of our code mimics
the edit inline behaviour found in the current Django admin using the
old forms and I haven't seen any way or examples of how to do this
with newforms.

Could someone please give me a push in the right direction, example
code or a link to a tutorial.

Thanks.


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



Re: newforms gurus: Forms With Multiple Inline Objects?

2007-04-03 Thread Paul Childs

Hi folks,

Can someone suggest to me what I need to do to make this question a
little more answerable?

On Apr 1, 12:05 am, "Paul Childs" <[EMAIL PROTECTED]> wrote:
> I am trying to make the switch to new forms with little success. I
> have searched the news group, looked over examples (found this to be
> very good  http://www.djangoproject.com/documentation/models/model_forms/)
> and looked at some suggested tutorials.
>
> The reason for the lack of success is that a lot of our code mimics
> the edit inline behaviour found in the current Django admin using the
> old forms and I haven't seen any way or examples of how to do this
> with newforms.
>
> Could someone please give me a push in the right direction, example
> code or a link to a tutorial.
>
> Thanks.


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



Re: Recieving XML Documents over HTTP

2007-04-07 Thread Paul Childs

Not sure if this is what you are looking for, but this might be a
place to start...
http://code.djangoproject.com/wiki/XML-RPC

On Apr 6, 8:19 pm, "johnny" <[EMAIL PROTECTED]> wrote:
> This may be stupid question for an expert.  But stupidity is in not
> asking.
>
> How do I access the XML Documents sent over to my server in Django
> View?  Is it like regular request.POST?
> How large POST data can be sent before connection timing out?
>
> Thank you.


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



Re: __str__ referencing variables in other classes

2007-04-20 Thread Paul Childs

Hey Jason

Try:
return self.title + self.member.first_name + self.member.last_name

instead of:
return self.title + member.first_name + member.last_name

I think that might be the problem.

Cheers,
/Paul


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



Re: Komodo and Django - code completion / code intellisensing

2007-05-10 Thread Paul Childs

I'm just guessing here but do you have your project in your
pythonpath?

If not, try this...

To put the project on the sys.path you can do it two ways:

1.  import sys and then write a  line of code sys.path.append("path/to/
project/parent/directory") for example: if the project is located at c:
\idms_project\idms then the way to import would be:
sys.path.append(r"c:\idms_project"), or;

2.  Follow the directions here: 
http://www.imladris.com/Scripts/PythonForWindows.html
to add the path to the PYTHONPATH in the windows registry.

/Paul


On May 9, 1:01 pm, oliver <[EMAIL PROTECTED]> wrote:
> Hi i am evaluating komodo as my django/python ide but i can't get the
> code completion to work. It gives me this error:
>
> error evaluating 'models' at models.py#4: NameError: global name 'XXX'
> is not defined (C:\Prog..\Active..\lib\mozilla\python\komodo
> \codintel2\tree_python.py#169 in _members_from_elem) (error
> determining completions)
>
> I am on Windows XP, python 2.5, komodo ide 4.0, latest django svn.
> This error appears when you type for example:
>
> class ...
>   name = models.
>
> right after the models "."
>
> any one got this to work or is this a general bug in komodo?
>
> Thanks!


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



Many-to-Many with Intermediate Table Bug in Admin in Django 0.95?

2006-09-29 Thread Paul Childs

Could someone please tell me if this is an unfixed bug in Django 0.95.
If it is I will submit a ticket.

I created a many-to-many relationship using an intermediate table
similar to
http://www.djangoproject.com/documentation/models/m2m_intermediary/
(see model below.)

I am able to successfully exercise the models with no problem in the
shell.

When I go to the Admin and I create an Action or a Reference document
and click on save the Admin throws an exception. But the Action or
Reference is still added to the database.

I searched existing tickets and found similar issues but I'm not sure
if they address the same circumstances.

Thanks,
/Paul


Models:

-
from django.db import models

class Action(models.Model):

name = models.CharField(maxlength=20)

class Admin:
pass

class ReferenceDocument(models.Model):

document_number = models.CharField("Document",maxlength=50,
core=True)
document_type = models.CharField(maxlength=5)

class Admin:
pass

def __str__(self):
return self.document_number

class ActionReference(models.Model):

action = models.ForeignKey(Action)
reference_document = models.ForeignKey(ReferenceDocument)
note = models.CharField(maxlength=50)

class Admin:
pass
--

The exception and traceback:

ProgrammingError at /admin/mmm/referencedocument/add/
ERROR: insert or update on table "django_admin_log" violates foreign
key constraint "django_admin_log_content_type_id_fkey" DETAIL: Key
(content_type_id)=(15) is not present in table "content_types"
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/mmm/referencedocument/add/
Exception Type: ProgrammingError
Exception Value: ERROR: insert or update on table "django_admin_log"
violates foreign key constraint "django_admin_log_content_type_id_fkey"
DETAIL: Key (content_type_id)=(15) is not present in table
"content_types"
Exception Location:
c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\util.py
in execute, line 12

Traceback (most recent call last):
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py"
in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\contrib\admin\views\decorators.py"
in _checklogin
  55. return view_func(request, *args, **kwargs)
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\views\decorators\cache.py"
in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\contrib\admin\views\main.py"
in add_stage
  256. LogEntry.objects.log_action(request.user.id,
ContentType.objects.get_for_model(model).id, pk_value, str(new_object),
ADDITION)
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\contrib\admin\models.py"
in log_action
  13. e.save()
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py"
in save
  203. ','.join(placeholders)), db_values)
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\util.py"
in execute
  12. return self.cursor.execute(sql, params)

  ProgrammingError at /admin/mmm/action/add/
  ERROR: insert or update on table "django_admin_log" violates foreign
key constraint "django_admin_log_content_type_id_fkey" DETAIL: Key
(content_type_id)=(13) is not present in table "content_types"


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



Re: Many-to-Many with Intermediate Table Bug in Admin in Django 0.95?

2006-09-30 Thread Paul Childs

Hello Malcom,

In cooking up my test I made some changes and did some rebuilding that
affected the  database so I suspect that the "django_content_type"
table got out of sync (I really can't confirm this since I am now at
home)

I retried, as you suggested, with a clean database at home and there
were no problems.

Thanks for saving me a lot of time.

Cheers,
/Paul


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



Rendering Many-to-Many with raw_id_admin=True in Template

2006-10-04 Thread Paul Childs

I have a Many-to-Many relationship between two models, Action and Part
(see below).

Part has thousands of records so I am using "raw_id_admin=True".  This
works great in the admin.

I am using a generic view to create an update form for an Action. This
works fine but it only displays the part ids and does not include the
__str__ representation of the parts like the admin interface does. I
looked at the output of {% debug %} in the template and I couldn't see
anything that might contain those values.

Does anyone know how to do this? Thanks in advance.

-
Models:
-
from django.db import models

class Action(models.Model):
name = models.CharField(maxlength=10)
part = models.ManyToManyField(Part,raw_id_admin=True)

class Admin:
pass

def __str__(self):
return self.name


class Part(models.Model):

part_number = models.CharField(maxlength=20,db_index=True)
description = models.CharField(maxlength=50,blank=True)

class Admin:
pass

def __str__(self):
return '%s - %s' % (self.part_number, self.id)

--
Template:
--


   Name:{{form.name}}

 
   Parts: {{ form.part }}






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



Re: Rendering Many-to-Many with raw_id_admin=True in Template

2006-10-04 Thread Paul Childs

Sorry to be a pest folks.

I had forgotten that the {{object}} was still accessible.

So to get what I want I just had to do this:

{% for part in object.part.all %}
{{part}}
{% endfor %}


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



AttributeError thrown by Validator

2006-10-13 Thread Paul Childs

I am sure that I have read everything there is available in the
newsgroup and docs concerning uploading files.
If I missed something I apologize in advance.

Right now all I am trying to do is upload a file and use the
manipulator to validate that it is not missing. Everything seems to be
working except when I call the manipulator.get_validation_errors
method. It throws an exception (see traceback below).

If I don't update the new_data dictionary with request.FILES then I get
a  'This field is required.' error.

I commented out the method call and did verify that the file was
uploaded to the view.

Any help would be most appreciated.

I am using Django 0.95

-
View:
-
def upload_album(request):

manipulator = AlbumUploadManipulator()

if request.POST:
new_data = request.POST.copy()


# if this if statement is commented out then
# 'error_dict': {'album_file': ['This field is required.']}
if request.FILES:
new_data = new_data.update(request.FILES)

# exception gets thrown here
errors = manipulator.get_validation_errors(new_data)


if not errors:



return HttpResponseRedirect("/albums/")

else:
errors = new_data = {}

form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('upload_form.html', {'form': form})


-
Manipulator:
-
from django import forms

class AlbumUploadManipulator(forms.Manipulator):

def __init__(self):
self.fields = (
forms.TextField(field_name="album_name",
length=30, maxlength=200,
is_required=True),
forms.FileUploadField(field_name="album_file",
is_required=True),
)
--
Template:
--



 Name:
 {{ form.album_name }}
 
 File:
 {{ form.album_file }}
 {{ form.album_file_file }}







--
Traceback:
--
Traceback (most recent call last):
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py"
in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Documents and Settings\HIAPRC\My
Documents\Python\wilds\..\wilds\albums\views.py" in upload_album
  29. errors = manipulator.get_validation_errors(new_data)
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\forms\__init__.py"
in get_validation_errors
  58. errors.update(field.get_validation_errors(new_data))
File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\forms\__init__.py"
in get_validation_errors
  345. if self.is_required and not new_data.get(self.field_name,
False):

  AttributeError at /albums/upload_album/
  'NoneType' object has no attribute 'get'


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



Re: AttributeError thrown by Validator

2006-10-14 Thread Paul Childs

Thanks a million Rajesh!

It is so great to have such a helpful community.

Cheers,
/Paul


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



General File Upload Questions.

2006-11-30 Thread Paul Childs

I have been investigating file uploads in general and also with Django
in mind. This thread gave me a place to start:
http://tinyurl.com/ymzmds


I have a few questions..

1. Is there an upper limit to the size of files that one can upload to
Django? I am able to upload files of about 5 MB or less with no
problems, but when I try to upload a file (to the Django dev server)
which is larger I get an error message from Django. (Traceback is
below)

2. Does anyone know of a *simple* client-side javascript that would
enable client side checking of a file's size? I have seen quite a few
progress bars which have way more features than I need. I would just
like to put a cap on the size of an uploaded file and stop the upload
*before* the whole file is sent to the web server and handed over to
the view.

Thanks,
/Paul

Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 272, in run
self.result = application(self.environ, self.start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 615, in __call__
return self.application(environ, start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 148,
 in __call__
response = self.get_response(request.path, request)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py",
line 102,
 in get_response
return self.get_technical_error_response(request)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py",
line 134,
 in get_technical_error_response
return debug.technical_500_response(request, *sys.exc_info())
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\views\debug.py",
line 131, in tec
hnical_500_response
return HttpResponseServerError(t.render(c), mimetype='text/html')
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 155,
in render
return self.nodelist.render(context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 688,
in render
bits.append(self.render_node(node, context))
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 716,
in render_node
raise wrapped
TemplateSyntaxError: Caught an exception while rendering:

Original Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 706,
in render_node
result = node.render(context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 752,
in render
output = self.filter_expression.resolve(context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 548,
in resolve
obj = resolve_variable(self.var, context)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\template\__init__.py",
line 634,
in resolve_variable
current = current[bits[0]]
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\http\__init__.py",
line 31, in __
getitem__
for d in (self.POST, self.GET):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 99,
in _get_post
self._load_post_and_files()
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 77,
in _load_post_and_files
self._post, self._files = http.parse_file_upload(header_dict,
self.raw_post_data)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 122,
 in _get_raw_post_data
self._raw_post_data =
self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"]))
  File "C:\Python24\lib\socket.py", line 303, in read
data = self._sock.recv(recv_size)
MemoryError

[30/Nov/2006 13:06:24] "POST /doc/update/49/ HTTP/1.1" 500 3110
Traceback (most recent call last):
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 2
72, in run
self.result = application(self.environ, self.start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\servers\basehttp.py",
line 6
15, in __call__
return self.application(environ, start_response)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\wsgi.py",
line 148,
 in __call__
response = self.get_response(request.path, request)
  File
"c:\python24\lib\site-packages\django-0.95-py2.4.egg\django\core\handlers\base.py",
line 102,
 in get_response
return self.get_technical_error_response(request)
  File
"c:\python24\l

Re: General File Upload Questions.

2006-12-01 Thread Paul Childs


Paul Childs wrote:


> 1. Is there an upper limit to the size of files that one can upload to
> Django? I am able to upload files of about 5 MB or less with no
> problems, but when I try to upload a file (to the Django dev server)
> which is larger I get an error message from Django. (Traceback is
> below)

Can anyone comment on the upload limitations of Django?


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



Apache ErrorDocument Question.

2006-12-01 Thread Paul Childs

Sorry if this is a tad off topic...

I have Django 0.95 up and running with no problems under Apache2 with
flatpages installed and also running fine.

I have limited uploads by adding the setting LimitRequestBody 5242880
to the httpd.conf file, which works great. If I try to upload a large
file I get this in the error.log:
[Fri Dec 01 11:08:28 2006] [error] [client 127.0.0.1] Requested
content-length of 8627377 is larger than the configured limit of
5242880, referer: http://127.0.0.1/doc/create/

I want Apache to send the user to a nice error page if this happens.

So, I created a nice error page using flatpages with the url:
/413error/
I tested it by typing in: http://127.0.0.1/413error/ in the address bar
of the browser and I get the nice error message.

The next thing I did was set: ErrorDocument 413 /413error/ in the
httpd.conf file hoping that Apache would send the user to the desired
URL but I get a message in Firefox stating: "The connection to the
server was reset while the page was loading."

I also tried a simple ErrorDocument 413 "The file is too big" and this
did not work either.

I'm tapped out, could someone please give me a hint as to what I am
missing here?

Thanks in advance.

PS I have been restarting Apache after every change to the httpd.conf
file.

References:
http://httpd.apache.org/docs/trunk/mod/core.html#errordocument
http://httpd.apache.org/docs/trunk/mod/core.html#limitrequestbody

My additions to httpd.conf for Django:

# Changed MaxRequestsPerChild 0 to 1 for Django

ThreadsPerChild 250
MaxRequestsPerChild  1


Alias /media/ "C:/idms_project/idms/media/"


SetHandler None


ErrorDocument 413 /413error/

LimitRequestBody 5242880


SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['C:\idms_project'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE idms.settings
PythonDebug On



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



Re: Help with Contact Form

2006-12-01 Thread Paul Childs

Assuming that you are using the example exactly...

Off-the-top-of-my-head try something like:

return render_to_response('thankyou.html', {'my_form_data': new_data})


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



Re: Apache ErrorDocument Question.

2006-12-01 Thread Paul Childs

It looks like I am going down the wrong path. I think that what I
observed was by design since Django is handling the request.

I think the question should be...

How do I handle the 413 error within Django?

Any help would be greatly appreciated.


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



Re: Apache ErrorDocument Question.

2006-12-04 Thread Paul Childs

Thanks Waylan but...

It appears that when I configure Apache to limit the request body, if a
file is uploaded that exceeds the setting, Apache doesn't seem to pass
on anything to mod_python and records an error in error.log. Thus the
view never gets called so there is no opportunity to raise the error in
the view.

It seems that mod_python interferes with the mechanism that Apache uses
when one configures the ErrorDocument setting. The user gets a message
from the browser saying that the connection was dropped.

Does anyone know how to get hold of this error message so that a *nice*
message can be sent to the user? Are there any other options?


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



Re: Apache ErrorDocument Question.

2006-12-04 Thread Paul Childs

Thanks Waylan but...

It appears that when I configure Apache to limit the request body, if a
file is uploaded that exceeds the setting, Apache doesn't seem to pass
on anything to mod_python and records an error in error.log. Thus the
view never gets called so there is no opportunity to raise the error in
the view.

It seems that mod_python interferes with the mechanism that Apache uses
when one configures the ErrorDocument setting. The user gets a message
from the browser saying that the connection was dropped.

Does anyone know how to get hold of this error message so that a *nice*
message can be sent to the user? Are there any other options?


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



Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

The firewall has the SVN port closed off so when I noticed this ticket
http://code.djangoproject.com/ticket/1327
I was encouraged to go and get a development version of Django. I
scooped the script and ran it and lo and behold I had Revision 4179 of
the 96-pre version of Django! I uninstalled my .95 (kept the same MySQL
DB) and ran the install script.

My elation was short lived when I logged into the admin and was
presented with a messed up interface with some missing images, missing
text, hash lines running all over and illegible buttons. It turned out
to be messed up in both Firefox and IE.

The rest of my site seems to be working just fine except the images
that I pull from media/images/admin seem to have wavy lines under them.

Is there a known bug here (I searched users and developers groups but
couldn't find anything) or is it the download script used from ticket
1327?

Any advise for upgrading from .95 to dev, possibly updating the DB for
example?

It would be nice to be working with the latest and greatest.

Thanks in advance.


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

Well, I tried again and installed everything from scratch - new
project, app, database. I went through the first two sections of the
tutorial and I still got the same problem. I have posted this image of
the problem which shows how the admin looks through Firefox...

http://static.flickr.com/108/316578699_11591b364d_o.gif

I think this is a serious problem, should this be posted on the
developer group or a ticket raised?


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

I'm pretty sure that the download script that I found here...

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

must not be doing the job properly.

I took the media from the admin in the 0.95 release and replaced the
dev version's media and that fixed a good chunk of it.

I'll have to do a SVN checkout from home and bring it in to try here.

Sorry for the alarm and thanks for your input.


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

Thanks Istvan,

You guessed right I am on windows.

I changed the script, ran it, installed django and navigated to the
built in admin site where I was greeted by the nice clean looking admin
interface that I am used to seeing.


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



Re: How would I add a custom widget in the admin for a ManyToMany relationship?

2006-12-08 Thread Paul Childs

There is a lot of information in this group about solving this problem.

Look at raw_id_admin

http://groups.google.com/group/django-users/search?group=django-users&q=raw_id_admin&qt_g=1&searchnow=Search+this+group


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



Bug? -- Scripting to Store Images Throws Exception but Still Successfully Stores Image

2006-12-20 Thread Paul Childs


I have a lot of images for the initial load and want to use a script to
get them into the database.
When I try to store the image in my Photo model (see the below) I get
an error. The funny thing is that I can go on and set the ssi_status,
caption and then execute save() and it will store everything to the
database. Is this a bug? I'm using the latest svn trunk.

This is what I executed in iPython
---
from idms.ssi.models import Photo, SsiStatus
from glob import glob
folder = r'\\Hiawnt04\ase\GBS\ASE-05390 - SSI List Update for IDMS
Testing\Figures\JPEGs'
files = glob(folder + '\\*.jpg')
photo1 = Photo()
photo1.caption = 'SSI diagram'
f=files[0]
img = open(f,'rb')

# now I try to store the image in the model...
photo1.save_image_file(f,img)

---
exceptions.TypeError Traceback (most
recent call last)

C:\idms_project\idms\

C:\Python24\lib\site-packages\django\db\models\fields\__init__.py in
(instance, filename, raw_contents)
   587 setattr(cls, 'get_%s_url' % self.name,
curry(cls._get_FIELD_url, field=self))
   588 setattr(cls, 'get_%s_size' % self.name,
curry(cls._get_FIELD_size, field=self))
--> 589 setattr(cls, 'save_%s_file' % self.name, lambda
instance, filename, raw_contents: in
stance._save_FIELD_file(self, filename, raw_contents))
   590 dispatcher.connect(self.delete_file,
signal=signals.post_delete, sender=cls)
   591

C:\Python24\lib\site-packages\django\db\models\base.py in
_save_FIELD_file(self, field, filename, raw_contents)
   346 full_filename = self._get_FIELD_filename(field)
   347 fp = open(full_filename, 'wb')
--> 348 fp.write(raw_contents)
   349 fp.close()
   350

TypeError: argument 1 must be string or read-only buffer, not file

In [12]: photo1.save_image_file(filename=files[0],raw_content=img)
---
exceptions.TypeError Traceback (most
recent call last)

#then I go on to set the ssi_status etc.
photo1.caption="This is a nice Caption"
photo1.ssi_status = SsiStatus.objects.get(title__contains="14-1001")
photo1.save()

# look in the admin and everything is there!?!

My model
---
class Photo(models.Model):

   ssi_status = models.ForeignKey(SsiStatus, edit_inline=True,
num_in_admin=2)
   caption = models.CharField(maxlength=100, core=True)
   image = models.ImageField(upload_to="ssi", blank=True, null=True)

   def __str__(self):
   return self.caption
---


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



Re: Bug? -- Scripting to Store Images Throws Exception but Still Successfully Stores Image

2006-12-20 Thread Paul Childs




The funny thing is that I can go on and set the ssi_status,
caption and then execute save() and it will store everything to the
database. Is this a bug? I'm using the latest svn trunk.


On closer inspection the files that are stored on the server are zero
bytes but all the database entries are correct.


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



Re: Bug? -- Scripting to Store Images Throws Exception but Still Successfully Stores Image

2006-12-21 Thread Paul Childs


Thanks Fredrik you saved me some nerve cells.
Your answer worked like a charm.

Of note:
I noticed that there was no need to call the save() method on the photo
since the save_image_file() [ie save_FIELD_file()] method saved all
photo fields to the database.

This means that I had to set all required fields of the photo object
before I called the save_image_file() method.


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



A single field keeps Duplicating on the many side of a many-to-one

2007-01-16 Thread Paul Childs


I'm using Django version 0.96-pre I checked out from SVN on the 12th.

I have two models: Photo and SsiStatus (see code below)
A SsiStatus object can have many photos.

I have written a view to handle updating the SsiStatus and every time I
click to save the update the caption of any existing photos gets
duplicated. The file name is not, it remains blank.

If I add a new photo, the photo is added but any existing photos get
their captions duplicated.

I edited some other data on the page (not photos) and I took a look at
"new_data" before and after the line
"manipulator.do_html2python(new_data)" and got this:

BEFORE
'photo.0.caption': ['SSI Diagram for ssi: 14-1024'],
'photo.0.image': ['ssi\\13-14-1024.jpg']
'photo.1.caption': [''],
'photo.1.image': [''],

AFTER
'photo.0.id': [None],
'photo.0.caption': ['SSI Diagram for ssi: 14-1024'],
'photo.0.image': ['ssi\\13-14-1024.jpg']}>
'photo.0.image_file': [],

'photo.1.id': [None],
'photo.1.caption': [''],
'photo.1.image': [''],
'photo.1.image_file': [],

It didn't seem to change the data significantly.

The problem seems to occur when the ssi status object gets saved.
I made a small edit clicked "edit and continue" and after the
post-save-redirect the "debug" tag on the update page revealed this...

'photo.0.id': 19L,
'photo.0.caption': 'SSI Diagram for ssi: 14-1024',
'photo.0.image': 'ssi\\13-14-1024.jpg'},

'photo.1.id': 88L,
'photo.1.caption': 'SSI Diagram for ssi: 14-1024', < DUPLICATED
NAME
'photo.1.image': '', < NO IMAGE

'photo.2.id': None, < Next blank image
'photo.2.caption': '',
'photo.2.image': '',

Has anyone seen this behaviour before?

Any help would be greatly appreciated.

---
View
---
def ssi_status_update(request, ssi_id, ssistatus_id):
   # Get the ssi status in question from the database and create a
   # ChangeManipulator at the same time.
   try:
   manipulator = SsiStatus.ChangeManipulator(ssistatus_id)
   except SsiStatus.DoesNotExist:
   raise Http404

   if request.method == 'POST':
   new_data = request.POST.copy()

   if request.FILES:
   print request.FILES
   new_data.update(request.FILES)

   errors = manipulator.get_validation_errors(new_data)

   if not errors:

   print new_data

   manipulator.do_html2python(new_data)

   print new_data

   manipulator.save(new_data)
   # Do a post-after-redirect so that reload works, etc.
   if new_data.has_key('_continue'):
   return
HttpResponseRedirect('/ssi/ssi_status/update/%s/%s/' %

(ssi_id, ssistatus_id))

   else:
   return HttpResponseRedirect('/ssi/%s/' % ssi_id)
   else:
   errors = {}
   # This makes sure the form accurately represents the fields of
the document.
   new_data = manipulator.flatten_data()

   form = forms.FormWrapper(manipulator, new_data, errors)
   return render_to_response('ssi/ssistatus_form.html',
   {'form': form,

'object':SsiStatus.objects.get(pk=ssistatus_id)},

context_instance=RequestContext(request))



---
Models
---
class Photo(models.Model):

   ssi_status = models.ForeignKey(SsiStatus, edit_inline=True,
num_in_admin=2)
   caption = models.CharField(maxlength=100, core=True)
   image = models.ImageField(upload_to="ssi")

   def __str__(self):
   return self.caption

   def get_absolute_url(self):
   from idms.settings import MEDIA_URL
   return "%s/%s" % (MEDIA_URL, self.image.replace("\\","/"))

class SsiStatus(models.Model):
   '''
   This model is used to manage ssi status.
   It can have many SSis

   '''
   title = models.CharField(maxlength=100, unique=True)
   tail_number = models.ManyToManyField(Aircraft)
   justification = models.TextField()
   status = models.IntegerField(choices=SSI_STATUS_CHOICES)
   priority = models.IntegerField(choices=PRIORITY_CHOICES)


---
template
---
Photos


{% for photo in form.photo %}

 Caption:
 {{ photo.caption }}
 

 File
name:
{{ photo.image_file }}
{{photo.image}}


{% endfor %}


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



Re: A single field keeps Duplicating on the many side of a many-to-one

2007-01-16 Thread Paul Childs


I figured it out...

I missed putting {{ photo.id }} in the template. The "new_data" values
helped out.
I am speculating that Django didn't know the id of the existing object
so it created a new one in the database even though one already
existed.

Sorry to bother everyone.


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



IPython Shell does not see database changes made by views.

2007-01-31 Thread Paul Childs

During unit testing I made changes to data in the database through my
Django app.

I wanted to do some checks through the shell, which I was opened
during my unit testing, and found that after making some queries using
Django objects there appeared to be no changes in the database. When I
checked the database using its admin tool the changes were there.

To yield the expected results I had to exit from the shell and restart
it. I then executed my queries using Django objects and all the
changes were there.

Does anyone know how to "refresh" or better yet "auto refresh" the
shell so I don't have to shut down and restart it every time I make a
change to data outside of it.

I'm using IPython 0.7.2 , MySQL 5.0.27, and a dev version of Django
from a couple of weeks ago.

Thanks in advance,
/Paul


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



Help please with get_absolute_url in admin and public pages

2006-05-17 Thread Paul Childs

I am new to Django and so far have found it amazing.

I have two simple questions based on the following models which I am
running using the development server that comes with Django 0.91:

#-
class RepairType(meta.Model):
repair_type = meta.CharField(maxlength=50,unique=True)

class META:
admin = meta.Admin()

def __repr__(self):
return self.repair_type

class Repair(meta.Model):

repair_type = meta.ForeignKey(RepairType)

location = meta.CharField(maxlength=200)
damage_type = meta.CharField(maxlength=50)
damage_size = meta.CharField(maxlength=50)
tlir = meta.CharField('TLIR',maxlength=50)
age = meta.CharField(maxlength=10)
flight_hours = meta.CharField(maxlength=10)
reference_document = meta.CharField(maxlength=50)

class META:
admin = meta.Admin()

def __repr__(self):
return '%s. %s' % (self.id,self.location)

def get_absolute_url(self):
return "/par/%i/" % self.id

class Requirement(meta.Model):
repair = meta.ForeignKey(Repair, edit_inline=meta.STACKED,
num_in_admin=1)
description = meta.CharField(maxlength=1000, core=True)
actual = meta.CharField(maxlength=1000, null=True, blank=True)
comments = meta.CharField(maxlength=1000, null=True, blank=True)
results = meta.CharField(maxlength=1000, null=True, blank=True)

class Photo(meta.Model):
repair = meta.ForeignKey(Repair, edit_inline=meta.TABULAR,
num_in_admin=1)
caption = meta.CharField(maxlength=200, core=True, blank=True)
filename = meta.ImageField(upload_to="par", blank=True, null=True)

def __repr__(self):
return self.caption

def get_absolute_url(self):
from django.conf.settings import MEDIA_URL
return "%s/%s" % (MEDIA_URL, self.filename.replace("\\","/"))
# developing on windows
#-

My first question is: How do I configure the get_absolute_url() method
and url.py so that I get the proper url for a photo to display on a
public view details page. I seem to have everything else running
smoothly (upload, media root etc) I have taken a crack at this and I
can't find any documentation or examples.

#-
Second Question: The "view on site" doesn't seem to work for the Repair
in the admin interface. The admin generates the link
http://127.0.0.1:8000/r/10/1/ when I thought it would use
"http://127.0.0.1:8000/par/1"; as per the Repair class'
get_absolute_url() method

>From the documentation: Django uses this [get_absolute_url] in its
admin interface. If an object defines get_absolute_url, the object
detail page will have a "View on site" link that will jump you directly
to the object's public view.

Thanks in advance.


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



Re: Help please with get_absolute_url in admin and public pages

2006-05-17 Thread Paul Childs

OK,

I was able to find the documentation on serving media files. I thought
Django might have some automagic way of doing it so I really didn't
clue into what my real problem was.

I'm still looking for the answer to question 2. Any help would be
appreciated.

Thanks


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



Re: Help please with get_absolute_url in admin and public pages

2006-05-18 Thread Paul Childs

Thanks everyone.


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



Controlling Display of Foreign Key Input Fieldsets in Admin

2006-05-30 Thread Paul Childs

I have been searching for a difinitive answer to a few questions but
can't find any. I am trying to get control of how foreign key fieldsets
display in the Django admin.

For example I have a Repair model. It is a foreign key for
SupportingDoc, Photo, and PartNumber. These are all to be edited
inline.

Through experimentation I have found that I can change the order in
which they appear and how their own fields are to be displayed by
changing their location in the code. This is good.

What I would like to do is:

One, to create a fieldset with one of the Repair's fields and a foreign
key fieldset. Is this possible? I tried it and it breaks the admin
display.

Two, the foreign key fieldsets all end up at the bottom of the page is
it possible to disperse them through the Repair model's input fields.

Three, use the "wide" css class, or any other css class for that
matter, for a foreign key fieldset.

Thanks in advance.


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



Re: Controlling Display of Foreign Key Input Fieldsets in Admin

2006-05-30 Thread Paul Childs

Forgot to mention I am using Django 0.91


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



Re: Controlling Display of Foreign Key Input Fieldsets in Admin

2006-05-31 Thread Paul Childs

OK,

Is this a case of RTFM?

If so please let me know and I will continue to dig.

Thanks


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



Re: Controlling Display of Foreign Key Input Fieldsets in Admin

2006-06-01 Thread Paul Childs

Thanks Luke.

I'm sure problem one is just a side effect of why two and three won't
work.
I'm still loving Django though!

Cheers


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



"View on Site" broken with move over to Apache/mod_python.

2006-06-05 Thread Paul Childs

View on Site broken with move over to Apache/mod_python.

I have moved my Django 0.91 project (idms, the application under the
idms project is called "pra" with several more apps to come) from my
development server over to Apache/mod_python on Windows XP SP1.
Everything was working fine using the development server.

Now the "view on site" in the admin interface is broken. It doesn't
seem to be resolving the urls to the correct pattern as it did with the
development server, I am getting http://127.0.0.1/r/20/1/  instead of
something like http://127.0.0.1/pra/1

I experimented with some different patterns with the (r'^r/',
include('django.conf.urls.shortcut')), [see below] but I can't seem to
crack the code.

I also tried adding the site: 127.0.0.1/pra in the admin sites section.
This didn't seem to work either.

Any help would be greatly appreciated.

Here is my Apache config:

#--
# added for Django
# Python path addition should point to the parent of the modules.

SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['C:\Documents and Settings\HIAPRC\My
Documents\Python'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE idms.settings
PythonDebug On


SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['C:\Documents and Settings\HIAPRC\My
Documents\Python'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE idms.settings
PythonDebug On



SetHandler None

#--

idms project urls.py:

(r'^r/', include('django.conf.urls.shortcut')),
(r'^pra/', include('idms.pra.urls')),
(r'^admin/', include('django.contrib.admin.urls.admin')),


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



Re: DoesNotExist at /accounts/login/

2006-06-07 Thread Paul Childs

I had the same troubles and then I found this...
http://www.carcosa.net/jason/blog/computing/django/gotchas-2006-04-19
You will notice some other goodies there too. :)

You may want these in your project's url.py file too

(r'^logout/', 'django.views.auth.login.logout'),
(r'', 'django.views.auth.login.login'),
(r'^login/', 'django.views.auth.login.login'),
(r'^accounts/login', 'django.views.auth.login.login'),

Hope this helps
/Paul


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



Re: DoesNotExist at /accounts/login/

2006-06-07 Thread Paul Childs

I'm using version 0.91. That's the difference.

The only other thing I can suggest is to chekc if you have your login
and logout templates in the right place and that the template locations
are in your settings.py file.

Sorry I couldn't help out. Good luck.


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



Subversion Repository is Asking for a User Name and Password

2006-06-07 Thread Paul Childs

I would really like to download the developer version.

I am using TortoiseSVN.

When I perform an import I get a dialogue that says...

 Django SVN repository
Requests a username and a password

Could someone please help me out.

Thanks,


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



Re: Subversion Repository is Asking for a User Name and Password

2006-06-07 Thread Paul Childs

Thanks very much Jeremy. Worked like a charm.
Regards,
/Paul


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



Guidance would be most welcome

2006-06-13 Thread Paul Childs

I have been using Django for about a month now and I just moved over to
the development version.

I am creating an application in which the client has dictated very
stringent database record management in order to have a detailed audit
trail on all changes made data. This does not necessarily mean logging.

The rules are quite simple.

·   once saved, records are immutable.
·   records can not be deleted. they must be marked for deletion only.
·   to "edit" a record a new record is created with the new changes
and a reference must point back to the old record
·   a comment must be attached to every edit or delete to explain why
the action was taken.

I was planning on doing this with a combination of Managers, Views and
overriding the delete() and save() methods of my models. I have done
some experimentation and found this to be awkward, not very elegant and
to contravention of the DRY principle.

Is there a better way of achieving this or am I on the right track?


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



Re: Guidance would be most welcome

2006-06-13 Thread Paul Childs

Thanks for the input Waylan.

It certainly gives me another angle on the solution.

I have been digging into the docs again and it seems to me that Django
is flexible enough to handle this without having to dive into the
source.

Of course it would be nice just to call the save() and delete() methods
and everything would behave as listed in my first post.

Cheers


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



Re: Controlling Display of Foreign Key Input Fieldsets in Admin

2006-06-14 Thread Paul Childs

Thanks Luke, it took me a while but now I understand...

http://code.djangoproject.com/wiki/NewAdminChanges#Adminconvertedtoseparatetemplates


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



Re: Guidance would be most welcome

2006-06-16 Thread Paul Childs

Sweet! Thanks for the heads up.


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



Please Help with Template for django.views.generic.create_update.update_object

2006-06-19 Thread Paul Childs

I am using the Dev trunk as of Saturday with the models below:

#--
class Repair(models.Model):

tail_number = models.IntegerField(choices=AIRCRAFT_CHOICES)

location = models.CharField(maxlength=30)
damage_type = models.CharField(maxlength=50)

class Admin:
pass

Iclass Photo(models.Model):
repair = models.ForeignKey(Repair, edit_inline=models.TABULAR,
num_in_admin=1)
caption = models.CharField(maxlength=200, core=True, blank=True)
filename = models.ImageField(upload_to="tam", blank=True,
null=True)
#--

The following template works but does not handle more than one photo.

#--

  
tail number:
{{ form.tail_number }}
{% if form.tail_number.errors %}
  *** {{ form.tail_number.errors|join:", " }}
{% endif %}
  
  
location:
{{ form.location }}
{% if form.location.errors %}
  *** {{ form.location.errors|join:", " }}
{% endif %}
  
  
damage type:
{{ form.damage_type }}
{% if form.damage_type.errors %}
  *** {{ form.damage_type.errors|join:", " }}
{% endif %}
  
  
Photo Caption:
{{ form.photo.0.caption }}
{% if form.photo.0.errors %}
  *** {{ form.photo.0.caption.errors|join:", " }}
{% endif %}

Photo Filename:
{{ form.photo.0.filename_file }}
{% if form.photo.0.filename_file.errors %}
  *** {{ form.photo.0.filename_file.errors|join:", " }}
{% endif %}

{{ form.photo.0.filename }}

  




#--

Could someone please give me a push in the right direction on how I
would handle more than one photo. I tried to take a stab at it doing
this but it just failed silently...

#--
{% for photo in form.photo_set.all %}

Photo
Caption:
{{ photo.caption }}
{% if photo.caption.errors %}
  *** {{ photo.caption.errors|join:", " }}
{% endif %}

Photo Filename:
{{ photo.filename_file }}
{% if photo.filename_file.errors %}
  *** {{ photo.filename_file.errors|join:", " }}
{% endif %}

{{ photo.filename }}

{% endfor %}
#--

I looked at the contrib/admin/templates, the wiki and docs and really
didn't come up with anything that describes how to handle this
situation. Any help will be greatly appreciated.


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



Re: Please Help with Template for django.views.generic.create_update.update_object

2006-06-20 Thread Paul Childs

Honest, I really tried to figure this out on my own. I have been
relying on the Django website for answers but template examples are in
really short supply. I'd even accept a search string for Google if
that's all anyone is willing to give.

Thanks in advance.


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



Re: Please Help with Template for django.views.generic.create_update.update_object

2006-06-20 Thread Paul Childs

I received an email from someone in the group for more clarification:

> But then, why do you want to put more than one image in a form?

There can be more than one photograph of each repair. I need to mirror
what is done in the admin with models that are edited inline.

> What is the form for? where does that 'form' come from?
The form is in a template (/repair_form.html) which the
django.views.generic.create_update.update_object generic view uses for
rendering/updating its data.

Thanks to Guillermo


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



Re: Please Help with Template for django.views.generic.create_update.update_object

2006-06-21 Thread Paul Childs

Hi Malcom,

> I am not 100% certain what you are wanting to display in the repeating
> section of the form. Is it every photo in the system? Or maybe every
> photo associated with the existing "repair" instance? Sorry for being
> dense; I'm trying to work out the context from some code fragments
> without a description of what you would like to have happen and if I
> guess it will probably end badly.

I am trying to display all photos associated with a single repair and
allow the user to update the repair with an additional photo.

> It looks like you are trying to do the equivalent of
> repair.photo_set.all() in your template, but are using "form" instead of
> a "repair" object, which doesn't look promising. Since you mentioned
> later in this thread that you are trying to use the generic
> create.update.update_object() function,

You are right I was just taking a stab at something to get the desired
result. I understand now (I wished this clicked in earlier) that I am
really dealing with a dictionary.

>can you maybe post what your
> call this function looks like (either the URLConf line or the wrapper
> function that ends up calling update_object, depending upon how you've
> written your code).

I'm trying to rely on the generic view to do all the heavy lifting so
all the code there is to look at is the URLConf:

update_dict = {
'model':Repair,
'template_name':'tam/repair_update.html'
}


(r'^update/(?P\d+)/$','django.views.generic.create_update.update_object',
update_dict),

NB: I have broken out create and update templates while I try to figure
out how to get the update working.

I have done some sleuthing and added {% debug %} at the top
of the template so I can see the contents of the Context.

I now see how the form wrapper works. All fields are are accessed by a
key value. So in the case of a repair form it is:
{'form': {'error_dict': {}, 'manipulator': , 'data': {'photo.0.id': 1,
'photo.0.caption': 'Oh my goodness!!!', 'repair_date': '1999-01-01',
'area': 13, 'tail_number': 102, 'photo.1.id': None, 'photo.1.filename':
None, 'damage_type': 'corrosion', 'photo.0.filename':
'tam\\damage1___.jpg', 'photo.1.caption': '', 'id': 1, 'location': 'L/H
lower sparcap WS 333'}, '_inline_collections': None, 'edit_inline':
True}

Notice that the photos come in as photo... In fact Django
supplies an extra "photo.1" that is blank. I am assuming this is due to
the "edit_inline" attribute.

***
I guess the question really boils down to: How does one handle a form
wrapper if one doesn't know how many objects will be present?
***

The following does NOT work but I hope it illustrates what I am trying
to accomplish...

{% for photo in form.keys %}

{% ifequal photo.startswith "photo"%}

Photo Caption:
{{ photo.caption }}
{% if photo.caption.errors %}
  *** {{ photo.caption.errors|join:", " }}
{% endif %}

Photo
Filename:
{{ photo.filename_file }}
{% if photo.filename_file.errors %}
  *** {{ photo.filename_file.errors|join:", " }}
{% endif %}

{{ photo.filename }}

{% endifequal %}

{% endfor %}

The above in Python code would be something like:

for photo in form.keys():
if photo.startswith('photo'):
# ... do the output

This makes me think that I will have to abandon the generic view and
create the view myself. I'm not against it but then it begs the
question: What's the point of having generic views if all you can do is
deal with the most simple cases?

Once I have a solution to this I will be quite happy to contribute a
tutorial.


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



Re: Please Help with Template for django.views.generic.create_update.update_object

2006-06-21 Thread Paul Childs

Thanks for your insight Jay.

I tried using the  {{ form.error_dict }} on my page and all I got was
an empty dictionary.

Thanks again.


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



Template to Render Unknown Number of Arguments

2006-06-22 Thread Paul Childs

I am trying to create a template that will only render selected values
of an unknown number of dictionary keys which follow a certain pattern.

This is the form of the dictionary in context:
{'pets':{'dog0':'Rover','dog1':'Spike','cat0':'Fang'}}

The pet dogs can go from dog0, dog1, dog2,...dogn. The same applies to
cats.

The following Pseudo code illustrates my desire to only select dogs
from the dictionary not knowing how many there will be and render their
values:

{% for pet in pets.keys %}

{% if_key_fits_pattern "dog\d" %}

{{pet key}}: {{pet value}}

{% endif_key_fits_pattern %}

{% endfor %}

I have tried a number of ways of doing this but can't come up with a
solution. I don't think pre-processing the data will help since the
template still doesn't know how many keys there will be. Changing the
structure of the data is not possible.

Does anyone know how to test each key to determine if the one desired
has been found and render its value?

Thanks in advance.


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



Re: Template to Render Unknown Number of Arguments

2006-06-22 Thread Paul Childs

Thanks for your input Malcom.
I'm going to take a look at extending with new template tags.


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



Re: Template to Render Unknown Number of Arguments

2006-06-22 Thread Paul Childs

You do have a point spacedman. I might be able to massage the data in a
view. It actually happens to be the results of a generic view, an
update_object to be precise. It is a model and the model in which it is
a foreign key i.e. edit_inline. Works great in the admin interface
(it's rendered quite differently if you look at the admin source) but
presents challenges in public views and templates.


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



Manager for Admin

2006-07-06 Thread Paul Childs

I am trying to create a manager for a model so that only objects with a
status of 0 or 1 show up in the admin.

Could someone please let me know how to write a "where" clause in the
manager
(e.g  "current_status < 2" or something like "current_status=0 or
current_status=1")

Here's what I tried...

#-
class Repair(models.Model):
# some code...

class Admin:
manager = EditableRepairsManager()
#-

I tried this...

#-
class EditableRepairsManager(models.Manager):
def get_query_set(self):
from django.db import connection
cursor = connection.cursor()
cursor.execute("""
SELECT r.id
FROM pra_repair r
WHERE current_status < 2
ORDER BY r.tail_number
""")
result_list = []
for row in cursor.fetchall():
id = row[0]
repair = Repair.objects.get(pk=id)
result_list.append(repair)
return result_list
#-

I got this error in the template:

AttributeError at /admin/pra/repair/
'list' object has no attribute 'filter'
Request Method: GET
Request URL:http://127.0.0.1:8000/admin/pra/repair/
Exception Type: AttributeError
Exception Value:'list' object has no attribute 'filter'

I tried this:

#-
class EditableRepairsManager(models.Manager):
def get_query_set(self):
return super(EditableRepairsManager,
self).get_query_set().filter(current_status=0,current_status=1)
#-

I got this error from the dev server terminal window:
SyntaxError: duplicate keyword argument

I understand why I got the errors but I don't understand how to create
the manager I need.


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



Re: Manager for Admin

2006-07-06 Thread Paul Childs

Many many thanks James. I have been going all over the map on that one.


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



Re: Manager for Admin

2006-07-06 Thread Paul Childs

Many many thanks James. I have been going all over the map on that one.


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



Re: Manager for Admin

2006-07-06 Thread Paul Childs

I did some more digging and here is the reference for those who are
interested:

Field lookups are how you specify the meat of an SQL WHERE clause.
They're specified as keyword arguments to the QuerySet methods
filter(), exclude() and get().

http://www.djangoproject.com/documentation/db_api/#field-lookups


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



Pre-processing Request Info in Generic View Wrapper

2006-07-17 Thread Paul Childs

I have written a wrapper around the object_list generic view. I would
like to do some pre-processing before sending the information to the
view.

Here is my wrapper...

##
from django.views.generic.list_detail import object_list

def change_status(*args, **kwargs):

print args

# code happens

return object_list(*args,**kwargs)
##

I did a dump of the args to the console (as seen above) and got this...

##
,
POST:,
COOKIES:{'sessionid': 'f9fa0106252f77a7583dfbe24148c08f'},
META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\\All Users',
 'APPDATA': 'C:\\Documents and Settings\\Paul\\Application Data',
 'CLASSPATH': 'C:\\Program
Files\\Java\\jre1.5.0_06\\lib\\ext\\QTJava.zip',
 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files',
 'COMPUTERNAME': 'Archie',

 # removed for brevity ...

 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}>
##

How do I get access to the POST values without having to resort to
changing the signature of my view? I can see them in the dump but for
the life of me I can't figure out how to get at them.

Am I going about this backwards?

Should I change the view signature to
def change_status(request):
and then build the args? I so, how would I build the args? Something
like this?

return
object_list(request.GET,request.POST,request.COOKIES,request.META,**kwargs)


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



Re: Pre-processing Request Info in Generic View Wrapper

2006-07-17 Thread Paul Childs

Of course seconds after the post I ran across this...
http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-generic-views/
Thanks go out to Malcolm Tredinnick.

and this...
http://code.djangoproject.com/browser/django/trunk/django/views/generic/list_detail.py

Sorry to bother everyone.

Cheers.


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



Re: QuerySet

2006-07-18 Thread Paul Childs

Check this out.

http://code.djangoproject.com/wiki/NewbieMistakes

Cheers,
/Paul


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



Custom Manipulator SelectField "blank" option

2006-07-19 Thread Paul Childs

I have created a custom manipulator for a search form.

#
from django import forms
from choices import AIRCRAFT_CHOICES, phase_choices, OBJECT_CHOICES,
STATUS_CHOICES

class SelectStatusManipulator(forms.Manipulator):
def __init__(self):
self.fields = (
forms.RadioSelectField(field_name="object_type",
choices=OBJECT_CHOICES, is_required=True),
forms.RadioSelectField(field_name="status",
choices=STATUS_CHOICES, is_required=True),
forms.SelectField(field_name="phase", choices=phase_choices(),
is_required=False),
forms.SelectField(field_name="tail_number",
choices=AIRCRAFT_CHOICES, is_required=False),
)
#

It works just fine except that when it creates the phase and
tail_number SELECT elements in the template it doesn't create the
-.  I expected this since it does this in
the admin and I have also made is_required=False. Never assume anything
I guess.

Am I missing something? I looked at the Django source and I didn't see
anyway to include the "blank" option other than to add
   ('','-')
at the top of the AIRCRAFT_CHOICES and phase_choices.

Thanks,
/Paul


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



Re: Custom Manipulator SelectField "blank" option

2006-07-19 Thread Paul Childs

I wonder if this would be worth pursuing as a new feature for the
SelectField widget.

It makes sense to me that if one sets is_required=False then the widget
should add the "blank" option.


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



Testing with LiveServerTestCase and Selenium

2012-06-28 Thread Paul Childs
Hello,
I'm using Django 1.4 and was really excited to learn about the new testing 
features. I am totally new to this.
I seem to have hit a bump in the road. If I overcome this I'm hopeful it 
will be smooth sailing and I will experience some great testing goodness.
I've been mucking around with this all morning and I can't seem to get the 
selenium Firefox webdriver to navigate to the given URL.

I have read the docs:
https://docs.djangoproject.com/en/1.4/topics/testing/#django.test.LiveServerTestCase
 
and read this tutorial
http://www.tdd-django-tutorial.com/tutorial/1/ 
and tried to run the test code that they suggest.

When I run the very simple test:

from django.test import LiveServerTestCase
from selenium import webdriver

class MySeleniumTests(LiveServerTestCase):
fixtures = ['lookups_security.json']

def setUp(self):
self.browser = webdriver.Firefox()

def tearDown(self):
self.browser.quit()

def test_login(self):
# Gertrude opens her web browser, and goes to the admin page
self.browser.get(self.live_server_url + '/admin/login/')

# She sees the familiar 'Django administration' heading
body = self.browser.find_element_by_tag_name('body')
self.assertIn('CISSIMP Admin', body.text)

A blank Firefox browser pops up, sits there and then closes.

The test output is:

(sitar_env2) C:\virtual_env\sitar_env2\cissimp>python manage.py test 
--liveserver=localhost:8082 sitar
Creating test database for alias 'default'...
E
==
ERROR: test_login (sitar.tests.MySeleniumTests)
--
Traceback (most recent call last):
  File "C:\virtual_env\sitar_env2\cissimp\sitar\tests.py", line 54, in 
test_login
self.assertIn('CISSIMP Admin', body.text)
AttributeError: 'NoneType' object has no attribute 'text'

--
Ran 1 test in 22.546s

FAILED (errors=1)
Destroying test database for alias 'default'...

It seems obvious that the browser is not navigating to the URL I want so 
the code is trying to get a reference to an non-existent body tag.

Can anyone see what I am doing wrong?

Thanks
/Paul

-- 
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/-/jh47T9WA7QkJ.
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: Testing with LiveServerTestCase and Selenium

2012-07-04 Thread Paul Childs
I thought it might be a good idea to remove Django testing from the 
equation by opening up an IPython session and executing the following:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://www.microsoft.com/";)
browser.title
'' # empty string

The the same thing is happening with just the webdriver alone.

The company I work for has McAffee installed on my machine. Could it be 
blocking automated browser activity?

On Saturday, June 30, 2012 8:39:54 AM UTC-3, Rafael Durán Castañeda wrote:
>
> El 28/06/12 15:45, Paul Childs escribi�: 
> > Hello, 
> > I'm using Django 1.4 and was really excited to learn about the new 
> > testing features. I am totally new to this. 
> > I seem to have hit a bump in the road. If I overcome this I'm hopeful 
> > it will be smooth sailing and I will experience some great testing 
> > goodness. 
> > I've been mucking around with this all morning and I can't seem to get 
> > the selenium Firefox webdriver to navigate to the given URL. 
> > 
> > I have read the docs: 
> > 
> https://docs.djangoproject.com/en/1.4/topics/testing/#django.test.LiveServerTestCase
>  
> > 
> > and read this tutorial 
> > http://www.tdd-django-tutorial.com/tutorial/1/ 
> > and tried to run the test code that they suggest. 
> > 
> > When I run the very simple test: 
> > 
> > from django.test import LiveServerTestCase 
> > from selenium import webdriver 
> > 
> > class MySeleniumTests(LiveServerTestCase): 
> > fixtures = ['lookups_security.json'] 
> > 
> > def setUp(self): 
> > self.browser = webdriver.Firefox() 
> > 
> > def tearDown(self): 
> > self.browser.quit() 
> > 
> > def test_login(self): 
> > # Gertrude opens her web browser, and goes to the admin page 
> > self.browser.get(self.live_server_url + '/admin/login/') 
> > 
> > # She sees the familiar 'Django administration' heading 
> > body = self.browser.find_element_by_tag_name('body') 
> > self.assertIn('CISSIMP Admin', body.text) 
> > 
> > A blank Firefox browser pops up, sits there and then closes. 
> > 
> > The test output is: 
> > 
> > (sitar_env2) C:\virtual_env\sitar_env2\cissimp>python manage.py test 
> > --liveserver=localhost:8082 sitar 
> > Creating test database for alias 'default'... 
> > E 
> > == 
> > ERROR: test_login (sitar.tests.MySeleniumTests) 
> > -- 
> > Traceback (most recent call last): 
> >   File "C:\virtual_env\sitar_env2\cissimp\sitar\tests.py", line 54, in 
> > test_login 
> > self.assertIn('CISSIMP Admin', body.text) 
> > AttributeError: 'NoneType' object has no attribute 'text' 
> > 
> > -- 
> > Ran 1 test in 22.546s 
> > 
> > FAILED (errors=1) 
> > Destroying test database for alias 'default'... 
> > 
> > It seems obvious that the browser is not navigating to the URL I want 
> > so the code is trying to get a reference to an non-existent body tag. 
> > 
> > Can anyone see what I am doing wrong? 
> > 
> > Thanks 
> > /Paulr 
> > -- 
> > 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/-/jh47T9WA7QkJ. 
> > 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. 
>
> The error is quite obvious, body is None and thus it doesn't have 'text' 
> attribute, why body is None is not so obvious since I think selenium 
> should raise NoSuchElementExceptionif it can't find the body tag, no 
> tjust returning None. When you manually browse the url, what do you get? 
> is the body tag there or are your getting a blank page? 
>

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



Middleware Causing OperationalError: (2006, 'MySQL server has gone away')

2013-09-10 Thread Paul Childs
Environment: Django 1.4, MySQL 5.5.33

In one of my views I am consistently getting  a MySQL 
error: OperationalError: (2006, 'MySQL server has gone away')

Traceback (most recent call last):
  File "C:\Python26\Lib\wsgiref\handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\contrib\staticfiles\handlers.py",
 
line 67, in __call__
return self.application(environ, start_response)
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\wsgi.py", 
line 241, in __call__
response = self.get_response(request)
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py", 
line 191, in get_response
signals.got_request_exception.send(sender=self.__class__, 
request=request)
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\dispatch\dispatcher.py", 
line 172, in send
response = receiver(signal=self, sender=sender, **named)
  File "C:\virtual_env\sitar_env2\lib\site-packages\django\db\__init__.py", 
line 62, in _rollback_on_exception
transaction.rollback_unless_managed(using=conn)
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\transaction.py", 
line 129, in rollback_unless_managed
connection.rollback_unless_managed()
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
line 214, in rollback_unless_managed
self._rollback()
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\mysql\base.py", 
line 404, in _rollback
BaseDatabaseWrapper._rollback(self)
  File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
line 54, in _rollback
return self.connection.rollback()
OperationalError: (2006, 'MySQL server has gone away')
[10/Sep/2013 10:29:11] "GET /trending/res_entry/pim/0/ HTTP/1.1" 500 59

Looking at the stack trace it didn't look like the problem was with my view.

I traced through the code and the error occurs in one of the middleware 
methods that is executed when I redirect to another page:

> c:\virtual_env\sitar_env2\cissimp\trending\views.py(67)res_management()
-> q_ress = Res.objects.filter(maintenance_phase=maintenance_phase)    
Hitting the DB OK here
(Pdb)
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(69)res_management()
-> res_list = fmas.get_ress(q_ress, mode, maintenance_phase)
(Pdb)
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(70)res_management()
-> request.session['my_res_list'] = res_list
(Pdb)
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(71)res_management()
-> return redirect('/trending/res_{0}/{1}/1/'.format(mode,
(Pdb)
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()
-> maintenance_phase))
(Pdb)
--Return--
> 
c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()->
-> maintenance_phase))
(Pdb)
> 
c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(124)get_response()
-> if response is None:
(Pdb) response is None
False
(Pdb) n
> 
c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(133)get_response()
-> if hasattr(response, 'render') and callable(response.render):
(Pdb) l
128 view_name = callback.__class__.__name__ + 
'.__call__' # If it's a class
129 raise ValueError("The view %s.%s didn't return 
an HttpResponse object." % (callback.__module__, view_name))
130
131 # If the response supports deferred rendering, 
apply template
132 # response middleware and the render the response
133  -> if hasattr(response, 'render') and 
callable(response.render):
134 for middleware_method in 
self._template_response_middleware:
135 response = middleware_method(request, 
response)
136 response = response.render()
137
138 except http.Http404, e:
(Pdb) n
> 
c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(183)get_response()
-> urlresolvers.set_urlconf(None)
(Pdb) l
178 
signals.got_request_exception.send(sender=self.__class__, request=request)
179 response = self.handle_uncaught_exception(request, 
resolver, sys.exc_info())
180 finally:
181 # Reset URLconf for this thread on the way out for 
complete
182 # isolation of request.urlconf
183  -> urlresolvers.set_urlconf(None)
184
185 try:
186 # Apply response middleware, regardless of the response
187 for middleware_method in self._response_middleware:
188 response = middleware_method(request, response)
(Pdb) n
> 
c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(185)get_response()
-> try:
(Pdb) n
> 
c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(187)get

Re: Middleware Causing OperationalError: (2006, 'MySQL server has gone away')

2013-09-10 Thread Paul Childs
I went as far as to reboot my machine.
I tried the view and it worked but then my other view started exhibiting 
the same error message.

On Tuesday, September 10, 2013 11:01:42 AM UTC-3, Paul Childs wrote:
>
> Environment: Django 1.4, MySQL 5.5.33
>
> In one of my views I am consistently getting  a MySQL 
> error: OperationalError: (2006, 'MySQL server has gone away')
>
> Traceback (most recent call last):
>   File "C:\Python26\Lib\wsgiref\handlers.py", line 93, in run
> self.result = application(self.environ, self.start_response)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\contrib\staticfiles\handlers.py",
>  
> line 67, in __call__
> return self.application(environ, start_response)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\wsgi.py", 
> line 241, in __call__
> response = self.get_response(request)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py", 
> line 191, in get_response
> signals.got_request_exception.send(sender=self.__class__, 
> request=request)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\dispatch\dispatcher.py", 
> line 172, in send
> response = receiver(signal=self, sender=sender, **named)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\__init__.py", line 
> 62, in _rollback_on_exception
> transaction.rollback_unless_managed(using=conn)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\transaction.py", 
> line 129, in rollback_unless_managed
> connection.rollback_unless_managed()
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
> line 214, in rollback_unless_managed
> self._rollback()
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\mysql\base.py",
>  
> line 404, in _rollback
> BaseDatabaseWrapper._rollback(self)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
> line 54, in _rollback
> return self.connection.rollback()
> OperationalError: (2006, 'MySQL server has gone away')
> [10/Sep/2013 10:29:11] "GET /trending/res_entry/pim/0/ HTTP/1.1" 500 59
>
> Looking at the stack trace it didn't look like the problem was with my 
> view.
>
> I traced through the code and the error occurs in one of the middleware 
> methods that is executed when I redirect to another page:
>
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(67)res_management()
> -> q_ress = Res.objects.filter(maintenance_phase=maintenance_phase)    
> Hitting the DB OK here
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(69)res_management()
> -> res_list = fmas.get_ress(q_ress, mode, maintenance_phase)
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(70)res_management()
> -> request.session['my_res_list'] = res_list
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(71)res_management()
> -> return redirect('/trending/res_{0}/{1}/1/'.format(mode,
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()
> -> maintenance_phase))
> (Pdb)
> --Return--
> > 
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()->
> -> maintenance_phase))
> (Pdb)
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(124)get_response()
> -> if response is None:
> (Pdb) response is None
> False
> (Pdb) n
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(133)get_response()
> -> if hasattr(response, 'render') and callable(response.render):
> (Pdb) l
> 128 view_name = callback.__class__.__name__ + 
> '.__call__' # If it's a class
> 129 raise ValueError("The view %s.%s didn't return 
> an HttpResponse object." % (callback.__module__, view_name))
> 130
> 131 # If the response supports deferred rendering, 
> apply template
> 132 # response middleware and the render the response
> 133  -> if hasattr(response, 'render') and 
> callable(response.render):
> 134 for middleware_method in 
> self._template_response_middleware:
> 135 response = middleware_method(request, 
> response)
> 136 response = response.render()
> 137
> 138 except http.Http404, e:
> (P

Re: Middleware Causing OperationalError: (2006, 'MySQL server has gone away')

2013-09-10 Thread Paul Childs
Hey Sanjay,

Thanks for the reply.
I will probably pick at this problem every so often but I am not hopeful 
about finding a solution as the problem seems to be down deep in Django. 
I'm afraid that I will probably be out of my league on this one.
I have been wanting to upgrade my Djano version for a while now and I may 
resort to bumping up to 1.5 or even 1.6 to see if that fixes things.

Cheers,
/Paul

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Middleware Causing OperationalError: (2006, 'MySQL server has gone away')

2013-09-10 Thread Paul Childs
I ran my test suite and the error didn't crop up there.
All tests that run my views passed.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Middleware Causing OperationalError: (2006, 'MySQL server has gone away')

2013-09-18 Thread Paul Childs
After much research and help from a DBA in a company the solution to the 
problem was to put the following in the mysqld section of the my.ini file:

max_allowed_packet=128M

I think that the HTML header was so large that when the middleware made a 
call to MySQL it couldn't handle the size of the packet, which I am told is 
only 1MB by default for windows.

On Tuesday, September 10, 2013 11:01:42 AM UTC-3, Paul Childs wrote:
>
> Environment: Django 1.4, MySQL 5.5.33
>
> In one of my views I am consistently getting  a MySQL 
> error: OperationalError: (2006, 'MySQL server has gone away')
>
> Traceback (most recent call last):
>   File "C:\Python26\Lib\wsgiref\handlers.py", line 93, in run
> self.result = application(self.environ, self.start_response)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\contrib\staticfiles\handlers.py",
>  
> line 67, in __call__
> return self.application(environ, start_response)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\wsgi.py", 
> line 241, in __call__
> response = self.get_response(request)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py", 
> line 191, in get_response
> signals.got_request_exception.send(sender=self.__class__, 
> request=request)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\dispatch\dispatcher.py", 
> line 172, in send
> response = receiver(signal=self, sender=sender, **named)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\__init__.py", line 
> 62, in _rollback_on_exception
> transaction.rollback_unless_managed(using=conn)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\transaction.py", 
> line 129, in rollback_unless_managed
> connection.rollback_unless_managed()
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
> line 214, in rollback_unless_managed
> self._rollback()
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\mysql\base.py",
>  
> line 404, in _rollback
> BaseDatabaseWrapper._rollback(self)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
> line 54, in _rollback
> return self.connection.rollback()
> OperationalError: (2006, 'MySQL server has gone away')
> [10/Sep/2013 10:29:11] "GET /trending/res_entry/pim/0/ HTTP/1.1" 500 59
>
> Looking at the stack trace it didn't look like the problem was with my 
> view.
>
> I traced through the code and the error occurs in one of the middleware 
> methods that is executed when I redirect to another page:
>
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(67)res_management()
> -> q_ress = Res.objects.filter(maintenance_phase=maintenance_phase)    
> Hitting the DB OK here
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(69)res_management()
> -> res_list = fmas.get_ress(q_ress, mode, maintenance_phase)
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(70)res_management()
> -> request.session['my_res_list'] = res_list
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(71)res_management()
> -> return redirect('/trending/res_{0}/{1}/1/'.format(mode,
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()
> -> maintenance_phase))
> (Pdb)
> --Return--
> > 
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()->
> -> maintenance_phase))
> (Pdb)
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(124)get_response()
> -> if response is None:
> (Pdb) response is None
> False
> (Pdb) n
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(133)get_response()
> -> if hasattr(response, 'render') and callable(response.render):
> (Pdb) l
> 128 view_name = callback.__class__.__name__ + 
> '.__call__' # If it's a class
> 129 raise ValueError("The view %s.%s didn't return 
> an HttpResponse object." % (callback.__module__, view_name))
> 130
> 131 # If the response supports deferred rendering, 
> apply template
> 132 # response middleware and the render the response
> 133  -> if hasattr(response, 'render') and 
> callable(response.render):
> 134 for middleware_method in 
> self._template_response_middl

Strange Admin CSS Behaviour

2010-12-15 Thread Paul Childs
I'm trying to use the Django admin (on the dev server that comes with
Django) for the latest stable version 1.2.3 on windows with Python
2.6. Functionally it works great.
For some reason the styles do not render for the site admin page and
my application admin page.
The respective URLS are: http://127.0.0.1:8000/admin/ and
http://127.0.0.1:8000/admin/asi/ where "asi" is my application.
All the other admin pages displaying properly: login, change pages,
list pages, change password, etc.
The only difference I see when I look at the source is that the pages
in question use dashboard.css instead of base.css.
I have tried moving the admin media directory to my project media
folder and serve it up myself but that did not seem to fix the
problem.
I uninstalled Django and reinstalled using a fresh download of 1.2.3.
I haven't come across anyone else having this problem either.
If anyone has an idea how to fix this or can point me in the right
direction to troubleshoot this, I would appreciate it.
/Paul

 Here are the media settings in my settings.py

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'


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



Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs


*What's been done so far:*

   - I was on Django 1.5 and upgraded to 1.6 (cannot go higher as we are on 
   Python 2.6) and this did not solve the problem.
   - I have researched this issue to death and cannot seem to find a 
   definite answer. Looking through the Django Project Bug Tracker, I have 
   seen similar issues but none seem to fit my particular case
   - I have resolved the problem in the past using a raw SQL call to 
   replace for example affpart.damage_types.all() with a custom function 
   but this is starting to happen more frequently now and is becoming a real 
   pain.

*Description:*

I have two Django apps under one project. One of the apps makes use of 
models in another app using a many-to-many relationship.

This has been working smoothly for months, and in fact it works fine on my 
production machine but fails on my development machine. The scenario lately 
has been that I am asked to add a new feature and when I start to work on 
it I get a FieldError in related code which I haven't even touched.

The offending line of code for this latest issue is: for dt in 
affpart.damage_types.all()

The error is:

Cannot resolve keyword u'affectedpart' into field. Choices are: 
cgs_damage_code, description, id, reg_exp, sti

The error occurs in the bowels of Django in the query.py module.

>From a high-level, this error occurs when I am trying to use a Many-to-many 
between models in different Django apps. For example, an affected part can 
have more than one type of damage and a damage type can be found on 
different affected parts.

The two apps are: trending and sitar

sitar was built first and has the models that I want to use from trending.

In trending, my models.py file has an AffectedPart model something like 
this:

from sitar.models import (Part, DamageType, Aircraft)
class AffectedPart(models.Model):
...

occurrence_date = models.DateField()
partnumber = models.ForeignKey(Part)
damage_types = models.ManyToManyField(DamageType, null=True, blank=True)
repair_types = models.ManyToManyField(RepairType, null=True, blank=True)

.If anyone has a solution to this or knows of best practices for models in 
one application having many-to-many relationships with models in another 
application I would love to hear it.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/beba2cda-7beb-4d1b-896a-497366759b58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
Hey Collin,

I had no problem in the shell...


In [4]: AffectedPart.objects.all().count()
Out[4]: 4090
# pick a random AffectedPart
In [5]: affpart = AffectedPart.objects.all()[22]

In [6]: affpart.damage_types.all()
Out[6]: []

I'm not sure why this doesn't work running under the server.

My models look like this:

from sitar.models import (Part, DamageType, Aircraft)
# this model is in trending.modelsclass AffectedPart(models.Model):
res = models.ForeignKey(Res, null=True)
arising = models.ForeignKey(Arising, null=True)

aircraft = models.ForeignKey(Aircraft)
# filled out automatically only if part to Damage/Repair type matching done
maintenance_phase = models.CharField(max_length=10,
 choices=MAINTENANCE_PHASE_CHOICES)
occurrence_date = models.DateField()
partnumber = models.ForeignKey(Part)
damage_types = models.ManyToManyField(DamageType, null=True, blank=True)
repair_types = models.ManyToManyField(RepairType, null=True, blank=True)

def __unicode__(self, ):
if self.res:
parent = self.res.number

else:
parent = str(self.arising)

return '{0} - {1}'.format(self.partnumber.number, parent)
# The following models are in sitar.modelsclass Part(models.Model):
''' This model is used to create pick-lists so the user can associate
one or more applicable parts from a pre-defined list to
a tracked item.

It will also allow for regular CRUD functionality which is
implemented by taking advantage of the Django admin interface. '''

# Added to associate a zone with a part
zones = models.ManyToManyField("Zone", null=True, blank=True)

number = models.CharField(max_length=50, unique=True)
description = models.CharField(max_length=100, blank=True)
comments = models.TextField(blank=True)
material = models.CharField(max_length=100, blank=True)

class Meta:
''' Order by part number field (ascending) when presenting data '''
ordering = ['number']


def __unicode__(self):
''' Return unicode description of a part instance '''
if self.description:
return '%s -- %s' % (self.number, self.description)
else:
return self.number


def get_encoded_part_number(self):
'''
   This method will remove any '/' in part numbers and replace them
   with '~' so that they can be used in URLs.
'''
return self.number.replace('/','~')

class DamageType(models.Model):

description = models.CharField(max_length=50, unique=True)
# a regular expression to account for possible spelling mistakes when
# querying the database
reg_exp = models.CharField(max_length=50, blank=True)

# Added to provide damage code for TRENDING
cgs_damage_code = models.CharField(max_length=10, blank=True,
   verbose_name="CGS Damage Code")

def __unicode__(self):
''' Return unicode representation of a DamageType instance. '''
return self.description

class Meta:
''' Order by description field (ascending) when presenting data '''
ordering = ['description']

def save(self):
''' Override the save method of the DamageType model in order to assign
a regexp if one does not exist.'''

# if the tracked item does not have a reg_exp just use
# the description
if not self.reg_exp:
self.reg_exp = self.description

super(DamageType,self).save()



/Paul

On Tuesday, October 21, 2014 12:52:45 PM UTC-3, Collin Anderson wrote:
>
> Hi Paul,
>
> Interesting. Your code should work fine. So if you run this code in the 
> shell it gives a FieldError?
>
> affpart.damage_types.all()
>
> What do your sitar models look like? There should not be a ManyToManyField 
> in the other direction.
>
> Collin
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a43b7fb-4937-4a41-b519-0134cd64a01f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
Here is the stack trace...

Environment:

Request Method: POSTRequest URL: http://127.0.0.1:8000/trending/trend/
Django Version: 1.6Python Version: 2.6.7Installed 
Applications:('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'sitar')Installed Middleware:('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback:File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py" in 
get_response
  114. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\contrib\auth\decorators.py" 
in _wrapped_view
  22. return view_func(request, *args, **kwargs)File 
"C:\virtual_env\sitar_env2\cissimp\trending\views.py" in trend
  418. list_result = utils.convert_queryset_to_lists(q_results, 
form)File "C:\virtual_env\sitar_env2\cissimp\trending\utils.py" in 
convert_queryset_to_lists
  918.for dt in affpart.damage_types.all()]),File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\manager.py" in all
  133. return self.get_queryset()File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\fields\related.py"
 in get_queryset
  539. return super(ManyRelatedManager, 
self).get_queryset().using(db)._next_is_sticky().filter(**self.core_filters)File
 "C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\query.py" in 
filter
  590. return self._filter_or_exclude(False, *args, **kwargs)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\query.py" in 
_filter_or_exclude
  608. clone.query.add_q(Q(*args, **kwargs))File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
add_q
  1198. clause = self._add_q(where_part, used_aliases)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
_add_q
  1232. current_negated=current_negated)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
build_filter
  1100. allow_explicit_fk=True)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
setup_joins
  1351. names, opts, allow_many, allow_explicit_fk)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
names_to_path
  1274.  "Choices are: %s" % (name, ", 
".join(available)))
Exception Type: FieldError at /trending/trend/Exception Value: Cannot resolve 
keyword u'affectedpart' into field. Choices are: cgs_damage_code, description, 
id, reg_exp, sti


On Tuesday, October 21, 2014 1:00:36 PM UTC-3, Paul Childs wrote:
>
> Hey Collin,
>
> I had no problem in the shell...
>
>
> In [4]: AffectedPart.objects.all().count()
> Out[4]: 4090
> # pick a random AffectedPart
> In [5]: affpart = AffectedPart.objects.all()[22]
>
> In [6]: affpart.damage_types.all()
> Out[6]: []
>
> I'm not sure why this doesn't work running under the server.
>
> My models look like this:
>
> from sitar.models import (Part, DamageType, Aircraft)
> # this model is in trending.modelsclass AffectedPart(models.Model):
> res = models.ForeignKey(Res, null=True)
> arising = models.ForeignKey(Arising, null=True)
>
> aircraft = models.ForeignKey(Aircraft)
> # filled out automatically only if part to Damage/Repair type matching 
> done
> maintenance_phase = models.CharField(max_length=10,
>  choices=MAINTENANCE_PHASE_CHOICES)
> occurrence_date = models.DateField()
> partnumber = models.ForeignKey(Part)
> damage_types = models.ManyToManyField(DamageType, null=True, blank=True)
> repair_types = models.ManyToManyField(RepairType, null=True, blank=True)
>
> def __unicode__(self, ):
> if self.res:
> parent = self.res.number
>
> else:
> parent = str(self.arising)
>
> return '{0} - {1}'.format(self.partnumber.number, parent)
> # The following models are in sitar.modelsclass Part(models.Model):
> ''' This model is used to create pick-lists so the 

Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
I am SHOCKED. That was the problem. THANK YOU

I guess that leads to a couple of questions:

1. How did you know!?!
2.I have the same code in production and it was working with no problems. 
Any idea why?

Cheers!

On Tuesday, October 21, 2014 1:12:33 PM UTC-3, Collin Anderson wrote:
>
> Hi Paul,
>
> Try putting 'trending' in INSTALLED_APPS.
>
> Collin
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9bb45159-61ba-4b65-8bcd-37c5593efaa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Many-to-many Relationship Between Django Apps Fails

2014-10-21 Thread Paul Childs
Thanks man. This was a huge relief!

On Tue, Oct 21, 2014 at 2:35 PM, Collin Anderson 
wrote:

> Hi Paul,
>
> 1. How did you know!?!
>>
> I hack... kidding :). I suspected something wasn't getting loaded, and the
> list of installed apps was in the traceback you posted.
>
> 2.I have the same code in production and it was working with no problems.
>> Any idea why?
>>
> In development, most, if not all of your code is loaded and run on
> startup, and in production (at least before 1.7), things are really only
> loaded as needed. Basically with the app loading refactor and
> django.setup(), we're finally fixing problems like this.
>
> Collin
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/4_Cdw5xpx-w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d1617a57-9a60-4727-a610-308e44789db1%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGOvLBpNtvkFbp9zOfYkpQDONfWQBmdRam6DZTrj-GOP9rrEpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.