Re: How to initialize M2M field in new ModelForm?

2007-12-23 Thread Yatla

Well, I tried the initial arguement again, and it worked this
time...must have made a typo the other time I tried this.

Thx

On Dec 23, 2:03 pm, Yatla <[EMAIL PROTECTED]> wrote:
> Joseph,
>
> Yes, for a new Document, I want to assign to an existing Category.
> The initial arguement works for a form class, which is what I first
> had, but then modified to use the new ModelForm class.  The ModelForm
> class does not seem to accept an initial arguement.
>
> On Dec 22, 5:25 pm, "Joseph Kocherhans" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 12/22/07, Yatla <[EMAIL PROTECTED]> wrote:
>
> > > I need to initialize a selection in a M2M field of the Document
> > > ModelForm during the first GET of a form that creates a new Document -
> > > classes and view as follows:
>
> > > class DocumentForm(forms.ModelForm):
> > >     class Meta:
> > >         model = Document
>
> > > class Document(models.Model):
> > >     ...
> > >     categories = models.ManyToManyField(Category)
>
> > > view function:
> > > def create(request, category_name, template='edit2.html', params={}):
> > >     category = get_object_or_404(Category, name=category_name)
> > >     new_doc = Document(author=request.user, pub_date=datetime.now())
> > >     if request.method == 'POST':
> > >         form = DocumentForm(request.POST, instance=new_doc)
> > >         if form.is_valid():
> > >             .
> > >     else:
> > >         form = DocumentForm(instance=new_doc)  # todo: figure out how
> > > to initialize categories
> > >     params['form'] = form
> > >     return render_to_response(template, params,
> > > RequestContext(request))
>
> > Are you trying to assign all new docs to an existing Category object
> > then? I think if you used the 'initial' argument in in the form
> > constructor it would work. Something like:
>
> >     initial_data={'categories': [category.id]}
> >     form = DocumentForm(request.POST, initial=initial_data, 
> > instance=new_doc)
>
> > Joseph- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to initialize M2M field in new ModelForm?

2007-12-23 Thread Yatla

Joseph,

Yes, for a new Document, I want to assign to an existing Category.
The initial arguement works for a form class, which is what I first
had, but then modified to use the new ModelForm class.  The ModelForm
class does not seem to accept an initial arguement.

On Dec 22, 5:25 pm, "Joseph Kocherhans" <[EMAIL PROTECTED]> wrote:
> On 12/22/07, Yatla <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > I need to initialize a selection in a M2M field of the Document
> > ModelForm during the first GET of a form that creates a new Document -
> > classes and view as follows:
>
> > class DocumentForm(forms.ModelForm):
> >     class Meta:
> >         model = Document
>
> > class Document(models.Model):
> >     ...
> >     categories = models.ManyToManyField(Category)
>
> > view function:
> > def create(request, category_name, template='edit2.html', params={}):
> >     category = get_object_or_404(Category, name=category_name)
> >     new_doc = Document(author=request.user, pub_date=datetime.now())
> >     if request.method == 'POST':
> >         form = DocumentForm(request.POST, instance=new_doc)
> >         if form.is_valid():
> >             .
> >     else:
> >         form = DocumentForm(instance=new_doc)  # todo: figure out how
> > to initialize categories
> >     params['form'] = form
> >     return render_to_response(template, params,
> > RequestContext(request))
>
> Are you trying to assign all new docs to an existing Category object
> then? I think if you used the 'initial' argument in in the form
> constructor it would work. Something like:
>
>     initial_data={'categories': [category.id]}
>     form = DocumentForm(request.POST, initial=initial_data, instance=new_doc)
>
> Joseph- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to initialize M2M field in new ModelForm?

2007-12-22 Thread Yatla

I need to initialize a selection in a M2M field of the Document
ModelForm during the first GET of a form that creates a new Document -
classes and view as follows:

class DocumentForm(forms.ModelForm):
class Meta:
model = Document

class Document(models.Model):
...
categories = models.ManyToManyField(Category)

view function:
def create(request, category_name, template='edit2.html', params={}):
category = get_object_or_404(Category, name=category_name)
new_doc = Document(author=request.user, pub_date=datetime.now())
if request.method == 'POST':
form = DocumentForm(request.POST, instance=new_doc)
if form.is_valid():
.
else:
form = DocumentForm(instance=new_doc)  # todo: figure out how
to initialize categories
params['form'] = form
return render_to_response(template, params,
RequestContext(request))

I've tried a few approaches without success.

TIA

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



Re: Django Web Hosting Service

2007-11-26 Thread Yatla

I have had two small Django sites running on asmallorange shared
hosting for more thane a year.  It took quite some time to get working
in the shared environment, but then worked ok.  The server reposne to
the first hit on the site is slow to respond, but then ok.  I just
recently moved to a VPS account on linode.com, and am very happy so
far with performance and low cost for a VPS option ($20/month).

On Nov 25, 2:32 pm, LaundroMat <[EMAIL PROTECTED]> wrote:
> I have had good experiences (albeit limited; the hosted site is more a
> testing thing than something else at the moment)  with a small orange
> as well: asmallorange.com
>
> On Nov 21, 2:40 pm, "Ronaldo Z. Afonso" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Hi all,
>
> > Can anybody recommend me  a Django Web Hosting Service?
> > Thanks.
>
> > Ronaldo.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin login problem

2006-12-15 Thread Yatla

Jorge,

Turns out that I did need to modify the url as you indicated like

 (r'^galeria/admin/', include('django.contrib.admin.urls')),

the first time the site or my browser must have been caching something
and it seemed to work.

Now onwards to build the site

Yatla

On Dec 13, 4:35 pm, "Yatla" <[EMAIL PROTECTED]> wrote:
> Jorge,
>
> Many thanks!  I was using an .htaccess in the subdirectory, but did not
> have the subdirectory specified after the fcgi file in the last rewrite
> rule.  I don't know much about this so just copied from a tutorial on
> this that did not have the subdirectory in the rewriterule.  Thanks
> again!
>
> btw, it seems to work correctly whether I had the subdirectory in front
> of the admin/ or not in the url.py file, ie, just
> (r'^admin/', include('django.contrib.admin.urls')),
> seems to work after I modified the rewriterule.
> 
> Yatla


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

2006-12-13 Thread Yatla

Jorge,

Many thanks!  I was using an .htaccess in the subdirectory, but did not
have the subdirectory specified after the fcgi file in the last rewrite
rule.  I don't know much about this so just copied from a tutorial on
this that did not have the subdirectory in the rewriterule.  Thanks
again!

btw, it seems to work correctly whether I had the subdirectory in front
of the admin/ or not in the url.py file, ie, just
(r'^admin/', include('django.contrib.admin.urls')),
seems to work after I modified the rewriterule.

Yatla


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



Admin login problem

2006-12-12 Thread Yatla

Newbie here - saw that the same question was asked earlier but not
answered, and the post was locked so I could not reply.

I have a Django site in a subdirectory as follows (via fcgi) - (using
ver 0.96 pre via svn)

http://mydomain.com/dj

When I go into the Admin area as follows

http://mydomain.com/dj/Admin/

The login form that comes up has action="/admin/" (not "/dj/admin"), so
the post goes to

http://mydomain.com/admin

which is not the Django site.  Somehow the /dg/ subdirectory info is
not prefixed to the form action.  Is there a configuration with the
main site prefix that I'm missing somwhere, I ony see path to media to
be set in tte seetings?

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