Re: Admin Pages - want horizontal scroll ability

2009-03-02 Thread Peter Bailey

Yeah, I have big objects in tables. Sigh, was hoping to avoid writing
more css, but thought it might come down to that.

Thanks Alex.


On Mar 2, 3:09 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Mon, Mar 2, 2009 at 3:06 PM, Peter Bailey <p.h.bai...@gmail.com> wrote:
>
> > Hello, I am building a small app that just requires admin
> > functionality, Thought I was about done, but my customer tried it on a
> > huge 1024x768 monitor (have not seen one for a few years). Turns out
> > the if the admin pages would slide horizontally as well as vertically,
> > things would be fine. Works real nice on 1900x1200 and my Macbook
> > Pro :-)
>
> > I have looked around and not seen an easy solution for this (which if
> > course I am hoping for, since I thought I was wrapping up). Does
> > anyone know any easy way to do this or can you shout me any good
> > pointers. '
>
> > Help most appreciated, thanks,
>
> > Peter
>
> From looking over the admin CSS it looks like it has the minimum width
> property on the container div set at 
> 760px:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm...
>
> To lower that you'll probably need to write some of your own CSS to make it
> play nice. FWIW it may just be that you have some really long strings being
> displayed in certain places since I don't notice any issues on my 1280*800
> laptop.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Admin Pages - want horizontal scroll ability

2009-03-02 Thread Peter Bailey

Hello, I am building a small app that just requires admin
functionality, Thought I was about done, but my customer tried it on a
huge 1024x768 monitor (have not seen one for a few years). Turns out
the if the admin pages would slide horizontally as well as vertically,
things would be fine. Works real nice on 1900x1200 and my Macbook
Pro :-)

I have looked around and not seen an easy solution for this (which if
course I am hoping for, since I thought I was wrapping up). Does
anyone know any easy way to do this or can you shout me any good
pointers. '

Help most appreciated, thanks,

Peter


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



Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

Well I experimented with your tips Daniel, and put this in my forms
file:

class SurveyForm(forms.ModelForm):

name = forms.CharField(max_length=50, widget=forms.TextInput(attrs=
{'size':'50'}))

class Meta:
model = Survey

And it works. I assume I just add the ones above that I want to change
the defaults on? Much DRYer - ah

Thank You


On Jan 15, 1:38 pm, Peter Bailey <p.h.bai...@gmail.com> wrote:
> Thanks for the tips Dan, I thought the DRY thing could not be right.
> Not sure I understand tho - I originally made the form with just the
> inner Meta class definition - do you do that and then override things
> that need to change (e.g. where I want to use a longer TextInput
> widget or whatever.
>
> Things worked fine until I changed to the above form definition so
> that I could make mods to the default output.
>
> re "client = forms.ModelChoiceField(User.objects.all())", that is the
> line I mentioned above that I commented out because I suspected it
> too. I tried your change, still not working
>
> Here is the traceback. Thanks Dan and Andrew, listening while I am
> being so verbose, but I wanted to convey as much info as possible. I
> am learning django and python together, and it gets to be pretty
> boggling sometimes, although it is the most fun developing I have had
> in years. I appreciate you taking your time looking at this.
>
> Environment:
>
> Request Method: GET
> Request URL:http://localhost:8000/surveyadd/
> Django Version: 1.1 pre-alpha SVN-9734
> Python Version: 2.5.1
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'generator.surveys']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.middleware.doc.XViewMiddleware')
>
> Traceback:
> File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
> in get_response
>   86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Users/peterbailey/pywork/generator/../generator/surveys/
> views.py" in surveyadd
>   137.         form = SurveyForm()
> File "/Library/Python/2.5/site-packages/django/forms/models.py" in
> __init__
>   212.             self.instance = opts.model()
>
> Exception Type: TypeError at /surveyadd/
> Exception Value: 'NoneType' object is not callable
>
> Hope that is all the traceback info you need.
>
> Peter
>
> On Jan 15, 1:16 pm, Daniel Roseman <roseman.dan...@googlemail.com>
> wrote:
>
> > On Jan 15, 5:35 pm, Peter Bailey <p.h.bai...@gmail.com> wrote:
>
> > > I have just recently started using forms. I was avoiding them because
> > > I thought they were not very DRY, but discovered I need them for added
> > > flexibility such as displaying field lengths for example.
>
> > > Anyway, I have created a Form for a Survey object that I use. If I go
> > > to my edit page for a Survey, everything works perfectly. If I go to
> > > do a simple add new (like right out of the docs), I always receive an
> > > error "NoneType' object is not callable". So I am assuming I am trying
> > > to use something not in existence yet, but it seems bizarre to me (but
> > > I am a form noob and hoping I am doing something stupid (at least 1
> > > thing)). Here is my model
>
> > 
>
> > > I tried commenting out the foreign key to the user but that made no
> > > difference. I must be doing something stupid here (obvious hopefully).
>
> > > Can anyone tell me what the problem is?
>
> > > Thanks,
>
> > > Peter
>
> > Why have you repeated all the definitions from the model in your form?
> > As you say, that isn't very DRY, but there's no reason to do it at
> > all.
>
> > It would have been helpful to have posted the full traceback. I
> > suspect your error is coming from this line:
> >         client = forms.ModelChoiceField(User.objects.all())
> > which should be
> >         client = forms.ModelChoiceField(queryset=User.objects.all())
> > However, as i note above, you don't need the line - or any of the
> > field declarations - at all. You do, however, need an inner Meta class
> > which defines the model the form belongs to (Survey).
>
> > --
> > DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

Thanks Andy


On Jan 15, 1:50 pm, Andy Mckay  wrote:
> I don't think you are defining the ModelForm correctly, the whole  
> point is that Django creates the fields for you. If you look at:
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms
>
> This is the key difference between a ModelForm and a normal form:
>
> http://docs.djangoproject.com/en/dev/topics/forms/#form-objects
>
> You'll see there are no field definitions and there is instead a  
> pointer through class Meta: to the model. The form is trying to create  
> the model and failing. A better form for you would be:
>
> class SurveyForm(forms.ModelForm):
>      class Meta:
>          model = Survey
>
> (add in your import statement so it knows what Survey is).
>
> Cheers
> --
>    Andy McKay
>    ClearWind Consulting:www.clearwind.ca
>    Blog:www.agmweb.ca/blog/andy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

Thanks for the tips Dan, I thought the DRY thing could not be right.
Not sure I understand tho - I originally made the form with just the
inner Meta class definition - do you do that and then override things
that need to change (e.g. where I want to use a longer TextInput
widget or whatever.

Things worked fine until I changed to the above form definition so
that I could make mods to the default output.

re "client = forms.ModelChoiceField(User.objects.all())", that is the
line I mentioned above that I commented out because I suspected it
too. I tried your change, still not working

Here is the traceback. Thanks Dan and Andrew, listening while I am
being so verbose, but I wanted to convey as much info as possible. I
am learning django and python together, and it gets to be pretty
boggling sometimes, although it is the most fun developing I have had
in years. I appreciate you taking your time looking at this.

Environment:

Request Method: GET
Request URL: http://localhost:8000/surveyadd/
Django Version: 1.1 pre-alpha SVN-9734
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'generator.surveys']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/peterbailey/pywork/generator/../generator/surveys/
views.py" in surveyadd
  137. form = SurveyForm()
