Questions tagged [manytomanyfield]

Manytomanyfield is a field of a model class in Django that defines many-to-many relationship

Manytomanyfield is a field of a model class in Django that defines many-to-many relationship.

Quote from docs about manytomanyfield database representation:

Behind the scenes, Django creates an intermediary join table to represent the many-to-many relationship. By default, this table name is generated using the name of the many-to-many field and the name of the table for the model that contains it. Since some databases don’t support table names above a certain length, these table names will be automatically truncated to 64 characters and a uniqueness hash will be used. This means you might see table names like author_books_9cdf4; this is perfectly normal. You can manually provide the name of the join table using the db_table option.

See also:

526 questions
0
votes
3 answers

Django : save a new value in a ManyToManyField

I gave details on my code : I don't know why my table is empty (it seems that it was empty out after calling save_model, but I'm not sure). class PostAdmin(admin.ModelAdmin): def save_model(self, request, post, form, change): …
Piaume
0
votes
2 answers

Storing a curve in a django model as manytomany?

I have a list of products (say diodoes) which have a curve associated to them. For example, Diode 1: curve 1: [(0,1),(1,3),(2,10), ...., (100,0.5)] Diode 2: curve 2: [(0,2),(1,4),(2.1,19), ..., (100,0)] So for each product there is a curve (with…
Massagran
  • 1,781
  • 1
  • 20
  • 29
0
votes
2 answers

Filter() keywords must be strings

I am working on a website with Django. I have created two models, one for photo and the other for a person. class Photo(models.Model): photo = models.ImageField(upload_to = 'toto') description = models.CharField(_('Description'),…
trnsnt
  • 674
  • 4
  • 15
0
votes
1 answer

invalid literal for int() with base 10: '345/add/Caipirinha'

So, I'm working on a bar tab application in Django, and when it came down to insert some data into the tabs I'm getting the error: ValueError at /tabs/345/add/Caipirinha/ invalid literal for int() with base 10: '345/add/Caipirinha' I have tried…
Pedro
  • 11
  • 2
0
votes
1 answer

"Cannot resolve keyword 'user' into field. Choices are: id, project_, user_"

py like the following class User_(models.Model): user_name = models.CharField(max_length=50) user_password = models.CharField(max_length=50) user_admin = models.BooleanField(False) class Project_(models.Model): project_name =…
N0rA
  • 612
  • 1
  • 7
  • 27
0
votes
1 answer

How to limit choices for a Many to Many relation?

I'm using Python + Django and have this in my model right now: class Team(models.Model): player = models.ManyToManyField(Player, related_name="player", through="Team_Player") squad = models.ManyToManyField(Player, related_name="squad",…
-1
votes
1 answer

How can I display only selected options of a fild type ManyToMany - django

Good morning, I need to display the values selected in the manytomany field named "sfide" in a table I will build with html, how can I do it? thanks I also attach the image of the class "Profilo" with the ManyToMany field "sfide" enter image…
Alemmo
  • 1
  • 2
-1
votes
1 answer

Django how the link ManytoManyField data with FloatField data?

I have manytomanyfield inside my model.The manytomanyfield field lists the products in the products table. I want to enter the amount for each product I choose. How can I relate manytomanyfield to floatfield field? That's my model: ` class…
-1
votes
1 answer

Django with social auth: Direct assignment to the forward side of a many-to-many set is prohibited

When trying to authenticate (create) a user in Django, I get the following error: Direct assignment to the forward side of a many-to-many set is prohibited. Use posts.set() instead. I'm aware that there are similar questions to this on Stack…
Chris
  • 1,206
  • 2
  • 15
  • 35
-1
votes
2 answers

How to filter and displayed 'many to many' elements in Django

I'm learning django and in my project can't figure out how properly get and displayed elements from many to many relation on deck detail page. model.py class Card(models.Model): def upload_path(self, filename): return…
Andrew
  • 1
-1
votes
1 answer

Many To Many NOT saving in django

my views.py file: form = ClassesForm(request.POST) if form.is_valid(): New_Class = Classes() New_Class.semester = Last_Semester New_Class.year = form.cleaned_data.get('year') if form.cleaned_data.get('year') >=…
-1
votes
1 answer

I am getting the error below every time I run the code and I do not know what is wrong

I am getting the error below. Any help is appreciated. I am probably missing something very important from the documentation. Kindly point out my mistake if you see it and enlighten me about many to many relations from Django. From the error…
HAN YAO FOONG
  • 137
  • 1
  • 8
-1
votes
1 answer

RecursionError at /form/movie/ maximum recursion depth exceeded while calling a Python object

I am not quite sure how manytomany fields work in django. so what i have here is a profile model where in the name field i want to add the username that i will get from the login credentials, and movies will be added from a form that was created…
-1
votes
1 answer

Count values in ManyToManyField - Django

i need some help. I have a model "Event" with manytomanyfield "users": class Event(models.Model): name = models.CharField(max_length=26) description = models.CharField(max_length=200) date = models.DateField() user =…
worm2d
  • 159
  • 1
  • 2
  • 14
-1
votes
2 answers

Regarding ManyToManyFields in Django

Suppose I make a model: class A(models.Model): col = models.ManyToManyField(B) Now after migration, this will create a table A_B with fields id,A_id,B_id. Now if I want to access the id of the table A_B, how to do that? And how to update the…
Priyansh Goel
  • 2,660
  • 1
  • 13
  • 37
1 2 3
35
36