Re: Many-to-many column admin interface

2009-08-31 Thread Thomas Guettler

Thank you for this link. Looks good

Sven Richter schrieb:
> Ah, and google does help or at least django_snippets.
> I found the solution here:
> http://www.djangosnippets.org/snippets/1295
> 
> The trick is to create a column in both models and in one with the option to
> not syncdb.
> Its really simple, just 6 lines at all.


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Yea, i thought about that, but for me this seems like an ugly workaround.
Dont misunderstand me, i dont know enough about django and its database
internals, but why should i use a third model for something i can access
directly?

The solution i posted above was exactly what i was looking for and what
seems logic to me, but i could of course be wrong too.


Greetings
Sven

On Fri, Aug 28, 2009 at 6:19 PM, patrickk  wrote:

>
> I could be mistaken ... but why not using a third model.
>
> C(models.model):
>   a = models.ForeignKey('A')
>   b = models.ForeignKey('B')
>
> when editing either A or B, you could use C as inlines.
>
> regards,
> patrick
>
>
> On 28 Aug., 17:18, Sven Richter  wrote:
> > But i wonder how this would help me further.
> > In the End it doesnt matter for me on which model i define the M2M
> relation.
> > But i need to access the M2M Table from both models, at least in the view
> or
> > in the template if not in the admin interface.
> >
> > I am having a hard time finding out how to achieve that.
> >
> > Any Ideas?
> >
> > Greetings
> > Sven
> >
> > On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter  >wrote:
> >
> > > I've opened a bug/feature request at:
> > >http://code.djangoproject.com/ticket/11795#comment:2
> > > if someone is interested.
> >
> > > Greetings
> > > Sven
> >
> > > On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan  >wrote:
> >
> > >> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter >
> > >> wrote:
> > >> > I found this thread:
> >
> > >>http://stackoverflow.com/questions/660260/django-admin-form-for-many-.
> ..
> > >> > on Stackoverflow, but when i try the suggested TabularInline thing i
> get
> > >> the
> > >> > error:
> >
> > >> >  has no ForeignKey to
> > >>  > >> > 'politlog.entry.models.Entries'>
> >
> > >> At least with Django 1.0.x, the admin interface does not support
> > >> many-to-many relationships on inlines -- it will always return an
> > >> error like the one you got above.  Indeed, the message is technically
> > >> accurate, because m2m relationships get implemented as a separate
> > >> table, so there is no direct relationship between the two.
> > >> InlineModelAdmin works great for one-to-many but not for many-to-many.
> >
> > >> I'd also be interested in solutions to this, not having found anything
> > >> in a bunch of Google searches.  The alternative I'm planning on is
> > >> having to hand-code some views, forms, and templates that let me do
> > >> the right thing -- not a huge amount of work, but having admin do it
> > >> for us would be way cool.
> >
> > >> Craig
> >
> > >> > Greetings
> > >> > Sven
> >
> >
> >
>

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
But i wonder how this would help me further.
In the End it doesnt matter for me on which model i define the M2M relation.
But i need to access the M2M Table from both models, at least in the view or
in the template if not in the admin interface.

I am having a hard time finding out how to achieve that.

Any Ideas?


Greetings
Sven

On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:

> I've opened a bug/feature request at:
> http://code.djangoproject.com/ticket/11795#comment:2
> if someone is interested.
>
>
> Greetings
> Sven
>
>
> On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>
>>
>> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
>> wrote:
>> > I found this thread:
>> >
>> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
>> > on Stackoverflow, but when i try the suggested TabularInline thing i get
>> the
>> > error:
>> >
>> >  has no ForeignKey to
>> > > 'politlog.entry.models.Entries'>
>> >
>>
>> At least with Django 1.0.x, the admin interface does not support
>> many-to-many relationships on inlines -- it will always return an
>> error like the one you got above.  Indeed, the message is technically
>> accurate, because m2m relationships get implemented as a separate
>> table, so there is no direct relationship between the two.
>> InlineModelAdmin works great for one-to-many but not for many-to-many.
>>
>> I'd also be interested in solutions to this, not having found anything
>> in a bunch of Google searches.  The alternative I'm planning on is
>> having to hand-code some views, forms, and templates that let me do
>> the right thing -- not a huge amount of work, but having admin do it
>> for us would be way cool.
>>
>> Craig
>>
>>
>> > Greetings
>> > Sven
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
Ah, and google does help or at least django_snippets.
I found the solution here:
http://www.djangosnippets.org/snippets/1295

