View that displays my ManyToManyField('self'...) relations in a with levels

2021-08-18 Thread M. GW
Hi,

I am now trying, for days, to get a tree like view from my assembly model 
into my template. I think I have read everything what I have found on 
StackOverflow and other sites. Somehow I am not able to get it working. I 
am trying to not use any 3rd party extensions => I'm happy to be proven 
wrong. But first let me explain my topic:

This are my models:

class Assembly(models.Model):
reference = models.OneToOneField('products.Reference', 
on_delete=models.RESTRICT, verbose_name=_('reference'))
subassembly = models.ManyToManyField(SubAssembly, blank=True, 
verbose_name=_('subassembly'))
component = models.ManyToManyField(Component, blank=True, 
verbose_name=_('component'))

class SubAssembly(models.Model):
reference = models.CharField(max_length=40, default=None)
subassembly_class = models.ForeignKey(SubAssemblyClass, 
on_delete=models.CASCADE)
nested_subassembly = models.ManyToManyField(
'self', symmetrical=False, blank=True)

class SubAssemblyClass(models.Model):
name = models.CharField(max_length=255)

class Component(models.Model):
reference = models.CharField(max_length=40, unique=True)
component_class = models.ForeignKey(ComponentClass, 
on_delete=models.CASCADE)
nested_component = models.ManyToManyField('self', blank=True')

class ComponentClass(models.Model):
name = models.CharField(max_length=255, unique=True)


For my view I am using the class based one. I am generally using CBV's

class AssemblyDetailView(LoginRequiredMixin, DetailView):
model = Assembly
template_name = "engineering/assembly/assembly_detail.html"

Now I want in my template all children of subassembly and component from 
one assembly like this:

assembly1
* subassembly1
* subassembly5
* component5
* component7
* component8
* subassembly6
* component7
* component8
* component1
* component2
* subassembly2
* component3
* subassembly3
* subassembly6
* component1
* component2
* component1
* component3

The depth can be infinity but for now there will be only 3-5 levels. I 
don’t care if it will be Depth-first-search or Breadth-first-search. I read 
a lot about recursive common table expressions and raw queries. I haven’t 
found a way to code the logic with my complicated ManyToMany fields.

I hope there is someone out there who can help me out. Maybe I have build 
up the models in a wrong way and that’s causing the problems why I am not 
able to solve it or or something else.

Thank you for your help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/95ef56a4-6fc5-4cdd-9d4a-9090e364a308n%40googlegroups.com.


Re: HELP me: "a beginner's questions"

2021-08-18 Thread M. GW

Hey,

have you check this:

https://docs.djangoproject.com/en/3.2/howto/deployment/
jt.vc...@gmail.com schrieb am Mittwoch, 18. August 2021 um 15:03:03 UTC+2:

> Hi
>
> I am now starting to work in Django.
>
> I built a development environment on my laptop. I experimented there, 
> things work.
>
> I have a web server on the net. With multiple hosted domains.
>
>  
>
> I would put my attempt on one. But things don't work.
>
> - python is installed, updated
>
> - I installed django
>
> - "python3 manage.py runserver" seems to work, but nothing comes out
>
>  
>
> Questions:
>
> - how do I transfer the developed file there?
>
> - what do I need to do to run as a web server?
>
>  
>
> Thanks for the help
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9d85813c-2aee-4dc4-9846-cff4511372f7n%40googlegroups.com.


Re: What is the difference bulk_update() and update() in django queryset.

2021-08-18 Thread M. GW

bulk_update() is a method that updates the provided list of objects into 
the database with one query.

and update() is just for one object

ambiti...@gmail.com schrieb am Donnerstag, 12. August 2021 um 00:03:25 
UTC+2:

> What is the difference bulk_update() and update() in django queryset.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/678c6d16-ebe7-4811-84c4-d9c194a80caen%40googlegroups.com.


Issue with saving manytomany items in custom form

2009-07-22 Thread gw

Hi all, I'm having an issue with saving manytomany items in a custom
form. I've pasted an error description and extensive code excepts
here: http://dpaste.com/69877/  .

Basically, the form doesn't save the main instance properly, so the
subsequent saving of manytomany items also fails (since the instance
of the form is a key to the manytomany items).

I'd be grateful if anyone could give me pointers on why the 'lapse'
item in my code should be null.

Many thanks,

Graeme West

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