File "/Library/Python/2.5/site-packages/django/forms/models.py" in
__init__
  212. self.instance = opts.model()

Exception Type: TypeError at /surveyadd/
Exception Value: 'NoneType' object is not callable


Hope that is all the traceback info you need.

Peter





On Jan 15, 1:16 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Jan 15, 5:35 pm, Peter Bailey <p.h.bai...@gmail.com> wrote:
>
> > I have just recently started using forms. I was avoiding them because
> > I thought they were not very DRY, but discovered I need them for added
> > flexibility such as displaying field lengths for example.
>
> > Anyway, I have created a Form for a Survey object that I use. If I go
> > to my edit page for a Survey, everything works perfectly. If I go to
> > do a simple add new (like right out of the docs), I always receive an
> > error "NoneType' object is not callable". So I am assuming I am trying
> > to use something not in existence yet, but it seems bizarre to me (but
> > I am a form noob and hoping I am doing something stupid (at least 1
> > thing)). Here is my model
>
> 
>
> > I tried commenting out the foreign key to the user but that made no
> > difference. I must be doing something stupid here (obvious hopefully).
>
> > Can anyone tell me what the problem is?
>
> > Thanks,
>
> > Peter
>
> Why have you repeated all the definitions from the model in your form?
> As you say, that isn't very DRY, but there's no reason to do it at
> all.
>
> It would have been helpful to have posted the full traceback. I
> suspect your error is coming from this line:
>         client = forms.ModelChoiceField(User.objects.all())
> which should be
>         client = forms.ModelChoiceField(queryset=User.objects.all())
> However, as i note above, you don't need the line - or any of the
> field declarations - at all. You do, however, need an inner Meta class
> which defines the model the form belongs to (Survey).
>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey

I have just recently started using forms. I was avoiding them because
I thought they were not very DRY, but discovered I need them for added
flexibility such as displaying field lengths for example.

Anyway, I have created a Form for a Survey object that I use. If I go
to my edit page for a Survey, everything works perfectly. If I go to
do a simple add new (like right out of the docs), I always receive an
error "NoneType' object is not callable". So I am assuming I am trying
to use something not in existence yet, but it seems bizarre to me (but
I am a form noob and hoping I am doing something stupid (at least 1
thing)). Here is my model

class Survey(models.Model):
"""Highest level class that defines the attriutes of a survey"""
STATUS_CHOICES = (
('A', 'Active'),
('C', 'Complete'),
('D', 'Development'),
)

TYPE_CHOICES = (
('A', 'Public'),
('B', 'Private'),
)

STATUS_DBS = (
('A', 'MySQL'),
('B', 'MS SQL'),
)

STATUS_OS = (
('A', 'Linux'),
('B', 'OS X'),
('C', 'Unix'),
('D', 'Windows'),
)

STATUS_LANG = (
('A', 'English'),
)

STATUS_ENC = (
('A', 'Autodetect'),
('B', 'Utf8 (UTF-8 unicode)'),
('C', 'ISO Latin 1 (latin1)'),
)


name = models.CharField(max_length=50)
client = models.ForeignKey(User)
gen_source_path = models.CharField(max_length=100)
gen_dest_path = models.CharField(max_length=100)
url = models.CharField(max_length=100, blank=True)
db_type = models.CharField(max_length=1, choices=STATUS_DBS)
db_name = models.CharField(max_length=50)
table_name = models.CharField(max_length=50)
cookie_name = models.CharField(max_length=50)
header_title1 = models.CharField(max_length=50)
header_title2 = models.CharField(max_length=50)
header_title3 = models.CharField(max_length=50)
footer_title1 = models.CharField(max_length=50)
footer_title2 = models.CharField(max_length=50)
status = models.CharField(max_length=1, choices=STATUS_CHOICES)
survey_type = models.CharField(max_length=1, choices=TYPE_CHOICES)
operating_system = models.CharField(max_length=1, choices=STATUS_OS)
language = models.CharField(max_length=1, choices=STATUS_LANG)
encoding = models.CharField(max_length=1, choices=STATUS_ENC)

def __unicode__(self):
return self.name

def client_name(self):
return str(self.client.user)

class Meta:
ordering = ["name"]

and this is the form:

class SurveyForm(forms.ModelForm):

"""Highest level class that defines the attriutes of a survey"""
STATUS_CHOICES = (
('A', 'Active'),
('C', 'Complete'),
('D', 'Development'),
)

TYPE_CHOICES = (
('A', 'Public'),
('B', 'Private'),
)

STATUS_DBS = (
('A', 'MySQL'),
('B', 'MS SQL'),
)

STATUS_OS = (
('A', 'Linux'),
('B', 'OS X'),
('C', 'Unix'),
('D', 'Windows'),
)

STATUS_LANG = (
('A', 'English'),
)

STATUS_ENC = (
('A', 'Autodetect'),
('B', 'Utf8 (UTF-8 unicode)'),
('C', 'ISO Latin 1 (latin1)'),
)

name = forms.CharField(max_length=50, widget=forms.TextInput(attrs=
{'size':'50'}))
client = forms.ModelChoiceField(User.objects.all())
gen_source_path = forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'size':'50'}))
gen_dest_path = forms.CharField(max_length=100 ,widget=forms.TextInput
(attrs={'size':'50'}))
url = forms.CharField(max_length=100, required=False,
widget=forms.TextInput(attrs={'size':'50'}))
db_type = forms.CharField(max_length=1, widget=forms.Select
(choices=STATUS_DBS))
db_name = forms.CharField(max_length=50 ,widget=forms.TextInput(attrs=
{'size':'50'}))
table_name = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
cookie_name = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
header_title1 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
header_title2 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
header_title3 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
footer_title1 = forms.CharField(max_length=50 ,widget=forms.TextInput
(attrs={'size':'50'}))
footer_title2 = forms.CharField(max_length=50 

Re: Django-like PHP framework?

2009-01-05 Thread Peter Bailey

You might want to have a look at CakePHP. It follows the MCV pattern I
believe, although I have not looked closely because it is PHP not
Python.

http://cakephp.org/

Peter


On Jan 5, 8:31 am, "thi.l...@gmail.com"  wrote:
> Hi,
>
> I have a hard time getting Django adopted as web framework in the
> office.
> Mostly because the boss paid for PHP-based trainings, and our current
> infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> I was wondering if some fo you know about competitor PHP frameworks
> that "look like" Django, or at least try to reach that level of
> purity.
>
> Thanks for any comment (and sorry about this unfair request :-P)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ForeignKey value return from web page

2008-12-03 Thread Peter Bailey

Sorry for babbling Daniel :-) , my use of all this terminology is
still growing (I hope). Anyway, I sorted it out thanks to your brief
description above. Trying to do too much twisting and turning lol.

Cheers


