Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Jinja2 - AttributeError: 'Environment' object has no attribute 'get_source'
I have the following two lines of code. Both are using jinja2 to replace the template variables: subject = Environment(loader=BaseLoader).from_string(template.email_subject).render(context) body = Environment(loader=BaseLoader).from_string(template.email_template).render(bodyContext) The first line works just fine, while the second line throws the Error: AttributeError: 'Environment' object has no attribute 'get_source' The context dictionary includes all necessary template variables and the jinja2 syntax should be correct as well. Just to be sure, here are the templates as well: template.email_template: Hallo {{name}}, {%- include invoiceType+'/email_body.tpl' -%} Viele Grüße {{emailFooter}} invoiceType/email_body.tpl: im Anhang findest du/findet ihr den Entwurf für die kommende Rechnung über alle angefallenen Kosten bis zum {{invoiceDate -}}. template.email_subject: Rechnung {{currentYear}}{{invoiceID}} -
How to show content with zip in view with django?
I hava a django applicaiton. And I try to show the content values from the backend in the template. There is a method: show_extracted_data_from_file where I combine three methods: class FilterText: def total_cost_fruit(self): return [3588.20, 5018.75, 3488.16, 444] def total_cost_fruit2(self): return [3588.20, 5018.75, 3488.99] def total_cost_fruit3(self): return [3588.20, 5018.75, 44.99] def show_extracted_data_from_file(self): regexes = [ self.total_cost_fruit(), self.total_cost_fruit2(), self.total_cost_fruit3, ] matches = [(regex) for regex in regexes] return zip(matches) and I have the view: def test(request): content_pdf = "" filter_text = FilterText() content_pdf = filter_text.show_extracted_data_from_file() context = {"content_pdf": content_pdf} return render(request, "main/test.html", context) and html: <div class="wishlist"> <table> <tr> <th>Method 1</th> <th>Method 2</th> <th>Method 3</th> </tr> {% for value in content_pdf %} <tr> <td>{{value.0}}</td> <td>{{value.1}}</td> <td>{{value.2}}</td> </tr> {% endfor %} </table> </div> But it looks now: Method 1 Method 2 Method 3 [3588.2, 5018.75, 3488.16, 444] [3588.2, 5018.75, 3488.99] [3588.2, 5018.75, 44.99] But I want it of course under each other: Method 1 Method 2 Method 3 3588.2 3588.2 3588.2 5018.75, 44.99 3488.99 5018.75, 5018.75 3488.16 444 -
Django Using Default Form & File Submission with Drag and Drop functionality
I have a django application that allow user to upload their image and then another dialog opens to collect user data related to them. After the dialog form has been submitted, I have added the javascript eventlistener to submit successfully submit the form with data and it redirects to the form's action attribute. I wanna implement the same functionality, if user drop their image in the browser then dialog opens to collect user data, then do the same as above and redirect to the form's action attribute. How can I achieve it? Here is my code #--urls.py from django.urls import path from . import views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('', views.index, name='index'), path('success/', views.success_function, name='success page'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) #--views.py def index(request): form = userForm() return render(request, 'polls/hello_world.html', {'form': form}) def success_function(request): if request.method == 'POST': form = userForm(request.POST, request.FILES) user_files = request.FILES.getlist('django_image_field') if form.is_valid(): images_data = [] for eachfile in user_files: #handle_uploaded_file(eachfile) file_path = file_upload(eachfile) img_details = {'file_path': file_path, 'file_name': eachfile.name} images_data.append(img_details) return render(request, 'polls/success.html', {'data': images_data}) else: print(form.errors) return HttpResponse("Not valid form") else: return HttpResponse("Not a valid method") --under forms.py class NameForm(forms.Form): your_name = forms.CharField(required=False, label='Your name', max_length=100) django_image_field = … -
assign a reserved word of sql as a variable in a sql query
I would like to know how to put a reserved word of sql as a variable in a sql query def requeteDB(sql_request): with connection.cursor() as cursor: cursor.execute(*sql_request) row = cursor.fetchall() return row def query1(choice, limit): return(''' SELECT col1, SUM(col2) as nb as ORDER BY nb %s LIMIT %s ''', [choice, limit]) requeteDB(query1(choice="DESC", limit="5")) > *** django.db.utils.ProgrammingError: ERROR: Type 'nb' does not exist LINE 10: ORDER BY nb 'DESC' ------------------^ -
Django DRF - nested serializer (level>2) does not show up in the response
We have the follwing structure (library->books->pages) the first serializer class Library(serializers.ModelSerializer): books = BookSerializer(many=True) class Meta: model = Library fields = '__all__' @transaction.atomic def create(self, validated_data): # create logic here the second serializer class BookSerializer(serializers.ModelSerializer): results = PageSerializer(many=True, required=False) class Meta: model = Book fields = '__all__' we have an endpoint library/, where we post the payload of the following format { "ref": "43a0c953-1380-43dd-a844-bbb97a325586", "books": [ { "name": "The Jungle Book", "author": "Rudyard Kipling", "pages": [ { "content": "...", "pagenumber": 22 } ] } ] } all the objects are created in the database, but the response does not contain pages key. It looks like this { "id": 27, "ref": "43a0c953-1380-43dd-a844-bbb97a325586", "books": [ { "id": 34, "name": "The Jungle Book", "author": "Rudyard Kipling" } ] } depth attribute does not seem to work. What do I have to do to make pages appear in the responce? -
How to delete UserFollowing based on user_id and following_user_id using Django Rest Framework
Here's the link to the answer of how the following relationship was created in the first place. https://stackoverflow.com/a/58799650/18498343 -
Is there a way that fully managed device under android management api stays enrolled after factory reset?
I enroll the device using qrCode and have not disabled factory reset. But once I factory reset the device, the device no longer stays enrolled and becomes a simple personal phone. Is there a way, the device stays enrolled after factory reset or any soft reset functionality? -
How to return empty queryset from django_filters.FilterSet in API view if querystring hasn't any valid key
I use django-filter package with djangorestframework package for filter objects that return from API view. There are my files: # models.py class Symbol(models.Model): title = models.CharField(max_length=30, verbose_name='title') # serializers.py class SymbolSerializer(serializers.ModelSerializer): class Meta: model = Symbol fields = ('title',) # filters.py class SymbolFilter(django_filters.FilterSet): st = django_filters.CharFilter(method='get_st', label='search') def get_st(self, queryset, field_name, value): return queryset.filter(title__icontains=value) class Meta: model = Symbol # views.py @api_view(['GET']) def symbol_list(request): queryset = Symbol.objects.all() view_filter = APIFilters.APISymbolFilter(request.GET, queryset=queryset) if (view_filter.is_valid() is False) or (not view_filter.qs): return Response(None, status=status.HTTP_404_NOT_FOUND) ser = SymbolSerializer(view_filter.qs, many=True) return Response(ser.data, status=status.HTTP_200_OK) # urls.py from .views import * urlpatterns = [ path('symbol/list/', symbol_list, name='symbol_list'), ] So, If I sent get request to localhost:8000/symbol/list/?st=sometitle all things are good and I will got Symbol objects that have sometitle in there title field. But when I remove st from querystring, django-filter will return all objects in Symbol model. My question is: How Can I return empty queryset if st key isn't in querystring or if filter(title__icontains=value) was empty? -
HeidiSQL is not showing any data even when table size is more than 0B
I have Postgresql Database in production and i'm trying to insert data from my localhost using psycopg2 library. i'm seeing my database through HeidiSQL. But after i finished inserting the data, my HeidiSQL shows that table size increased but when i try to see the data, it shows 0 rows. I have tried to drop all tables and re-migrate and re-insert the data, but still it shows 0 rows even when the table size is not 0 B. I have tried to insert table one by one from the program by comment the other insert and it works. But i still can't understand why i can't see any data when i'm inserting simultaneously -
How to deal with foreign keys from another microservice?
I have 2 microservices: one for subjects and one for questions. Don't ask me why. It has to be like that. So in questions I have this m2m-like model: class QuestionsSubjects(models.Model): question = models.ForeignKey(Question, ...) subject_id = models.PositiveIntegerField() And question model has this property: @property def subjects(self) -> QuerySet[int]: return QuestionsSubjects.objects \ .filter(question=self).values_list('subject_id', flat=True) I don't have Subject model I only have ids coming from frontend. I need to store relations between questions and subjects. But what I have now is not convenient because it's hard to create questions with subjects. For example, I have this QuestionSerializer: class QuestionSerializer(serializers.ModelSerializer): subjects = serializers.ListField(child=serializers.IntegerField()) class Meta: model = Question fields = [ # some other question fields 'subjects', ] def create(self, validated_data: dict[str, Any]) -> Question: subject_ids: list[int] = validated_data.pop('subjects', []) question = Question.objects.create(**validated_data) create_questions_subjects(question, subject_ids) return question def update(self, question: Question, validated_data: dict[str, Any]) -> Question: # delete all existing rows for specific question QuestionsSubjects.objects.filter(question=question).delete() # and recreate them with new subject ids subject_ids: list[int] = validated_data.pop('subjects', []) create_questions_subjects(question, subject_ids) return super().update(question, validated_data) The problem is I'm getting subject ids from client and everytime I need to go through each subject id and create row in QuestionsDirections for each subject with … -
Django +4.1: How to show in templates the message from violation_error_message in UniqueConstraint
I'm lost... In my model in models.py I have class Project(models.Model): ... fields ... ... save ... ... etc ... class Meta: constraints = [ UniqueConstraint( fields=['name', 'owner'], name='unique_name', violation_error_message='my_error_message' ) ] In my class in views.py I have class CreateProject(LoginRequiredMixin, CreateView): form_class = ProjectForm model = Project def form_valid(self, form): return super().form_valid(form) In forms.py I have class ProjectForm(forms.ModelForm): class Meta: model = Project fields = ("name", "description") How do I display the message in violation_error_message in templates when I don't have a unique name for each user (owner field)? -
Is there a way to make this django annotate query more efficient
I'm struggling to make a django query more efficient. It either takes a long time on localhost, times out on my production server, or just gives a 500 on the tiny AWS nano server that I use for testing. What I'm trying to do is find the most "rolled on" charts (these are random tables or random generators), over a period of time. The largest period of time is 12 months. The query looks a bit like this... queryset = Chart.objects.all().filter(diceroll__timestamp__gt=time_delta, diceroll__timestamp__lte=timestamp_now).annotate(num_dicerolls=Count("diceroll")).order_by('-num_dicerolls') The problem is that the longer the period of time, the longer the query takes, so it seems that the massive number of dice rolls is a contributing factor. Each dice roll is logged as its own entry in a DiceRoll table (so Chart is a fk in the DiceRoll table). The only alternative I can think of is a non-django related solution where a completely different database table is used to cache the number of dice rolls per chart for every past month. That would mean that the annotator would have less to count. This is just a guess though, so untested, so before I go down that rabbit hole, I would to know if there is … -
i need a program for every second we need to print a "Hii" stirng using the python language
for every one second we need to greet "Hii" , I want this program in python langugage i need python programm -
Can I delete .env file from server?
I have a Django application where all the secret information (secret key and keys for encryption) are in the .env file as environment variables - I'm using the python-dotenv library. After starting the application, I removed the .env file from the server files and the application continues to work as it should. Can deleting this file cause any problems? Is there any other (or better) way to secure these secrets in a Django application? If it's relevant, I use pythonanywhere.com -
The current path, products/ didn't match any of these
I am watching a Django tutorial from PROGRAMMING WITH MOSH on YouTube however even though my code is exactly the same as shown in the video for some reason I get this message: The current path, products/, didn’t match any of these. I am using python 3.1 and Django 4.1.4, here is my code: PyShop/products/views.py` from django.http import HttpResponse from django.shortcuts import render # URL ----> Uniform resourse locator def index(request): return HttpResponse('Hello world ') PyShop/pyshop/urls.py ` from django.contrib import admin from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), path("products/", include ('products.urls')) PyShop/products/urls.py ` from django.urls import path from . import views urlpatterns = [ path (' ', views.index) ] I was expecting to get a message saying hello world when I type products/ in the search bar. I rewatch the tutorial a couple of times and I am pretty sure that I have the same code as the person on the tutorial ` -
Django in connection with Postgres says settings.DATABASES is improperly configured
I am so new to Django and postgresql. Dajngo made a connection at first step and created my tables, but after that just keep telling 'settings.DATABASES is improperly configured, Please supply the NAME or OPTIONS['service'] value.'. I really don't know what is the issue. I will post some of code related to database. my database is running and I can see my tables there via pgAdmin. Django version is 4.1.4 and psycopg2 version is 2.9.5. My sttings.py POSTGRES_HOST = os.environ.get('POSTGRES_HOST', default="") POSTGRES_DB = os.environ.get('POSTGRES_DB', default="") POSTGRES_USER = os.environ.get('POSTGRES_USER', default="") POSTGRES_PASSWORD = os.environ.get('POSTGRES_PASSWORD', default="") DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': POSTGRES_DB, 'USER': POSTGRES_USER, 'PASSWORD': POSTGRES_PASSWORD, 'HOST': POSTGRES_HOST, 'PORT': 5432, } } My docker-compose.yml version: "3.11" x-service-volumes: &service-volumes - ./:/app/:rw,cached x-database-variables: &database-variables POSTGRES_DB: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres x-app-variables: &app-variables <<: *database-variables POSTGRES_HOST: postgres services: website: image: iranrevolution-website:latest command: python3 manage.py runserver 0.0.0.0:8000 volumes: *service-volumes depends_on: - db_migrate ports: - "8000:8000" db_migrate: image: iranrevolution-website:latest command: python3 manage.py migrate volumes: *service-volumes environment: *app-variables depends_on: - postgres postgres: image: postgres ports: - "5432:5432" environment: *database-variables volumes: - db-data:/var/lib/postgresql/data volumes: db-data: I checked both project and database is running in docker. and database is listening to new connections. I tried to put real … -
Video loading 5 times when changing source with javascript
I'm attempting to change the video being loaded for a hero video based off the screen size. It is successfully changing the video but it is loading the video 5 times. I'm not sure where I'm going wrong. Here's my Javascript <script> var w = window.matchMedia("(max-width: 850px)"); var vid = document.getElementById("vid"); var source = document.createElement("source"); source.id = "hvid"; source.setAttribute("type", "video/mp4"); vid.appendChild(source); if (w.matches) { vid.pause(); source.removeAttribute("src"); source.setAttribute("src", "{% static 'img/bg-mobi-final.mp4' %}"); vid.load(); vid.play(); } else { vid.pause(); source.removeAttribute("src"); source.setAttribute("src", "{% static 'img/final-bg_1.mp4' %}"); vid.load(); vid.play(); } window.addEventListener("resize", function () { var w = window.matchMedia("(max-width: 850px)"); var vid = document.getElementById("vid"); var source = document.getElementById("hvid"); if (w.matches) { vid.pause(); source.src = "{% static 'img/bg-mobi-final.mp4' %}"; vid.load(); vid.play(); } else { vid.pause(); source.src = "{% static 'img/final-bg_1.mp4' %}"; vid.load(); vid.play(); } }); </script> and the html <video autoplay muted id="vid"> </video> I've tried loading the videos from an outside source to see if it is something that Django may be doing and that still resulted in the video being loaded 5 times. -
Django login/authentication system not really working
I'm a newbie in django and I'm having some problems, what I'm trying to do is a simple login system in Django with a custom backend and using postgresql as the main db. The problem is, my authentication and login function is apparently working normally but the user is not actually logged in, I wrote a custom message to let me know when the user is logged in and my index is protected against anonymous user, so I basically can't access. This code from my views.py @login_required(login_url='signin') def index(request): return render(request, 'index.html') def signin(request): now = datetime.now() if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] print(username, password) user = UserBackend.authenticate(UserBackend(), username=username, password=password) if user is not None: login(request, user, backend='core.backends.UserBackend') print('Logged In') #### This print/checking is working fine! return redirect('/') #return render(request, 'index.html') else: messages.info(request, 'Invalid Username or Password! Try again') return redirect("signin") #else: return render(request,'signin.html') #user = auth.authenticate(username=username, password=password) return render(request, 'signin.html') This is my user class from models.py class user(AbstractBaseUser): id = models.AutoField(primary_key=True) username = models.TextField() real_name = models.TextField() email = models.TextField() password = models.TextField() description = models.TextField() last_login = models.DateField() created_at = models.DateField() is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) class Meta: managed = False db_table … -
How to access the field of a model which sits in 2 ForeignKey connections to the model, from where it being accessed?
Question might sound confusing but here is what I want to do. So, I somehow want to access the name of the course from the lesson model to create a file path to save videos class Course(models.Model): name = models.CharField(max_length=80) ... class Section(models.Model): name = models.CharField(max_length=80) course = models.ForeignKey(Course, on_delete=models.CASCADE, related_name='sections') ... class Lesson(models.Model): name = models.CharField(max_length=80) section = models.ForeignKey(Section, on_delete=models.CASCADE) video = models.FileField(upload_to=f'courses/{section.course.name}/{section.name}/') Interpreter does not complain when I want to access the name of a section through this: section.name. But when I try the same approach and try to access the course name section.course.name I get this error: video = models.FileField(upload_to=f'courses/{section.course.name}/{section.name}/') AttributeError: 'ForeignKey' object has no attribute 'course' So what would be the best approach to access the name field of a course model? Thanks in advance!!! -
How to filter data in table based on user selection in form in Django?
I have Data model with records and these records are presented in web page. I have created function which prepares table with records from Data model and returns required structure of these data in pu.html web page. And I would like to filter these data based on user selection in a form on the same webpage. Therefore I created second model Manager_selection where user selection is stored and I get from this model last value based on which data are filtered in my function which prepares table with records. And what I need is to somehow include function for form in Views to be able to save user selection and based on which data will be filtered as my View is based on model Data, but form is based on model Manager_selection. models.py: Data model - includes detail data for each project (date, document_number, amount, project, account, company,...) Projects model - includes data about project (code, mo - project manager, vps - site manager, ...). This model is connected with Data model 1:N connection, so one project can have multiple Data records Employee model - includes first, second name and position - it is connected with Project model 1:N - … -
How to render results from API based on the user's search using Django
As you can see in the picture below I'm trying to have the user search for a given country, start/end date and get the result of "Confirmed Cases" and "Date" back from the API, but I'm not sure how to do it. Image I tried using this API, to fill the drop-down menu of the countries --> https://api.covid19api.com/summary but this is the other API that I have to use but while changing the parameters for the country and dates --> https://api.covid19api.com/country/afghanistan/status/confirmed?from=2020-09-06T00:00:00Z&to=2020-09-11T00:00:00Z Here are snippets of my code: views.py def home(request): # second_response = requests.get('https://api.covid19api.com/country/afghanistan/status/confirmed?from=2020-09-06T00:00:00Z&to=2020-09-11T00:00:00Z').json() second_response = requests.get('https://api.covid19api.com/summary').json() my_list = [] for i in range(0, len(second_response['Countries'])): my_list.append(second_response['Countries'][i]['Country']) if request.method=='POST': selected_country = request.POST['selected_country'] print('here', selected_country) return render(request, 'home.html', {'my_list': my_list}) home.html <div class="container justify-content-center"> <form action="{% url 'home' %}" method="post"> {% csrf_token %} <label for="selected_country" style="margin-right: 5px;"> Select a Country, Start & End Dates : </label> <select name="selected_country" > {% for object in my_list %} <option value="">{{object}}</option> {% endfor %} </select> <label for="startdate"></label> <input type="date" id="startdate"> <label for="enddate"></label> <input type="date" id="enddate"> <input type="submit" value="Search" /> </form> </div> PLUS: when I click on "search" i should get the value of the selected_country because I tried printing it, but it doesn't show for some … -
How can Django keep an API user logged in without a browser or return token?
https://github.com/mugartec/django-ninja-auth/blob/bf36b4583a37213001131678d5ecda07f92ba2f6/ninja_auth/api.py#L33 It doesn't return any token, so how to does it identify them post-login for subsequent requests? -
When deployment I got this error [error] 9#9: *1 connect() failed (111: Connection refused) while connecting to upstream Nginx 502 Bad Gateway
I have a project that contains Django - Docker - Postgresql - Nginx I followed this tutorial for adding SSL to my project using LetsEncrypt Link Before following this tutorial, my project was live on digitalocean succesfully. After that i got nginx 502 gateway error on my browser and when i check the certificate, certificate is verified and my connection is secure. When i check the log of proxy container on terminal i saw the [error] 9#9: *1 connect() failed (111: Connection refused) while connecting to upstream error upstream: uwsgi://my_ip:9000. my docker-compose-prod-yml file: version: "3.9" services: app: build: context: . dockerfile: ./Dockerfile restart: always command: /start environment: - DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY} - DJANGO_ALLOWED_HOSTS=${DOMAIN} depends_on: - postgres proxy: build: context: ./docker/proxy restart: always depends_on: - app ports: - 80:80 - 443:443 volumes: - certbot-web:/vol/www - proxy-dhparams:/vol/proxy - certbot-certs:/etc/letsencrypt environment: - DOMAIN=${DOMAIN} certbot: build: context: ./docker/certbot command: echo "Skipping..." environment: - EMAIL=${ACME_DEFAULT_EMAIL} - DOMAIN=${DOMAIN} env_file: - ./.env volumes: - certbot-web:/vol/www - certbot-certs:/etc/letsencrypt/ depends_on: - proxy postgres: image: "postgres:latest" container_name: postgres_data volumes: - postgres_data:/var/lib/postgresql/data/ environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=te7eyp9cc - POSTGRES_DB=dj-crm-tenant ports: - "54320:5432" volumes: certbot-web: proxy-dhparams: certbot-certs: postgres_data: my defult-ssl-conf.tpl file: server { listen 80; server_name ${DOMAIN} www.${DOMAIN}; location /.well-known/acme-challenge/ { root /vol/www/; } … -
Why does Django randomly break when I use a deleted model in a migration?
I inherited a messy project, so as I've been cleaning up, I've deleted a lot of models. Sometimes, I have to copy date out of the model into another one before deletion. I've been writing migrations that do both. Everything is working fine - sometimes. And seemingly randomly, sometimes it doesn't work. Process: Make the necessary changes to the codebase, including deleting the model and references to it. Create a migration which: copies data out of model deletes the model Here's an example of what such a migration would look like: from django.db import migrations, models def doit(apps, schema_editor): OldModel = apps.get_model("myapp", "OldModel") NewModel = apps.get_model("myapp", "NewModel") for obj in OldModel.objects.all(): ...transform and save data in NewModel... class Migration(migrations.Migration): dependencies = [("myapp", "0001_initial")] operations = [ migrations.RunPython(doit, reverse_code=migrations.RunPython.noop), migrations.DeleteModel(name="OldModel"), ] Sometimes the migration runs as expected. Other times the migration fails with: LookupError: App 'myapp' doesn't have a 'OldModel' model. I cannot find any notable difference between the migrations that work and the migrations that blow up this way. I've had multiple examples of each, and have wracked my brain trying to spot the difference. My understanding is that the apps object passed to your function by the RunPython() method … -
How to remove square brackets when rendering dictionary items in django
I am working on a django project whereby I am saving values to the database of a Model instance. The project is a resume parser which seems to be getting the values as a dictionary. I have succesfully saved the data but when rendering the output does not look good as it renders with the square brackets and quotes. Is there a way I can render them as a list? Here is my models.py: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) avatar = models.ImageField(default='default.jpg', upload_to='profile_images') bio = models.TextField() resume = models.FileField('Upload Resumes', upload_to='resumes/', null=True, blank=True,default='resume.docx') name = models.CharField('Name', max_length=255, null=True, blank=True) email = models.CharField('Email', max_length=255, null=True, blank=True) mobile_number = models.CharField('Mobile Number', max_length=255, null=True, blank=True) education = models.CharField('Education', max_length=255, null=True, blank=True) skills = models.CharField('Skills', max_length=1000, null=True, blank=True) company_name = models.CharField('Company Name', max_length=1000, null=True, blank=True) college_name = models.CharField('College Name', max_length=1000, null=True, blank=True) designation = models.CharField('Designation', max_length=1000, null=True, blank=True) experience = models.CharField('Experience', max_length=1000, null=True, blank=True) total_experience = models.CharField('Total Experience (in Years)', max_length=1000, null=True, blank=True) whatsapp = models.URLField(null=True, blank=True) facebook = models.URLField(null=True, blank=True) twitter = models.URLField(null=True, blank=True) linkedin = models.URLField(null=True, blank=True) languages = models.CharField(max_length=1000, null=True, blank=True) profession = models.CharField(max_length=100, null=True, blank=True) nationality = models.CharField(max_length=100, null=True, blank=True) def __str__(self): return self.user.username My views.py @login_required def myprofile(request, …