Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to sort by nested objects integer field
I'm trying to get elasticsearch docs sorted by price. I have this docs: class OfferDocument(InnerDoc): partner_price = Float() class ProductDocument(DocType): view_count = Integer() offers = Nested(OfferDocument) So, I have 55000 products in elasticsearch and I have to get them sorted by its offers price. So what I did: s = ProductDocument.search().query(some_query).sort({'offers.partner_price':{'order':'asc', 'mode': 'min'}}) When I do: s = ProductDocument.search().query(some_query).sort({'view_count':{'order':'desc'}}) It sorts correct. But It sorts incorrectly with nested object offer and its field partner_price. What's my problem? -
Django admin - Hidden field - Cannot assign must be an instance
I have a CustomUser model with ForeignKey to another model. In my Signup form, I'm using a hidden field that is populated with a value depending on a search result from the user (the user is searching for a company and after clicking on the result the hidden input value represents that company's ID). When I'm saving the User object I can easily get the ID, make a query and add the company object to the field. The problem is with my Admin. The Admin is using the same form and the company field is rendered as hidden with the ID value. When I try to change some User info and try to save it I get this error: Cannot assign "'3'": "CustomUser.kompanija" must be a "Kompanija" instance. I thought that the Admin is using the same save method from my custom UserAccountAdapter...? Is it possible to override the hidden input just for the Admin to show: forms.ModelChoiceField(queryset=Kompanija.objects.all(), empty_label="Kompanija") with initial value from the saved user object? My models.py: class Kompanija(models.Model): naziv = models.CharField(max_length=50) adresa = models.CharField(max_length=50, blank=True) def __str__(self): return self.naziv class CustomUser(AbstractUser): ime = models.CharField(max_length=30, default='') prezime = models.CharField(max_length=30, default='') kompanija = models.ForeignKey(Kompanija, on_delete=models.CASCADE, null=True, blank=True) is_premium = … -
Django change the field value after changing the value from another field
Im trying to add the value from another field/ColorField to another field. I currently made it work using the code below. The problem is once yun change the color in the admin changeview page the color_label does not get updated you need to save the actual data so the color_label will be updated. Any suggestions on how to make this work? Any signals that will be triggered after a form field has been changed? Model class Colors(models.Model): color = RGBColorField(null=True,blank=True) Admin class ColorsAdminForm(forms.ModelForm): color_label = forms.CharField() def __init__(self, *args, **kwargs): super(ColorsAdminForm, self).__init__(*args, **kwargs) self.fields['color'].label = 'Actual Color' self.fields['color'].disabled = True self.fields['color_label'].initial = self.initial['color'] -
How to set Python module like uwsgi in AWS beanstalk
Some applications I am deploying are using __init__.py instead of wsgi.py or application.py (app/wsgi/__init__.py) and setting a WSGI module like uwsgi would be great (module = app.wsgi:application in uwsgi.in) myapp/wsgi/__init__.py == myapp.wsgi:application .ebextensions/django.config: option_settings: aws:elasticbeanstalk:container:python: WSGIPath: saleor/uwsgi/__init__.py (!!! DOES NOT WORK !!!) uwsgi.ini: [uwsgi] die-on-term = true http-socket = :$(PORT) log-format = UWSGI uwsgi "%(method) %(uri) %(proto)" %(status) %(size) %(msecs)ms [PID:%(pid):Worker-%(wid)] [RSS:%(rssM)MB] master = true max-requests = 100 memory-report = true module = saleor.wsgi:application processes = 4 static-map = /static=/app/static mimefile = /etc/mime.types New account at AWS forums so can't post a question there yet. SO to the rescue! -
django.core.exceptions.ImproperlyConfigured: WSGI application 'invoice_project.wsgi.application' could not be loaded; Error importing module
I suddenly opened my Django project and when I tried to launch it with py manage.py runserver it gave me this error. django.core.exceptions.ImproperlyConfigured: WSGI application 'invoice_project.wsgi.application' could not be loaded; Error importing module. This is my traceback. I checked the settings.py and the wsgi.py file and they both (I think) are configured properly, therefore I do not know where to start looking for the error Traceback (most recent call last): File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\site-packages\django\core\servers\basehttp.py", line 45, in get_internal_wsgi_application return import_string(app_path) File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\site-packages\django\utils\module_loading.py", line 17, in import_string module = import_module(module_path) File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\Enrico\Desktop\prova\django_invoice\invoice_project\invoice_project\wsgi.py", line 16, in <module> application = get_wsgi_application() File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application return WSGIHandler() File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\site-packages\django\core\handlers\wsgi.py", line 135, in __init__ self.load_middleware() File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\site-packages\django\core\handlers\base.py", line 35, in load_middleware middleware = import_string(middleware_path) File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\site-packages\django\utils\module_loading.py", line 17, in import_string module = import_module(module_path) File "C:\Users\Enrico\.virtualenvs\invoice_project-JDtH6-bZ\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen … -
django template language is not the same as jinja2
i'm new in Django. i'm really curious to Django template language. i have used jinja2 before Django template language. Some people say says that jinja2 and Django template language are the same. But i stuck on if statement on Django template language. usually when we are comparing some value to "True" we are usually not using "==" : {% if somevalue %} ..... {% endif %} instead of.... {% if somevalue == true %} ..... {% endif %} i can't do the first method... why ??? -
How to pass python variable to javascript in django template for Dygraph
I want to send a pandas dataframe output that is in Django Views.py, to the template in order to graph in a Dygraph. The Dygraph will display if I leave the array definition in the template with the Dygraph script. If I copy that same array definition to views.py and render it to the template the graph won't display. The example array from Dygraphs (http://dygraphs.com/data.html#array). And it works correctly. output.html: <div id="graphdiv"></div> <script> new Dygraph( document.getElementById("graphdiv"), [ [1,10,100], [2,20,80], [3,50,60], [4,70,80] ] , ); </script> Below is my intent with the array defined in views.py, but this won't render the graph. Views.py: def output(request): DAT = [ [1,10,100], [2,20,80], [3,50,60], [4,70,80] ] #DAT = json.dumps(DAT) This doesn't seem to help either. data = { 'DAT': DAT, } return render(request, 'cylon/output.html', data) ------------------------------------------------------ Output.html: <div id="graphdiv"></div> <script> new Dygraph( document.getElementById("graphdiv"), "{{DAT}}" , ); </script> -
Django rate-limit not run
I want to limit the number of login is 2, so I use Django rate-limit, but I can log in with 3rd account in mobile. Any suggestions what I am doing wrong? views.py @ratelimit(key='user_or_ip', rate='1/m', method=['GET', 'POST']) def login(req): was_limited = getattr(req, 'limited', False) if was_limited: mess = "Try again" return HttpResponse(mess) if req.method == 'POST': login_form = LoginForm(req.POST) if login_form.is_valid(): email = login_form.cleaned_data['email'] password = login_form.cleaned_data['password'] user = authenticate(username=email, password=password) if user is not None: auth_login(req, user) if user.is_staff != 0: return HttpResponseRedirect('/admin') return HttpResponseRedirect('/') else: return render(req, 'app/templates/pages/login.html', {"result": "Account is incorrect", 'form': login_form}) elif req.user.is_authenticated: if req.user.is_staff != 0: return HttpResponseRedirect('/admin') return HttpResponseRedirect('/') else: form = LoginForm() return render(req, 'app/templates/pages/login.html', {'form': form}) settings.py # RATELIMIT SETTINGS #RATELIMIT_CACHE_PREFIX = 'rl:' RATELIMIT_ENABLE = True RATELIMIT_USE_CACHE = 'default' #RATELIMIT_VIEW = None MIDDLEWARE = [ ... 'ratelimit.middleware.RatelimitMiddleware' ] -
Change paragraph on homepage from django admin panel
I want to be able to edit paragraphs on my homepage from the django admin panel. I tried making a "Homepage" class in models.py and calling it like so. models.py class Homepage(models.Model): homepage_image = models.ImageField(blank=True) image_text = models.CharField(max_length=200, blank=True) header_title = models.CharField(max_length=200, blank=True) header_text = models.TextField(blank=True) class Meta: verbose_name_plural = "Homepage" def __str__(self): return "Homepage" views.py from .models import Homepage # Create your views here. def homepage_view(request): context = { "title": "Grey Bear Industries | Home", "homepage": Homepage.objects.all() } return render(request, "main/index.html", context) index.html <p class="lead"> {{ homepage.header_text }} </p> This may not be the ideal way to do this as in django admin I only want to have one "Homepage" that I can edit and swap out pictures from rather than having the add button. -
how to show short version of post in the main page of template in django
I'm writing a blog app and I want to show short versions of posts on the main page, after title then would have just 4 line of detail of each post then have another post, but problem is post of detail all shows in the main page. def tours(request): featured = Tour.objects.filter(featured=True) context = { "object_list": featured, } return render(request, 'tours.[html][1]', context) def sidebar(request): return render(request, 'sidebar.html', {}) -
cannot import name 'detail_route' from 'rest_framework.decorators'
I'm trying to run longclaw but when I python manage.py migrate i get an error . $python manage.py makemigrations catalog home Traceback (most recent call last): File "manage.py", line 11, in <module> execute_from_command_line(sys.argv) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 361, in execute self.check() File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks return checks.run_checks(**kwargs) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config return check_resolver(resolver) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver return check_method() File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/urls/resolvers.py", line 398, in check for pattern in self.url_patterns: File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/urls/resolvers.py", line 579, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/urls/resolvers.py", line 572, in urlconf_module return import_module(self.urlconf_name) File "/home/x/Documents/Longclaw/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen … -
Django 2.2 staticfiles don't work in production (DEBUG False)
I'm making a new django app where a user can upload images and then they can be displayed on a page. I've read the django docs 10000 times through and I still don't understand why my images aren't loading. All my images are going to where they're supposed to be and in the admin in my models django has the right path that leads to the image but it just won't load properly. my setup in settings.py: STATIC_URL = '/static/' STATIC_ROOT = 'static' # live cdn such as AWS S3 STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media') MEDIA_URL = '/img/' my directories: |- src |- myproject |- settings.py, views.py, urls.py etc |- myapp |- views.py urls.py models.py forms.py etc |- static (this folder is empty and appeared after running collectstatic |- templates |- db.sqlite3 |- manage.py |- static (this folder is OUTSIDE src) |- admin |- django admin stuff |- media |- img |- myimage.png in models.py of myapp the imagefield upload_to = 'img/' if i am in debug mode and i add the reccomended code to make it work: if settings.DEBUG: from django.conf.urls.static import static urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) everything works. this … -
Django Model Query to Group Results By Month/Year and Display Each Month's Results in Separate DIV Elements
I want to create a model (name is Event) query in my view that groups events by month/year (launch_date field), then I want to display (using a for loop) the group of each month's events in it's own DIV element. For example, all September 2019 events would be in a single DIV element, all October 2019 events would be in a single DIV element next to September, and so on. The model is really simple: class Event(models.Model): name = models.CharField(max_length=300, blank=True) overview = models.TextField(max_length=1200,blank=True) launch_date = models.DateField(blank=True, default=datetime.now) Any help on this would be appreciated. -
Pycharm debugger not working with docker for mac
When starting my debugger docker seems to run fine with no errors but I do not get a connection to my localhost server. Docker logs are fine as well. This issue only occurs when starting the debugger. I am using docker for mac. -
django auth form jump to login page
i would like to protect some web pages to use only auth users to have access and if user is not auth then jump him to login page.but I have some errors because auth users jump to dead link . here the code entry page : @login_required(login_url="login/") def add_entry(request): if request.method == "POST": form = entryForm(request.POST) if form.is_valid(): note = form.save(commit=False) note.save() else: form = entryForm() return render(request, 'add_entry.html', {'form': form}) urls.py url(r'^add-entry/$', views.add_entry, name='add_entry'), url(r'^login/$', views.login, {'template_name': 'auth/login.html', 'authentication_form': LoginForm}), dead link : 127.0.0.1:8000/add-entry/login/?next=/add-entry/ any idea ?thanks -
Define Django model with flaggit
I'm trying to use this django app https://github.com/mkalioby/ModelTracker I believe I have installed the dependency via pip in my environment. Then in models.py I have import flaggit print(flaggit) class Thread(flaggit.models.Flag): author = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True ) but I get error AttributeError: module 'flaggit' has no attribute 'models'. Can someone provide a minimal example of how to use this django app? I'm using django rest framework btw. -
How to create Django objects so as to avoid duplicate key errors after restoring your database?
In Django, when you create an object, either with a Django helper function like 'create_user' or with an object's 'create' method, Django automatically creates an auto-incrementing primary key for that new object: user = User.objects.create_user(username='foo', password='bar') # id = 1 user.save() account = Account.objects.create(user=user) # id = 1 account.save() But in the real world, if your server crashes and you have to rebuild your database server and then reload all your data, the first time you try to create a new object, you're going to get this type of error: django.db.utils.IntegrityError: duplicate key value violates unique constraint "new-object_pkey" Whenever you create a new model instance, Django seems to assume you're starting with a clean, new database and it assigns the new object an id of 1 even though, if you had to restore the database, you already have an object in the restored table with an id of 1. What is the "Django way" to avoid this situation with both Django's helper functions as well as the object "create" method? I would think that this would be a common problem for any production Django website and that Django would recognize this and handle it automatically. But I don't see such … -
I am trying to inser dictionary in database from django how to do this task at onclick event
I need code example to insert data from data dictionary in data base from django please help. I am stuck in this -
Django Admin formfield_for_foreignkey generic owner filter
I want to use formfield_for_foreignkey method to filter owned objects in selection list. There are many so i wanted to use a generic way. Also show all if super user. This is what i found in the documentation. class OwnerFilteredAdmin(admin.ModelAdmin): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "company": kwargs["queryset"] = Company.objects.all() if request.user.is_superuser is not True: kwargs["queryset"] = kwargs["queryset"].filter(client=request.user.userprofile.client) return super().formfield_for_manytomany(db_field, request, **kwargs) return super().formfield_for_manytomany(db_field, request, **kwargs) class FooAdmin(OwnerFilteredAdmin): # configs In this case, only work for Company model. ¿Any ideas? -
ListView without queryset
I am trying to increase performance in a view that has to render a list of events. Currently, I populate a database table on the fly and with a generic list view I show it. However, since it has to do a dababase bulk insert it takes few seconds. I wonder if there is a way -since I have the information in a list in memory- to use the ListView not having to create the database table and the respective queryset. I mean to render the LisView directly from the list structure that I have in memory. Is it possible ? I would appreciate if anyone can give me a hand with this since I have not found any information in google regarding this issue. Best regards. -
Django makemigrations check generates same migration
I created a new model that has two foreign keys to existing models, nothing complex, ran makemigrations, and did a git push. After pushing, my Jenkins build failed immediately on account of a check migrations detecting more were needed. I ran makemigrations --check and sure enough a new migration appeared altering a field to my new model that did nothing but set it to what was already in the model. Running the command multiple times results in the same migration being generated every single time. At a loss as to what is triggering this behavior. I tried renaming the field and the same issue persists. Models: class CustomReference(BaseModelHardDelete): reference = models.CharField(max_length=constants.CHARFIELD_SIZE_256, null=False, blank=False) company_preferences = models.ForeignKey(CompanyPreferences, null=False, on_delete=models.CASCADE, related_name='custom_references') class Meta: ordering = ('created_at',) unique_together = ('reference', 'company_preferences',) class CustomReferenceValue(BaseModelHardDelete): custom_reference = models.ForeignKey('companies.CustomReference', null=False, on_delete=models.CASCADE) shipment = models.ForeignKey(Shipment, null=False, on_delete=models.CASCADE, related_name='custom_reference_values') value = models.TextField(blank=True, null=True) class Meta: ordering = ('created_at',) unique_together = ('custom_reference', 'shipment',) Migrations 1: class Migration(migrations.Migration): dependencies = [ ('companies', '0113_auto_20190730_1544'), ('shipments', '0191_merge_20190729_2140'), ] operations = [ migrations.CreateModel( name='CustomReferenceValue', fields=[ ('created_at', common.fields.CreatedField(default=django.utils.timezone.now, editable=False)), ('updated_at', common.fields.LastModifiedField(default=django.utils.timezone.now, editable=False)), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')), ('value', models.TextField(blank=True, null=True)), ('custom_reference', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='companies.CustomReference')), ('shipment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='custom_reference_values', to='shipments.Shipment')), ], options={ 'ordering': ('created_at',), }, ), … -
Can django.forms.DateInput be customized to accept a range produced by daterangepicker?
I am using django-filter and django-tables2 to generate a report built from the Django framework. I have a filter that filters dates, and I'm trying to add the daterangepicker widget to the view. It provides dates in a range format 'MM/DD/YYYY - MM/DD/YYYY'. I am using forms.DateInput in my filter and it is complaining about format being invalid. How can I customize the Filter to accept the date range and perform the filtering based on the range? I've tried looking through the FilterView source code to see if I can tell how to make this work. I've been looking around for ways to integrate daterangepicker into this django-filter framework, but I'm having a hard time. I've tried using django_filters.DateFilter() but it only expects one date. Here is the view: from django_tables2.views import SingleTableMixin from django_filters.views import FilterView from .models import WorkHours from .tables import WorkHoursTable from .filters import WorkHoursFilter class FilteredWorkHoursView(SingleTableMixin, FilterView): table_class = WorkHoursTable model = WorkHours template_name = 'hub/multi_day_report.html' filterset_class = WorkHoursFilter the filter: import django_filters from django import forms from .models import WorkHours class WorkHoursFilter(django_filters.FilterSet): date_worked = django_filters.DateFromToRangeFilter( widget=forms.DateInput( attrs={ 'id': 'datepicker' } ) ) class Meta: model = WorkHours fields = [ 'date_worked', 'employee', 'job_number', ] … -
How to properly authenticate with both username and email with oauth2 toolkit
I would like to be able to login either with username or email using oauth2 toolkit - when I log with an email, I want to pass email parameter, not username to distinguish them. This is what I came up with from django.contrib.auth import get_user_model from oauth2_provider import views class TokenView(views.TokenView): def create_token_response(self, request): try: email = request.GET.copy().pop('email')[0] self.set_username_from_email(request, email) except (KeyError, get_user_model().DoesNotExist): pass return super().create_token_response(request) @staticmethod def set_username_from_email(request, email): """ Parameters used for request are for some reason stored in request.META['QUERY_STRING'] which is just url query string, we need to parse it, and replace email with username """ a = [] for pair in request.META['QUERY_STRING'].split("&"): username = get_user_model().objects.get(email=email).username items = pair.split('=') if items[0] == 'email': items[1] = username items[0] = "username" a.append('='.join(items)) request.META['QUERY_STRING'] = "&".join(a) This works, but it feels really ugly to alter the parameters like this. Is there a better way how to do it? Perhaps extend something else then TokenView? I was inspired by https://stackoverflow.com/a/44226177/4710968 but the request.POST attribute is empty and adding something to it changed nothing. I am using Django 2.1.7 and oauth2_toolkit 1.2.0 -
Paginating without model in django
this is my first post ever related to programming therefore please forgive if it is a bit silly. I'm making a website that will aggregate real estate data from some classified ads websites. I've already managed to write simple scrapers that update the website's database and now I wanted to make the actual web app using Django. The website would take data from users that can search the real estate database according to their criteria (already set up a django form and provisionary interface for that.) I'm a newbie and don't know a lot about django therefore I've been trying to use a simple function-based-view to process queries and display results based on user's choices. I've got completely stuck on pagination - as some queries might have thousands of results it's absolutely essential to implement it but django paginator seems to only be working with a predefined django model. I've tried using django paginator to no avail as it appears to require defined models. I've tried the paginate library but there is no real documentation or examples so I couldn't make it work https://pypi.org/project/paginate/ I'm thinking of writing the pagination script by myself but it will take me a very … -
updating web site witout deleting database
I am using docker for my django project with ubuntu server. When I was chaning something always I am removing my docker images and building it again and my database also removed and I have to be populate my database again. I am trying these steps: pulling new code from git docker stop $(docker ps -aq) docker rm $(docker ps -aq) docker-compose up --build -d and as I mentioned my database also removed. I have tried without stopping and removing. Only docker-compose up --build -d but it did not worked. Also I tried docker-compose restart it also not worked. What I have to be tried. Please note that I am new in docker and django. Its my first project.