Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
can not update data in Django Form
can not upload data in Profile. How to Solve the problem. can not upload data in Profile. How to Solve the problem. can not upload data in Profile. How to Solve the problem. can not upload data in Profile. How to Solve the problem. model.py class Profile(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE, blank=True, null=True) name = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200, null=True) created_at = models.DateField(auto_now_add=True) alamat = models.CharField(max_length=200, null=True) no_tlp = models.IntegerField(default=0) wilayah = models.CharField(max_length=200, null=True) j_kel = models.CharField(max_length=200, null=True) pic_Profile = models.ImageField(upload_to='profil/',default="person-circle.svg",null=True, blank=True) def __str__(self): return str(self.id) this form.py class Uplaoddata(ModelForm): no_tlp = forms.CharField(label='No Telpon', max_length=100) wilayah = forms.ChoiceField(label =("Wilayah"),widget=forms.Select, choices=wilayah ,help_text="<style>.errorlist{display:None} </style>") j_kel = forms.ChoiceField(label = ("Jenis Kelamin"),widget=forms.Select, choices=Jenis ,help_text="<style>.errorlist{display:None} </style>") pic_Profile = forms.ImageField(label='Foto Profil', max_length=100) class Meta: model=Profile fields=["email", "name", "alamat", "no_tlp", "wilayah", "j_kel", "pic_Profile"] this my view.py def home(request): data = cartData(request) cartItems = data['cartItems'] id_profil = request.user.profile profiles = Profile.objects.get(id__contains=id_profil) if request.method == "POST": form = Uplaoddata(request.POST ,request.FILES, instance=profiles) if form.is_valid(): form.save() else: form=Uplaoddata(instance=profiles) print("Data Tidak terupdate") context = {'profiles':profiles,'form':form, 'cartItems':cartItems} return render(request, 'home.html',context) -
Django smtp mail is having HTTP link in button but the plain text contains the correct HTTPS one
My server is sending different mail for things like password reset, email verification etc. The mail template button link gets changed to HTTP one, which gives a non-secure warning. The plain paragraph text link is the correct HTTPS one. When using 'django.core.mail.backends.smtp.EmailBackend' Let's say that the current host is localhost and port 8000. So {{ activate_url }} for confirming the mail becomes http://localhost:8000/some-path/account-confirm-email/<token>/ but the button shows a different URL http://url5948.domain/ls/click?upn=<very-long-token>. It seems to be a kind of redirect. What's the problem here? Note: I am using the same variable to generate button href and plain-text link. -
How to use Django oscar catalogue options?
I have a product where it as multiple options for the user to select. say its a food item and it has different flavours and size packs.So i need to have an option in the UI for the users to select the option they want and that product need to be added to the basket with the user provided options. -
how to show image just after uploading in django form
I have a model of image and I want that when a user uploads the image field of the model the image should be shown in the form so that user can confirm the uploaded image but I didn't find any easy solution to do this task. Please show me what is the good and easy way to implement this functionality. -
Django channels can't use redis
I am trying to do a chat app with Django channels. To do it I copied the code of a youtube video from Github. The video link is here. But when I run it I get WebSocket is already in CLOSING or CLOSED state. I use redis. CHANNEL_LAYERS = { 'default': { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [('127.0.0.1', 6379)], }, }, } But when I use InMemoryChannelLayer it works perfectly. Also I haven't enabled the Redis localhost. What should I do? Thanks. -
Doesn't provide model team
ValueError: The field accounts.Ninja.id_team was declared with a lazy reference to 'mission.team', but app 'mission' doesn't provide model 'team'. This is my error when I try migrate or migrate --fake. class Ninja(models.Model): id_user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="ninja", blank=True, null=True) id_team = models.ForeignKey("mission.Team", null=True, blank=True, on_delete=models.SET_NULL) def __str__(self): return '{}'.format(self.id_user) class Team(models.Model): id_mission = models.ForeignKey(Mission, null=True, blank=True, on_delete=models.SET_NULL) name = models.CharField(max_length=200, null=True) leader = models.ForeignKey("accounts.Ninja", related_name='team_leader_set', null=True, on_delete=models.SET_NULL) # member = models.ForeignKey(Ninja, null=True, on_delete=models.SET_NULL) # count_members = models.PositiveIntegerField(null=True) date_created = models.DateTimeField(auto_now_add=True, null=True) def __str__(self): return self.name I have two apps - Mission and Accounts. My accounts.showmigrations: [X] 0001_initial [X] 0002_remove_time_description [X] 0003_time_description [X] 0004_alter_time_value [X] 0005_alter_time_value [X] 0006_alter_time_value [X] 0007_remove_time_value [X] 0008_time_value [X] 0009_remove_team_leader_remove_team_member_and_more [X] 0010_alter_time_category [X] 0011_alter_goal_status_alter_time_category [X] 0012_alter_goal_status_alter_time_category [X] 0013_alter_goal_status_alter_time_category [X] 0014_alter_time_description [X] 0015_alter_goal_description [X] 0016_alter_time_category [X] 0017_alter_time_category [X] 0018_remove_time_category [X] 0019_time_category [X] 0020_alter_time_description [X] 0021_alter_goal_description_alter_goal_status_and_more [X] 0022_alter_goal_status_alter_time_category [X] 0023_remove_time_category [X] 0024_time_category [X] 0025_alter_time_category [X] 0026_alter_time_category [X] 0027_alter_time_category_alter_time_description [X] 0028_alter_time_category_ninja [X] 0029_remove_goal_id_user_goal_id_ninja [X] 0030_rename_id_ninja_goal_id_user [X] 0031_alter_goal_id_user [X] 0032_alter_goal_id_user_alter_ninja_id_team_and_more [X] 0033_rename_id_user_goal_id_ninja [X] 0034_remove_goal_id_ninja_goal_id_user [X] 0035_alter_ninja_id_user [X] 0036_alter_ninja_id_user [X] 0037_remove_goal_id_user [X] 0038_goal_id_user [X] 0039_remove_goal_id_user_goal_id_ninja [X] 0040_remove_ninja_id_user [X] 0041_remove_goal_id_ninja [X] 0042_ninja_id_user [X] 0043_remove_ninja_id_user [X] 0044_goal_id_user [X] 0045_goal_id_ninja [X] 0046_remove_goal_id_user [X] 0047_goal_id_user [X] 0048_alter_goal_id_ninja [X] 0049_remove_goal_id_ninja [X] 0050_goal_id_ninja [X] 0051_ninja_id_user [X] 0052_alter_ninja_id_user [ … -
Populating db with initial data in Django
I need a way to populate db with initial data(cities) for my refs. So I've tried to do it through migrations(https://docs.djangoproject.com/en/4.0/topics/migrations/#data-migrations) Not sure it's a best way, since now I've made changes in this file after migration and can't apply it again, neither can't roll it back(since operation ...populate_cities... is not reversible) and apply again. So the questions are: is there a way to roll such migration back(may be manually)? may be there is a better way to populate db with such data -
Looping through <TD> and linking to whatever is in the loop - Django
I have a loop inside HTML that goes over every user and shows whats linked to it as shown in pic How do I make the HTML link to whatever is shown in the URL? using the following snippet : <td> <a href="{{ user.speciality }}">{{ user.speciality }} </td> will link me to http://127.0.0.1:8000/['http://127.0.0.1:8000/api/speciality/1/',%20'http://127.0.0.1:8000/api/speciality/2/'] -
I need simple django rest framework microservice project
There are 3 services in project. Services are: account category product -
Django restframework filtering with multiple query
I have viewset like this with django-restframework class MixViewSet(viewsets.ModelViewSet): serializer_class = MixSerializer filter_backends = [django_filters.rest_framework.DjangoFilterBackend] filter_fields = ["id","user"] def list(self,request,*args,**kwargs): #filterset = FilterBook(request.query_params, queryset=Mix.objects.all()) queryset = self.filter_queryset(self.get_queryset()) #print(request.GET['access_token']) if ('at' in request.GET): try: user = AccessToken.objects.get(token=request.GET['at']).user except: print("access token invalid") return Response({'message':'invalid access token'}) print(user.id) queryset = queryset.filter(user=user) #http://localhost:8008/api/mixs/?access_token=128 serializer = self.get_serializer(queryset, many=True) custom_data = { 'items': serializer.data } custom_data.update({ 'meta':{"api":"Mix"} }) return Response(custom_data) def get_queryset(self): queryset = Mix.objects.all() ids = self.request.query_params.get('id') print(ids) if ids is not None: queryset = queryset.filter(id=ids) return queryset class MixSerializer(serializers.ModelSerializer): pub_date = serializers.DateTimeField(format="%m/%d/%Y,%I:%M:%S %p") class Meta: model = Mix fields = ('id','pub_date','detail','user') Now I want to get the items by multiple id such as https://example.com/mix/?id=100&id=112&id=143 however in this case only 143 works and it returns the one row. How can I make this work for multiple query?? -
How to Make use of Pagination in this API using Django
Here I am trying to create a getData API using Django Rest Framework in which i want to get data using Pagination, i had created this statically but it should be like (getting PAGE and number of ROWS on that page) in request and accordingly data get fetch from database and also show the number entries i got. please help me out to solve this, i have no idea about how pagination works logically just have basic understanding. class DeviceControlPolicyView(APIView): def get(self, request): if request.data.get('page', 'rows'): if request.data.get('page') == "1" and request.data.get('rows') == "1": print(request.data.get('rows')) print(request.data.get('page')) qry = DeviceControlPolicy.objects.all()[0:1] serializer = DeviceControlPolicySerializer(qry, many=True).data entries = 1 data = { 'details':serializer, 'entry':entries } return Response(data) elif request.data.get('page') == "1" and request.data.get('rows') == "2": print(request.data.get('rows')) print(request.data.get('page')) qry = DeviceControlPolicy.objects.all()[0:2] serializer = DeviceControlPolicySerializer(qry, many=True).data entries = 2 data = { 'details': serializer, 'entry': entries } return Response(data) -
Client sent an HTTP request to an HTTPS server Docker Django Nginx
I have recently started learning docker and I created a django app which I went ahead and dockerized. I am however experiencing an error I can't get past. The error message is Client sent an HTTP request to an HTTPS server. Here is my nginx config file server { listen 80; listen [::]:80; server_name 192.168.99.106; charset utf-8; location /static { alias /usr/src/app/static; } location / { proxy_pass http://web:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } And here is my docker-compose.yml version: '3' services: web: restart: always build: ./web expose: - "8000" links: - postgres:postgres - redis:redis volumes: - web-django:/usr/src/app - web-static:/usr/src/app/static env_file: .env environment: DEBUG: 'true' command: sh -c "python manage.py makemigrations && python manage.py migrate && usr/local/bin/gunicorn inventory.wsgi:application -w 2 -b :8000" nginx: restart: always build: ./nginx/ ports: - "80:80" volumes: - web-static:/www/static - ./certbot/www:/var/www/certbot/:ro - ./certbot/conf/:/etc/nginx/ssl/:ro links: - web:web certbot: image: certbot/certbot:latest volumes: - ./certbot/www/:/var/www/certbot/:rw - ./certbot/conf/:/etc/letsencrypt/:rw command: certonly --webroot -w /var/www/certbot --force-renewal --email example@gmail.com -d 192.168.99.106 --agree-tos postgres: restart: always image: postgres:latest ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data/ environment: POSTGRES_DB: "db" POSTGRES_HOST_AUTH_METHOD: "trust" POSTGRES_PASSWORD: ${DB_PASS} redis: restart: always image: redis:latest ports: - "6379:6379" volumes: - redisdata:/data volumes: web-django: web-static: pgdata: redisdata: The docker … -
WebSocket connection to 'url' failed
I just deployed a django project that uses djagno channels in heroku.. when I try to create a websocket connection form http://localhost:3000/ to the url, I am getting connection to websocket failed Is this due to improper deployment or something else I am not able to understand can anyone help me.. This is how i am connecting to websocket useEffect(() => { Socket = new WebSocket(`${WEBSOCKET_URL}/room/${roomName}/${myUserName}/`); Socket.onmessage = ({ data }) => { let res = JSON.parse(data); if (!res.error && res["data-type"] === "begin-game") { const { gameId } = res; Socket.close(); navigate(`/game/${gameId}/`, { state: { gameId, data: res.data, myUserName }, }); } else if (!res.error) setUsersOnRoom({ ...res.data }); }; }, []); where WEBSOCKET_URL is export const WEBSOCKET_URL = "wss://ludo-thegameforlegends.herokuapp.com/ws"; The codes in my django project is in asgi.py import os from django.core.asgi import get_asgi_application from channels.routing import ProtocolTypeRouter,URLRouter from channels.auth import AuthMiddlewareStack from main.routing import websocket_urlpatterns as room_urlpatters from gameManager.routing import websocket_urlpatterns as gameManager_urlpatterns from channels.security.websocket import AllowedHostsOriginValidator os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ludo.settings') websocket_urlpatterns = room_urlpatters + gameManager_urlpatterns application = ProtocolTypeRouter({ 'http':get_asgi_application(), 'websocket':AllowedHostsOriginValidator(AuthMiddlewareStack(URLRouter(websocket_urlpatterns))), }) I am configuring channel layers like this CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { "hosts": [(os.environ.get('REDIS_URL'), 6379)], }, }, } routing is like this.. from django.urls import … -
why does css file is not working in django project
When i shutdown my PC and reopen my project every time i have to change the css file name to see the changes on the web i have tried many ways to fix this issues. *i have researched online but i did not get any answer on it * i have tried these ways to fix this error i have tried settings up STATIC_ROOT=''. i have tried setting up STATICFILES_DIRS=[]. please guide me to solve this error. -
Can We Have Two Views For The Same Page - Django
I am working on a simple project of creating a e-commerce for having a product and orders pages for customer and admin of website. Now I wanted the same product page for both customer and admin but admin should have more options like editing that product or who ordered the product whereas customers shouldn't be able to see this. Is it possible by creating a different views but passing two different values or can we use jinja tags for this ? NB : I am beginner so please forgive me if i missed a point or while explaining please use simpler terms. Thanks For Answers -
Diagnosing diseases in python
I want to create a system to diagnose diseases. This system has a test and asks some questions from user. New question apears base on the user's answer. Finally shows the result according to the user's answers. I want to design this system using django and react. I will be happy if you recommand me the way I should choose to create it. Thank you. -
Not able to install psycopg2 module when deploying Django to Elasticbeanstalk
I am having trouble adding the psycopg2 module to my elastic beanstalk setup, so that I can deploy my Django project. Some details: Platform: Amazon Linux 2/3.3.14 Python 3.8 running on 64bit Stack Trace from /var/log/web.stdout.log Jun 22 02:39:11 ip-172-31-20-172 web: return _bootstrap._gcd_import(name[level:], package, level) Jun 22 02:39:11 ip-172-31-20-172 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 29, in <module> Jun 22 02:39:11 ip-172-31-20-172 web: raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e) Jun 22 02:39:11 ip-172-31-20-172 web: django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2' Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3578] [INFO] Worker exiting (pid: 3578) Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3572] [INFO] Shutting down: Master Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3572] [INFO] Reason: Worker failed to boot. Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3586] [INFO] Starting gunicorn 20.1.0 Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3586] [INFO] Listening at: http://127.0.0.1:8000 (3586) Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3586] [INFO] Using worker: gthread Jun 22 02:39:11 ip-172-31-20-172 web: [2022-06-22 02:39:11 +0000] [3592] [INFO] Booting worker with pid: 3592 Jun 22 02:39:12 ip-172-31-20-172 web: [2022-06-22 02:39:12 +0000] [3592] [ERROR] Exception in worker process Jun 22 02:39:12 ip-172-31-20-172 web: Traceback … -
How to create tables in a different schema in django?
I'm using postgresql database in my django project. I have multiple apps in my projects. users/ UserProfile model myapp/ CustomModel model Now I need UserProfile table should be created in public schema And CustomModel table needs to be created in a separate schema called myapp How to implement this and Do I need to change anything in the queries or migration command in future after implementing this? -
How does Django handle importing of apps?
I would like to know how Django's imports work. For example, in this code: # in some_app/views.py from another_app.models import UserModel # another_app is another app of the same project there's an import statement that imports UserModel from models.py in another_app (another app of the same project). I was just wondering how Django handles this importing because usual Django project's directory structure looks like this: . ├── another_app │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── manage.py ├── some_app │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py └── some_project ├── __init__.py ├── asgi.py ├── settings.py ├── urls.py └── wsgi.py some_app and another_app are separate directories. I want to know how the importing works because I want to find a workaround for one of my projects that have separate directories but requires each other's functions. -
Django CORS Missing Allow Origin Error even with corsheaders middleware
Hi I'm building a SPA with Django + Vue.js and struggling with CORS Missing Allow Origin error. It occurs when Vue.js frontend call some API and Django backend returns redirect to external URL. From Django backend, this API returns something as below. return redirect('https://api.external.service.com/sso/authorize?param1=xxx&param2=yyy>') And then Vue.js frontend tries to redirect to the URI but it fails. Since console tells "CORS Missing Allow Origin", I'm using corsheaders with the following configuration, but it doesn't solve the issue. What's wrong with what I'm doing?? settings.py DJANGO_DEBUG = True ALLOWED_HOSTS = ('localhost', 'api.external.service.com',) CORS_ORIGIN_ALLOW_ALL = False CORS_ORIGIN_WHITELIST = ('https://localhost:8000', 'https://0.0.0.0:8000', 'https://api.external.service.com',) ... INSTALLED_APPS = [ ... 'django_extensions', 'corsheaders', 'rest_framework', ... ] MIDDLEWARE = [ ... 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ... ] For debug, I tried the follows but it also failed with the same error... settings.py DJANGO_DEBUG = True ALLOWED_HOSTS = ('*',) CORS_ORIGIN_ALLOW_ALL = True CORS_ORIGIN_WHITELIST = ('https://localhost:8000', 'https://0.0.0.0:8000', 'https://api.external.service.com',) ... INSTALLED_APPS = [ ... 'django_extensions', 'corsheaders', 'rest_framework', ... ] MIDDLEWARE = [ ... 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', ... ] Otherwise am I misunderstanding "CORS", and perhaps I should register my app domain to the external service to allow access from my app to it?? -
Django Signals: Creating instance of different models when one is created based on a boolean field on the sender model
I have three models ProductOrService, Product and Service. I have a BooleanField named is_product in the ProductOrService model which says that an item is a product if it is true and it is a service if it is false. I want to automatically create a Product instance if the is_product field is True or automatically create a Service instance if the is_product field is False. The code given below creates a Product instance when a ProductOrService instance is created with is_product set to True. But it does not create a Service instance when a new ProductOrService instance is created with is_product set to False. models.py: class ProductOrService(models.Model): web_id = models.CharField(max_length=50, unique=True, verbose_name=_("product web id"), help_text=_("format: required, unique")) slug = models.SlugField(max_length=255, null=False, blank=False, verbose_name=_("product/service url"), help_text=_("format: required, letters, numbers, underscore or hyphen")) name = models.CharField(max_length=250, null=False, blank=False, verbose_name=_("product/service name"), help_text=_("format: required, max_length=250")) seller = models.ForeignKey(User, related_name="product_or_service", on_delete=models.PROTECT) description = models.TextField(verbose_name=_("product description"), help_text=_("format: required")) category = TreeManyToManyField(Category) is_visible = models.BooleanField(default=True, verbose_name=_("product/service visibility"), help_text=_("format: true->product is visiible")) is_blocked = models.BooleanField(default=False, verbose_name=_("product/service blocked"), help_text=_("format: true->product is blocked")) created_at = models.DateTimeField(auto_now_add=True, editable=False, verbose_name=_("date product/service created"), help_text=_("format: Y-m-d H:M:S")) updated_at = models.DateTimeField(auto_now=True, verbose_name=_("date product/service last updated"), help_text=_("format: Y-m-d H:M:S")) is_product = models.BooleanField(default=True, verbose_name=_("Is this product?"), help_text=_("format: … -
AJAX-based refresh without data duplication
I am confused about AJAX requests. I am using the load() function to refresh specific elements on the page. Unwanted duplication does not occur when there is only one matched element on the page. {% for example in examples %} <div class="refresh" id="single{{ example.id }}"> <div class="container"> <p> Different content </p> </div> </div> {% endfor %} Assuming the above example, I would like to refresh the contents of a container with different contents in multiple elements on the page. In this case, if the 'examples' elements are four, there will be 8 after the refresh. I've tried everything I can find, but so far the data is duplicated. -
Django 4 seems to be caching my query. How can I turn it off?
Some context I have a model with 20+ attributes. This is for a property-listing site (like Airbnb). So there are things like size, bedrooms, city, state, etc. There needs to be an auto-complete functionality on the textboxes when I am editing these properties. So for example, State is a text field in my form. When I am adding a 2nd house to my website, the State textbox should suggest values from the previous houses that I have in my system. (Basically when I type C, it should show California if I have any houses with California already in the DB) UpdateView I am using an Update View to show my Property-Edit (House-Edit) page. I need to pass in all these auto-complete fields inside this Update View so that I can add them to my text boxes. The code looks like this: class PropertyUpdateView(LoginRequiredMixin, UpdateView): context_object_name = 'property' model = models.Property form_class = forms.PropertyForm template_name = 'desertland/admin/property_update.html' extra_context = get_autocomplete_fields() def get_success_url(self): messages.success(self.request, 'The property was updated successfully.') return reverse('property_update', kwargs={'pk': self.object.id}) The extra_content is where I am passing my autocomplete fields. The get_autocomplete_fields() method is like so: def get_autocomplete_fields(): ac_keys = ['state', 'city', 'county', 'zip_code', 'zoning', 'power', 'water_district', 'water', 'access', … -
127.0.0.1:8080/data/ping should return pong json response (something like {‘data’:‘pong’}
I am using Redis in my project for caching, now I need to return pong in the browser when i point to the /data/ping and also other Redis CLI operations if possible, I did some research and found something in js but I need to implement this in pure Django or DRF -
I am getting the error disallowed host with python anywhere
I am trying to deploy my blog to python anywhere but I keep getting this error DisallowedHost at /. The error log says this Invalid HTTP_HOST header: 'codewizblog.pythonanywhere.com'. You may need to add 'codewizblog.pythonanywhere.com' to ALLOWED_HOSTS. I do not know why it is asking me to add something I have already added to my sittings file. if anyone knows how to fix this any help would be appreciated. Also if anyone can give me tips on security for my site that would also be appriceated. setting.py from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ['codewizblog.pythonanywhere.com',] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'blog.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'blog.wsgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } …