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
0
votes
0answers
6 views

django middleware modify response message

I need to write a custom django middleware where i need to modify the response message from the view.Is it possible with process_response method of the middleware something like this class ...
1
vote
0answers
9 views

Django session deletion effects another django application

I have two applications running on the same server with different ports and with their SQLite DB's are also different which is used to store user sessions data. if request.session.exists(...
0
votes
0answers
7 views

Remotely manage the number of objects in a model

Let's say I have a model called Players. I want to limit the amount of players to 20 in one of my Django servers. I also have another, main control panel Django server that would manage all my other ...
0
votes
0answers
7 views

Django Internal Server Error, when DEBUG = False

I have this relatively famous problem but I just can´t found the solution, when my DEBUG = True everything works fine and then I set it to False and it just doesn't work... And I set also the 'ADMINS ...
0
votes
1answer
12 views

Django: Problem with Adding Editing and Deleting Functionality in Django Form with TemplateView

I am learning Django by building an application, called TravelBuddies. It will allow travelers to plan their trip and keep associated travel items (such as bookings, tickets, copy of passport, ...
0
votes
0answers
11 views

Python 3 Django 3.0 Running but not listening or opening port

I am using PyCharm and an instance running in AWS for remote debugging. When I start debugging the server starts and continues to run. However, it is inaccessable and doesn't appear to be grabbing ...
0
votes
0answers
13 views

Hitting 500 error on django with debug=False even with ALLOWED_HOSTS=[“*”]

I am getting 500 errors on every page I try to go with. The only thing that i'm changing is DEBUG to False. Here is my config: SECRET_KEY = os.environ.get("SECRET_KEY", "0$ke!x1bz5cj0mpzo1zfx4omw-...
0
votes
1answer
9 views

django, update modified_at when doing update()

Following field gets updated whenever model_obj.save() happens. modified_at = models.DateTimeField(auto_now=True, db_index=True) However, it is not updated when doing MyModel.objects.filter(id=...
-2
votes
0answers
12 views

Is Django REST framework suppose to be public?

I recently found some security holes in my university website. Among other issues was that, a page for viewing and managing api requests, using Django REST framework was found to be public. There were ...
0
votes
1answer
11 views

django post api through postman

**Hi when I try to hit the post api from postman I am receiving the response from API but the request is not received from postman when I print the request it showing but not the data and i attached ...
-4
votes
0answers
13 views

CSRF verification failed only in production, Django [closed]

{% csrf_token %} is set. Tried @ensure_csrf_cookie as well. code: views.py: https://bpaste.net/show/UANTI template (landing.html): https://bpaste.net/show/P5YJA form_fields.html: https://bpaste....
0
votes
0answers
21 views

django-cacheops… what is the “ops”?

I've searched, but I can't find anything that explains this. I know I'm risking a downvote here, but what is meant by "ops" with django-cacheops? https://github.com/Suor/django-cacheops I would ...
0
votes
3answers
16 views

Structure in Django tutorial does not match match my strucuture

Starting a new project and realized that the structure for tutorial and my structure do not match. It looks like a directory was created for the myproject and a directory AND a file were created for ...
0
votes
2answers
15 views

Invoke function after all methods Django Rest Framework ModelViewSet

I would like to invoke a function after all methods in a ModelViewSet. The function itself will be used as an external event log. So the response from the views would not be modified. I was not able ...
0
votes
1answer
30 views

How to set initial value that is reference to an object

We are trying to set object as an initial value (image, it is a foreign key to an Image). We just cannot make it work, we are always getting NULL/blank value instead. Thanks for any help! from views....
0
votes
0answers
9 views

why home.html (for adding a new post) is not showing the rendered django form with ckeditor toolbar in add new post?

i am integrating some apps to make a bigger project but the problem is when i try insert ckeditor in html login page it is not showing. for this reason i tried to make separate app is to see whats ...
0
votes
1answer
10 views

Fail to load diferente content in modal Table

I Have two bootstrap tables, one of them (table_compras) call a modal (table_modal) depending on the column clicked, but i am having troubles refreshing the content rows in table, here is my code: ...
0
votes
0answers
9 views

Add fields to a form with django at application level

I am using django and I need to use a form that is dynamic, that at the application level the user can add fields to the form. For example, I have a beer and I want to add features, which function ...
0
votes
1answer
16 views

Celery schedule

I have some schedule problem in Celery. The task works, however I want it to run once on Monday, but it runs every minute. My schedule config: CELERY_BEAT_SCHEDULE = { 'kek': { 'task'...
0
votes
1answer
12 views

How to delete 0001_initial.py in Django? Django migrations are not working

I am using Django 2.2 with Python 3.7 on Windows 10. I created a project and then an app. The models.py was populated by using INSPECTDB for an existing Postgres database. I removed the line '...
0
votes
0answers
9 views

Getting PostSyncDb error when I run Python manage.py runserver (Trying to update to DJango 1.9)

I am trying to update my django slowly, I just went up to 1.9 today (from 1.8) and I am running into ImportError: cannot import name post_syncdb. I made sure my signals are imported for my models and ...
0
votes
1answer
11 views

Return more than just the Auth Token with Django Rest + Djoser?

I'm using Django REST along with Djoser as my authentication service. However, when making a post request to the djoser auth endpoints, e.g. .../auth/token/login, the only response I get back is ...
1
vote
1answer
15 views

Pass slug or id on GET request

I'm trying to test an API view for my Django project: BOOK_URL = reverse('api:book') // '/api/book/' book_id = 1 res = APIClient().get(f'BOOK_URL${book_id}/') This works, but as you can see I need ...
0
votes
0answers
12 views

Problem with redirection on save form in UpdateView

I'm using Class Based Views in my project. After create object IdentityDocument in CreateView it redirects to correct Person DetailView (IdentityDocument owner), but after update in UpdateView ...
0
votes
1answer
16 views

The POST method in DJANGO returns “None” when a form is submitted

I have built a small web application that will get the data from a HTML table and dump it into sqlite database. When I use the POST method to capture a particular cell value, it returns none. Could ...
0
votes
1answer
17 views

Django rest framework - Optimizng serialization of nested related field

Given the following models: class Model_A: ... class Model_B: ... class Model_C: model_a = ForeignKey(Model_A, related_name='c_items') model_b = ForeignKey(Model_B) ... And the ...
0
votes
0answers
14 views

registration with username and email, and login with email only

I am creating a login that requests for username and email with Django-rest-auth, the email is key as it will be used to log in to the user. but the username also has its importance in my app as when ...
0
votes
0answers
25 views

Django Form Validation And Google Recaptcha Not Working

I have a form that is not validating phone numbers and emails properly even though I am using PhoneNumberField and EmailField. When a user inputs invalid data, no error messages are showing up such as ...
0
votes
1answer
13 views

Add dynamic attribute to serializer

I'd like to add a dynamic attribute to my serializers whenever they are called. Note that I'm talking about an attribute, not a field. Here's the idea: User call the API Viewset calls the serializer ...
1
vote
1answer
15 views

Django get_or_create not getting data back

i have created a FBV for Modal form (popup) i want to have the same view to handle both create and update, the reason i am using FBV is that am assigning the foreign key through queries rather that ...
0
votes
1answer
25 views

The view didn't return an HttpResponse object. It returned None instead, using Django

So, I am trying to display a form into my html using Django, it has to be a form that creates a new page in the database. I am using ModelForm since I've read is the best way to provide the user with ...
0
votes
0answers
14 views

Python manage.py runserver issuing the no module Error

Trying to runserver but I'm getting this errors Traceback (most recent call last): File "manage.py", line 13, in <module> execute_from_command_line(sys.argv) File "/usr/lib/python2.7/dist-...
0
votes
1answer
21 views

Django - grabbing an additional field from related table

I have the following models: class User(AbstractBaseUser, PermissionsMixin): SUPERVISOR = 1 REVIEWER = 2 VERIFIER = 3 READ_ONLY = 4 USER_TYPE = [ (SUPERVISOR, 'Supervisor')...
0
votes
0answers
7 views

How send a request error inside the save function?

I need to validate the video duration before the video is saved,but he only message error i found is the forms.ValidationError. The upload request is getting error 500 because of the raise. ...
0
votes
1answer
9 views

How to create my own endpoint in Django with rest_framework_json_api?

I am new to Django and need some help to understand! I have been able to create the Api and it works! But ... how do I create an endPoint to do something specific that I want? For example, validate an ...
0
votes
1answer
17 views

Django raising AppRegistryNotReady after update from to 1.9

I have read many similar posts with the same situation and tried a few things suggested if they were at all related. I just updated to Django 1.9 and I received this traceback: Traceback (most recent ...
0
votes
1answer
26 views

How can I modify this JS function so that it runs whenever the field is equal a certain length?

I have a function that currently runs whenever the user clicks/tabs out of the employee_number field. I would like it to run whenever the length of the numbers entered is equal to 6, without having to ...
0
votes
0answers
14 views

Calculate multiple annotated properties based on 2-layer deep one-to-many relationships in Django

I am looking for a more-optimal way to get annotated values on records of a model when in order to calculate those values I must annotate a set of records on the base model, which needs to use values ...
0
votes
0answers
12 views

“Can't connect to local MySQL Server” using SSH tunnel

Starting an SSH tunnel to MySQL so MySQL Workbench can connect to the remote DB using the following command: ssh -L 3306:localhost:3306 <username>@<domain> -N MySQL Workbench is able to ...
1
vote
1answer
20 views

how to check what port django used on a running server? `manage.py runserver 0.0.0.0:<port>`, or through apache/nginx

I need to troubleshot a django app which already running in a server. I'd like to access the APP URL IP:PORT but I don't know what port former developer used to run it. Eg: manage.py runserver 0.0.0.0:...
0
votes
0answers
14 views

Configuring user permissions with django

299/5000 Hi, I wrote an API service with Django. I have authorized the user to list only clients via django admin panel. When I enter the django admin panel with the user name I authorize, there is ...
0
votes
1answer
15 views

How do I prevent a 500 CORS error when attempting to create and download a csv file containing a large data set using python's StreamingHttpResponse?

The function runs and works perfectly fine for a small data set, but for a large data set, the following error is produced: (URL is hidden in the red) A 500 CORS error. As you can see from the code ...
0
votes
1answer
23 views

Django Forms.py Change EmailField Value To Auto Populated value=“{{ user.email }}”

I want my Django form's EmailField to auto populate with the user's email. How does this get accomplished? I am not using models.py with this form. Full Code: https://dpaste.org/4PrR Instead of '...
-1
votes
0answers
12 views

Need advice on SaaS project based on Django [closed]

I need advice: I want to create a Django App SaaS and Im on the point where I create Database Models. But how can I use a database for each customer without duplicate the code? I read a lot about ...
0
votes
1answer
25 views

What is the Django query for the below SQL statement?

There is a simple SQL table with 3 columns: id, sku, last_update and a very simple SQL statement: SELECT DISTINCT sku FROM product_data ORDER BY last_update ASC What would be a django view code for ...
0
votes
0answers
19 views

How to get UpdateView to work with generic FormView

I have a Formview and an UpdateView which are conflicting with each other. They are supposed to work together but not in this way. Whenever I try to use the UpdateView the values get passed through ...
0
votes
1answer
37 views

Django Error -django.db.utils.DataError: value too long for type character varying(1)

I have been trying to do this data migration and i keep getting this error django.db.utils.DataError: value too long for type character varying(1) My goal is to add a row to the User table here is ...
-5
votes
0answers
45 views

Django missing 1 required positional argument “username” [closed]

My error: create_superuser() missing 1 required positional argument: 'username' def create_superuser(self, email, username, password): user = self.create_user( email = self....
0
votes
1answer
30 views

django dynamic custom queryset

I have a table to store view events, that is, if a user views an entity, a record will be stored into that table. This table is represented by a model that has a generic relation, that is, it can be ...
1
vote
1answer
12 views

Change Django Form Attribute on view

I'm using a Django Form with a DatePicker widget. I have to define the Min and Max date of the DatePicker on a class level. I would like to have these two values change when I run my view, otherwise, ...