Questions tagged [django]

Django is an open-source server-side web application framework, written in Python. It is designed to reduce the effort required to create complex data-driven websites and web applications, with a special focus on less code, no-redundancy and being more explicit than implicit.

Filter by
Sorted by
Tagged with
-1
votes
0answers
4 views

Session-django for access username from mysql database

I want to access mysql database of django and by taking username from database I want to create username's directory on s3 and by using django-sessions..how to do this?
-1
votes
0answers
6 views

can one have multiple html files in a single template directory in django?

Directory structure of my project, here I have a templates directory with two other directories home and diagnosis each directory having its a respective HTML file. So I want to know if that's the ...
0
votes
0answers
6 views

Javascript not working in Bootstrap Carousel [Django Template]

I am working on Django template. All the path of the extended HTML files path are correct and working. My dashboard.html is: {% extends "./base.html" %} {% block content %} <style type="text/css"&...
0
votes
0answers
6 views

Do I have to clean form data with no inputs?

I currently have a form submission wiht only a button thats posting to my backend to perform API calls. The form does not have any data being submitted other than the name of the name of the button to ...
0
votes
0answers
10 views

Unable to access document from mongo collection using pymodm in Django shell

Here is my Model: class Member(MongoModel): first_name = fields.CharField(required=True, max_length=200) last_name = fields.CharField(required=True, max_length=200) Here is Data in the mongo ...
0
votes
0answers
12 views

Django forms - how to add labels inside boxes?

