Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How i can display a list instead of choicelist in django
Each time i want to add an invoice, i want to have a unique invoice_id which is an increment number (+1), but the problem is that i have a multiple users app, so i get the error that this invoice_id already exist. how can i customize the ids so each user can have its ids following the latest of same user. class Company(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) name = models.CharField(max_length=64) class Invoice(models.Model): company = models.ForeignKey('Company', on_delete=models.CASCADE) invoice_id = models.CharField(max_length=20, unique=True) name = models.CharField(max_length=256) -
how can i edit multiple objects/row atonce in django html template
i facing an problem on my django project . i try to edit and update an objects . but it's showing an error which is name is MultipleObjectsReturned . hear is my issue screenshots . when i was clicked this update button ( user can update which he went ) . than showing next 2nd image 1st img showing this error 2nd image Views.py def purchase_order_item_update(request,order_id): purchase_item_list = Purchase_order_item.objects.filter(order_id=order_id) # porder = Purchase_order_item.objects.get(order_id=order_id) # this is the form for getting data from html if request.method == 'POST': for bt in Purchase_order_item.objects.filter(order_id=order_id): pu_id = bt.puid # product Id quantity = request.POST.get('asqty') unit_price = request.POST.get('uprice') # itemid = pk type total = int(quantity) * float(unit_price) cv = Purchase_order_item.objects.get(puid=pu_id) cv.quantity = quantity cv.unit_price = unit_price cv.total_price = total cv.save() return redirect('purchase_order_item',order_id= order_id) return render(request,'back/purchase/assign_purchas_item.html', {'purchase_item_list':purchase_item_list, }) Actually i went to edit and update this list of entries and update also if user making any typing mistake then he can update . thank you -
Django Celery Beat and Tasks Results
Is it possible for django-celery-beat not to save tasks that are performed in a short time interval? By default, all results are saved to the Task Results table. I cannot find this information on celeryproject webpage. Alternatively, what should be the settings for postgres auto vacuum so that indexes don't take up that much disk space? I want a simple solution. Overwriting django celery logic is not an option. -
Failure to install psycopg2 in Pycharm
I'm trying to install psycopg2 to use a postgresql db in the backend of my django project, but every time I run the pip install psycopg2 command I get an error saying: Error: pg_config executable not found. pg_config is required to build psycopg2 from source. Please add the directory containing pg_config to the $PATH or specify the full executable path with the option: python setup.py build_ext --pg-config /path/to/pg_config build ... or with the pg_config option in 'setup.cfg'. I have added the \bin\ folder containing the file to my path, I've ran the pip install psycopg2-binary command as well, and I've uninstalled and reinstalled posgresql on my computer, I've also ran the python setup.py build_ext command mentioned in the error message, and this error still pops up. I'm operating on a windows 10 os and using posgresql 13.1. Any suggestions? -
UserCreationForm override password hint_id_password1
Hello I want to override the password hints that Django generates for you in the UserCreationForm(). These: Your password cannot be too similar to your other personal information. Your password must be 8 characters long. Your password cannot be a frequently used password. Your password cannot be entirely digital. I tried by overriding help_text in Meta but without any success. -
Invalid parameter error while trying to create stripe payment
i am creating an ecommerce website where i have included stripe payment method but when i try to create the payment there occur invalid parameters error. i have no idea what is going wrong, i have followed as same as the video and tried many thing to solved this but still that error was occuring here is my View.py from django.conf import settings import stripe stripe.api_key = settings.STRIPE_SECRET_KEY class PaymentView(View): def get(self, *args, **kwargs): order = Order.objects.get(user=self.request.user, ordered=False) if order.billing_address: context = {'order': order, 'DISPLAY_COUPON_FORM': False, } return render(self.request, "payment.html", context) else: messages.warning(self.request, "you have not added a billing address") return redirect("First:checkout") def post(self, *args, **kwargs): order = Order.objects.get(user=self.request.user, ordered=False) token = self.request.POST.get('stripeToken') amount = int(order.get_total() * 100) try: charge = stripe.Charge.create( amount=amount, currency="usd", source=token, ) # create the payment payment = Payment() payment.stripe_charge_id = charge['id'] payment.user = self.request.user payment.amount = order.get_total() payment.save() # assign the payment to the order order_items = order.items.all() order_items.update(ordered = True) for item in order_items: item.save() order.ordered = True order.payment = payment order.ref_code = create_ref_code() order.save() messages.success(self.request, " your order was sucessful") return redirect("/") except stripe.error.CardError as e: body = e.json_body err = body.get('error', {}) messages.error(self.request, f"{err.get('messages')}") return redirect("/") except stripe.error.RateLimitError as e: # Too … -
Saving data on OneDrive or Google Drive (Heroku)
Hello I am new to using django and heroku and through out me designing my first project I Found out that I need a AWS 3 account/S3 storage to store images/files but I was wondering if I could use either a OneDrive or a Google Drive to save the files/images that the user uploads and if so, is it Like when using a AWS 3 storage. -
try to sand Email by Django but 504 Gateway Time-out and haven't received an email
I try to write code (on cs50) to send a verification email via Django but occur error and not received a verification email. On page 504 Gateway Time-out and on terminal OSError: [Errno 99] Cannot assign requested address my setting.py EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'example@gmail.com' EMAIL_HOST_PASSWORD = 'password of gmail account' MAILER_EMAIL_BACKEND = EMAIL_BACKEND DEFAULT_FROM_EMAIL = EMAIL_HOST_USER EMAIL_PORT = 587 EMAIL_USE_TLS = True my view.py after saving the account current_site = get_current_site(request) mail_subject = 'subject' message = render_to_string('register/acc_active_email.html', { 'user': account, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(account.pk)), 'token': default_token_generator.make_token(account), }) to_email = form.cleaned_data.get('email') email = EmailMessage(mail_subject, message to=[to_email]) email.send() -
vscode is showing problem in code though it runs properly
i was doing template inheritance while doing a project in django Though my website is working but in the code vscode is showing problem <title>{% block title%} {% endblock %}</title> <style> {% block css %} {% endblock %} </style> after writing another page and inheriting.....my css also works but vscode shows problem in {% block css %} {% endblock %} line -
DJango - Update text depending on dropdown selection?
My Google search skills evidently aren't up to scratch, so I'm wondering if Django has the capability to dynamically update text displayed on the HTML page depending on what option is selected from a dropdown? Or would I need to look into utilising another tool to help with this? Apologies for the noob question as I'm still learning Python/Django. -
Django smart selects is not working properly
I try to chain four categories with django smart select but it does not work properly. Django does not take or input values from in the last one. clothing_size. It is working properly till clothing sizes. That selectbox is always empty. My model: What could be the problem here? That does not seem like js problem, because other fields are working properly. from django.db import models from smart_selects.db_fields import ChainedForeignKey # Create your models here. class MainCategory(models.Model): name = models.CharField(max_length=20, null=True) def __str__(self): return self.name class ClothingType(models.Model): main_category = models.ForeignKey(MainCategory, on_delete=models.CASCADE, null=True) clothing_type = models.CharField(max_length=64, null=True) def __str__(self): template = '{0.main_category} {0.clothing_type}' return template.format(self) class ClothingSubType(models.Model): main_category = models.ForeignKey(MainCategory, on_delete=models.CASCADE, null=True) # clothing_type = models.ForeignKey(ClothingType, on_delete=models.CASCADE, null=True) clothing_type = ChainedForeignKey(ClothingType, chained_field="main_category", chained_model_field="main_category", show_all=False, auto_choose=True, sort=True, null=True) clothing_sub_type = models.CharField(max_length=254, null=True) def __str__(self): template = '{0.main_category} {0.clothing_type} {0.clothing_sub_type}' return template.format(self) class ClothingSize(models.Model): main_category = models.ForeignKey(MainCategory, on_delete=models.CASCADE, null=True) clothing_type = ChainedForeignKey(ClothingType, chained_field="main_category", chained_model_field="main_category", show_all=False, auto_choose=True, sort=True, null=True) clothing_sub_type = ChainedForeignKey(ClothingSubType, chained_field="clothing_type", chained_model_field="clothing_type", show_all=False, auto_choose=True, sort=True, null=True) # clothing_sub_type = models.ForeignKey(ClothingSubType, on_delete=models.CASCADE, null=True) clothing_size = models.CharField(max_length=30, null=True) def __str__(self): template = '{0.main_category} {0.clothing_type} {0.clothing_sub_type} {0.clothing_size}' return template.format(self) class Product(models.Model): name = models.CharField(max_length=30, null=True) sku = models.CharField(max_length=20, null=True) main_category = models.ForeignKey(MainCategory, on_delete=models.CASCADE, null=True) clothing_type … -
Django's runserver on Oracle Cloud?
I am trying to use a free instance of Oracle Cloud for my Django project. But I have no idea how I can check the Django's "runserver" page like this python ./manage.py runserver since the public IP address given to my instance didn't load the Django's page. I tried to look into "network" session of Oracle Cloud but I wasn't able to find any meaningful stuff related to this. When I googled this, it seemed that it has to do with firewall setting in terms of Google Cloud so maybe Oracle has the same but in vain. -
django push notifications throws gcm error
I am using django push notifications but I am sometimes getting the following error raised unexpected: GCMError({'multicast_id': 1826728239203974173, 'success': 4, 'failure': 1, 'canonical_ids': 0, 'results': [{'message_id': '0:1605278994023650%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994028849%2fd9afcdf9fd7ecd'}, {'error': 'InternalServerError'}, {'message_id': '0:1605278994038573%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994030881%cc9b4facf9fd7ecd'}]},) Traceback (most recent call last): File "/home/project/server-side/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task R = retval = fun(*args, **kwargs) File "/home/project/server-side/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 629, in __protected_call__ return self.run(*args, **kwargs) File "/home/project/server-side/app/tasks.py", line 299, in alarm_users is_business_app=True, File "/home/project/server-side/tools/utils.py", line 246, in send_push web_devices.send_message(None, extra=kwargs, use_fcm_notifications=True) File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/models.py", line 73, in send_message r = gcm_send_message(reg_ids, data, cloud_type, application_id=app_id, **kwargs) File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/gcm.py", line 209, in send_message chunk, data, cloud_type=cloud_type, application_id=application_id, **kwargs File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/gcm.py", line 166, in _cm_send_request return _cm_handle_response(registration_ids, response, cloud_type, application_id) File "/home/project/server-side/.venv/lib/python3.6/site-packages/push_notifications/gcm.py", line 111, in _cm_handle_response raise GCMError(response) push_notifications.gcm.GCMError: {'multicast_id': 1826728239203974173, 'success': 4, 'failure': 1, 'canonical_ids': 0, 'results': [{'message_id': '0:1605278994023650%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994028849%2fd9afcdf9fd7ecd'}, {'error': 'InternalServerError'}, {'message_id': '0:1605278994038573%0f493ae6f9fd7ecd'}, {'message_id': '0:1605278994030881%cc9b4facf9fd7ecd'}]} The most interesting thing is that it sometimes works but sometimes not I have not able to find the bug yet. If anyone has encountered this before or anyone knows how to fix this. please can you help? Thanks in advance! -
How to delete the Token from backend in Django
I'm using django rest-auth along with the django rest api. I can logout the user by calling rest-auth/logout in the browsable api and it will delete the token from the Database. In the browsable api, I don't have to send the Token along with the logout url. I called the same url rest-auth/logout from a React js front end and it gives the response as 'successfully logged out' but Token remains in the database. How can I remove the Token by calling the url from the front end. -
plz help mw sir I am getting error when i run migrate commad
mayur@mayur-Latitude-E5440:~/Desktop/practice/myproject$ python manage.py migrate Traceback (most recent call last): File "manage.py", line 21, in main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/usr/lib/python3/dist-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/usr/lib/python3/dist-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 361, in execute self.check() File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 390, in check include_deployment_checks=include_deployment_checks, File "/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py", line 64, in _run_checks issues = run_checks(tags=[Tags.database]) File "/usr/lib/python3/dist-packages/django/core/checks/registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "/usr/lib/python3/dist-packages/django/core/checks/database.py", line 10, in check_database_backends issues.extend(conn.validation.check(**kwargs)) File "/usr/lib/python3/dist-packages/django/db/backends/mysql/validation.py", line 9, in check issues.extend(self._check_sql_mode(**kwargs)) File "/usr/lib/python3/dist-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode with self.connection.cursor() as cursor: File "/usr/lib/python3/dist-packages/django/db/backends/base/base.py", line 256, in cursor return self._cursor() File "/usr/lib/python3/dist-packages/django/db/backends/base/base.py", line 233, in _cursor self.ensure_connection() File "/usr/lib/python3/dist-packages/django/db/backends/base/base.py", line 217, in ensure_connection self.connect() File "/usr/lib/python3/dist-packages/django/db/backends/base/base.py", line 195, in connect self.connection = self.get_new_connection(conn_params) File "/usr/lib/python3/dist-packages/django/db/backends/mysql/base.py", line 227, in get_new_connection return Database.connect(**conn_params) File "/usr/lib/python3/dist-packages/pymysql/init.py", line 94, in Connect return Connection(*args, **kwargs) File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 325, in init self.connect() File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 599, in connect self._request_authentication() File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 871, in _request_authentication auth_packet = self._process_auth(plugin_name, auth_packet) File "/usr/lib/python3/dist-packages/pymysql/connections.py", line 902, in _process_auth return _auth.sha256_password_auth(self, auth_packet) File "/usr/lib/python3/dist-packages/pymysql/_auth.py", line 179, in sha256_password_auth data = sha2_rsa_encrypt(conn.password, conn.salt, conn.server_public_key) File "/usr/lib/python3/dist-packages/pymysql/_auth.py", line 144, in sha2_rsa_encrypt rsa_key = … -
Primary key with multiple fields in MYSQL DB wrongly recognized by Django, when connecting MYSQL table to Django
Below is the MYSQL table of Votes_list. As you can see here the primary key is {g_aadhaar_number, a_grievance_id} fields. Now while importing this table into Django as Model, below is the autogenrated code. g_aadhaar_number = models.ForeignKey(People, models.DO_NOTHING, db_column='G_Aadhaar_number') # Field name made lowercase. a_grievance = models.OneToOneField(Grievance, models.DO_NOTHING, db_column='A_Grievance_ID', primary_key=True) # Field name made lowercase. type = models.CharField(db_column='Type', max_length=10) # Field name made lowercase. class Meta: managed = False db_table = 'votes_list' unique_together = (('a_grievance', 'g_aadhaar_number'),) My doubt is even after Django correctly recoginising that the two fields together act as primary key in the line unique_together = (('a_grievance', 'g_aadhaar_number'),) , why is a_grievance expicitly mentioned as a primary key. This is causing a lot of errors. Can I know a solution? Thank you in advance :) -
set default view for date/time input field, overriding user locale?
I am rendering a datepicker within a Django Form. The answer may apply more to JS and HTML, but I'm being specific. date_field= forms.DateField( input_formats=['%Y-%m-%d'], widget=forms.DateInput( format='%Y-%m-%d', attrs={'type': 'date'} ) ) This renders my form and all, but unfortunately, the datepicker display field itself conforms to my US locale: Is it possible to preset the default display to something like 2020-11-13? -
how to override settings per test file in django?
I have two tests that when run at the same time fails: pytest -s -v blog/tests/ but when run individually it passes: pytest -s -v blog/tests/test_A.py pytest -s -v blog/tests/test_B.py I think the cause of this is both uses this pytest.fixture to override the settings: test_A.py: @pytest.fixture(autouse=True) def override_url(settings): settings.A_URL = f'https://{ip_host}:{port}' test_B.py @pytest.fixture(autouse=True) def override_url(settings): settings.B_URL = f'https://{ip_host}:{port}' Is there a way to fix this fixture to avoid the tests failing when ran at the same time? -
how can I get and edit image in Django views.py
I have a model of image with them name in Django. my model: class images(models.Model): name = models.CharField(max_length=150) image = models.ImageField() in my template I show the users a list of image name. I want when user click on the name of image, in the image detail template show hem the edited image. my model manager is: def get_by_id(self, product_id): qs = self.get_queryset().filter(id=product_id) if qs.count() == 1: return qs.first() else: return None and my views is: def image_detail(request, *args, **kwargs): img_id= kwargs['image_id'] im = images.objects.get_chart(ch_id) if MineralSpectrum is None: raise Http404 reach_image = im.image.path 'my code for edit image' context = {} return render(request, 'image_detail.html', context) but line 6 is wrong. how can I access the image to edit then render it to image_detail template? -
How to create a view for nested comments?
I want to have a nested comment system for my project. I have product model so I want to clients can comment on my products. I have my product and comment models and serializers and I related comments to products in product serializer so I can show product comments. what should i do to clients can write their comment for products??? the comments must be nested. this is my code: #models class Comment(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='comments') parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True,blank=True, related_name='replys') body = models.TextField() created = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.user} - {self.body[:30]}' class Meta: ordering = ('-created',) #serializers: class CommentSerializer(serializers.ModelSerializer): class Meta: model = Comment fields = ['id', 'user', 'product', 'parent', 'body', 'created'] class ProductSerializer(serializers.ModelSerializer): comments = CommentSerializer(many=True, read_only=True) class Meta: model = Product fields = ['id', 'category', 'name', 'slug', 'image_1', 'image_2', 'image_3', 'image_4', 'image_5', 'description', 'price', 'available', 'created', 'updated', 'comments'] lookup_field = 'slug' extra_kwargs = { 'url': {'lookup_field': 'slug'} } how should be my view?? #views: class Home(generics.ListAPIView): queryset = Product.objects.filter(available=True) serializer_class = ProductSerializer permission_classes = (permissions.AllowAny,) filter_backends = [filters.SearchFilter] search_fields = ['name', 'category__name', 'description'] class RetrieveProductView(generics.RetrieveAPIView): queryset = Product.objects.all() serializer_class = ProductSerializer permission_classes = (permissions.AllowAny,) lookup_field = 'slug' -
Django help : AttributeError: module 'django.db.models' has no attribute 'DateTimeFireld'
I have no idea why I am getting the error. from django.db import models from django.utils import timezone from django.urls import reverse class Post(models.Model): title = models.CharField(verbose_name = 'TITLE', max_length = 100) content = models.TextField('CONTENT', default = "") pub_date = models.DateTimeFireld("PUBLISH DATE", default = timezone.now) mod_date = models.DateTimeField('MODIFY DATE', auto_now = True) class Meta: verbose_name = 'post' verbose_name_plural = 'posts' db_table = 'blog_posts' ordering = ('-mod_date',) def __str__(self): return self.title def get_absolute_url(self): return reverse('blog:post_detail', args = (self.id,)) def get_pervious(self): return self.get_next_by_mod_date() def get_next(self): return self.get_next_by_mod_date() -
How to annotate a value from a related model in Django
I have a Post model: class Post(models.Model, NiceTextPrintMixin): text = models.TextField() pub_date = models.DateTimeField("date published", auto_now_add=True, db_index=True) author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="posts") group = models.ForeignKey(Group, on_delete=models.SET_NULL, blank=True, null=True, related_name="posts", ) image = models.ImageField(upload_to='posts/', blank=True, null=True) and a Like model: class Like(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE, blank=False, null=False, related_name="likes") user = models.ForeignKey(User, on_delete=models.CASCADE, blank=False, null=False, related_name="likes") value = models.IntegerField() What i need is to annotate a field to a Post queryset that would contain a 'value' value from a Like model where the post_id=corresponding post_id and user=request.user if such a record exists is there a way to get that done in a simple annotate way ? -
how to clone a token from the Platform account to a Connect account. when using stripe prebuilt checkout page?
I am working on stripe payments, where i require having a shared customer across different connected accounts, that are connected with the platform I am using "Express Accounts" in stripe connect for connecting the connected accounts, that are linked with the platform account. On the frontend (client-side) (Angular), using the "Stripe Prebuilt checkout page", for accepting payment and I am verifying the payment in webhooks(checkout.session.completed) at backend using Django Rest Framework. I am using Destination Charges, for handling the payments and separate charges and transfers. (That i am able to achieve using stripe prebuilt checkout page by specifying payment_intent_data.application_fee_amount and payment_intent_data.transfer_data.destination) Now I have a requirement where I need to have shared customers and share customers across the connected accounts, i need to create token on connected account level and represent the customer there, a way to link the platform-level customer with the connected account without having to create it again. I tried to follow this article Clone customers across accounts but I have not had any luck, unfortunately. With Connect, you can accomplish this by following three steps: Storing customers, with a payment method, on the platform account Making tokens to clone the payment method when it’s time to … -
Multiple checkbox with same id in row and one needs to be selected
I'm trying to add a popup block which will work differently for each row. I used same checkbox id to work with CSS. But it always checks the first option. As a result, the first option in the list get deleted (as I'm working with delete button) instead of the selected one This is my HTML part : {% for item in items %} <input type="checkbox" id="popup"> <label for="popup" class="del_btn">Delete</label> <div class="popup-content"> <div class="pop-header"> <h2>Confirm deletion?</h2> <label for="popup" class="fa fa-times"></label> </div> <label for="popup" class="fa fa-exclamation"></label> <p>Once deleted, all data related to it can't be restored again.<br>Proceed to delete?</p> <div class="line"></div> <a href="{% url 'delete_item' item.id %}" class="btn btn-danger btn-sm" role="button"> <i class="fa fa-trash"></i> <span>Delete</span> </a> <label for="popup" class="close-btn">Cancel</label> </div> And my CSS part : .popup-content { top: 50%; left: 50%; opacity: 0; visibility: hidden; transform: translate(-50%, -50%); position: fixed; width: 450px; height: 350px; transition: 0.3s ease-in; background-color: khaki; border-radius: 3px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.4); } /* #popup { display: none; } */ #popup:checked ~ .popup-content { opacity: 1; visibility: visible; } .pop-header { height: 90px; background-color: #27AE60; overflow: hidden; border-radius: 3px 3px 0 0; box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); } .pop-header … -
django-Did you forget to register or load this tag?
I am trying to create a static file to show my image in Django 3.8.3 I am using this code <!DOCTYPE html> {% load static %} <html> <head> <title>empty page</title> </head> <body> <h1>welcome to empty zone</h1> <h1> my name is {{name}} </h1> <img src="{% 'images/Django_Unchained_logo.jpg' %}" alt="no image found"> </body> </html> I already registered static in settings.py BASE_DIR = Path(__file__).resolve().parent.parent TEMPLATE_DIR=os.path.join(BASE_DIR,'templates') STATIC_DIR=os.path.join(BASE_DIR,'static') #staticfiles STATIC_URL = '/static/' STATICFILES_DIR=[ STATIC_DIR, ]