On Dec 3, 11:24 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Dec 3, 3:25 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am trying to use ForeignKey data returned from a page and view, and
> > am having trouble. I am missing something fundamental I think.
>
> > Say I have 2 models
>
> > class TopModel(models.Model):
> >         name = models.CharField(max_length=50)
> >         db_type = models.CharField(max_length=1, choices=STATUS_DBS)
>
> > # and another class with an FK to the above
>
> > class OtherModel(models.Model):
> >         name = models.CharField(max_length=50)
> >         topmodel = models.ForeignKey(TopModel)
>
> > # Form classes for the above are just as follows:
>
> > class TopModelForm(forms.ModelForm):
>
> >     class Meta:
> >             model = TopModel
>
> > class OtherModel(forms.ModelForm):
>
> >     class Meta:
> >             model = OtherModel
>
> > Anyway, if I go to a page template and view for OtherModel, say the
> > user selects an fk for TopModel in OtherModel,
> > I want to get back the actual fk number , e.g, 3, 10, 1, or whatever
> > from the post dict. I currently do not get a value back for this (or
> > I am calling it the wrong thing or something).
>
> > I just want the Interger id for the fk that would be in the db). I
> > want to use this type of access several layers deep in cases,
> > and this seems like it should be dirt simple (it would be the old
> > school way), but of course, I am trying to get away from that.
>
> > I have been looking through the docs and things and just confusing
> > myself
> > more and more.
>
> > So, can anyone tell me what I am doing wrong or if there is an easy
> > (and efficient) way to do this, or perhaps point me to a piece of
> > actual code that does something similar.
>
> > Thanks very much,
>
> > Peter
>
> Sorry, I'm not able to understand what your issue is. What do you mean
> by 'going to a page template' and 'getting back' an FK?
>
> I think you need to explain your use case a bit more. A ModelForm is
> basically for editing and creating instances of a model. Are you
> trying to use it for navigation? Maybe an example of your view might
> help.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ForeignKey value return from web page

2008-12-03 Thread Peter Bailey

I am trying to use ForeignKey data returned from a page and view, and
am having trouble. I am missing something fundamental I think.

Say I have 2 models

class TopModel(models.Model):
name = models.CharField(max_length=50)
db_type = models.CharField(max_length=1, choices=STATUS_DBS)

# and another class with an FK to the above

class OtherModel(models.Model):
name = models.CharField(max_length=50)
topmodel = models.ForeignKey(TopModel)


# Form classes for the above are just as follows:

class TopModelForm(forms.ModelForm):

class Meta:
model = TopModel

class OtherModel(forms.ModelForm):

class Meta:
model = OtherModel


Anyway, if I go to a page template and view for OtherModel, say the
user selects an fk for TopModel in OtherModel,
I want to get back the actual fk number , e.g, 3, 10, 1, or whatever
from the post dict. I currently do not get a value back for this (or
I am calling it the wrong thing or something).

I just want the Interger id for the fk that would be in the db). I
want to use this type of access several layers deep in cases,
and this seems like it should be dirt simple (it would be the old
school way), but of course, I am trying to get away from that.

I have been looking through the docs and things and just confusing
myself
more and more.

So, can anyone tell me what I am doing wrong or if there is an easy
(and efficient) way to do this, or perhaps point me to a piece of
actual code that does something similar.

Thanks very much,

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



Re: Multiple saves without redirecting

2008-11-05 Thread Peter Bailey

Well that sounds very logical. Thanks very much. I'll make the changes
and give it a go.

Thanks again,

Peter


On Nov 5, 11:51 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 5, 3:54 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
>
>
> > I want to create a form for a large object that has numerous non-
> > mandatory fields. I am still learning django, and am missing something
> > easy I hope. All the examples and docs I see say to redirect after the
> > form is posted and saved to the db (in my case). What I want is to
> > leave the form up after the initial post, and allow a user to say, add
> > 3 more field entries and re-save, etc. This is to handle a use case of
> > when they are working on some data entry, want to save a partially
> > done page, and then either leave it up and continue at their leisure
> > or also come back and choose the object again and fill some more of
> > the info in (I guess those are really 2 use cases!).
>
> > This is a fairly common way of doing things in many of the business
> > sites I have worked on, but I cannot find much discussion on it or
> > documentation regarding it. Can anyone point me at some examples of
> > this type of usage or suggest an alternative. I am starting to wonder
> > if I am trying to bend the framework the wrong way, and maybe I need
> > to rethink my design.
>
> > Thanks for any feedback or help. It will be greatly appreciated. This
> > is an amazing framework but it is taking me a while to learn some of
> > the ins and outs. Must be from all those years of MS web programming
> > that have clouded my brain!
>
> > Cheers,
>
> > Peter
>
> There's nothing to say you shouldn't redirect back to the same page,
> or a version of it. The point of the redirect is simply to remove the
> possibility that the user would re-post the data if they pressed Back.
>
> Presumably, you have an 'add' page where the users create the original
> data. Once that is submitted, you'll need a page they can go to edit
> existing data. So, to use the same model as the built-in admin site,
> you'd have /mymodel/add/ and /mymodel/x/, where x is the PK of the
> existing instance. So all you want to do is, on save redirect to the
> 'edit' screen. In your view:
> if form.is_valid():
>     obj = form.save()
>     return HttpResponseRedirect('/mymodel/%s/' % obj.pk) # or better,
> use a URL reverse function
>
> You might want to do some checking of the POST first to see if they've
> chosen a button that allows them to continue editing, rather than
> quit.
>
> Now I've written this, I've realised this is *exactly* what the admin
> site does with the 'Save and continue editing' button - you might want
> to look in django.contrib.admin.views for some clues as to how this
> works.
>
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiple saves without redirecting

2008-11-05 Thread Peter Bailey

I want to create a form for a large object that has numerous non-
mandatory fields. I am still learning django, and am missing something
easy I hope. All the examples and docs I see say to redirect after the
form is posted and saved to the db (in my case). What I want is to
leave the form up after the initial post, and allow a user to say, add
3 more field entries and re-save, etc. This is to handle a use case of
when they are working on some data entry, want to save a partially
done page, and then either leave it up and continue at their leisure
or also come back and choose the object again and fill some more of
the info in (I guess those are really 2 use cases!).

This is a fairly common way of doing things in many of the business
sites I have worked on, but I cannot find much discussion on it or
documentation regarding it. Can anyone point me at some examples of
this type of usage or suggest an alternative. I am starting to wonder
if I am trying to bend the framework the wrong way, and maybe I need
to rethink my design.

Thanks for any feedback or help. It will be greatly appreciated. This
is an amazing framework but it is taking me a while to learn some of
the ins and outs. Must be from all those years of MS web programming
that have clouded my brain!

Cheers,

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



Re: Abstract Superclass and Foreign Keys

2008-09-22 Thread Peter Bailey

Well a good session with my db made it apparent why this looked like
it was working in Admin but not my other code - I had a join table
pointing to the item superclasses, and thus their names showed up - OK
- I feel even sillier now!

So, I am proceeding with the generic keys/relations and so far am not
sure that the Admin is creating my supertype class properly when I
create a subtype. Can anyone tell me if it should, or whether I need
to hook the code and do something manually when I am creating these
through the Admin.

Sorry to keep bothering everyone.

Peter



