Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Default the value of an external key in a form
In the form for adding a calendar (of the Model "Calendar"), in the "group" field shows a drop-down menu where all the "CalendarGroups" are. I would like this menu not to be there and "group" to be set by default with the "group" id which I pass through the url parameter ("group_id"). How could I solve this? In models.py: class CalendarGroups(models.Model): name = models.CharField(max_length = 155, blank=True, null=True, unique=True) def __str__(self): return str(self.name) @property def get_html_url(self): url = reverse('', args=(self.id,)) return f'<a href="{url}"> {self.name} </a>' class Calendar(models.Model): name = models.CharField(max_length=200, unique=True) #created_by group = models.ForeignKey(CalendarGroups, on_delete = models.CASCADE, default='') @property def get_html_url(self): url = reverse('cal:calendar_view', args=(self.id, self.group)) return f'<a href="{url}"> {self.name} </a>' In forms.py: class CalendarGroupsForm(ModelForm): class Meta: model = CalendarGroups fields = ('name',) def __init__(self, *args, **kwargs): super(CalendarGroupsForm, self).__init__(*args, **kwargs) class CalendarForm(ModelForm): class Meta: model = Calendar fields = ('name', 'group') def __init__(self, *args, **kwargs): super(CalendarForm, self).__init__(*args, **kwargs) In views.py: def group(request, group_id=None): instance = CalendarGroups() if group_id: instance = get_object_or_404(CalendarGroups, pk=group_id) else: instance = CalendarGroups() form = CalendarGroupsForm(request.POST or None, instance=instance) if request.POST and form.is_valid(): form.save() return HttpResponseRedirect(reverse('cal:home')) return render(request, 'cal/form.html', {'form': form}) def calendar(request, group_id=None): instance = Calendar() form = CalendarForm(request.POST or None, instance=instance) if request.POST and … -
Django-ajax submitted data and created but gives error
I created a signup function captcha with the ajax method. if the user fills up fillup captcha correctly user account is created but the user doesn't fillup captcha code incorrectly user not created. It is ok. The problem is when user-submitted data always goes to the error block in the ajax part. if the user fillup invalid captcha it doesn't give any error. How can I fix it? HTML part <form class="user_signup_sidebar_form" action="{% url 'account:signup-sidebar' %}" method="post" data-mail-validation-url="{% url 'account:check_if_email_available' %}" id="customer-signup-form"> {% csrf_token %} <fieldset> {% bootstrap_form_errors form type="non_fields" %} {% for field in signform %} {% if not forloop.last %} {% bootstrap_field field %} {% endif %} {% endfor %} <div class="captcha_wrapper"> <label for="id_captcha_1" id="id_captcha_2">{{ signform.captcha.label }}</label> <div class="captcha_input"> {% bootstrap_field signform.captcha show_label=False %} <div class="captcha_reloader"> <span><i class="icon-refresh" id="js-captcha-refresh_modal"></i></span> </div> </div> </div> <style type="text/css"> </style> {# <input type="hidden" id="id_next" name="{{ REDIRECT_FIELD_NAME }}" value="{{ request.get_full_path }}"/>#} </fieldset> {% url 'page:details' slug='customer-terms-conditions' as page_details_url %} <p>By clicking "Signup", you agree on aadi <a target="_blank" href="{{ page_details_url }}">Terms & Conditions</a>.</p> <div class="form-group w-100 align-items-center d-flex justify-content-center m-0"> <button title="Signup" type="submit" class="btn btn-dark w-100 text-uppercase">Signup</button> </div> <a title="Seller Signup" rel="nofollow" class="link--styled pt15" href="{% url 'account:vendor-signup' %}"> Want to be a seller at … -
How can you dynamically set initial value of form select field at the time of rendering django template
I have a requirement to render select field multiple times and each field will have pre-selected value. Now My question is: How can you dynamically set initial value of django form selectfield at the time of rendering django template?? my form: class RequestProdApvr(forms.Form): product = forms.ModelChoiceField(queryset=SPA_Product.objects.all().order_by('hierarchy_code'), label='', required=False) I have to use this form in multiple row in my listview and pre-populate value based on saved data. I searched SO for the solution and non of them met my requirement... Django. Initial value of Choice Field dynamically Dynamically set default form values in django Hence I am posting separate question here... -
Things to check when there is 'no such table' exception in Django
I defined a new model in django. It looks like this: class User(models.Model): email = models.EmailField(primary_key=True) REQUIRED_FIELDS = [] USERNAME_FIELD = 'email' is_anonymous = False is_authenticated = True I've registered the app it is contained under into the settings.py INSTALLED_APPS = [ # 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'lists', 'accounts', # <-- this ] I've flushed database, re-made migrations and migrated. So that I do not have any you have un-applied migrations messages when running server. However, the django.db.utils.OperationalError: no such table : accounts_user persists. I've used shell, and it too throws error: >>> from accounts.models import * >>> User <class 'accounts.models.User'> >>> User.objects <django.db.models.manager.Manager object at 0x7fbcbea35ef0> >>> User.objects <django.db.models.manager.Manager object at 0x7fbcbea35ef0> >>> User.objects.all() Traceback (most recent call last): django.db.utils.OperationalError: no such table: accounts_user I've exhausted all other options known to me. Can someone provide a general check-list for things to check (no matter how stupid), when faced with an error like this? -
Pass extra params in DRF serializer class
I am trying to pass arguments table_name and serial_class to the serializer class, but request.data_name says Name error : request is not defined http://localhost:8000/get_data??format=json&table_name=something&serial_class=other Please suggest where I am doing wrong views.py class get_data(generics.ListAPIView): table_name = eval(request.GET.get('table_name')) # NOT WORKING serial_class = eval(request.GET.get('serial_class')) # NOT WORKING start = table_name.objects.values("start_date").order_by("-start_date")[0]['start_date'] end = table_name.objects.values("end_date").order_by("-end_date")[0]['end_date'] queryset = table_name.objects.filter(start_date=start,end_date=end) serializer_class = serial_class serializer.py class OrdersDataSerializer(serializers.ModelSerializer): class Meta: model = orders_data fields = '__all__' -
How reverse an include pattern path in Django
Hi i am wondering how i can reverse a urlpattern path that uses include pattern. Since there is no namespace i don't know how to reverse it. Also i am new to Django so all this is a little bizarre to me. v1_api = Api(api_name='v1') urlpatterns = [path('', include(v1_api.urls))] + restless.get_urls()] + restless.get_urls() I want to use from django.urls import reverse class SiteResource(ModelResource): baselayer = fields.ToOneField( 'erma_api.api.resources.data_layer.DataLayerResource', 'baselayer', null=True) class Meta(ModelResource.Meta): queryset = models.Site.objects.all() resource_name = 'site' authorization = SiteAuthorization() validation = CleanedDataFormValidation(form_class=SiteForm) detail_allowed_methods = ['get', 'post', 'put', ] list_allowed_methods = ['get', 'post'] excludes = [] abstract = False filtering = { 'site_name': ALL, 'verbose_site_name': ALL, 'site_id': ALL, 'site_path': ALL, 'extent': ALL, } -
Django: Get a queryset of ForeignKey elements from another queryset
Let's say I have a Foo class. Given a queryset of Foo, how can I retrieve the queryset of Users? class Foo(models.Model): user = models.ForeignKey("users.User", related_name="foos") ... foo_objects = Foo.objects.all() One method I've seen is: users = Users.objects.filter(id__in=list(foo_objects.values_list("user_id", flat=True)) Is there any way to get the list of all users in the foo_objects queryset without this list conversion? users = User.objects.filter(user_id__in=foo_objects.values("user_id")) If the second option works– does anyone have any experience re: which method works better with postgresql? I've heard nested queries (the second option) doesn't work great on some databases. -
Can I create a progressive web application in django?
Convert the Django website to a progressive web application. Would it work on mobile devices? What do I need, due to the loss of connection through Wifi, in a private network. I run Python with Django and postgresql, when I run: python3 manage.py runserver_plus 0.0.0.0:8000, within the same network I can connect with my mobile device, but I want to use the web application in offline mode. I use Service Worker, in offline mode, but it doesn't work for me on mobile devices. Why Sera? It doesn't give me an error, just when I connect from a mobile device and when I want to use it in offline mode it doesn't work, but it works in Chrome on laptop. One of the requirements, if I'm not mistaken is to use SSL certificate in Django? Please help me. -
How can I Upload Files to AWS S3 Using React Js with Django and GraphQl in the Backend?
I am trying to upload audio files to AWS S3 using React in the frontend and a backend built with Django and Graphene. I keep getting the following errors in the console index.js:1 Error uploading file Error: Request failed with status code 400 at createError (createError.js:16) at settle (settle.js:17) at XMLHttpRequest.handleLoad (xhr.js:61) console.<computed> @ index.js:1 overrideMethod @ react_devtools_backend.js:2273 handleAudioUpload @ CreateTrack.jsx:45 async function (async) handleAudioUpload @ CreateTrack.jsx:32 handleSubmit @ CreateTrack.jsx:53 onSubmit @ CreateTrack.jsx:75 callCallback @ react-dom.development.js:188 invokeGuardedCallbackDev @ react-dom.development.js:237 invokeGuardedCallback @ react-dom.development.js:292 invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306 executeDispatch @ react-dom.development.js:389 executeDispatchesInOrder @ react-dom.development.js:414 executeDispatchesAndRelease @ react-dom.development.js:3278 executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3287 forEachAccumulated @ react-dom.development.js:3259 runEventsInBatch @ react-dom.development.js:3304 runExtractedPluginEventsInBatch @ react-dom.development.js:3514 handleTopLevel @ react-dom.development.js:3558 batchedEventUpdates$1 @ react-dom.development.js:21871 batchedEventUpdates @ react-dom.development.js:795 dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3568 attemptToDispatchEvent @ react-dom.development.js:4267 dispatchEvent @ react-dom.development.js:4189 unstable_runWithPriority @ scheduler.development.js:653 runWithPriority$1 @ react-dom.development.js:11039 discreteUpdates$1 @ react-dom.development.js:21887 discreteUpdates @ react-dom.development.js:806 dispatchDiscreteEvent @ react-dom.development.js:4168 httpLink.ts:134 POST http://localhost:8000/graphql/ 400 (Bad Request) (anonymous) @ httpLink.ts:134 Subscription @ Observable.js:197 subscribe @ Observable.js:279 (anonymous) @ observables.ts:10 Subscription @ Observable.js:197 subscribe @ Observable.js:279 (anonymous) @ QueryManager.ts:217 (anonymous) @ QueryManager.ts:210 step @ tslib.es6.js:100 (anonymous) @ tslib.es6.js:81 (anonymous) @ tslib.es6.js:74 __awaiter @ tslib.es6.js:70 QueryManager.mutate @ QueryManager.ts:142 ApolloClient.mutate @ ApolloClient.ts:348 MutationData.mutate @ MutationData.ts:99 MutationData._this.runMutation @ MutationData.ts:67 handleSubmit @ CreateTrack.jsx:54 async function (async) handleSubmit … -
Phantom unapplied migrations -
I changed my schema and then couldn't get the initial migration to detect changes ( No migrations to apply Error). I then did the following: Manually dropped all the old tables from the DB Dropped django-migrations table Dropped django-admin-log table Reran make migrations and migrated All looked good in my tables, my django_migrations folder in the db and in the migration in the app but now when I run the code I get: You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. When I run: pipenv run python3 manage.py makemigrations core I get no changes detected. Here's my database structure: Schema | Name | Type | Owner --------+----------------------------+-------+----------- public | auth_group | table | mobiusapi public | auth_group_permissions | table | mobiusapi public | auth_permission | table | mobiusapi public | auth_user | table | mobiusapi public | auth_user_groups | table | mobiusapi public | auth_user_user_permissions | table | mobiusapi public | core_genericpart | table | mobiusapi public | core_org | table | mobiusapi public | core_partlisting | table | mobiusapi public | core_specificpart | table | mobiusapi public | core_user | table | mobiusapi public | … -
Why does Django not allow a user to extract a usable query from a QuerySet as a standard feature?
In Django, you can extract a plain-text SQL query from a QuerySet object like this: queryset = MyModel.objects.filter(**filters) sql = str(queryset.query) In most cases, this query itself is not valid - you can't pop this into a SQL interface of your choice or pass it to MyModel.objects.raw() without exceptions, since quotations (and possibly other features of the query) are not performed by Django but rather by the database interface at execution time. So at best, this is a useful debugging tool. Coming from a data science background, I often need to write a lot of complex SQL queries to aggregate data into a reporting format. The Django ORM can be awkward at best and impossible at worst when queries need to be very complex. However, it does offer some security and convenience with respect to limiting SQL injection attacks and providing a way to dynamically build a query - for example, generating the WHERE clause for the query using the .filter() method of a model. I want to be able to use the ORM to generate a base data set in the form of a query, then take that query and use it as a subquery/CTE in a larger query … -
Postman (NodeJS): Not saving cookies returned from api
Issue: Cookies were earlier getting saved until I reinstalled Postman. I have literally tried everything (stackoverflow + google), I would really appreciate the help. URL : http://localhost:5000/api/users/signup Settings: Interceptor connected like: Idk what settings are changed after installation. I'm stuck in my development process because of this. -
django, Adding a passcode to restrict who can register on my website
I have a registration page that I want to restrict who can register to my website. views.py: def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) passcode = PassCodeForm(request.POST) if form.is_valid(): passcode == "FreedomLivesHere" if passcode == 'Passcode': form.save() username = form.cleaned_data.get('username') messages.success(request, f'Account created for {username}!') return redirect('login') else: messages.error(request, f'Passcode incorrect, please try again!') else: messages.error(request, f'Oops I did it again! Please try again later.') return redirect('register') else: form = UserRegisterForm() passcode = PassCodeForm() context = { 'passcode':passcode, 'form':form } return render(request, 'users/register.html', context) forms.py class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] class PassCodeForm(forms.ModelForm): class Meta: model = Passcode fields = ['passcode'] When I run my registeration page I get the else statement: 'Oops I did it again! please try again later.'), whats the best way of adding a passcode field that matches a string. Also, depending on the passcode string. Its going to create either an active, admin, or staff permission type. Is this possible? -
Django recommendation for flow
I am starting my first project >> DJango. I try to think about what process I need to do to work properly. Install a Docker on my PC or open a VM? Install the Django work environment. 3.Replace to postgres database. How often should I use git version control, meaning when do you upload your changes? (By number of changes or by each X time?) Deploy the APP to AWS / heroku / digital ocean (what do you recommend?) -
Django Microservices authentication
I was reading about Microservices in django , and came to know in Microservices we keep small services separately and they can operate individually . if I am not wrong about this concept how I will validate using JWT token from a user from one Database to use that in 2nd Microservices ? ? -
Capturing users site coming from
I am trying to capture the website the user is coming from on a django app.... I have an anchor link on SITE A.COM (<a href='www.b.com'>Click here</a>) So on site B.COM I would like to know the user is coming from site A.COM.... Some analytics tool are able to capture it, but I am not sure how to do it... I am trying to captur it with the request on the view with: def myView(request): print(request.META.items()) And my output has no clue on the other domain! I have a Django app behind AWS Load Balancer, so not sure whats possible with that. I appreciate any help -
Starnge problem migrating database to the django psycopg
I have strange problem with my database... It is postgresql, any help would be awesome! I did following commands in terminal, I'm transfering from windows to centos 7 server: [ [/home/pro]]# source s_project/bin/activate (s_project) [ [/home/pro]]# cd projects (s_project) [ [/home/pro/projects]]# cd sc (s_project) [ [/home/pro/projects/sc]]# python3 manage.py makemigrations No changes detected (s_project) [ [/home/pro/projects/sc]]# python3 manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying auth.0012_alter_user_first_name_max_length...Traceback (most recent call last): File "/home/pro/s_project/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.NotNullViolation: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, auth, 0012_alter_user_first_name_max_length, 2020-08-25 17:53:12.869298+00). I would delete this row from database or would give an id to it. But the problem is, that is no where to find in my database... I suppose it is to be in django_migrations table, by the data of it... but it's not there. What could I do about it? It looks like discrepancy... It looks like database tried to set today's data of changes in migrations in 0 record/raw... Because I have logs from 1 to 24... which were made long time ago... How to fix it... I have fogged understanding of how to... Either … -
Problem with migrating a django server (syntax error)
I am trying to make a django server for a sociometric badge (https://github.com/HumanDynamics/openbadge-server) for our university's project. The code (and the whole badge) has been done by someone else and I have not myself changed anything. I am able to build the server but when trying to migrate or create a superuser, I get a syntax error. I've been trying to troubleshoot it by myself but I have very limited knowledge of python, django and Ubuntu so I'm probably missing something. I tried asking the original developer but he is busy with other stuff so haven't gotten a reply but as I have to get the project going, I'll try asking here. The error implies an error in the line 44 of /usr/local/lib/python2.7/site-packages/pkgconf/init.py but I cannot find the file so I cannot check it. In fact, the whole site-packages folder is empty so I wonder if I have installed modules in a wrong way? The code is written in python2.7 so I also wonder if the python2.7 being EOL could cause issues? It has already broken some parts, mainly how to get some of the modules. The code and docker files used in this project can be found here: https://github.com/HumanDynamics/openbadge-server … -
Django static files not being served by amazon s3 even though all the instructions have been strictly followed
This is my first time ever on this platform, so please don't mind me if I am breaching any rules. I just finished building my first django project and I am using an amazon s3 bucket to serve media and static files. I have deployed the app onto heroku but static and media files are not being loaded. When I inspect the page, I see that it is throwing a 403 error. All the policies of my bucket have been set as prescribed in the documentation. below is a picture of my relevant setting.py settings .py -
Create flexbox container one after another horizontally
I am trying to create 2 flexbox containers one after the other, I have applied a number of classes combination to make this work. Flexbox gets created but when I scroll, the lower one goes below upper one. The output is as shown here: Current Scenario Output. My requirement is those 2 horizontal bars to be fixed and one after another, irrespective of scrolling. <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="{% static 'personal/mystyles.css' %}"> </head> <body> <div class="d-flex flex-column flex-md-row align-items-center pt-1 px-md-4 mb-3 border-bottom shadow-sm sticky-top" style="background-color: #80ccff;"> <h5 class="my-0 mr-md-auto font-weight-normal"> <p>Hello, User </p> </h5> <nav class="my-0 my-md-0 mr-md-3"> <a class="p-2 text-dark" href=""><b>Home</b></a> <a class="p-2 text-dark" href=""><b>Account</b></a> <a class="p-2 text-dark" href=""><b>Logout</b></a></p> </nav> </div> <!--This div will be used in different html file and first div will be included using 'include' keyword of django. --> <div class="d-flex flex-column flex-md-row align-items-center pt-5 px-md-4 border-bottom shadow-sm sticky-top" style="background-color: #80ccaa;"></div> </body> </html> -
Using a postgres docker as a database for django || Launching dockers before build of another one in the docker-compose.yml file
I know there have been similar questions on this site, but the answers to these are sadly outdated. So I have a django application and i want to use postgres as the underlying database. Additionally a want to separate both programs in separate dockers. Now the docker docs have a way to do it, but sadly it seems to be outdated: link The problem appears when i call manage.py migrate in the docker build function which is being run by the docker compose file. But i get the error that the host 'db' is unknown/invalid. Compose excerpt: services: db: image: postgres restart: always volumes: - DataBase:/var/lib/postgresql/data environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres ports: - "5432:5432" app: build: FehlzeitErfassungProject restart: always volumes: - Logs:/app/logs - Backups:/app/Backups - Media:/app/MEDIA ports: - "5432:5432" depends_on: - db app dockerfile: FROM ubuntu WORKDIR /app ADD ./requirements.txt ./ RUN apt-get update && \ apt-get upgrade -y # getting tzdata to shutup ARG DEBIAN_FRONTEND=noninteractive ENV TZ=Europe/Berlin RUN apt-get -y install tzdata #installing all needed porgramms RUN apt-get install -y uwsgi python3 python3-pip RUN python3 -m pip install pip --upgrade RUN python3 -m pip install -r requirements.txt COPY ./ ./ RUN ./manage.py migrate CMD ["uwsgi", "uwsgu.ini"] PS: … -
How to use django-jalali calendar in tempates?
Im new to Django and im trying to use django in a Persian app, therefore I need users pick i a date(jalali date) and send it to server. I've used django-jalali in admin area and its working fine, but I need to use this in front-end too. I've set locale to Asia/Tehran and Time Zone to fa but default date picker shows up Gregorian calendar. please help me with that. How can I solve this? -
Seeing Django debug 404 page despite having DEBUG = False
I have been following this tutorial along to deploy my first Django site and have successfully reached the section 'Configure Nginx to Proxy Pass to Gunicorn' which all seems to be working. My problem is that, despite my settings.py file containing the following: # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False I am still getting Django's debug=true 404 page with the following error: "You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page." I changed the file to DEBUG = False after completing the 'Configure Nginx to Proxy Pass to Gunicorn' step in the tutorial by pulling the change from my GitHub repository. Am I missing an additional step with Nginx in order to turn debug off and serve a standard 404 page? -
Get data from frontend (vuejs) save it in django database and pass the data to local running API service outside of django
I'm trying to save the frontend data from the frontend(Vuejs) and save it in Django database with models.models and then pass the data to another API service running locally To give you an idea I'm using Vuejs as my frontend and Django as my backend but I have another API service running that has the following API calls that I want to make use of Lenght:"100" prefix: "some text here" temprature:"0.7" the data between the "" above is just used as an example When you do get a response with the above filled in it looks like this {"text":"this is the response data requested bla bla bla bla"} My data save in my database when I post from the frontend to Django with status code 200 with a class-based view and when it saves the data into Django and pass it to the local running API service it sends with a status code 200 that is showed on the local API service but then responds with an error in Django status code 500from the local running API and doesn't deliver the requested information to the frontend. the error in Django is as follow from the local running API Internal Server … -
Django: Display each user's profile
I'm new to Django and I'm trying to display each user's profile. So far, I've made a sign-in, sign-up system. User can also update their profiles but I'm really not able to show each user's profile as soon as the logged in user clicks on the other user's username. I was wondering if I could do something with the primary key/ID of the each profile and use it to get access to every profile. A little help would be really appreciated! Here's what my code looks like: The URL to the Profile's page: path('profile/', views.userprofile, name='userprofile'), My view to view the profile: @login_required def userprofile(request): Post = post.objects.order_by('-created') return render(request,'social_media/profile.html', {'Post':Post,'Profile':Profile}) Model for user's profile: class profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) desc = models.CharField(max_length=1000) pfp = models.FileField(default='images/profile.jpg', upload_to='profile_pics/', blank=True) cover = models.FileField(default='images/profile.jpg', upload_to='cover_pics/', blank=True) Link that take me to the profile URL: <div class="user-pfp-name"> <a href="{% url 'userprofile' %}"> <img src="{% static 'social_media/images/profile.jpg' %}" style="height: 35px; width: auto; border-radius: 100%;" alt=""> {{ i.user.first_name }} {{ i.user.last_name }} </a> </div> and lastly here's my profile page: <div class="profile"> <div class="coverpad"> {% if Profile.cover %} <img src="{{ Profile.cover.url }}"> {% endif %} </div> <div class="profilepic"> {% if Profile.pfp %} <img src="{{ Profile.pfp.url …