I have simple django- form: class ContactUsForm(forms.ModelForm): class Meta: model = Contact fields = ('subject', 'email', 'message') widgets = {'time': forms.HiddenInput(...
0
votes
1answer
18 views

Auto date with read only mode in Django

def __init__(self, *args, **kwargs): #now = datetime.now() super(TestForm, self).__init__(*args, **kwargs) self.fields['training_date']=datetime.date.today How can we get auto ...
0
votes
1answer
40 views

Django equivalent of SELECT * GROUP BY in MySQL

I'm having troubles using .annotate() and .aggregate() in Django ORM. My table structure: ----------------------------------------------------- | id group_id date_time | ...
0
votes
1answer
16 views

Django create path to an image file

I have a normal app that has a directory structure similar to the following: ...static/ Training/ css/ img/ js/ ...templates/ .... Within one of my ...
-3
votes
0answers
14 views

django setup is not sefine

File "populate.py", line 4, in django.setup() File "C:\Users\hp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django__init__.py", line 19, in setup configure_logging(settings....
0
votes
0answers
17 views

Django i18n issue on heroku

I am developing a Django web application and deploy this application to heroku. I use i18n to implement multi-language function. this is my po file /locale/zh_hant/LC_MESSAGES/django.po #: lib/...
0
votes
1answer
14 views

Django daphne asgi: Django can only handle ASGI/HTTP connections, not websocket

This is really frustrating, I did set everything up according to the documentation, but daphne keeps throwing an error when I try to run it independently, it does work correctly when I use python ...
0
votes
1answer
7 views

After running inspectdb for POSTGIS DB, python manage.py runserver gives error (Django-2.2)

Running: python manage.py inspectdb --database=geoserver > map/models.py After: python manage.py runserver gives below errors: Watching for file changes with StatReloader Exception in thread ...
-1
votes
0answers
13 views

django template loading takes time

i made an app in django which shows data taking it from various sources like excel, sql and web scrapping. everything is working fine except the time to load the webpage. i need to optimize so that ...
1
vote
3answers
35 views

Unable to set background image in Django

So I have a base.html file, to which I am trying to add a background image. This base.html file is inherited in all other system files, and I am hoping that adding the background image to base.html ...
0
votes
1answer
33 views

How to add variables inside the for loop of Jinja python

I am trying to loop over a product list{more so a queryset} in django using for loop, by adding the range of products The following code works when printed out in cmd prompt for card in allproduct[...
0
votes
1answer
14 views

Save reverse Foreign Key in Django CreateView

I have these 2 models: class Company(models.Model): ... contact_person = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, verbose_name=_("Contact person")) .....
0
votes
1answer
22 views

Django REST Framework - serializer users

I would like to add new offer using username instead of userID. Could you please advise how this should be managed with user_receiver? models.py User = get_user_model() class Offer(models.Model):...
1
vote
1answer
27 views

TypeError at /users/sigup create_user() takes from 2 to 4 positional arguments but 5 were given

My models has username, birthdate, language, curreny, etc... i make guest need to fill there username, email, password (required), and birthdate(optional) when they try to sign up. but error occur. ...
1
vote
0answers
12 views

form method clean_field not working properly during testing

I have a little project where users can make posts. Posts are not published by default (e.g. status is 'pre-moderation'), but if a user is in a specific group, their post status will be automatically ...
0
votes
2answers
28 views

manage.py (python manage.py makemigrations) Error

So i am new to Python and Django and following a tutorial by Mr. Vitor Freitas link: https://simpleisbetterthancomplex.com/series/2017/09/11/a-complete-beginners-guide-to-django-part-2.html I copied ...
-2
votes
0answers
19 views

Best API Gateway framework? [closed]

I have built my microservice in Django and deployed in Heroku. I also built an API Gateway in Django but it was an overkill and increased latency. Which is the best framework I can use either on ...
0
votes
0answers
22 views

passing parameters from models

I have this model where I upload a file and save it to s3 . Here is the model. class ExcelFiles(models.Model): PLAN_CHOICES = ( ('x1', 'x1'), ('x2', 'x2'), ('x3', 'x3') ...
0
votes
4answers
47 views

Is Docker an alternative for 'virtualenv' while develping Django project?

A virtual environment is required when creating an application and now I am using 'virtualenv' for creating a virtual environment while developing my Django application. I heard of Docker about its ...
0
votes
0answers
8 views

djangomultimodelform with Inlineform using django-multform package

I have a problem with handling the Updateview in django. My design contains 2 models and one Inlineformset. This view will be added with more models and inlineformsets if this works. My createview ...
0
votes
1answer
28 views

How to write python code in HTML in Django?

I need to create a path in an HTML code that is used to generate a download link. {% for data in all_data %} {% path_zip = '/home/harish/Desktop/cvision/users_output_files/{0}.zip'.format(data....
0
votes
0answers
8 views

Best way to make admin site work in apps where USERNAME_FIELD is email?

I'm writing a Django app where users sign up and login with their emails rather than usernames. At first, I just changed the USERNAME_FIELD and set username=None on the Custom User Model. But then I ...
0
votes
1answer
23 views

Issue with Saving Data into Database in Django using Instance

My Code is working but not saving into Database. I will like to know where the issue is coming from. However, I have tired my best in checking for the error. I am getting success message after ...
1
vote
2answers
27 views

How to call view in another app using template tags in django?

I am Getting an error Reverse for 'question_list' not found. 'question_list' is not a valid view function or pattern name. after using the template tag 'collab_app:question_list' in template. home....
1
vote
2answers
34 views

Matching either pattern with re_path in Django 3.0

I'm struggling to figure out how to use a regex with re_path in Django to match either of a set of patterns. I want to match /bucket/, /buckets/, /pail/, or /pails to a single view. In my primary ...
0
votes
1answer
13 views

Error upon submitting empty forms in Django

I have a webpage with two forms, form1 and form2. Upon submitting empty forms, I am getting errors 1)MultiValueDictKeyError at /profiles/adminKaLogin/ 2)invalid literal for int() with base 10 for ...
0
votes
1answer
18 views

Identity error at attemt_myuser.email.UNIQUE constraint failed in django project

enter code here #This is my models .py : 'like so' while post operation through POSTMAN im getting error. :connection error after that again hitting POST button data is getting and access token ...
1
vote
1answer
17 views

how to make horizontal product list view in django template

how to make horizontal product list view in django template you can take a look at my product list image here, 1: https://i.stack.imgur.com/b6ZBH.png views.py class ProductView(ListView): ...
1
vote
1answer
24 views

Pass variable from one method to another in python/django

I want to pass variable from details method to downloader method and perform operations.I tried several methods but not working Views.py from django.shortcuts import render import pytube from ....
0
votes
0answers
8 views

Django formset_factory with extra parameter

I want to use formset_factory to allow user add multiple products with on button "Add to cart". forms.py: class CartAddItemForm2(forms.Form): item_id = forms.IntegerField() quantity = forms....
0
votes
1answer
14 views

How can I access ForeignKey model attributes in Angular using serialized data from Django

I am using Angular 8 and Django 3. I want to create a page for a Restaurant that shows all of the Recipes that the Restaurant has. I have a Restaurant model and a Recipe model with ForeignKey relation ...
0
votes
1answer
26 views

Is there anyway to use a text editor in django template to let user create and add code to a python file? [closed]

Is there any way to use a text editor in html template to let user write code in front end, then save it as python file in the database. I am using django framework and mongodb.
0
votes
0answers
25 views

Django signals post_save update Related objects [duplicate]

When the student enrollment record (discount type) is updated the student discount (discount type) is also updated, but what should i do if i want to update the student enrollment record (discount ...
0
votes
0answers
17 views

How to use subquery or stored procedure in a field in the Django model

I am trying to insert a data where the value of the field will be the maximum value + 1. INSERT INTO model (count) VALUES ((SELECT count + 1 FROM model)) How to represent this in the django model? ...
-1
votes
0answers
12 views

How to execute a Celery task on a date entered by the use [duplicate]

I need to execute the following task on a date that the user defined in the registry, the date was captured in an APIView of Django Rest Framework. @task(bind=True) def expiration_quote(quote, ...
-1
votes
0answers
12 views

How to display all modelForm to a Classed Based Detail View

I have been working on this project for a while now but now I am stuck and can't seems to move any further. The issue is I have 4 modelForm I will like to display in a detail view. I have been able to ...
0
votes
0answers
17 views

Django queryset for intersecting ManyToMany relations fields

I have a difficult problem, I'm trying to select models related to each other with ManyToMany relations, depending on the intersection of the models present on each ManyToMany fields. I tried to ...
0
votes
2answers
24 views

Django: too many values to unpack (expected 2)

I am new in Django. In my Django view.py, I have following get method: customer_list = Customer.objects.filter(CustId = '1001') and it returns result. When I substitute with a String like following: ...
0
votes
1answer
16 views

Django signals how properly connect sender with receiver

I faced with problem while trying to play with django signals. I have a project with following structure authexample manage.py posts #django app func.py #here is sender and receiver logic is ...
0
votes
0answers
18 views

How can I integrate Behance social authentication with Django (Python)?

I am developing a website using Django, I have a task to make users can register and login with their Behance accounts. I saw some libraries like 'django-social-auth' and 'python-social-auth' and it ...
0
votes
0answers
13 views

Django - Dynamic Tables - Add rows and columns

I am learning Django. Are there tutorials on how I can add additional columns to a database when the users clicks "Add Columns".
2
votes
2answers
21 views

Returning a list with python magic methods in django models.py

I needed to select multiple items in a models.py (subjects app) which is linked with ForeignKey to another models.py (tutors). I get an error while trying to add items to the database after selecting ...
1
vote
0answers
21 views

Importing data in database using django

I have the resource file look like this. class UmuryangoResource(resources.ModelResource): cell = fields.Field(column_name='cell', attribute='cell',widget=ForeignKeyWidget(...
2
votes
0answers
26 views

Order queryset filter in django using orderby and supplying a function

I am trying to return some locations from my sql db, ordered by distance from my current long lat. I have built an external function that takes my long/lat and somewhere else's long/lat and returns a ...
0
votes
1answer
15 views

Django forms styling input field for login page

I am working with Django templets and I am trying to create a beautiful login page. I want to use this snippet to beautify my login page input fields. <div class="form-label-group"> ...