Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ValueError: Missing staticfiles manifest entry for 'favicon.png' when DEBUG = False
raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name) ValueError: Missing staticfiles manifest entry for 'favicon.png' when DEBUG = False I only get this error when DEBUG = False, I do not get any error when DEBUG = True To fix this issue while keeping DEBUG = False, I must add back in favicon.png (which I had deleted a while back) to the static_root folder and then run python manage.py collectstatic I checked all my files and all my html documents have the link favicon.png line commented out, so that is not the issue. settings.py has the following: STATIC_URL = '/static/' STATICFILES_DIRS =[ os.path.join(BASE_DIR, 'static_root'), ] VENV_PATH = os.path.dirname(BASE_DIR) STATIC_ROOT = os.path.join(BASE_DIR, 'static/') urls.py has following: if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -
How to add placeholder text to a Django Admin field
I'd like to add placeholder text to a field in the Django Admin change form. In a regular ModelForm you can do this by overriding the field's widget or by modifying self.fields['my_field'].widget in the ModelForm __init__() method. How do I do something similar for a Django Admin? -
DRF ignoring permission classes for owner
I implemented BasePermission class in project but when I am going to retrieve logged user with his token it says You don't have a permission to perform this action permissions.py class IsLoggedInOrAdmin(permissions.BasePermission): def has_object_permission(self, request, view, obj): return obj.user == request.user or request.user.is_staff class IsAdminUser(permissions.BasePermission): def has_permission(self, request, view): return request.user and request.user.is_staff def has_object_permission(self, request, view, obj): return request.user and request.user.is_staff and my views file looks like this class UserViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = UserSerializer def get_permissions(self): permission_classes = [] if self.action == 'create': permission_classes = [AllowAny] elif self.action == 'retrieve' or self.action == 'update' or self.action == 'partial_update': permission_classes = [IsLoggedInOrAdmin] elif self.action == 'destroy' or self.action == 'list': permission_classes = [IsAdminUser] return [permission() for permission in permission_classes] here what i have done so far. I created simple user and took token If I send GET request in Postman I am getting a detail error but it works fine with superuser's token but not owner. Where Am I making mistake? Any help please? Thanks in advance! -
Django using icontains filter with multiple values from dictionary
Hi i'm trying to run a model search query through a dictionary data which i got like so: { "city":5, "direction":"ne", ..other data that can be dynamic... "address__icontains" = ["word1", "word2", "word3"], } My search query: Models.objects.filter(**query_dict) since the other data are dynamic that why i use filter with dictionary.And i'm using __icontains to search up field address(string value) that contains those 3 words in that string, so the problem right now is since __icontains doesn't accept array like so in the query set: Models.objects.filter(other keys and values from dictionary, address__icontains= ["word1", "word2", "word3"]) How would i make this work with the dictionary filter search ? I also tried changing the dictionary to "address__icontains" = "word1 word2 word3" but it also doesn't work Thank for reading -
Django update_or_create results in a duplicated row
I'am trying to update or create an entry. Here are my relevent codes: Models.py class Comment(SafeDeleteModel): id = models.AutoField(primary_key=True) content1 = models.TextField() content2 = models.TextField() fieldA = models.ForeignKey('A') fieldB = models.ForeignKey('B') views.py class CommentViewSet(viewsets.ModelViewSet): def post(self, request): comment, created = Comment.objects.update_or_create( fieldA =request.data.fieldB, fieldB =request.data.fieldB, defaults={ 'content1': request.data.content1, 'content2': request.data.content1, } ) return Response(comment, created) At this point, every time i'm trying to edit a comment where fieldA and fieldB already exist, i got a duplicated row. I sure tried to add unique_together unique_together = (('fieldA', 'fieldB', ),) I now get an integrity error, saying fieldA and fieldB have to be a unique set. Looks like my post class is ignored. Any help would be greatly appreciated. Thanks -
How to have a ModelChoiceField show only one attribute of the class?
I have a model that uses a bunch of foreign keys. That model has its own form and view which works perfectly fine. But one field in the form needs to call only one attribute from the foreign key's class in models. At the moment the dropdown field on the form shows ALL of the info from that model Models: class Book(models.Model): book = models.Charfield(max_lenght=255) author = models.Charfield(max_lenght=255) summary = models.TextField() def __str__(self): field_values = [] for field in self._meta.get_fields(): field_values.append(str(getattr(self, field.name, ''))) return ' '.join(field_values) class BookInventory(models.Model): book = models.ForeignKey(Book, on_delete=models.CASCADE) supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE) location = models.ForeignKey(Location, on_delete=models.CASCADE) serial_number = models.CharField(max_length=255) Form: class BookInventoryForm(forms.ModelForm): book_title = forms.ModelChoiceField(queryset=Book.objects.all()) # book_title field should only list books author = forms.ModelChoiceField(queryset=Book.objects.all()) # author field should only show authors summary = forms.TextField() serial_number = forms.CharField(max_length=255) supplier_name = forms.ModelChoiceField(queryset=Supplier.objects.all()) location_name = forms.ModelChoiceField(queryset=Location.objects.all()) class Meta: model = BookInventory fields = ["book_title", "author", "serial_number", "supplier_name", "location_name"] View: def book_inventory(request): if request.method == "POST": form = BookInventoryForm(request.POST) if form.is_valid(): form.save() return redirect("index") else: form = BookInventoryForm return render(request, "add_book_inventory.html", {"form" : form}) So on the add_book_inventory.html page's form there will be two dropdowns, one for author and one for title. At the moment the book title drop … -
Django - Create related object on first call
I have some models: class User(AbstractUser): cart = models.OneToOneField('cart.Cart', on_delete=models.SET_NULL, null=True, blank=True) class Cart(models.Model): products = models.ManyToManyField('product.Product') date_updated = models.DateTimeField(auto_now=True, editable=False) Now I need to create user cart instance at first call. if request.user.cart is None: request.user.cart = Cart.objects.create() request.user.save() This method is not good for me, because it leads to code duplication (every time I need to import Cart model and check the user's cart is it None or not). The best way that I can find is AutoOneToOneField in django-annoying, but unfortunately it absolutely broke current field autocomplete in PyCharm. What is the right way to do that? P.S. I really don't need to create user cart object at user creation moment. P.P.S. Sorry for my bad English. -
Django "OR queries in **kwargs" for filtering
I have an existing **filter_kwargs used for "and" filtering, how do I insert the "or" queries? currently the supposed "OR" queries are treated as "and" query. Here's my base code: search_text = form_data.get("search_text", "").strip(" ") filter_kwargs = { "is_active": True, "is_admin": False, } if search_text != "": // these are the supposed "OR" queries. how do I insert "OR" queries in kwargs? filter_kwargs['user__first_name__icontains'] = search_text filter_kwargs['user__last_name__icontains'] = search_text filter_kwargs['user__email__icontains'] = search_text Profiles = Profile.object.filter(**filter_kwargs) -
Include variables in one template file into another in Django
I have a template file temp1.html having code like this --- {% load customtags %} {% get_val 'VAR1' as var1 %} {% get_val 'VAR1' as var2 %} In second template file temp2.html i want to use these variables var1, var2 and var3. I am going to use these variables in multiple template files. So want to reuse the code every where. I am including the temp1.html into temp2.html but these variables are not accessible into the temp2.html {% include 'temp1.html' %} So how to use these variables in another template files ? Please any body suggest me ! -
how to adding new fields for django-registration form
I had a lotof things to enter in my registrations form but I'am use base registration form in django 2.2 version. But I can't make it, I am new from Django and not fully understrand how to add extra fields to the base registration form. I write like this code: models.py from django.db import models from django.shortcuts import reverse from django.conf import settings from home.models import Locations, Levels class User(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) photo = models.ImageField(upload_to='static/img/profile/', blank=True) levels = models.ManyToManyField(Levels, verbose_name='levls') name = models.CharField(max_length=120, db_index=True) first_name = models.CharField(max_length=120, db_index=True) birdate = models.DateField() locations = models.ManyToManyField(Locations, verbose_name='locl') telnum = models.IntegerField(null=True) levelreg = models.DateTimeField(auto_now_add=True) levelchange = models.DateTimeField(auto_now=True) slug = models.SlugField(max_length=120) aside = models.CharField(max_length=120, unique=True) bside = models.CharField(max_length=120, unique=True) friendusers = models.CharField(max_length=120, unique=True) rebuy = models.IntegerField(null=True) balls = models.IntegerField(null=True) total = models.IntegerField(null=True) date_pub = models.DateTimeField(auto_now_add=True) def __str__(self): return 'Profile for user {}'.format(self.user.username) forms.py from django.contrib.auth.models import User from .models import Profile from django import forms class UserRegistrationForm(forms.ModelForm): password = forms.CharField(label='Password', widget=forms.PasswordInput) password2 = forms.CharField(label='Repeat password', widget=forms.PasswordInput) class Meta: model = User fields = ('username', 'name', 'first_name', 'birdate', 'telnum', 'email', 'aside', 'bside','rebuy', 'balls', 'total') def clean_password2(self): cd = self.cleaned_data if cd['password'] != cd['password2']: raise forms.ValidationError('Passwords don\'t match.') return cd['password2'] class UserForm(forms.ModelForm): class Meta: … -
Serving Static File on Django
I have been trying to serve my static files at my Django project, however it cannot find or load it. I have tried different approaches, but none seems to fix the issue. The static folder is in the same directory as the manage.py. Also, I have installed the WitheNoise but it also did not solve the problem. In addition: I am using docker, I have done the collect static and checked the container. All the files are correctly there. setting.py STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') html file {% load staticfiles %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <!-- Bootstrap --> <link rel="stylesheet" href="{% static "css/bootstrap.css" %}"> <link rel="stylesheet" href="{% static "css/jquery.bxslider.css" %}"> <!-- Custom --> <link rel="stylesheet" href="{% static "css/style.css" %}"> <link rel="stylesheet" href="{% static "css/animate.css" %}"> <title>SOS Media</title> </head> Let me know if there is anything else that I need to add to the post that will help you. Thank you, -
Pytest-Django does not specifically support Django’s multi-db and fails Database access not allowed
I was trying to run the testing with multi-db setup with the unmanaged (read-only) models. when I ran test the import functionality in the serailizers.py is failing and test database is not accessible. settings.py if 'test' in sys.argv or 'test_coverage' in sys.argv: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'db.sqlite3', }, 'test_db': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'db.sqlite3', } } INSTALLED_APPS += ['test'] pytest.ini [pytest] DJANGO_SETTINGS_MODULE=apps.settings models.py from django.db import models class TestModelA(models.Model): testid = models.CharField(max_length=200) class Meta: managed = False db_table = 'TestD' serializers.py from rest_framework import serializers from apps.services import get_testid class SearchSerializer(serializers.Serializer): application_names = serializers.MultipleChoiceField( choices=get_testid(), required=False, style={'base_template': 'select_multiple.html'} ) services.py from apps.models import TestModelA def get_testid(): return TestModelA.objects.values_list('testid ', flat=True) tests.py import pytest from django.test import RequestFactory, TestCase from appsviews import ( details ) class MyTestCase(TestCase): def setUp(self): self.request = RequestFactory().get('/details/') @pytest.mark.django_db def test_my_function(self): response = details(self.request) self.assertEqual(response.status_code, 200) Error apps/tests/tests.py:4: in <module> from apps.views import ( <frozen importlib._bootstrap>:971: in _find_and_load??? <frozen importlib._bootstrap>:955: in _find_and_load_unlocked ??? <frozen importlib._bootstrap>:665: in _load_unlocked ??? /tmp/lib/python3.6/site-packages/_pytest/assertion/rewrite.py:149: in exec_module exec(co, module.__dict__) apps/views.py:6: in <module> from apps.serializers import ( <frozen importlib._bootstrap>:971: in _find_and_load ??? <frozen importlib._bootstrap>:955: in _find_and_load_unlocked ??? <frozen importlib._bootstrap>:665: in _load_unlocked ??? /tmp/lib/python3.6/site-packages/_pytest/assertion/rewrite.py:149: in exec_module exec(co, module.__dict__) apps/serializers.py:9: in <module> … -
Django API - Chart.js
Im having difficulties using json data from a model in the template. I set the api endpoint, but the data from the model does not come through. views.py class ChartData(APIView): authentication_classes = [] permission_classes = [] def get(self,request,format=None): mobilen = Mobiles.objects.all() serializer = DeviceSerializer(mobilen,many=True) labels = ['Jan','Feb','March','Jan','Feb','March','Jan','Feb','March'] out = serializer.data data = { "labels":labels, "default":out, } return Response(data) index.html {% block jquery %} var endpoint = '/api/chart/data/' var defaultData = [] var labels = [] $.ajax({ method: 'GET', url: endpoint, success: function(data){ labels = data.labels defaultData = data.default setChart() }, error:function(error_data){ console.log("error") console.log(error_data) } }) function setChart(){ var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'line', data: { labels: labels, datasets: [{ label: '#', data: defaultData, }] } }) } {% endblock %} I get the data from the labels, but no data from the model in the chart. Thank you for any help -
How to link a profile to a newly created user using Django
Just finished a website using Django and i got stuck after creating a user or superuser. For some reason the same code i used before does not work anymore, and now whenever i create a new user it is saved (because i cant create another one with the same name) but not a profile for it. So now, after the registration form, the user should be redirected to the profile page which brings back an error. If i try to restart the server and login again, same error appears. Here is my signals.py from django.db.models.signals import post_save from django.contrib.auth.models import User from django.dispatch import receiver from .models import Profile @receiver(post_save, sender=User) def create_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_profile(sender, instance, **kwargs): instance.profile.save() and models.py from django.db import models from django.contrib.auth.models import User from PIL import Image class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) image = models.ImageField(default='default.jpg', upload_to='profile_pics') def __str__(self): return f'{self.user.username} Profile' def save(self): super().save() img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) TypeError at /register/ save() got an unexpected keyword argument 'force_insert' -
validate_email python library working on local machine but not on aws elasticbean
validate_email is a python library to verify if an email exists or not.I have been using it in my local machine for a long time but when I made a web app using django,and hosted it on aws elasticbean it is not able to validate and always returns None.code is: from validate_email import validate_email choice="someoneeg@somedomain.com" is_valid = validate_email(choice,verify=True) I suspect if it is problem of some port or some firewall issue ,I have tried adding http listener at port 25 but still it didn't work. I also tried directly using the validate.py file of the developer which is available on github ,still results are same (I have validate_email and Py3DNS installed as required) -
How use class-based views inheritance to override to parent class?
In my ShowChart has model called Electronic(Electronic.objects.values..etc) , in my inheritance class(ChartElectrical) it need to changed to to Electrical (Electronic.objects.values..etc), here i just pass it. I don't know how to do it class ShowChart(View): def get(self, request): my_count = Electronic.objects.values('allocated_time')\ .annotate(complete=Count('allocated_time', filter=Q(batch_18=True)), not_complete=Count('allocated_time', filter=Q(batch_18=False)), complete_1=Count('allocated_time', filter=Q(batch_19=True)), not_complete_1=Count('allocated_time', filter=Q(batch_19=False)), complete_2=Count('allocated_time', filter=Q(batch_20=True)), not_complete_2=Count('allocated_time', filter=Q(batch_20=False)), complete_3=Count('allocated_time', filter=Q(batch_21=True)), not_complete_3=Count('allocated_time', filter=Q(batch_21=False))) class ChartElectrical(ShowChart): pass -
How to use for loop tag inside chart.js template
Hello guys i am having trouble using for loop in chart.js template i do not know how to use for loop tag inside chart.js template in order to get some data dynamically i am unable to find complete tutorial of chart.js and django kindly help me please. template var endpoint = '/api/chart/data/' var defaultData = [] var labels = []; $.ajax({ method: "GET", url: endpoint, success: function(i){ labels = i.newlabels defaultData = i.newdata var myChart = new Chart(ctx, { type: 'bar', data: { labels: labels, datasets: [{ label: '# of Votes', data: defaultData, backgroundColor: "#4e73df", hoverBackgroundColor: "#2e59d9", borderColor: "#4e73df" borderWidth: 1 }] }, }); }, error: function(error_data){ console.log("error") console.log(error_data) } }) views.py class ChartData(APIView): authentication_classes = [] permission_classes = [] def get(self, request, format=None): qs_count = User.objects.all().count() av = Add.objects.aggregate( bud=Sum('budget'), exp=Sum('expense'), budexp=Sum('budget')-Sum('expense')) # I WANT TO DISPLAY THIS DATA labels = ["Black", "Blue", "Yellow", "Green", "Purple", "Orange"] default_items = [qs_count, 23, 2, 3, 12, 2] data = { "newlabels": labels, "newdata": default_items, } return Response(data) -
How To Get URL Parameters in django mako template?
I have url like this, blablabla.com/home?public=true how can I get the value public in django mako template? I previously using request.path but it's just show '/home' as a string Thank you for your answer -
how to set customize delimiter in vue-cli 3?
I'm using django with vue-cli 3 and I want to access the django data in vue template but there is a conflict with the syntax of data accessing i.e. delimiter in case of vue. Now I want to resolve this issue but the delimiter option is not working or I don't know where or how to add this command. I tried to add this to the main.js file in the src directory but it did not work out. Please suggest me if you know the solution or have any solution. new Vue({ router, store, vuetify, delimiters: ['[[',']]'], render: h => h(App) }).$mount('#app') Thank you. -
How can I use TTL to prevent a message backlog when using Firebase Cloud Messaging with Django-Push-Notifications?
I am working with Firebase Cloud Messaging in Django using django-push-notifications to deliver push notifications to our users via desktop notifications. After a browser is fully closed (such as when the the computer is turned off), our users receive a backlog of all notifications previously sent next time they boot up. While there are situations where a user would want to receive the entire backlog of messages, this is not one of them. It seems the answer is to set TTL=0, as per this section of the FCM documentation, but my attempts are not resulting in the desired behavior. Please help me better understand TTL in this context. If TTL is the right way to go, what is the proper way to format TTL in send_message() using django-push-notifications so that messages will not accumulate if not immediately delivered? Here is what I have attempted: devices.send_message( body, TTL=0, time_to_live=0, link='blah', extra={'title': 'blah blah', 'icon': '/foo/bar.png'} ) -
Optimize the filtering of Queryset results in Django
I'm overriding Django Admin's list_filter (to customize the filter that shows on the right side on the django admin UI for a listview). The following code works, but isn't optimized: it increases SQL queries by "number of product categories". (The parts to focus on, in the following code sample are, qs.values_list('product_category', flat=True) which only returns an id (int), so I've to use ProductCategory.objects.get(id=i).) Wondering if this can be simplified? from django.utils.translation import ugettext_lazy as _ from django.contrib.admin import SimpleListFilter from product_category.model import ProductCategory class ProductCategoryFilter(SimpleListFilter): title = _('ProductCategory') parameter_name = 'product_category' def lookups(self, request, model_admin): qs = model_admin.get_queryset(request) ordered_filter_obj_list = [] # TODO: Works, but increases SQL queries by "number of product categories" for i in qs.values_list('product_category', flat=True).distinct().order_by('product_category'): cat = ProductCategory.objects.get(id=i) ordered_filter_obj_list.append((i, cat)) return ordered_filter_obj_list def queryset(self, request, queryset): if self.value(): return queryset.filter(product_category__exact=self.value()) # Above filter is then used in the admin class ItemAdmin(admin.ModelAdmin): list_filter = ( ProductCategoryFilter, ) -
It is normal django_redis generate this kind of session key
I'm new to django_redis lib. I'm using this confs for session store with redis: ... CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", }, "KEY_PREFIX": "" } } SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' SESSION_CACHE_ALIAS = "default" ... Everything seems to work properly. But, when i check the key for a session on the database (default sqlite) and then compare that key value with the redis db in redis-cli, the session key are diferent. In the redis-cli version the session key has a prefix, even when I set no prefix. DB (sqlite) Version of Session Key skxn0oqp3goeipt6hnwvpeyp83hhoao0" redis-cli version of the key 127.0.0.1:6379[1]> keys * 1) ":1:django.contrib.sessions.cached_dbskxn0oqp3goeipt6hnwvpeyp83hhoao0" 127.0.0.1:6379[1]> This is normal ? -
django.db.utils.OperationalError: (1054, "Unknown column 'commons_smsmessages.sent_date' in 'field list'")
I'm using mysql as a db and I'm getting a django.db.utils.OperationalError: (1054, "Unknown column 'commons_smsmessages.sent_date' in 'field list'") when I add a field to the a pre-existing model. How do I fix it? I tried python manage.py makemigrations and I've also tried deleting all the migration files and running python manage.py makemigrations but it doesn't seem to work. This is the model I'm trying to update/add a field to: class SMSMessages(models.Model): sms_number_to = models.CharField(max_length=14) sms_content = models.CharField(max_length=160) sender_company = models.ForeignKey("SMSUser", on_delete=models.PROTECT, related_name="company_that_sent", limit_choices_to=1) sent_date = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = "SMSMessages" def __str__(self): return self.sender_company The field I'm trying to add to the model is sent_date. But whenever I run python manage.py makemigrations I get the error Traceback (most recent call last): File "/home/gadd/vscodeworkspace/sms.et/api.sms.et/api_env/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/gadd/vscodeworkspace/sms.et/api.sms.et/api_env/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 71, in execute return self.cursor.execute(query, args) File "/home/gadd/vscodeworkspace/sms.et/api.sms.et/api_env/lib/python3.6/site-packages/MySQLdb/cursors.py", line 209, in execute res = self._query(query) File "/home/gadd/vscodeworkspace/sms.et/api.sms.et/api_env/lib/python3.6/site-packages/MySQLdb/cursors.py", line 315, in _query db.query(q) File "/home/gadd/vscodeworkspace/sms.et/api.sms.et/api_env/lib/python3.6/site-packages/MySQLdb/connections.py", line 226, in query _mysql.connection.query(self, query) MySQLdb._exceptions.OperationalError: (1054, "Unknown column 'commons_smsmessages.sent_date' in 'field list'") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in … -
Azure Docker Django sqlite3 not deploying
I have spent an entire day trying to deploy a simple Django app to Azure with a docker container following this links advice. Dockerfile: # My Site # Version: 1.0 FROM python:3.7.2 # Install Python and Package Libraries RUN apt-get update && apt-get upgrade -y && apt-get autoremove && apt-get autoclean RUN apt-get install -y \ libffi-dev \ libssl-dev \ default-libmysqlclient-dev \ libxml2-dev \ libxslt-dev \ libjpeg-dev \ libfreetype6-dev \ zlib1g-dev \ net-tools \ vim # Project Files and Settings RUN mkdir -p myproject WORKDIR /myproject COPY requirements.txt manage.py . ./ RUN pip install -r requirements.txt # Server EXPOSE 8000 STOPSIGNAL SIGINT ENTRYPOINT ["python", "manage.py"] CMD ["runserver", "0.0.0.0:8000"] docker-compose.yml version: "2" services: django: container_name: django_server build: context: . dockerfile: Dockerfile image: johnmweisz/education_app:latest stdin_open: true tty: true volumes: - .:/myproject ports: - "8000:8000" using docker-compose build/run locally works perfectly fine but when deploying the app from https://cloud.docker.com/repository/docker/johnmweisz/education_app to Azure it will not start and says that it cannot find manage.py. I keep going in circles trying to find instructions that work. Anyone with advice please help. -
Django get related foreignkey count (Distinct)
i want to get count of related foreignkey values like this; Assume that, the value table of this GAME STATUS GAME1 FINAL GAME2 FINAL GAME3 PLAYOFF GAME4 FINAL I want to show how many different situations (the result from the table above should be 2) models.py class Game(models.Model): gamestatus = models.ForeignKey(Status, on_delete=models.CASCADE, null=True, blank=True) class Status(models.Model): name...