On Sep 22, 12:34 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> Malcolm, (or any other knowledgeable soul), I have been experimenting
> with bothabstractclasses and GenericForeignKeys and Relations to
> solve my issues, and I still have some problems and questions. There
> are not a lot of examples of those, and what I really need is for this
> all to work properly in the admin so I can add a page and in the page
> inline be able to add any sub-classed "Item". Can you tell me if that
> type of functionality is supported in Admin yet with generic keys?
>
> Also, I discovered my issue above when I was writing some backend code
> to generate pages from the data collected in the Admin. Theforeignkeyissue 
> then became apparent. One thing I am trying to wrap my head
> around however is that when using my original model as above, the
> Admin app handled everything correctly. I was able to add several
> different item sub-types individually and attach them to pages without
> problem, and everything seemed to work fine and things also seemed
> correct in the database, So I guess I completely see the logic of why
> a generickeywould be required, but the Admin seems to work with what
> I gave it correctly - I know it has a lot of magic, but I keep going
> back and thinking if the Admin can work properly with this, there must
> be a way that I can too. Very frustrating. Thoughts anyone (maybe I am
> losing it :-) .
>
> Thanks again,
>
> Peter
>
> On Sep 16, 9:37 am, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the responses. There are a number of subclasses and I won't
> > know the specifics initially. I'll check out the GenericForeighnKey.
> > Sounds like it is what I want.
>
> > Thanks again,
>
> > Peter
>
> > On Sep 16, 8:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Mon, 2008-09-15 at 18:10 -0700, Peter Bailey wrote:
> > > > Hi all. I have a set of classes (web page items like radios,
> > > > checkboxes, etc.) They are built on asuperclass- Item.  I need a
> > > > join table to link them to specific pages in which I also store a
> > > > position (PageItem) . Here is a snippet:
>
> > > > #
> > > > ---
> > > >  ---
> > > > # will use this for subclassing into our item subtypes
> > > > #
> > > > ---
> > > >  ---
>
> > > > class Item(models.Model):
> > > >    name = models.CharField(max_length=30)
>
> > > >    def __unicode__(self):
> > > >        return self.name
>
> > > >    class Meta:
> > > >        abstract= True
>
> > > > #
> > > > ---
> > > >  ---
>
> > > > class Page(models.Model):
> > > >    website = models.ForeignKey(Website)
> > > >    position = models.IntegerField()
> > > >    file_name = models.CharField(max_length=50)
> > > >    h1_title = models.CharField(max_length=50)
>
> > > >    def __unicode__(self):
> > > >            return self.file_name
>
> > > >    class Meta:
> > > >        ordering = ["file_name"]
>
> > > > #
> > > > ---
> > > >  ---
>
> > > > class PageItem(models.Model):
> > > >    page = models.ForeignKey(Page, editable=False)
> > > >    item = models.ForeignKey(Item) # WANT THIS TO POINT TO SPECIFIC
> > > > SUBCLASS ITEM
> > > >    position = models.IntegerField()
>
> > > >    def name(self):
> > > >            return str(self.item.name)
>
> > > >    class Meta:
> > > >            ordering = ['position']
>
> > > > #
> > > > -

Re: Abstract Superclass and Foreign Keys

2008-09-22 Thread Peter Bailey

Malcolm, (or any other knowledgeable soul), I have been experimenting
with both abstract classes and Generic Foreign Keys and Relations to
solve my issues, and I still have some problems and questions. There
are not a lot of examples of those, and what I really need is for this
all to work properly in the admin so I can add a page and in the page
inline be able to add any sub-classed "Item". Can you tell me if that
type of functionality is supported in Admin yet with generic keys?

Also, I discovered my issue above when I was writing some backend code
to generate pages from the data collected in the Admin. The foreign
key issue then became apparent. One thing I am trying to wrap my head
around however is that when using my original model as above, the
Admin app handled everything correctly. I was able to add several
different item sub-types individually and attach them to pages without
problem, and everything seemed to work fine and things also seemed
correct in the database, So I guess I completely see the logic of why
a generic key would be required, but the Admin seems to work with what
I gave it correctly - I know it has a lot of magic, but I keep going
back and thinking if the Admin can work properly with this, there must
be a way that I can too. Very frustrating. Thoughts anyone (maybe I am
losing it :-) .

Thanks again,

Peter


On Sep 16, 9:37 am, Peter Bailey <[EMAIL PROTECTED]> wrote:
> Thanks for the responses. There are a number of subclasses and I won't
> know the specifics initially. I'll check out the GenericForeighnKey.
> Sounds like it is what I want.
>
> Thanks again,
>
> Peter
>
> On Sep 16, 8:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Mon, 2008-09-15 at 18:10 -0700, Peter Bailey wrote:
> > > Hi all. I have a set of classes (web page items like radios,
> > > checkboxes, etc.) They are built on asuperclass- Item.  I need a
> > > join table to link them to specific pages in which I also store a
> > > position (PageItem) . Here is a snippet:
>
> > > #
> > > ---
> > >  ---
> > > # will use this for subclassing into our item subtypes
> > > #
> > > ---
> > >  ---
>
> > > class Item(models.Model):
> > >    name = models.CharField(max_length=30)
>
> > >    def __unicode__(self):
> > >        return self.name
>
> > >    class Meta:
> > >        abstract = True
>
> > > #
> > > ---
> > >  ---
>
> > > class Page(models.Model):
> > >    website = models.ForeignKey(Website)
> > >    position = models.IntegerField()
> > >    file_name = models.CharField(max_length=50)
> > >    h1_title = models.CharField(max_length=50)
>
> > >    def __unicode__(self):
> > >            return self.file_name
>
> > >    class Meta:
> > >        ordering = ["file_name"]
>
> > > #
> > > ---
> > >  ---
>
> > > class PageItem(models.Model):
> > >    page = models.ForeignKey(Page, editable=False)
> > >    item = models.ForeignKey(Item) # WANT THIS TO POINT TO SPECIFIC
> > > SUBCLASS ITEM
> > >    position = models.IntegerField()
>
> > >    def name(self):
> > >            return str(self.item.name)
>
> > >    class Meta:
> > >            ordering = ['position']
>
> > > #
> > > ---
> > >  ---
>
> > > class RadioBoxType(Item):
> > >    """A Radio Button object with its specific attributes"""
> > >        . etc.
>
> > > My problem is that I want the item/page relationship in the join table
> > > PageItem, so I can track the position. I realize that I can't have a
> > > fk to an abstract class though and obviously want it to point to the
> > > subclassed object.
>
> > So point it at the subclass you want it to point at.
>
> > If you mean, however, that you want it to point to one of a number of
> > possible subclasses, depending on the instance, then that isn't a
> > ForeignKey (a ForeignKey points to one particular model). What you're
> > modelling in that case is best done with the GenericForeignKey, since
> > that encodes both the content type (i.e. the model type) of the target
> > as well as the primarykeyvalue.
>
> > 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: Abstract Superclass and Foreign Keys

2008-09-16 Thread Peter Bailey

Thanks for the responses. There are a number of subclasses and I won't
know the specifics initially. I'll check out the GenericForeighnKey.
Sounds like it is what I want.

Thanks again,

Peter