The trick is to create a column in both models and in one with the option to
not syncdb.
Its really simple, just 6 lines at all.


Greetings and a nice Weekend
Sven

On Fri, Aug 28, 2009 at 5:18 PM, Sven Richter wrote:

> But i wonder how this would help me further.
> In the End it doesnt matter for me on which model i define the M2M
> relation.
> But i need to access the M2M Table from both models, at least in the view
> or in the template if not in the admin interface.
>
> I am having a hard time finding out how to achieve that.
>
> Any Ideas?
>
>
> Greetings
> Sven
>
>
> On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:
>
>> I've opened a bug/feature request at:
>> http://code.djangoproject.com/ticket/11795#comment:2
>> if someone is interested.
>>
>>
>> Greetings
>> Sven
>>
>>
>> On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>>
>>>
>>> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
>>> wrote:
>>> > I found this thread:
>>> >
>>> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
>>> > on Stackoverflow, but when i try the suggested TabularInline thing i
>>> get the
>>> > error:
>>> >
>>> >  has no ForeignKey to
>>> >> > 'politlog.entry.models.Entries'>
>>> >
>>>
>>> At least with Django 1.0.x, the admin interface does not support
>>> many-to-many relationships on inlines -- it will always return an
>>> error like the one you got above.  Indeed, the message is technically
>>> accurate, because m2m relationships get implemented as a separate
>>> table, so there is no direct relationship between the two.
>>> InlineModelAdmin works great for one-to-many but not for many-to-many.
>>>
>>> I'd also be interested in solutions to this, not having found anything
>>> in a bunch of Google searches.  The alternative I'm planning on is
>>> having to hand-code some views, forms, and templates that let me do
>>> the right thing -- not a huge amount of work, but having admin do it
>>> for us would be way cool.
>>>
>>> Craig
>>>
>>>
>>> > Greetings
>>> > Sven
>>>
>>> >>>
>>>
>>
>

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-28 Thread patrickk

I could be mistaken ... but why not using a third model.

C(models.model):
   a = models.ForeignKey('A')
   b = models.ForeignKey('B')

when editing either A or B, you could use C as inlines.

regards,
patrick


On 28 Aug., 17:18, Sven Richter  wrote:
> But i wonder how this would help me further.
> In the End it doesnt matter for me on which model i define the M2M relation.
> But i need to access the M2M Table from both models, at least in the view or
> in the template if not in the admin interface.
>
> I am having a hard time finding out how to achieve that.
>
> Any Ideas?
>
> Greetings
> Sven
>
> On Fri, Aug 28, 2009 at 3:04 PM, Sven Richter wrote:
>
> > I've opened a bug/feature request at:
> >http://code.djangoproject.com/ticket/11795#comment:2
> > if someone is interested.
>
> > Greetings
> > Sven
>
> > On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:
>
> >> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
> >> wrote:
> >> > I found this thread:
>
> >>http://stackoverflow.com/questions/660260/django-admin-form-for-many-...
> >> > on Stackoverflow, but when i try the suggested TabularInline thing i get
> >> the
> >> > error:
>
> >> >  has no ForeignKey to
> >>  >> > 'politlog.entry.models.Entries'>
>
> >> At least with Django 1.0.x, the admin interface does not support
> >> many-to-many relationships on inlines -- it will always return an
> >> error like the one you got above.  Indeed, the message is technically
> >> accurate, because m2m relationships get implemented as a separate
> >> table, so there is no direct relationship between the two.
> >> InlineModelAdmin works great for one-to-many but not for many-to-many.
>
> >> I'd also be interested in solutions to this, not having found anything
> >> in a bunch of Google searches.  The alternative I'm planning on is
> >> having to hand-code some views, forms, and templates that let me do
> >> the right thing -- not a huge amount of work, but having admin do it
> >> for us would be way cool.
>
> >> Craig
>
> >> > Greetings
> >> > Sven
>
>
--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-28 Thread Sven Richter
I've opened a bug/feature request at:
http://code.djangoproject.com/ticket/11795#comment:2
if someone is interested.


