Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why django RowNumber() does not start ordering from 1
I'm trying to use RowNumber to get sequential ordering of queryset objects (1,2,3...) qs = self.filter_queryset(self.get_queryset()) qs = qs.annotate( row_number=Window( expression=RowNumber() ) ) but when I iterate over qs and print objects, ordering starts from 4 for q in qs: print(q.row_number) result is: 4,1,2,5,6,3,10... I have no idea why this happens and how can I fix it. any help? thank you -
How to make (if & else) for internal values in django orm?
I am making models for my store project and I wanted to know why the code I wrote is wrong? And how can I write correctly? I want only the time when a product is sold from me to be recorded in the database. class Product(models.Model): product_type = models.ForeignKey(ProductType, on_delete=models.PROTECT, related_name='products_types') upc = models.BigIntegerField(unique=True) title = models.CharField(max_length=32) description = models.TextField(blank=True) category = models.ForeignKey(Category, on_delete=models.PROTECT, related_name='products') brand = models.ForeignKey(Brand, on_delete=models.PROTECT, related_name='products') soled = models.BooleanField(default=False) if soled == True: soled_time = models.DateTimeField(auto_now_add=True) created_time = models.DateTimeField(auto_now_add=True) modified_time = models.DateTimeField(auto_now=True) def __str__(self): return self.title I hope that my problem will solve the question of many friends <3 -
'ManyRelatedManager' object has no attribute 'save'
I've got the same problem as this post. I tried the solution from cshelly, but my adoption fails on the last line given (the save). The difference is my code uses model based views and forms and has a polymorphic model. It's throwing an exception on the last line, where a save of the append to the manytomany field. I use whatever django gives as the through table. I can see the value being added. If I comment out the offending line, the match object has everything from the form (including the objects selected on the form from the other (in this case, the student) manytomany field. All help is much appreciated. Here's the view: if form.is_valid(): instance = form.save(commit=False) current_user = self.request.user instance.lvm_affiliate = current_user.affiliate instance.save() if pt == 'tutor': person = Tutor.objects.get(id=pk) print("before ", vars(instance)) print("student ", instance.student.all()) print("tutor ", instance.tutor.all()) instance.tutor.add(person.id) print("after ", vars(instance)) print("student ", instance.student.all()) print("tutor ", instance.tutor.all()) instance.save() instance.tutor.save() here's the output: before {'_state': <django.db.models.base.ModelState object at 0x000001E84D5CEAA0>, 'id': 46, 'lvm_affiliate_id': 34, 'match_status_id': 3, 'date_started': datetime.date(2022, 7, 23), 'date_dissolved': None, 'comments': ''} student <PolymorphicQuerySet []> tutor <PolymorphicQuerySet []> after {'_state': <django.db.models.base.ModelState object at 0x000001E84D5CEAA0>, 'id': 46, 'lvm_affiliate_id': 34, 'match_status_id': 3, 'date_started': datetime.date(2022, 7, 23), … -
how to update feed in django using feedparser?
i am lookig for a way to update rss feeds using feedparser. i tried: in models.py class Feed(models.Model): title = models.CharField(max_length=200, unique=True) url = models.URLField(unique=True) is_active = models.BooleanField(default=True) def __str__(self): return self.title def load_articles(self): new_list = feedparser.parse(self.url) for entry in new_list.entries: try: Article.objects.create(entry) except IntegrityError: pass class Article(models.Model): feed = models.ForeignKey('Feed', on_delete=models.CASCADE) title = models.CharField(max_length=200) url = models.URLField() description = models.TextField() publication_date = models.DateTimeField() and i created managment command from django.core.management.base import BaseCommand, CommandError from news.models import Feed, Article art = Article() class Command(BaseCommand): help = 'updates feeds' def handle(self, *args, **kwargs): Feed.load_articles(art) self.stdout.write("feeds updated") command doesn't return any error and prints feeds updated but i don't see any effect. -
Why can't I save my form data into a model db?
When I try to save the info inputted into the form, I get the ValueError: Cannot assign "<class 'auctions.models.User'>": "Listing.user" must be a "User" instance. I think that this may be because the model field Listing.user is a foreign key between the Listing model and the User model. Even when I change Listing.user = User to Listing.user = User() (includes brackets), it returns the ValueError: save() prohibited to prevent data loss due to unsaved related object 'user'. So how do I add who the current user is to the model field Listing.user? models.py: class User(AbstractUser): pass class Listing(models.Model): ... user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) views.py: def save_new(request): if request.method == 'POST': form = NewListing(request.POST) if form.is_valid(): obj = Listing() ... obj.user = User # this returned the first ValueError # obj.user = User() - this returned the second ValueError obj.save() return HttpResponseRedirect('/') -
Django Multiple Forms from related Models
I am pretty new to Django and have come stuck on how to approach an issue I have with collecting Data via multiple forms. I have the following models, the first being where I store data of an asset: class Model_AssetData(models.Model): UU_Project_Number = models.ForeignKey(Model_Project, null=True, on_delete=models.CASCADE) Site_Code = models.CharField(blank=True, null=True,max_length=5) Facility = models.ForeignKey(Model_Facility, null=True, on_delete=models.CASCADE) Facility_Number = models.IntegerField(blank= False, null= True,) Process = models.ForeignKey(Model_Process, null=True, on_delete=models.CASCADE) Process_Number = models.IntegerField(blank= False, null= True) Arrangement = models.ForeignKey(Model_Arrangement, null=True, on_delete=models.CASCADE ) Arrangement_Number = models.IntegerField(blank= False, null= True) Asset_Group = models.ForeignKey(Model_AssetLocation, null=True, on_delete=models.CASCADE ) Asset_Group_Number = models.IntegerField(blank= False, null= True) Asset_Number = models.CharField(blank=False, null=False,max_length=50) Equipment_Group_Identifiier = models.ForeignKey(Model_EGI, null = True, on_delete=models.CASCADE) Engineering_Design_Identifier = models.ForeignKey(Model_EDI, null = True, on_delete=models.CASCADE) ITR = models.ForeignKey(Model_ITR, null = True, on_delete=models.SET_NULL) def __str__(self): return self.Asset_Number def save(self, *args, **kwargs): # Only generate key on creating if it was not provided if not self.id: # Use f-string to concatenate the asset code into the Database self.Asset_Number = f'{self.UU_Project_Number}-{self.Site_Code}-{self.Facility} {self.Facility_Number}-{self.Process}{self.Process_Number}-{self.Arrangement} {self.Arrangement_Number}-{self.Asset_Group}{self.Asset_Group_Number}' super().save(*args, **kwargs) Then I am trying to collect basically some answers to questions to ensure certain things have been checked when the asset was installed: This model is a reference to what questions need to be asked for a particular asset: … -
Django Sessions, SESSION_EXPIRE_AT_BROWSER_CLOSE does not change session expire date
I have set SESSION_EXPIRE_AT_BROWSER_CLOSE = True in my settings.py and it works fine. The problem is that when the user closes the browser, he is logged out just fine but in the session instance related to that user the expire_date field does not change. I have a piece of code for listing all active sessions. from django.contrib.sessions.models import Session from django.utils import timezone sessions = Session.objects.filter(expire_date__gte=timezone.now()) uid_list = [] for session in sessions: data = session.get_decoded() uid_list.append(data.get('_auth_user_id', None)) print("#", uid_list[-1]) The output of the code contains the user id of the logged out user. The Session Base Class is: class AbstractBaseSession(models.Model): session_key = models.CharField(_('session key'), max_length=40, primary_key=True) session_data = models.TextField(_('session data')) expire_date = models.DateTimeField(_('expire date'), db_index=True) objects = BaseSessionManager() class Meta: abstract = True verbose_name = _('session') verbose_name_plural = _('sessions') def __str__(self): return self.session_key @classmethod def get_session_store_class(cls): raise NotImplementedError def get_decoded(self): session_store_class = self.get_session_store_class() return session_store_class().decode(self.session_data) The question is that how do I know if a user has closed the browser and logged out. -
While migrating default database model assigned for another database is being migrated
I was working on two database for my Django project. I followed online Django documentation and made work two sqlite database at the same time for different purposes but I ended up having one issue which is while migrating default database the model Game that I created for 'games.db' is also being migrated to 'default.sqlite'. I have added my code below. Kindly help me fix this issue as I have tried multiple things but nothing worked out. Project/settings.py ------------------- DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'games': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'games.db'), }, } DATABASE_ROUTERS = ( 'Games.dbrouters.GamesDBRouter', ) Games/models.py --------------- from django.db import models from django.urls import reverse STATUS = ( (1, "Publish"), (0, "Draft") ) class Game(models.Model): title = models.CharField(max_length=2000, unique=True) slug = models.SlugField(max_length=2000, unique=True) image = models.CharField(max_length=2000, unique=True) overlay = models.CharField(max_length=2000, blank=True) updated_on = models.DateTimeField(auto_now=True) story_p = models.TextField(blank=True) story_span = models.TextField(blank=True) about_p = models.TextField(blank=True) about_span = models.TextField(blank=True) screenshot_1 = models.CharField(max_length=2000, blank=True) screenshot_2 = models.CharField(max_length=2000, blank=True) screenshot_3 = models.CharField(max_length=2000, blank=True) screenshot_4 = models.CharField(max_length=2000, blank=True) gameplay = models.CharField(max_length=2000, blank=True) download_android = models.CharField(max_length=2000, blank=True) download_ios = models.CharField(max_length=2000, blank=True) download_windows = models.CharField(max_length=2000, blank=True) download_linux = models.CharField(max_length=2000, blank=True) download_mac = models.CharField(max_length=2000, blank=True) torrent_android = models.CharField(max_length=2000, blank=True) torrent_ios … -
How to serialise Generic Relation in DrangoRestFramework
I have these serialisers to work with Generic Foreign Key in DRF. class GenericContactsSerializer(serializers.ModelSerializer): id = serializers.IntegerField(read_only=False) class Meta: model = GenericContacts fields = ( 'id', 'email', 'phone', 'ext', 'contact_name', 'fax', 'producer_email', 'producer_phone', 'producer_phone_ext', 'producer_contact_name', ) class CompanyCreateOrUpdateSerializer(serializers.ModelSerializer): company_contacts = GenericContactsSerializer(many=True) class Meta: model = Company fields = ( "id", "company_contacts", "company_name", ) def _manage_company_contacts(self, instance, contacts): contact_instances = [] c_type = ContentType.objects.get(model='company') for contact in contacts: contact_instances.append(GenericContacts(**contact, object_id=instance.id, content_type=c_type)) GenericContacts.objects.bulk_create(contact_instances) instance.refresh_from_db() def create(self, validated_data): company_contacts = validated_data.pop('company_contacts', []) instance = super().create(validated_data) self._manage_company_contacts(instance, company_contacts) return instance def update(self, instance, validated_data): company_contacts = validated_data.pop('company_contacts', []) instance = super().update(instance, validated_data) instance.company_contacts.all().delete() self._manage_company_contacts(instance, company_contacts) return instance My JSON to frontend is looks like: { "id": 1, "company_contacts": [ { "id": 14, "email": "lol@mail.com", "phone": "999-000-1231", "ext": "321", "contact_name": "Tom", "fax": null, "producer_email": "", "producer_phone": "", "producer_phone_ext": null, "producer_contact_name": null }, { "id": 13, "email": "iliass@mail.com", "phone": "111-122-2121", "ext": "123", "contact_name": "John", "fax": "", "producer_email": "ins@mail.com", "producer_phone": "241-245-1245", "producer_phone_ext": "333", "producer_contact_name": "Max" } ], "company_name": "Company" } And incoming request JSON is looks like: { "company_contacts": [ { "id": 13, "email": "iliass@mail.com", "phone": "111-122-2121", "ext": "123", "contact_name": "John", "fax": "", "producer_email": "ins@mail.com", "producer_phone": "241-245-1245", "producer_phone_ext": "333", "producer_contact_name": "Max" }, { "email": "somemail@mail.com", "phone": "333-333-3333", … -
¿Cómo comparar cada uno de los elementos de una lista con ellos mismos?
Tengo una lista en Python lista = [1,2,3,4,5,6,7,8,9] Quiero recorrer la anterior lista , pero en cada iteración comparar esa iteración con todos los demás elementos de la misma lista (incluyendo al valor de la iteración actual) para realizar una consulta a la base de datos y verificar si existe un valor , de lo contrario regresaría cero (0) suponiendo que estamos iterando en la lista: para la primera iteración que es el 1 ahí se debe iterar de nuevo todos los elementos de la misma lista para realizar unas comparaciones y la consulta mencionada anteriormente , y así seguido con la iteración 2, 3, 4 etc. Lo ideal es que esas comparaciones no llenen la memoria RAM o se ponga lento el programa, ya que estoy trabajando con Django 4. por eso no he intentado realizar bucles for Agradezco cualquier aporte que me ayude a solucionar este problema. Muchas gracias -
social-auth-app-django problem with DjangoStrategy
After installing social-auth-core social-auth-app-django on Django 4.0.6 and including to the INSTALLED_APPS and made everything on documents I got this error 'DjangoStrategy' object has no attribute 'get_backend' This error happens when I click on login link on this URL http://localhost/login/google-oauth2/ In settings.py I have this backends AUTHENTICATION_BACKENDS = ( 'social_core.backends.google.GoogleOAuth2', 'django.contrib.auth.backends.ModelBackend', ) -
change Django default URL
first sorry for my bad English When I run my server, I want to Django redirect me to http://127.0.0.1:8000/home instead of http://127.0.0.1:8000. what should I do? -
SweetAlert in Django not appeared No JavaScript reporting
I started learning Django by following a YouTube tutorial. Everything seems to be fine, the only thing that is not working is a short script at the end of the template, which is unfortunately not working: <!-- MESSAGESS FROM BACKEND --> {% for messagge in messagges %} {% if messagge.tags == 'success' %} <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script> var m = "{{ messagge }}"; swal("Perfect!", m, "success"); </script> {% endif %} {% endfor %} </div> <!-- END OF CONTAINER DIV --> {% endblock content %} -
how to save django data in to tow model
hi please help me i have to model i want after create and save store the result save to main store like this store.name == mainstore.name store.the_rest_of_quantity==mainstore.quantity i trying to use signals but i fail class Store(models.Model): CHOICES = ( ('NUM','number'), ('M','meter'), ) name = models.CharField(max_length=60) quantity = models.PositiveSmallIntegerField (validators=[MinValueValidator(0)],default=0,blank=True,null=True) date_of_add = models.DateTimeField(auto_now_add=True) add_new_item = models.PositiveSmallIntegerField (validators=[MinValueValidator(0)],default=0,blank=True,null=True) date_of_remove = models.DateTimeField(auto_now =True) remove_old_item = models.PositiveSmallIntegerField (validators=[MinValueValidator(0)],default=0,blank=True,null=True) the_rest_of_quantity = models.PositiveSmallIntegerField (validators=[MinValueValidator(0)],default=0,blank=True,null=True) accept_stor = models.BooleanField(default = False) classyfiyed = models.CharField(max_length=3,choices=CHOICES,blank=True,null=True) def __str__(self): return 'Device Name :( {0} ) Have Quantity({1}) '.format(self.name,self.quantity) def save(self, *args, **kwargs): try: totla_sum = sum([self.quantity , self.add_new_item]) self.the_rest_of_quantity = int(totla_sum - self.remove_old_item) except Expression as identifier: 'you add remove bigger than quantity' return super().save(*args, **kwargs) class MainStore(models.Model): name = models.CharField(max_length=120) quantity = models.PositiveIntegerField (null=True,default=0) store = models.OneToOneField(Army,on_delete=models.CASCADE,related_name='Store',null=True) -
Why do i keep getting UTC time zone even when Django settings is configured differently
I'm not sure why the datetime response is always one hour behind (UTC) Django settings configuration LANGUAGE_CODE = "en-us" TIME_ZONE = "Africa/Lagos" USE_I18N = True USE_L10N = True USE_TZ = True DATE_FORMAT = "F j, Y" SITE_ID = 1 from django.utils import timezone timezone.now() response: datetime.datetime(2022, 7, 23, 13, 58, 6, 739601, tzinfo=<UTC>) You can see that the time zone info is UTC -
Exception Value: 'tuple' object has no attribute 'backend'
Also I got this error 'tuple' object has no attribute 'backend' when I do @login_required(login_url = "/oauth2/login") But when I just go to /oauth2/login all works fine. -
How can i use await async function in Django view function?
in my django project, I want the function that generates the returned result not to process the other request before it ends. How can I provide this? views.py def orderresult(request): if request.method == 'POST': username = request.POST["username"] order = request.POST["order"] doubleResult = ResultsFormView(order,username).resultview() # ====> Async await function result = doubleResult[0] boolresult = doubleResult[1] context = { "result" : result, "boolresult" : boolresult } return render(request, 'npages/result.html', context=context) I tried something like this but it doesn't work. async def orderresult(request): if request.method == 'POST': username = request.POST["username"] order = request.POST["order"] doubleResult = await ResultsFormView(order,username).resultview() # ====> Async await function result = doubleResult[0] boolresult = doubleResult[1] context = { "result" : result, "boolresult" : boolresult } return render(request, 'npages/result.html', context=context) -
Django-Oscar Unable to Customise ProductCreateUpdateView and ProductForm - Traceback: ProductForm.__init__() missing 1 required positional argument
I am working on a web shop using Django-Oscar. I want to customise the page which creates a new product, and show different sets of attributes on the page depending on the product's metal type (which has been selected before this page is created - see below image). But I am getting the Traceback ProductForm.__init__() missing 1 required positional argument: 'metal'. Desired Output: Traceback Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.10/contextlib.py", line 79, in inner return func(*args, **kwds) File "/usr/local/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view return view_func(request, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/oscar/apps/dashboard/catalogue/views.py", line 218, in dispatch resp = super().dispatch( File "/usr/local/lib/python3.10/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/django/views/generic/edit.py", line 190, in get return super().get(request, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/django/views/generic/edit.py", line 133, in get return self.render_to_response(self.get_context_data()) File "/usr/local/lib/python3.10/site-packages/oscar/apps/dashboard/catalogue/views.py", line 274, in get_context_data ctx = super().get_context_data(**kwargs) File "/usr/local/lib/python3.10/site-packages/django/views/generic/edit.py", line 66, in get_context_data kwargs['form'] = self.get_form() File "/usr/local/lib/python3.10/site-packages/django/views/generic/edit.py", line 33, in get_form return form_class(**self.get_form_kwargs()) Exception Type: TypeError at /dashboard/catalogue/products/create/earrings/gold/diamond Exception Value: ProductForm.__init__() missing 1 required positional argument: 'metal' Views from django.views.generic import CreateView, … -
How to render forms based on selected settings in django
I want to render forms based on selected settings. I have a journal type below: class Journal(models.Model): journalsId = models.AutoField(primary_key=True) name = models.CharField(max_length=500) acname = models.CharField(max_length=100) issnprint = models.CharField(max_length=500) issnonline = models.CharField(max_length=500) logo = models.ImageField(null=True, blank=True, upload_to="images/journals/") msg = models.CharField(max_length=500) status = models.BooleanField(default=True) c1_form_checkbox = models.BooleanField(default=True) c2_form_checkbox = models.BooleanField(default=True) c3_form_checkbox = models.BooleanField(default=True) . . c19_form_checkbox = models.BooleanField(default=True) Each C*_form is a html file. Lets say I have below Journal Types: A -> 5 random Checboxes are selected B -> 10 random Checkboxes are selected How can I render these C*_form.html in order? Thanks -
How do I import from current app in Django without using the app name?
My app is full of statements like this: from my_app.model import Customer While it works, I'll like to have a way to reference the current app without hard coding the app name into the import. Something like: from keyword_for_current_app.model import Customer Is there a clean way of achieving this with Django? -
in django ecommerce product price change according to size and color
What should I do for changing price according to product size and color. in models.py , views.py and also product_detail.py code class color class size class variation what should I do next in view and detail page -
Best way to store and display warning messages using Django?
I'm looking for the best and easiest way to store and to display warning messages shown to the user at the creation or at the update of instances of some models. I want users to tick a box (or to click twice) to be 100% sure that they are aware of what they are doing. I want the warnings to be saved in the database if and only if they have been read. My current solution on the client side Currently, on the front-end side, this is how it looks like: But I'm not totally satisfied with this homemade interface because it still lacks some JS functions to update/hide the warning(s) when the input changes, without waiting for the user to resubmit the form. I guess I could write them or draft a dedicated validation page but I wonder if there isn't a library or a framework that could partially do the job. My current solution on the server side For now, on the back-end side, I use a parent abstract class with a custom JSONField keeping track of that information: class AbstractBase(models.Model): warnings: dict = models.JSONField( default=dict, validators=[JSONSchemaValidator(limit_value=WARNINGS_JSON_SCHEMA)], ... ) ... Along with these few lines of code, I … -
Constantly problems with Python: Python was not found, can't open file…,
For unknown reasons, I started to have constantly failures with python. I started yesterday, not sure if I have a relation, but I installed Docked with WSL 2 Linux kernel, and PostgreSQL recently too. The first problem, all my paths were deleted. I wrote again: C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts After, it starter to appear in the console: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. After trying to fix it, uninstall Python completely and reinstall it. Show me something about getting from Microsoft Store. I did, I reinstalled Django and I added too new path which was recommended: C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts Started to work again (yesterday), but today it's not working again with this message: C:\Users\user\AppData\Local\Microsoft\WindowsApps\python.exe: can't open file 'D:\code\proyectWeb\manage.py': [Errno 2] No such file or directory It's like each new day, the python installation gets corrupted or something, and start to make me crazy. If anyone had similar problems or can have an idea about what is going on, I would greatly appreciate your help, thanks. I have Windows 10, and the last versions of python, django and pip, because I updated after the first problems. After many … -
What exactly does X_FRAME_OPTIONS = 'SAMEORIGIN'?
I created a site in Django that I deployed on heroku. I am looking to display this site in an iframe in an html page present on my localhost. Which is not done, because the default value of X_FRAME_OPTIONS is DENY which don't autorize this. When I search the internet, I am asked to replace the value DENY with the value SAMEORIGIN. I learned about the official Django documentation from this passage: Modern browsers respect the X-Frame-Options HTTP header which indicates whether a resource is allowed to load inside a frame or iframe. If the response contains the header with a value of SAMEORIGINthen the browser will only load the resource in a frame if the request comes from the same site. What I don't understand is that I'm looking to load a site that's on the web from a web page that has an iframe in it and I'm wondering if they mean by this passage in the doc that the site can be loaded by a web page present on the computer that deployed it or can one of the web pages present on the deployed site load it in an iframe, something that I do not understand … -
How do I resolve typeError: unsupported operand type(s) for /: 'str' and 'str' in django app by heroku?
When I deployed django app by heroku, I got error. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file))) Setting.py has this BASE_DIR. How do I resolve this error? Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 386, in execute settings.INSTALLED_APPS File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 87, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 74, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 183, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 848, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/app/MovieReview/settings.py", line 77, in <module> 'DIRS': [BASE_DIR / 'templates'], TypeError: unsupported operand type(s) for /: 'str' and 'str'