On Sep 16, 8:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Mon, 2008-09-15 at 18:10 -0700, Peter Bailey wrote:
> > Hi all. I have a set of classes (web page items like radios,
> > checkboxes, etc.) They are built on a superclass - Item.  I need a
> > join table to link them to specific pages in which I also store a
> > position (PageItem) . Here is a snippet:
>
> > #
> > --- 
> > ---
> > # will use this for subclassing into our item subtypes
> > #
> > --- 
> > ---
>
> > class Item(models.Model):
> >    name = models.CharField(max_length=30)
>
> >    def __unicode__(self):
> >        return self.name
>
> >    class Meta:
> >        abstract = True
>
> > #
> > --- 
> > ---
>
> > class Page(models.Model):
> >    website = models.ForeignKey(Website)
> >    position = models.IntegerField()
> >    file_name = models.CharField(max_length=50)
> >    h1_title = models.CharField(max_length=50)
>
> >    def __unicode__(self):
> >            return self.file_name
>
> >    class Meta:
> >        ordering = ["file_name"]
>
> > #
> > --- 
> > ---
>
> > class PageItem(models.Model):
> >    page = models.ForeignKey(Page, editable=False)
> >    item = models.ForeignKey(Item) # WANT THIS TO POINT TO SPECIFIC
> > SUBCLASS ITEM
> >    position = models.IntegerField()
>
> >    def name(self):
> >            return str(self.item.name)
>
> >    class Meta:
> >            ordering = ['position']
>
> > #
> > --- 
> > ---
>
> > class RadioBoxType(Item):
> >    """A Radio Button object with its specific attributes"""
> >        . etc.
>
> > My problem is that I want the item/page relationship in the join table
> > PageItem, so I can track the position. I realize that I can't have a
> > fk to an abstract class though and obviously want it to point to the
> > subclassed object.
>
> So point it at the subclass you want it to point at.
>
> If you mean, however, that you want it to point to one of a number of
> possible subclasses, depending on the instance, then that isn't a
> ForeignKey (a ForeignKey points to one particular model). What you're
> modelling in that case is best done with the GenericForeignKey, since
> that encodes both the content type (i.e. the model type) of the target
> as well as the primary key value.
>
> 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
-~--~~~~--~~--~--~---



Abstract Superclass and Foreign Keys

2008-09-15 Thread Peter Bailey

Hi all. I have a set of classes (web page items like radios,
checkboxes, etc.) They are built on a superclass - Item.  I need a
join table to link them to specific pages in which I also store a
position (PageItem) . Here is a snippet:

#
--
# will use this for subclassing into our item subtypes
#
--

class Item(models.Model):
name = models.CharField(max_length=30)

def __unicode__(self):
return self.name

class Meta:
abstract = True

#
--

class Page(models.Model):
website = models.ForeignKey(Website)
position = models.IntegerField()
file_name = models.CharField(max_length=50)
h1_title = models.CharField(max_length=50)

def __unicode__(self):
return self.file_name

class Meta:
ordering = ["file_name"]

#
--

class PageItem(models.Model):
page = models.ForeignKey(Page, editable=False)
item = models.ForeignKey(Item) # WANT THIS TO POINT TO SPECIFIC
SUBCLASS ITEM
position = models.IntegerField()

def name(self):
return str(self.item.name)

class Meta:
ordering = ['position']

#
--

class RadioBoxType(Item):
"""A Radio Button object with its specific attributes"""
   . etc.

My problem is that I want the item/page relationship in the join table
PageItem, so I can track the position. I realize that I can't have a
fk to an abstract class though and obviously want it to point to the
subclassed object. Is there a better way to go about this or a work
around anyone can point me at. Seems straight forward from an object
perspective, maybe not for the ORM?

My join table was working fine until I changed to the abstract
supercalss (to solve another problem :-), and there are quite a few
different item types.

Any thoughts most appreciated. I am using django 1.0

Thanks for listening,

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



Re: Stupid noob question - admin link

2008-09-10 Thread Peter Bailey

Thanks everyone for your answers. Lots to learn here, but sure is fun!


On Sep 10, 1:03 pm, AmanKow <[EMAIL PROTECTED]> wrote:
> > Summary : You could simply copy the file base_site.html from admin
> > templates to a directory called "admin" in your own template directory
> > and add a link to your own pages in {% block branding %} so you would
> > have access to the link on every admin page.
>
> Actually, there is an empty block defined in base.html to serve this
> purpose:
>
> {% block nav-global %}
> 
> Main |
> Grants |
> Global |
> Site
> 
> {% endblock %}
>
> I use the above in a custom base_site.html and it works great
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Stupid noob question - admin link

2008-09-09 Thread Peter Bailey

Hi Daniel.

I think this is way more complex than what I want.
I have a main page (e..g. the default page in my web root). It is
really just a title page with several links, one of which is to my
admin site to add/update objects. I just want a straight link back on
the admin page to the page in my root where I came from, so the user
can navigate there after completing whatever they were doing in admin.

On Sep 9, 3:42 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Sep 9, 7:16 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Hi all, starting to think there is so much stuff in django and python
> > that I will never learn it all. I am building a site that used the
> > admin piece for most of the CRUD and a few other pages for the rest of
> > my requirements. I link to the admin from my main app page, and would
> > like to be able to link back the other way. Don't see an obvious way
> > to do this. Can anyone tell me a easy way to add a hyperlink from the
> > main admin page to somewhere else outside the admin app.
>
> > Thanks, and sorry for the dumb question.
>
> > Peter
>
> If you define a get_absolute_url() method on your model, you'll get an
> automatic 'view on site' link from the editing page in the admin which
> goes to the view defined by that method - 
> seehttp://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolu...
> . Is that what you want?
> --
> DR
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Stupid noob question - admin link

2008-09-09 Thread Peter Bailey

Hi all, starting to think there is so much stuff in django and python
that I will never learn it all. I am building a site that used the
admin piece for most of the CRUD and a few other pages for the rest of
my requirements. I link to the admin from my main app page, and would
like to be able to link back the other way. Don't see an obvious way
to do this. Can anyone tell me a easy way to add a hyperlink from the
main admin page to somewhere else outside the admin app.

Thanks, and sorry for the dumb question.

Peter


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



Re: Migrating to newforms-admin and classes already registered error

2008-07-22 Thread Peter Bailey

That works much better Malcolm, thank you very much. Appreciate the
explanations too.

Cheers,

Peter


On Jul 22, 3:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-22 at 12:21 -0700, Peter Bailey wrote:
> > Hi all. I am attempting to convert an app I am writing to use the nfa.
> > I have looked at all the docs available about this, but must have
> > missed something. I am using:
>
> > Django version 1.0-alpha-SVN-8053
>
> > Anyway, I have changed my urls.py file to be like so:
>
> > from django.contrib import admin
>
> >     (r'^admin/(.*)', admin.site.root),  # in urlpatterns
>
> > and in my models file I have:
>
> > from django.contrib import admin
>
> > and then after my Page class declaration I have
>
> > admin.site.register(Page)
>
> > which creates the following error at runtime:
>
> > ImproperlyConfigured at /
> > Error while importing URLconf 'generator.urls': The model Page is
> > already registered
>
> > I have tried using the autodiscover and not using it - same result - I
> > also see some people are using an admin.py file and some are just
> > modifying the model.py file.
>
> > Can anyone point me at some info or tell me what I am doing wrong.
> > Feeling kinda stupid about now...
>
> The recommended approach (and the reason for autodiscover()) is to put
> the admin classes and registration into admin.py. Your models.py files
> are imported more than once, which is leading to the duplicate
> registration error (which is a real error in other situations, which is
> why it exists).
>
> Putting things in admin.py is a way to make sure they're only registered
> once.
>
> 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
-~--~~~~--~~--~--~---



Migrating to newforms-admin and classes already registered error

2008-07-22 Thread Peter Bailey

Hi all. I am attempting to convert an app I am writing to use the nfa.
I have looked at all the docs available about this, but must have
missed something. I am using:

Django version 1.0-alpha-SVN-8053

Anyway, I have changed my urls.py file to be like so:

from django.contrib import admin

(r'^admin/(.*)', admin.site.root),  # in urlpatterns

and in my models file I have:

from django.contrib import admin

and then after my Page class declaration I have

admin.site.register(Page)

which creates the following error at runtime:

ImproperlyConfigured at /
Error while importing URLconf 'generator.urls': The model Page is
already registered

I have tried using the autodiscover and not using it - same result - I
also see some people are using an admin.py file and some are just
modifying the model.py file.

Can anyone point me at some info or tell me what I am doing wrong.
Feeling kinda stupid about now...

Thanks,

Peter



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



Re: Add column to generated ManyToMany table and access from admin

2008-05-19 Thread Peter Bailey

Thanks Russ.

On May 17, 4:26 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Sat, May 17, 2008 at 2:19 AM, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > However, I would really like to add a column to the join table,
> > "order", so I can use the admin of my Page class to add Items and
> > define their order on that particular page. Is there a way to do this?
>
> At present, this isn't possible. However, it is the subject of ticket
> #6095, which is under development. This includes some support for
> editing in the admin, but if you read the comments associated with
> that ticket, you'll find that there are some difficulties associated
> with the problem.
>
> [1]http://code.djangoproject.org/ticket/6095
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add column to generated ManyToMany table and access from admin

2008-05-16 Thread Peter Bailey

Thanks Richard, I'll give it a go.

Cheers


On May 16, 2:44 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
> I do not think that admin currently supports this, but I could be wrong. but
> here are two ways to accomplish it.
>
>  class Item(models.Model):
>name = models.CharField(max_length=30)
>
> class ItemOrder(models.Model):
> item = models.FK(Item)
> order = models.int()
>
> def __unicode__(self): return ('%s - %s'
> %(self.item.__unicode__(), self.order))
>
> class Page(models.Model):
>survey = models.ForeignKey(Survey)
>item = models.M2M(ItemOrder)
>order = models.IntegerField() #Page Order
>file_name = models.CharField(max_length=50)
>
> You can also add a 'unique_together' constraint to your meta class in
> ItemOrder, if helpful.
> hth,
> -richard
>
> On 5/16/08, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am pretty new to Django, and am building a web generating app. I am
> > hoping to get a lot of functionality out of the admin. So far that is
> > working great. I do have 2 classes in my models that have a many to
> > many relationship. The code is generated nicely and everything works
> > correctly.
> > The classes represent web pages and generic items that go on pages
> > such as radios, dropdowns, etc.
>
> > However, I would really like to add a column to the join table,
> > "order", so I can use the admin of my Page class to add Items and
> > define their order on that particular page. Is there a way to do this?
> > I have searched around and found lots of discussions, but no solid
> > answers. Sorry if this is a dumb question, but I admit I am a noob.
> > Here is a code snippet:
>
> > # will use this for subclassing into our item subtypes
> > class Item(models.Model):
> >name = models.CharField(max_length=30)
>
> >def __unicode__(self):
> >return self.name
>
> > class Page(models.Model):
> >"""Page information for survey pages - surveys will contain one or
> > more of these"""
> >survey = models.ForeignKey(Survey)
> >items = models.ManyToManyField(Item)
> >order = models.IntegerField()   # this is for page ordering - not
> > item ordering
> >file_name = models.CharField(max_length=50)
>
> >def __unicode__(self):
> >return self.file_name
>
> >class Admin:
> >pass
>
> > class RadioBoxType(Item):
> >"""A Radio Button object with its specific attributes"""
> > ...
>
> > So, if I could somehow add an order column to the generated
> > gen_pageitem table and edit it from the admin for the page, I would be
> > set. I'm also not using the new admin branch which I just noticed a
> > couple of days ago. Any advice on if I should switch now or later
> > would be most welcome. I don't mind using newer code, but I am unsure
> > of the timelines for that branch to move into the trunk etc. Don't
> > want to waste time learning code that will be obsolete, but do have
> > some deadlines to meet (of course).
>
> > Advice or pointers greatly appreciated,
>
> > Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Add column to generated ManyToMany table and access from admin

2008-05-16 Thread Peter Bailey

I am pretty new to Django, and am building a web generating app. I am
hoping to get a lot of functionality out of the admin. So far that is
working great. I do have 2 classes in my models that have a many to
many relationship. The code is generated nicely and everything works
correctly.
The classes represent web pages and generic items that go on pages
such as radios, dropdowns, etc.

However, I would really like to add a column to the join table,
"order", so I can use the admin of my Page class to add Items and
define their order on that particular page. Is there a way to do this?
I have searched around and found lots of discussions, but no solid
answers. Sorry if this is a dumb question, but I admit I am a noob.
Here is a code snippet:

# will use this for subclassing into our item subtypes
class Item(models.Model):
name = models.CharField(max_length=30)

def __unicode__(self):
return self.name

class Page(models.Model):
"""Page information for survey pages - surveys will contain one or
more of these"""
survey = models.ForeignKey(Survey)
items = models.ManyToManyField(Item)
order = models.IntegerField()   # this is for page ordering - not
item ordering
file_name = models.CharField(max_length=50)

def __unicode__(self):
return self.file_name

class Admin:
pass

class RadioBoxType(Item):
"""A Radio Button object with its specific attributes"""
...

So, if I could somehow add an order column to the generated
gen_pageitem table and edit it from the admin for the page, I would be
set. I'm also not using the new admin branch which I just noticed a
couple of days ago. Any advice on if I should switch now or later
would be most welcome. I don't mind using newer code, but I am unsure
of the timelines for that branch to move into the trunk etc. Don't
want to waste time learning code that will be obsolete, but do have
some deadlines to meet (of course).

Advice or pointers greatly appreciated,

Peter


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



Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Thanks for the info and pointers Karen, I really appreciate it. I got
the feeling this might be a semi-scary way when searching the web for
meta and python this afternoon, and didn't really find a lot. I did up
screen prototypes for this app, and then designed a db model to
accommodate it, and now need to write the python code for the db and
the views, etc. That's probably the reverse order a lot of django devs
use, but it has worked well for me over the years. And, I always look
at the actual db structure and try to reduce wasted space etc. I'll do
some re-thinking here - I was actually torn on whether to use subtypes
or not. More complicated (bad) but better db space usage (good). I
guess disk space is pretty cheap these days lol.

Thanks again,

Peter