Greetings
Sven

On Fri, Aug 28, 2009 at 6:59 AM, Craig McClanahan wrote:

>
> On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter
> wrote:
> > I found this thread:
> >
> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
> > on Stackoverflow, but when i try the suggested TabularInline thing i get
> the
> > error:
> >
> >  has no ForeignKey to
>  > 'politlog.entry.models.Entries'>
> >
>
> At least with Django 1.0.x, the admin interface does not support
> many-to-many relationships on inlines -- it will always return an
> error like the one you got above.  Indeed, the message is technically
> accurate, because m2m relationships get implemented as a separate
> table, so there is no direct relationship between the two.
> InlineModelAdmin works great for one-to-many but not for many-to-many.
>
> I'd also be interested in solutions to this, not having found anything
> in a bunch of Google searches.  The alternative I'm planning on is
> having to hand-code some views, forms, and templates that let me do
> the right thing -- not a huge amount of work, but having admin do it
> for us would be way cool.
>
> Craig
>
>
> > Greetings
> > Sven
>
> >
>

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-28 Thread Craig McClanahan

On Thu, Aug 27, 2009 at 10:00 AM, Sven Richter wrote:
> I found this thread:
> http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
> on Stackoverflow, but when i try the suggested TabularInline thing i get the
> error:
>
>  has no ForeignKey to  'politlog.entry.models.Entries'>
>

At least with Django 1.0.x, the admin interface does not support
many-to-many relationships on inlines -- it will always return an
error like the one you got above.  Indeed, the message is technically
accurate, because m2m relationships get implemented as a separate
table, so there is no direct relationship between the two.
InlineModelAdmin works great for one-to-many but not for many-to-many.

I'd also be interested in solutions to this, not having found anything
in a bunch of Google searches.  The alternative I'm planning on is
having to hand-code some views, forms, and templates that let me do
the right thing -- not a huge amount of work, but having admin do it
for us would be way cool.

Craig


> Greetings
> Sven

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-27 Thread Sven Richter
I found this thread:
http://stackoverflow.com/questions/660260/django-admin-form-for-many-to-many-relationship
on Stackoverflow, but when i try the suggested TabularInline thing i get the
error:

 has no ForeignKey to


Greetings
Sven



On Thu, Aug 27, 2009 at 5:03 PM, Thomas Guettler  wrote:

>
> Hi,
>
> I had the same question some time ago and found no answer,
> but maybe you try harder.
>
> Sven Richter schrieb:
> > Hi,
> >
> > i have a new problem with my many-to-many field.
> >
> > I have two models A and B.
> > A(models.model):
> >   b = models.ManyToManyField('app.B')
> >
> > Now when i edit A in the admin interface everything is ok, i can select
> all
> > B instances A belongs to.
> >
> > What i need now is to be able to do the same thing from B's admin
> interface.
> > When i edit B i want to select all instances of A B belongs to.
> >
> > Is there a way to achieve that?
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail : guettli (*)
> thomas-guettler + de
>
> >
>

--~--~-~--~~~---~--~~
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: Many-to-many column admin interface

2009-08-27 Thread Thomas Guettler

Hi,

I had the same question some time ago and found no answer,
but maybe you try harder.

Sven Richter schrieb:
> Hi,
> 
> i have a new problem with my many-to-many field.
> 
> I have two models A and B.
> A(models.model):
>   b = models.ManyToManyField('app.B')
> 
> Now when i edit A in the admin interface everything is ok, i can select all
> B instances A belongs to.
> 
> What i need now is to be able to do the same thing from B's admin interface.
> When i edit B i want to select all instances of A B belongs to.
> 
> Is there a way to achieve that?

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Many-to-many column admin interface

2009-08-27 Thread Sven Richter
Hi,

i have a new problem with my many-to-many field.

I have two models A and B.
A(models.model):
  b = models.ManyToManyField('app.B')

Now when i edit A in the admin interface everything is ok, i can select all
B instances A belongs to.

What i need now is to be able to do the same thing from B's admin interface.
When i edit B i want to select all instances of A B belongs to.

Is there a way to achieve that?


Greetings
Sven

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