Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add ArrayField in Django?
my models.py class LiveClass_details(models.Model): standard = models.ForeignKey(LiveClass, on_delete=models.CASCADE) chapter_details = models.TextField(default='') mentor_id = models.ForeignKey(Mentor, max_length=30, on_delete=models.CASCADE) start_time = models.DateTimeField() end_time = models.DateTimeField() doubtClass = models.OneToOneField(DoubtClasses, on_delete=models.PROTECT, null=True, blank=True) isDraft = models.BooleanField(default=True) ratings = models.FloatField(default=0) no_of_students_registered = models.IntegerField(default=0) # registered_students = models.ManyToManyField(RegisteredNames, null=True, blank=True) no_of_students_attended = models.IntegerField(default=0) class Meta: verbose_name_plural = 'LiveClass_details' class RegisteredNames(models.Model): name = models.CharField(max_length=100, unique=True) liveclass_id = models.ForeignKey I am creating a endpoint where when a user register himself his name will get added to registered_students , so i had made a registered students ManyToMany Field hoping it will get updated when a user is registered but then i understand that it will contain all the names that are present in the RegisteredNames Model meaning names registered across all the liveclasses but i want only the names that are registered for a particular liveclass in the field so i need a array like field which i think is not possible so please help me in improving my logic, how can i achieve it -
Django reset password and verification with email using function based view
Django reset password and verification with email using function based view. -
App is Not showing up in Django 3.0 admin
I have put my app in the settings.py: 'jet', 'jet.dashboard', 'store.apps.StoreConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tinymce', ] no error is there. I suspect the admin.py of my app: from django.contrib import admin from .models import Customer, Product, Order, OrderItem, Shipping, models from tinymce.widgets import TinyMCE class ProductAdmin(admin.ModelAdmin): formfield_overrides = { models.TextField: {"widget": TinyMCE()} } admin.register(Customer) admin.register(Product, ProductAdmin) admin.register(Order) admin.register(OrderItem) admin.register(Shipping) But the models are registered properly, and no error is there. I have use Django-3-jet module to customise my admin page. Help Will Be appreciated. App name: store. -
nginx 502 bad gateway, location of nginx.config
I am trying to upload my app to AWS (Python 3.8 running on 64bit Amazon Linux 2) through Elastic Beanstalk. My app has been developed with Django 3.0. OS is Ubuntu 20.04. I start with an empty Django project, this works fine with a green status health check, and Django admin works fine. When I add files from my app it throws the 502 bad gateway error. I have spent many days trying to fix this with no luck. var/log/nginx/error/log: 2021/06/29 15:29:42 [error] 4854#4854: *4084 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.20.250, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "35.176.238.136" django.config option_settings: aws:elasticbeanstalk:container:python: WSGIPath: FFfF_project.wsgi:application aws:elasticbeanstalk:environment:proxy:staticfiles: /static: static aws:elasticbeanstalk:application:environment: DJANGO_SETTINGS_MODULE: FFfF_project.settings PYTHONPATH: "/var/app/current:" 01_packages.config packages: yum: python3-devel: [] mariadb-devel: [] requirements.txt django==3.0 django-crispy-forms==1.9.2 Pillow==8.2.0 gunicorn==20.0.4 mysqlclient==1.4.6 config.yml branch-defaults: master: environment: FFfF-env group_suffix: null environment-defaults: FFfF-env: branch: null repository: null global: application_name: FFfF_project branch: null default_ec2_keyname: ff-KeyPair default_platform: Python 3.8 running on 64bit Amazon Linux 2 default_region: eu-west-2 include_git_submodules: true instance_profile: null platform_name: null platform_version: null profile: eb-cli repository: null sc: git workspace_type: Application I think the error is related to the nginx.config file, but I cannot find this file to either edit or modify. … -
Using D3.js to pick and choose data out of SQLite3 database
I am pretty new to coding and am trying to build a web app that is able to visualize Data out of a SQLite3 database. Is it possible to pick individual datapoints out of a 30k row database to visualize it as a stacked bar chart? I would like to build a search field where its possible to search for the datapoints. And idealy have an update field to update the visualization after picking the datapoints. Many Thanks in Advance -
Issue using progress_recorder (celery-progress): extends time of task
I want to use celery-progress to display progress bar when downloading csv files my task loop over list of cvs files, open each files, filtered data and produce a zip folder with csv filtered files (see code below) but depending where set_progress is called, task will take much more time if I count (and set_progress) for files processed, it is quite fast even for files with 100000 records but if I count for records in files, that would be more informative for user, it extends time by 20 I do not understand why how can I manage this issue for file in listOfFiles: # 1 - count for files processed i += 1 progress_recorder.set_progress(i,numberOfFilesToProcess, description='Export in progess...') records = [] with open(import_path + file, newline='', encoding="utf8") as csvfile: spamreader = csv.reader(csvfile, delimiter=',', quotechar='|') csv_headings = ','.join(next(spamreader)) for row in spamreader: # 2 - count for records in each files processed (files with 100000 records) # i += 1 # progress_recorder.set_progress(i,100000, description='Export in progess...') site = [row[0][positions[0]:positions[1]]] filtered_site = filter(lambda x: filter_records(x,sites),site) for site in filtered_site: records.append(','.join(row)) -
Django Form Widgets SyntaxError: cannot assign to function call
I'm trying form widgets and I coded this class in my forms.py: class RawProductForm(forms.Form): title = forms.CharField(label='', widget=forms.TextInput(attrs={"placeholder: "Your title"})) description = forms.CharField( required= False, widget=forms.Textarea( attrs={ "class": "new-class-name two", "id": "my-id-for-textarea", "rows": 100, "cols": 20 } ) ) price = forms.DecimalField(initial=199.99) But I'm getting an error which I do not know how to solve: line 16 title = forms.CharField(label='', widget=forms.TextInput(attrs={"placeholder: "Your title"})) ^ SyntaxError: expression cannot contain assignment, perhaps you meant "=="? -
Is there a tool that syncs two parts of a code base so that updating one automatically updates the other?
I'm looking for a vim, vscode, or emacs tool/plugin that allows you two define a link two parts of the same codebase (same or different files), such that they stay synced up. If you update one of them, the other is updated to match it automatically. An example is with a Django project below. On the left (line 12) is a view called detail with a docstring that contains the url endpoint that calls that view. On the right (line 8) is the code that links that url to that function. The url endpoint is place/<int:place_id>/. If I update the url on the left or on the right to place/<int:place_id/asdf, the other one should update automatically. (This can occur live, or whenever the file is saved). Do you know of any tool that can do this live syncing of specific parts of code files? -
Migrating a Python package in Django on Heroku?
I'm working on a Django project, and I installed a Python package using pip (specifically the django-gsheets package). This package has its own set of migrations contained in its own package files (/env/lib/python3.7/gsheets/migrations/), and when I run python manage.py migrate, Django finds them and applies them, even though they're not in my project directory. However, I run into problems with doing it remotely on the Heroku server. I've added the package to my requirements.txt and 'gsheets' (the app name) to INSTALLED_APPS in settings.py, but when I do heroku run python manage.py migrate, it can't find the migrations. I tried manually adding a 'gsheets' folder in the root directory of my project, with its own 'migrations' folder, copying over the migrations into it, committing, and pushing to Heroku, but Heroku still can't find the migrations. I've also tried heroku run python manage.py makemigrations, which does make the right migrations on the Heroku server, but Heroku can't find these when I tried to run the migration. It's starting to feel like I might have to just copy the entire gsheets project into my root project directory in order to actually use it on Heroku, but I'm wondering if there are any better … -
Retrieving the true size of a html document
I have a html document that I created using googles "site" service. I tried exporting and embedding this document into my django website by including it into one of my templates. However, the content of my website overlaps with the footer, since apparently the html engine doesn't recognize the actual size of the embedded document and starts placing elements before it has actually ended. Editing the document itself is impossible because it's just a large block of unstructured code. I can solve the problem by adding break tags at the end of the document and seeing how many I need to get the footer to the correct height again, but I would like to be able to reedit this site and don't want to keep calculating how many tags i need each time. The recognized size is always the same, however long the document itself actually becomes. The file itself is too large to paste into pastebin but contains too many elements to properly navigate. Is there a good way to still embed this document into a regular html document without requiring the use of additional code? -
"non_field_errors" upon loging in using Django Rest Framework and Knox
I looked through all the relevant threads I could find and nothing seems to work. When I try to login through the API, it shows the 'non_field_errors' (username and password are correct). Here's my views.py, serializers.py and settings.py: views.py: class LoginAPI(generics.GenericAPIView): serializer_class = LoginUserSerializer permissions_classes = () queryset = User.objects.all() def post(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.validated_data return Response({ "user": UserSerializer(user, context=self.get_serializer_context()).data, "token": AuthToken.objects.create(user)[1] }) def get(self, request, *args, **kwargs): user = User.objects.all() serializer = UserSerializer(user, many=True) return Response(serializer.data) serializers.py: class LoginUserSerializer(serializers.Serializer): username = serializers.CharField() password = serializers.CharField() def validate(self, data): user = authenticate(**data) if user and user.is_active: return user raise serializers.ValidationError("invalid details") settings.py: REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'knox.auth.TokenAuthentication' ), 'DEFAULT_PERMISSIONS_CLASSES': ( 'rest_framework.permissions.AllowAny', ) } -
"detail": "CSRF Failed: CSRF token missing or incorrect." Django Rest Framework
My Error: { "detail": "CSRF Failed: CSRF token missing or incorrect." } My Model: class Booking(models.Model): booking_id = models.AutoField(primary_key=True) booking_owner = models.TextField(max_length=20) booking_city = models.TextField(max_length=20) booking_place = models.TextField(max_length=20) booking_arrival = models.DateField() booking_departure = models.DateField() booking_vehicle = models.TextField(max_length=20) booking_amount = models.TextField(max_length=20) booking_payment_date = models.DateField(default=now) booking_status = models.TextField(max_length=10, default=None, blank=True, null=True) booking_payment_status = models.TextField(max_length=10, default=None, blank=True, null=True) booking_entrance_time = models.TimeField(default=None, blank=True, null=True) booking_exit_time = models.DateTimeField(default=None, blank=True, null=True) def __str__(self): return "%s - %s" % (self.booking_id, self.booking_city) My Serializer: class AddBookingSerializer(serializers.ModelSerializer): class Meta: model = Booking fields = '__all__' My View: class BookingAddAPI(APIView): @staticmethod def post(request): data = {} try: serializer = WitPark.serializers.AddBookingSerializer(data=request.data) if serializer.is_valid(): serializer.save() data['status'] = status.HTTP_201_CREATED data['message'] = "Data saved successfully" else: data['status'] = status.HTTP_204_NO_CONTENT data['message'] = "Invalid data" except Exception as e: data['status'] = status.HTTP_404_NOT_FOUND data['message'] = "Failed to save the data" data['error'] = e return Response(data=data) I have also other POST methods. This post method is working fine in localhost but not working in live server (pythonanywhere.com) All other methods are also working fine on live server except this one -
Django Pagination in ListView does not have page_obj?
I am a little confused here... I have assigned paginate_by within my class but it simply does not paginate. I have read many articles about query_set and others but nothing seems to solve my issue. Here is my original view: class Clients(ListView): paginate_by = 5 model = Client template_name = 'clients.html' def get_clients_view(self, request): """ Primary View """ last_name = request.GET.get('last_name', '') email = request.GET.get('email', '') if request.method == 'GET': object_list = Client.objects.filter(last_name__contains=last_name).filter(email__contains=email) register_form = ClientRegisterForm(request.POST) remove_form = ClientRemoveForm(request.POST) search_form = ClientSearchForm(request.GET) update_form = ClientUpdateForm(request.POST) client_context= { 'object_list' : object_list, 'register_form' : register_form, 'remove_form' : remove_form, 'search_form' : search_form, 'update_form' : update_form } return render(request, template_name='clients.html', context=client_context) As well as my nav: <nav class="step-links"> {% if is_paginated %} {% if page_obj.has_previous %} <a href="?page=1">&laquo; first</a> <a href="?page={{ page_obj.previous_page_number }}">previous</a> {% endif %} {% if page_obj.number %} <p class="current"> Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. </p> {% endif %} {% if page_obj.has_next %} <a href="?page={{ page_obj.next_page_number }}">next</a> <a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a> {% endif %} {% else %} <p> Is not paginated.</p> {% endif %} </nav> -
Django: django.urls.exceptions.NoReverseMatch: Reverse for 'book' with arguments '('',)' not found
I am working on CS50 Django tutorial. I am not able to open one of the pages and it shows the following error. Reverse for 'book' with arguments '('',)' not found. 1 pattern(s) tried: ['flights/(?P<flight_id>[0-9]+)/book$'] Here is my urls.py urlpatterns = [ path('', views.index, name="index"), path('admin/', admin.site.urls), path('<int:flight_id>', views.flight, name="flight"), path('<int:flight_id>/book', views.book, name="book") ] Here is my views.py related code def book(request, flight_id): if request.method == "post": flight = Flight.objects.get(pk=flight_id) passenger = Passenger.objects.get(pk=int(request.POST["passenger"])) passenger.flights.add(flight) return HttpResponseRedirect(reverse("flight", args=(flight_id,))) I have used it in an html page <form action="{% url 'book' flight.id %}" method="post"></form> {% csrf_token %} I'd like to know what's the problem, I have checked some related problem but none of them are helpful -
Python Huey throws huey.exceptions.HueyException: xxxxxx not found in TaskRegistry
I'm trying to integrate Huey with Django where I'm almost done with the initial setting of app and everything with redis. Now when I'm running the actual .py file I'm getting an exception huey.exceptions.HueyException: xxxxxxx not found in TaskRegistry. I have followed all the steps mentioned on here but still no luck so far. Can someone please help and through some light on what I'm missing or if something is wrong. Thanks in advance. Below is my code and app settings: schedule_task.py settings.py Command which I'm using to run the schedule_task.py python manage.py shell < hueyTasks/schedule_task.py Redis running on my local python manage.py run_huey command to run the consumer -
Django API architecture
I have an API and I use DRF with class based views. My API got these models: """ Model for System """ import uuid from django.db import models from django.utils.translation import ugettext as _ from simple_history.models import HistoricalRecords from common_config import custom_model_fields as version_model from systems.models.manager.manager import SystemManager class System(models.Model): """ Define fields for system model. machine(1-1): machine/models/machine.py owner(N-N): user/models/user.py support(N-N): user/models/user.py dealer(1-N): user/models/company.py console(1-1): console/models/console.py vision(1-N): vision/models/vision.py """ class MarketChoice(models.TextChoices): """ Enum for market location """ AUSTRALIA = 'Australia', _('Australia') EUROPE = 'Europe', _('Europe') class ProductChoice(models.TextChoices): """ Enum for Product """ SPRAYER = 'Sprayer', _('Sprayer') OPTICAL_SORTER = 'Optical sorter', _('Optical sorter') uuid = models.UUIDField( default=uuid.uuid4, editable=False, unique=True) name = version_model.VersionCharField( verbose_name=_('Commercial name of the system'), max_length=30, default='1', null=False, blank=False, unique=True, version=1) code = models.CharField(verbose_name=_('code'), max_length=30, default='') description = models.TextField(verbose_name=_('Description'), blank=True) machine = models.OneToOneField('machine.Machine', on_delete=models.PROTECT) owner = models.ManyToManyField('users.User', related_name='own') support = models.ManyToManyField('users.User', related_name='support') dealer = models.ForeignKey('users.Company', on_delete=models.PROTECT) console = models.OneToOneField('console.Console', on_delete=models.PROTECT, related_name='console') market_location = models.CharField(max_length=25, choices=MarketChoice.choices, default=MarketChoice.EUROPE) is_telemetry_available = models.BooleanField(default=True, verbose_name=_('Is the telemetry activated for this system ?')) product = models.CharField(verbose_name=_('Product type'), max_length=25, choices=ProductChoice.choices, default=ProductChoice.SPRAYER) application = models.CharField(verbose_name=_('Application'), max_length=30, default='') history = HistoricalRecords() objects = SystemManager() class Meta: # pylint: disable=too-few-public-methods """ Meta class for System """ verbose_name = _('System') … -
How to customize Many-to-Many Inline in Admin Site
This is how I've defined my models: class Technology(models.Model): title = models.CharField(max_length=10) class Meta: verbose_name_plural = 'Technologies' def __str__(self): return self.title class Project(models.Model): title = models.CharField(max_length=100) description = HTMLField() technology = models.ManyToManyField(Technology, related_name='projects') image = models.ImageField(upload_to='projects/') def __str__(self): return self.title And this is how I've defined the models in admin.py: class TechnologyInline(admin.StackedInline): model = Project.technology.through @admin.register(Technology) class TechnologyAdmin(admin.ModelAdmin): pass @admin.register(Project) class ProjectAdmin(admin.ModelAdmin): inlines = [ TechnologyInline, ] exclude = [ 'technology', ] And this is the result: This is exactly what I need, but it's very ugly. Is it possible to customize the strings such as "Project-technology relationship: #1" and others? -
Issues on File Validation using python magic
I have made validators.py in Dimensions project directory for file validation (In Simple words, If It's a video model accept only mp4 ,If it's a image model accept jpg and png only). But I dont't get it It gives me Validation error 'Sorry, Cannot accept unacceptable file extension' when I add for Video, Image, File to check. What am I doing wrong? I couldn't figure out. import os import magic from django.core.exceptions import ValidationError def validate_is_video(file): valid_mime_types = ['application/.mov'] file_mime_type = magic.from_buffer(file.read(1024), mime=True) if file_mime_type not in valid_mime_types: raise ValidationError('Sorry,Cannot accept unsupported file type.') valid_file_extensions = ['.mov',] ext = os.path.splitext(file.name)[1] if ext.lower() not in valid_file_extensions: raise ValidationError('Sorry,Cannot accept unacceptable file extension.') def validate_is_image(file): valid_mime_types = ['application/.png','application/.jpg'] file_mime_type = magic.from_buffer(file.read(1024), mime=True) if file_mime_type not in valid_mime_types: raise ValidationError('Sorry,Cannot accept unsupported file type.') valid_file_extensions = ['.png','.jpg'] ext = os.path.splitext(file.name)[1] if ext.lower() not in valid_file_extensions: raise ValidationError('Sorry,Cannot accept unacceptable file extension.') def validate_is_audio(file): valid_mime_types = ['application/.mp3','application/.wav'] file_mime_type = magic.from_buffer(file.read(1024), mime=True) if file_mime_type not in valid_mime_types: raise ValidationError('Sorry,Cannot accept unsupported file type.') valid_file_extensions = ['.mp3','.wav'] ext = os.path.splitext(file.name)[1] if ext.lower() not in valid_file_extensions: raise ValidationError('Sorry,Cannot accept unacceptable file extension.') def validate_is_file(file): valid_mime_types = ['application/.zip','application/.rar'] file_mime_type = magic.from_buffer(file.read(1024), mime=True) if file_mime_type not in valid_mime_types: raise … -
Integrating a PHP tool within a Django (Python) application
I am running a Django website which aims at providing 360 degrees virtual tours of different locations on Earth. However, the tool that I am using for generating the 360 pages and administrating them, runs in PHP. I managed to make my Django site run on Apache using mod_wsgi but it still doesn't work. The .php pages appear, but they are static: I can't do anything with them except looking at them. Has anyone ever had to deal with this sort of issue? Thank you for your help! -
How to check Django's automatic form validation result before javascript submit
I'm working on an advanced search page of a Django (3.2) project. I'm using pure javascript and Django's formset_factory to create a dynamic form where the user can create a hierarchy of forms containing advanced search criteria (for and/or groups). It works great. However... Early on during development, before I wrote the javascript to pass the additional hierarchy information to views.py's form_valid method, Django (without me adding any specific code to do so) was performing nice form validation before submit and would present a nice tooltip that pointed to missing form fields, and the form (desirably) would not submit: When I implemented the javascript to save the hierarchy information, attached to a listener on the submit button, I noticed that the tooltip would appear for a fraction of a second and the invalid form would inappropriately submit. Here's the code that was introduced that inadvertently bypassed Django's automatic form validation: <script> document.addEventListener("DOMContentLoaded", function(){ appendInnerSearchQuery(document.querySelector('.hierarchical_search'), 0, rootGroup); var myform = document.getElementById("hierarchical_search_form"); document.getElementById("advanced_search_submit").addEventListener("click", function () { saveSearchQueryHierarchy(document.querySelector('.hierarchical_search')); myform.submit(); }); }); console.log("Ready with rootGroup: ", rootGroup); </script> In fact, subsequent efforts appear to submit even before the tooltip has a chance to show up, presumably due to the time it takes to validate, … -
How to define user models with multiple access level in django
How can a user be a member of multiple organizations and have different roles in each organization, depending on what level of access they need. -
Django pass to an url a list of parameters
In my dhango project i create a function callable via url: url(r'^pd/(?P<c_id>[\w\-]+)\/$', calc_q), So my function need to manage at least 4 input @csrf_exempt def calc_q(request, c_id): start_d = datetime.date(2021, 6, 28) end_d = datetime.date(2021, 6, 29) v_id = 17 q_time ="15min" ... How can i pass, for example a list or a dict from url to my function with my 4 variables inside? Is possible pass all variables directly in url? Whitch is the best method? So many thanks in advance -
python json convert Timestamp to string as key
In my django project i convert a pandas dataset into a dict (json) object and try to return as a value: ... # Iterate for index, row in df_15.iterrows(): d_ret[index.to_pydatetime().strftime("%m/%d/%Y-%H:%M:%S")] = {'first': row['first'], 'last': row['last']} return JsonResponse(d_ret) if i print to output my dict i get: {'06/28/2021-00:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-00:15:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-00:30:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-00:45:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-01:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-01:15:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-01:30:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-01:45:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-02:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-02:15:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-02:30:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-02:45:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-03:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-03:15:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-03:30:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-03:45:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-04:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-04:15:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-04:30:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-04:45:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-05:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-05:15:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-05:30:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-05:45:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-06:00:00': {'first': 0.0, 'last': 0.0}, '06/28/2021-06:15:00': {'first': 0.0, 'last': 0.0} that is correct, but if i call my link for see my json at http://127.0.0.1:8000/pd/21/ in my browser i get: SyntaxError: JSON.parse: unexpected character … -
Running Python on HTML(how to reference on drive)
I am new to HTML,and have abit of experience with python but wanted to create a simple UI to run some daily tasks for my team. The goal is to run a HTML website that is running python in the back-end from a drive. I do have a few questions as I am abit lost with this. We have a drive where we want to keep the html file and then run it by sharing the link, which works as intended, so when you click on the link it opens the drive and runs the html file. But if now i want to run python for example with Django, how do i reference the HTML file? because they arent in a directory. I dont know if this is possible or how to make them reference each other. I am using amazon.corp.drive.com I am sorry if this question might sound very dull, but I am extremely new to the web side of things. Either way thank you in advance! -
Many to many relation in django
I have 2 models model A and model B as below class ModelA(TimeStampedModel): field_a= models.TextField(default="") field_b= models.ManyToManyField("ModelB", related_name="modeA_modelB", blank=True) class ModelB(TimeStampedModel): field_c= models.TextField(default="") field_d= models.ManyToManyField("ModelA", related_name="modeB_modelA", blank=True) what I'm trying to achieve whenever a model A is assigned modelB instances it should reflect i model B as well for example: a particular terms and conditions have several policy that will be model A, Next in model B I have to have field _d having the list of terms and condition which have that policy Any help or guidance will be a great help