On May 6, 6:25 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, May 6, 2008 at 3:01 PM, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Hey Karen. I used manage.py validate. My model validated before I
> > added the abstract class and changed the class signatures. But I
> > probably did something silly. Here is a chunk of the code:
>
> > # will use this for subclassing into our item subtypes
> > class AbstractType(models.Model):
> >    name = models.CharField(max_length=100)
> >    class Meta:
> >        abstract = True
>
> > class Item(models.Model):
> >    """Item information for survey pages - pages will contain one or
> > more of these"""
> >    sub_item = models.ForeignKey(AbstractType)
>
> This is the problem: you can't have a ForeignKey to an abstract model.  See
> this thread:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...
>
> particularly Malcolm's reply.  As mentioned in that thread, Django's way to
> have a ForeignKey "point" to an unknown (or incompletely specified) type is
> something called generic relations.  Though it might seem (as suggested at
> the beginning of that thread) that generic relations could be dropped in
> favor of model inheritance, that's not actually the case (as Malcolm
> describes).
>
> Alternatively, perhaps your use case would be better served by non-abstract
> inheritance?  Inheritance doc is here:
>
> http://www.djangoproject.com/documentation/model-api/#model-inheritance
>
> You probably want to give it a careful read and see which way best fits with
> they way you are approaching your problem.
>
> [snipped remainder of model definitions]
>
> > Well there is some of the model code - thanks for taking a look - I
> > think I need to spend a couple of weeks reading 24 hours a day to get
> > up to speed on all this technology, But I have just escaped from dot
> > niet and asp and sql server etc etc. Oh, what a feeling, what a rush!
>
> You are rather jumping into the deep end by starting off with inheritance,
> which only recently landed in the Django trunk.  So there are probably not
> that many blog posts or mailing list threads yet with guidance, sample
> scenarios, how to use the feature. etc.  But if you're comfortable with a
> steep learning curve, in the end I expect you will figure it out.  Good
> luck!
>
> Karen
>
> > Cheers
>
> > On May 6, 2:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]>
> > wrote:
>
> > > > Hey alen. I have tried implementing this and it makes good sense as
> > > > far as I can see, but when I validate the model I always get an
> > > > AttributeError: 'NoneType' object has no attribute 'name'.
>
> > > How are you validating the model?
>
> > > I have tried removing name from the definition of the class - same
>
> > > > message (not sure where it is getting 'name' from since I deleted it.
> > > > I also looked around and saw that some other have had similar
> > > > problems, and it seemed to be a string definition problem. So I put
> > > > back 'name' and changed it to an IntegerField - same unhappy result.
>
> > > > Do you have any notion of what the problem is? The code looks right to
> > > > me.
>
> > > It sounds like you have some code somewhere that is expecting to always
> > be
> > > handed an instance of your model, and thus be able to access the field
> > > 'name', but it is in fact sometimes getting handed None.  When handed
> > None,
> > > it still tries to access 'name', but since None has no attribute 'name',
> > you
> > > get the error.  If you post the code someone could probably help
> > pinpoint
> > > the error more specifically.
&

Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Hey Karen. I used manage.py validate. My model validated before I
added the abstract class and changed the class signatures. But I
probably did something silly. Here is a chunk of the code:

# will use this for subclassing into our item subtypes
class AbstractType(models.Model):
name = models.CharField(max_length=100)
class Meta:
abstract = True

class Item(models.Model):
"""Item information for survey pages - pages will contain one or
more of these"""
sub_item = models.ForeignKey(AbstractType)
order = models.IntegerField()
class Admin:
pass

class Page(models.Model):
"""Page information for pages - surveys will contain one or more
of these"""
survey = models.ForeignKey(Survey)
item = models.ForeignKey(Item)
order = models.IntegerField()
file_name = models.CharField(max_length=50)
class Admin:
pass

class RadioBoxType(AbstractType):
"""A Radio Button object with its specific attributes"""
question_text = models.CharField(max_length=100)
question_sub_text = models.CharField(max_length=100)
item_type = models.CharField(max_length=20)
required = models.BooleanField()
randomize = models.BooleanField()
splitlist = models.BooleanField()
include_other = models.BooleanField()
other_prompt = models.CharField(max_length=100)
other_maxlen = models.IntegerField()
other_box_size = models.IntegerField()
class Admin:
pass

Well there is some of the model code - thanks for taking a look - I
think I need to spend a couple of weeks reading 24 hours a day to get
up to speed on all this technology, But I have just escaped from dot
niet and asp and sql server etc etc. Oh, what a feeling, what a rush!

Cheers

On May 6, 2:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Hey alen. I have tried implementing this and it makes good sense as
> > far as I can see, but when I validate the model I always get an
> > AttributeError: 'NoneType' object has no attribute 'name'.
>
> How are you validating the model?
>
> I have tried removing name from the definition of the class - same
>
> > message (not sure where it is getting 'name' from since I deleted it.
> > I also looked around and saw that some other have had similar
> > problems, and it seemed to be a string definition problem. So I put
> > back 'name' and changed it to an IntegerField - same unhappy result.
>
> > Do you have any notion of what the problem is? The code looks right to
> > me.
>
> It sounds like you have some code somewhere that is expecting to always be
> handed an instance of your model, and thus be able to access the field
> 'name', but it is in fact sometimes getting handed None.  When handed None,
> it still tries to access 'name', but since None has no attribute 'name', you
> get the error.  If you post the code someone could probably help pinpoint
> the error more specifically.
>
> Karen
>
>
>
> > Thanks,
>
> > Peter
>
> > On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> > > Thanks very much for your solution and reply alen. I'm learning the
> > > ins and outs of python and django at the same time - fun adventure -
> > > so far python is blowing me away - I love it. Better than anything I
> > > have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> > > (guess I am dating myself lol - most people don't seem to even ever
> > > have looked at assembler these days. I used to love it - 7 years of
> > > that after university) Oh, and of course C was always the bomb too :-)
>
> > > Thanks again,
>
> > > Peter
>
> > > On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > Define a 'abstract' attribute of Meta inner class and set it to true
> > > > like so:
>
> > > > class AbstractType(models.Model):
> > > >     name = models.CharField(max_length=100)
>
> > > >     class Meta:
> > > >         abstract = True
>
> > > > class RadioBoxTypes(AbstractType):
> > > >     radio_lable = models.CharField(max_length=20)
>
> > > > Regards,
> > > > -Alen
>
> > > > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > > > > I have designed a small db model (on paper) and want to implement it
> > > > > in my models.py file. So far, this has been pretty straight forward,
> > > > > but I have a generic superclass and several subclasses, and I

Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Hey alen. I have tried implementing this and it makes good sense as
far as I can see, but when I validate the model I always get an
AttributeError: 'NoneType' object has no attribute 'name'.

I have tried removing name from the definition of the class - same
message (not sure where it is getting 'name' from since I deleted it.
I also looked around and saw that some other have had similar
problems, and it seemed to be a string definition problem. So I put
back 'name' and changed it to an IntegerField - same unhappy result.

Do you have any notion of what the problem is? The code looks right to
me.

Thanks,

Peter


On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> Thanks very much for your solution and reply alen. I'm learning the
> ins and outs of python and django at the same time - fun adventure -
> so far python is blowing me away - I love it. Better than anything I
> have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> (guess I am dating myself lol - most people don't seem to even ever
> have looked at assembler these days. I used to love it - 7 years of
> that after university) Oh, and of course C was always the bomb too :-)
>
> Thanks again,
>
> Peter
>
> On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Define a 'abstract' attribute of Meta inner class and set it to true
> > like so:
>
> > class AbstractType(models.Model):
> >     name = models.CharField(max_length=100)
>
> >     class Meta:
> >         abstract = True
>
> > class RadioBoxTypes(AbstractType):
> >     radio_lable = models.CharField(max_length=20)
>
> > Regards,
> > -Alen
>
> > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > > I have designed a small db model (on paper) and want to implement it
> > > in my models.py file. So far, this has been pretty straight forward,
> > > but I have a generic superclass and several subclasses, and I am
> > > unsure how to implement this.
>
> > > My DB has page objects (webpages) with a few common attributes, and a
> > > fk to an Item object. The item object is the generic superclass. It
> > > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> > > have attributes specific to themselves.
>
> > > Anyway, I don't grok how to set up this type of relationship in my
> > > models.py file. Is there a standard way of doing this, or does anyone
> > > have an suggestions or can point me to some relevant info?
>
> > > e.g.     Pages - pointed to by fk in Items
> > >           --
>
> > >           Items - has key to one of the below
> > >           
>
> > > RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
> > > ---   ---
> > > -    
>
> > > Thanks very much. Sorry if this is a dumb question - always fun being
> > > a newbie :-(
>
> > > Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Thanks very much for your solution and reply alen. I'm learning the
ins and outs of python and django at the same time - fun adventure -
so far python is blowing me away - I love it. Better than anything I
have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
(guess I am dating myself lol - most people don't seem to even ever
have looked at assembler these days. I used to love it - 7 years of
that after university) Oh, and of course C was always the bomb too :-)

Thanks again,

Peter


On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Define a 'abstract' attribute of Meta inner class and set it to true
> like so:
>
> class AbstractType(models.Model):
>     name = models.CharField(max_length=100)
>
>     class Meta:
>         abstract = True
>
> class RadioBoxTypes(AbstractType):
>     radio_lable = models.CharField(max_length=20)
>
> Regards,
> -Alen
>
> On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > I have designed a small db model (on paper) and want to implement it
> > in my models.py file. So far, this has been pretty straight forward,
> > but I have a generic superclass and several subclasses, and I am
> > unsure how to implement this.
>
> > My DB has page objects (webpages) with a few common attributes, and a
> > fk to an Item object. The item object is the generic superclass. It
> > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> > have attributes specific to themselves.
>
> > Anyway, I don't grok how to set up this type of relationship in my
> > models.py file. Is there a standard way of doing this, or does anyone
> > have an suggestions or can point me to some relevant info?
>
> > e.g.     Pages - pointed to by fk in Items
> >           --
>
> >           Items - has key to one of the below
> >           
>
> > RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
> > ---   ---
> > -    
>
> > Thanks very much. Sorry if this is a dumb question - always fun being
> > a newbie :-(
>
> > Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Newbie Data Model Question

2008-05-06 Thread Peter Bailey

I have designed a small db model (on paper) and want to implement it
in my models.py file. So far, this has been pretty straight forward,
but I have a generic superclass and several subclasses, and I am
unsure how to implement this.

My DB has page objects (webpages) with a few common attributes, and a
fk to an Item object. The item object is the generic superclass. It
could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
have attributes specific to themselves.

Anyway, I don't grok how to set up this type of relationship in my
models.py file. Is there a standard way of doing this, or does anyone
have an suggestions or can point me to some relevant info?

e.g. Pages - pointed to by fk in Items
  --

  Items - has key to one of the below
  

RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
---   ---
-

Thanks very much. Sorry if this is a dumb question - always fun being
a newbie :-(

Peter


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



Re: MS SQL and Django - Any current info?

2007-11-02 Thread Peter Bailey

Thanks Carl. I'll give it a go.

Cheers,

Peter


On Nov 1, 7:11 pm, Carl Karsten <[EMAIL PROTECTED]> wrote:
> Peter Bailey wrote:
> > Can anyone tell me if there is any current news about MS SQL support?
> > I am looking at frameworks for a client, and my preference is really
> > to go the Django route. The plan will be to migrate over time from an
> > asp environment with an MS SQL back end. So basically I am stuck
> > having to use MS SQL for a while, and no support for it in Django will
> > unfortunately be a show stopper. We will eventually migrate the
> > databases to an Open Source alternative, but that is not an option at
> > the start.
>
> > I have successfully connected to MS SQL via TurboGears and Elixir/
> > SQLAlchemy, so I know it is possible via python, and I realize that
> > most people here are not that interested in dealing with MS software.
> > I have also looked at the latest tickets, but they really don't say
> > anything definitive, although there appears to be some work being done
> > on it.
>
> > I know this is an Open Source project, so it is hard to put schedules
> > and dates to specific things, but if anyone can give me a realistic
> > guess at when this support will be included (assuming it will be), I
> > would greatly appreciate it.
>
> I am actually pretty sure it is actively supported, but given that support can
> come and go, here is how I can reassure you that it isn't a big mistake.
>
> I have worked with MS SQL using bothhttp://www.freetds.orgbased pymssql and
> odbc based cdODBC.  I have not worked with adodbapi which is what django uses,
> but given what I know about the things I have worked with, it A) can be done 
> and
> B) probably has been done and C) I can do it if it hasn't.
>
> So my advice is run though the django tutorial using ado_mssql.  If you run 
> into
> problems, post here.  If you don't get any response after a day or 2, forward 
> it
> to me (above address) and I'll help you get through it.
>
> Carl K


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



