1👍
This is most probbly the related django ticket you should check https://code.djangoproject.com/ticket/24513
And this issue could be somehow related though not 100% https://github.com/jet-admin/jet-django/issues/7
You might get some insight reading the threads.
0👍
If you want to access a ForeignKey field from an instance you can not access it directly as you did here
{% for user in current_folder.company.members.all %}
ForeignKey field is a company so it should be
current_folder.company_set()
Note: ForeignKey returns a set of objects. In your case a set of companies. That’s why it returns FieldDoesNotExist
- Unique if not null SQLAlchemy and Django
- Generate jwt when signing in with allauth
- Trying to pass a QuerySet as initial data to a formset
- Force delete of any previous test database (autoclobber) when running Django unit tests, eg, in PyCharm
-1👍
In ManyToManyFields you must add the related_name
parameter if you want to access the related objects. So for this case, it should be like this:
class Company(models.Model):
name = models.CharField(max_length=200)
members = models.ManyToManyField(User, related_name='members')
class Folder(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField(null=True, blank=True)
company = models.ForeignKey(Company, null=True, blank=True)
parent = models.ForeignKey("Folder", null=True, blank=True)
- Django: i18n – change language
- How to make a rest_framework Serializer disallow superfluous fields?
- Args and kwargs in django views
-1👍
try adding null and blank field
members = models.ManyToManyField(user, blank=True, null=True)
-2👍
There is propably duplicate items in the datebase.
You can check by listing all items in model using:
YourModel.objects.values_list('id', 'name')
To avoid it make sure to set unique=True.
name = models.CharField(max_length=200, unique=True)
- Django – MEDIA_ROOT and MEDIA_URL
- Python: How can I override one module in a package with a modified version that lives outside the package?
- What is the difference between a Multi-table inherited model and a simple One-to-one relationship between the same two models?