MS SQL and Django - Any current info?

2007-11-01 Thread Peter Bailey

Can anyone tell me if there is any current news about MS SQL support?
I am looking at frameworks for a client, and my preference is really
to go the Django route. The plan will be to migrate over time from an
asp environment with an MS SQL back end. So basically I am stuck
having to use MS SQL for a while, and no support for it in Django will
unfortunately be a show stopper. We will eventually migrate the
databases to an Open Source alternative, but that is not an option at
the start.

I have successfully connected to MS SQL via TurboGears and Elixir/
SQLAlchemy, so I know it is possible via python, and I realize that
most people here are not that interested in dealing with MS software.
I have also looked at the latest tickets, but they really don't say
anything definitive, although there appears to be some work being done
on it.

I know this is an Open Source project, so it is hard to put schedules
and dates to specific things, but if anyone can give me a realistic
guess at when this support will be included (assuming it will be), I
would greatly appreciate it.

Thanks,

Peter


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



Re: Django on Linux, MS SQL on Windoz

2007-08-10 Thread Peter Bailey
Thanks Florian. Guess I better have a look at SQLAlchemey - too bad that
branch of django does not seem to be advancing much either!. Thanks for your
help.

Peter


On 8/10/07, Florian Apolloner <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> There is currently no fully working backend for mssql, but someone is
> working on it already (and I am sure he will need some testers).
> If I am not mistaken there is also http://pymssql.sourceforge.net/
>
> I hope this helps,
> Florian
>
> On Aug 9, 7:10 pm, [EMAIL PROTECTED] wrote:
> > Is it possible to run a django web server on a nix box and communicate
> > with a MS-SQL (2000) database on a Windoz 2003 server. I am looking
> > for a good python framework, and django seems like it might be the
> > one, but if it can't do this, that could be a show stopper. From what
> > I have seen, there is only the adodapi that you can use to connect to
> > sql server (and it may not be great), and I believe that has to run on
> > a doz box.
> >
> > I am trying to migrate away from windows, thus the desired
> > implementation above. Plan won't work if I have to run django on a
> > windows box.
> >
> > Help anyone ...
> >
> > Thanks,
> >
> > Peter
>
>
> >
>

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



Re: Pro Django Book preview

2006-10-17 Thread Peter Bailey

It would be cool if Apress could use some type of process with that
book like Dave Thomas did with Agile Web Development With Rails (and
some of their other titles). The Pragmatic Programmers released early
beta versions of the book in pdf format, automated input from their
readers to deal with errors in the text etc., kept updating and
releasing new betas,  and eventually the book was completed and printed
and also improved I think by the community involvement.

I found it to be great getting the book early to help me get going (I
was a total Rails newbie then) and then watching it evolve into the
finished product. Very good work on their part imho.


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