Questions tagged [django]
Django is a Python-based framework for creating web applications.
323 questions
3
votes
1
answer
667
views
Email verification resend implementation Django
I'm trying to build an email verification for user signup using CreateView. This view check whether the user is a new or already existing inactive user? and resend ...
3
votes
1
answer
227
views
How can I refactor the validation code to minimize it?
I am using Django Rest Framework and below is the code of one of the API Endpoints. The code creates generates the PUBLIC and SECRET Values based on Stellar SDK.
...
3
votes
1
answer
556
views
Storing database references to files/media
This is an extension of this question due to it not covering an important role of my setup that I think needs more attention.
The files are stored on a different server for separation and convenience....
3
votes
1
answer
154
views
Django view and template for a virtual zoo
I have a Django view and template that work together, but I think I probably did things in a crappy way. I basically have many dynamic values that I want to display on the page, and in two different ...
3
votes
2
answers
227
views
Make django, weasyprint code object oriented
Please ignore the comments in the code for the purpose of reviewing. I just require tips on using SOLID principles and how classes can be used in this code.Comments in the code are for mapping the ...
3
votes
1
answer
71
views
Django voting implementation
I am creating a translation application and the users can add new translations to the "core" language, e.g. a Latin translation of the German word, and other users can vote on this translation. A ...
3
votes
1
answer
1k
views
Using a thread to update a table automatically in Django
For my portfolio app using Django I made a thread that pulls out the usd exchange rates for various currencies every 6 hours and updates the database. The program kicks in as soon as the module ...
3
votes
1
answer
161
views
Django module to transform data from database to be displayed in Slickgrid tables
This is a Django tag with 2 classes, but can be viewed as a module:
What does the module do? it loads a database, performs some transformations on the data, returns the output as a dictionary of json ...
3
votes
1
answer
946
views
Web scraping news articles with Beautiful Soup
It's been nearly a year I've been working with C++ and now I am diving in Python and its libraries and frameworks. I am currently creating a website for my portfolio that gathers news articles from a ...
3
votes
1
answer
41
views
Updating multiple membership plan expiration dates at once
I have model action in RequestAdmin like this:
...
3
votes
1
answer
60
views
Optimisation of a views.py for survey application
I have developed a small survey application in Django 1.6.2 which requires that the participants fill out a number of questions over 27 pages using a ...
3
votes
1
answer
45
views
URL selection function that is designed to randomly assign users to different surveys until full
I'm trying to condense some of my code to make it more maintainable and to learn a few new tricks.
Below is a Python 2.7 / Django 1.6 function which is designed to assign users to one of three ...
3
votes
2
answers
2k
views
Django ListView with MySQL query for the queryset
(Note: Even if you don't know Django, it's probably the query that needs work anyway, so you probably don't need to know Django/Python)
I have a ListView that ...
3
votes
1
answer
2k
views
jQuery slider in a Python/Django SessionWizardView
I have created a Data Verification page in a Django SessionWizardView where a user has to confirm an earlier submitted rating of an image using a jQuery UI Slider (-...
3
votes
2
answers
112
views
Optimising and condensing Django View Class
This follows on from a previous question I asked which was of huge help to me. I am still only learning Python and Django and I would love to learn how to code better.
The below is a ...
3
votes
1
answer
1k
views
i18n translator using Jinja2
I'm learning to Jinja2 and what's important in this case isn't speed but i18n translations and functionality. With Python 2.7, Jinja2 and not Django seems to preferred way to go, so I'm rewriting much ...
3
votes
1
answer
56
views
Scraping weather conditions for mountain peeks
I have built a website in Django in which I tried for the first time to create a complex app. It's an app that scrapes weather conditions on a peak in mountains, which are 17. I wanted to show a ...
3
votes
1
answer
199
views
Python REST API and Mongo - Aggregation Pipeline/Stage classes
This has been my approach for "simplifying" MongoDB aggregation queries in a pythonic syntax - was my intent, at the very least:
...
3
votes
1
answer
85
views
Speed up Python Script to populate MongoDB
How would I go about making this script much faster? Essentially it reads from a file and the slowest part is populating the words. In the words file there are over 100k words and I was looking for a ...
3
votes
1
answer
3k
views
Custom login class based view
I am trying to fight my way trough self learning Django (as this is a beast on its own) and Python (just for coding <3) in combination with nginx, PostgreSQL and gunicorn - I have some limited ...
3
votes
1
answer
784
views
Django post function : split method is a good way?
I'm working on my Django project and I'm trying to develop this one with 'Class Based View' (CBV) method in order to keep the code maintainable.
I have a class ...
3
votes
1
answer
60
views
Ordering colors into a multidimensional list
The code below works fine but seems really hard coded and I feel like I over-complicated the way it should be, I have a list containing hex and non-hex colors.
example : ...
3
votes
1
answer
53
views
Returning information about searches performed by a user
I have this simple piece of code from my django project. I feel that it isn't very well written.
Maybe it possible to write this simple function in a better way? Maybe could you give me any advices ...
3
votes
1
answer
833
views
Backup MySQL database for Django projects
I have a usual Django application with a single MySQL database. The purpose of this shell script is to backup a MySQL database every midnight by crontab and check that everything goes right.
The ...
3
votes
1
answer
63
views
Profile creation
I was creating a view with Django that would create a user profile for a website and this is what I came up with:
...
3
votes
2
answers
236
views
Object oriented architecture with an image processing code
This code is python 3X code (in django).
It takes an instance of user entry, and process images: it creates a resized version of original image, 2 thumbs, saves all, and update instance fields to ...
3
votes
1
answer
2k
views
Serving a growing audio file with Django
I would like to serve a growing audio file (raw PCM audio for now) with the possibility of seeking. I tried to manage it with Apache, but in the end wasn't able to achieve what I wanted.
Now I ...
3
votes
2
answers
42
views
Fetching BasicInfo, BillingInfo, and DocumentInfo objects
The repetition is super obvious here. How can I rewrite this code? I need one base method in which I pass a Django model, to call objects.filter, but I can't figure ...
3
votes
1
answer
731
views
Try to implement comments tree for Django
I've tried to create an implementation of a tree for comments. I want use it in Django to store comments. Please tell me how to implement it much simpler, without recursion, to find child nodes.
<...
3
votes
2
answers
2k
views
Django class-based generic views - am I doing it right?
I am working on a simple "to do list" app in Django (two models: List and Item). I'm trying to learn and make use of class-...
3
votes
1
answer
638
views
Storing folders of list of records in Google Drive
I've written a script using the Django ORM to store 'configuration settings' and interacting with the Google Drive API and another API. The script creates a base project folder and subfolders in ...
3
votes
1
answer
311
views
Am I being too redundant in this Django view (or can I reduce the repetition in my code)?
I'm new to Django and learning my ways around it. I'm writing a fake basic CRUD app to get me started. In the following code I pretty much copy and paste the same code four times with minor ...
3
votes
1
answer
129
views
Django User Model to authenticate using email address and password
This is my second Django project for an actual client and I want some review on one of my important models.
This model will be responsible for authenticating users using their E-Mail Addresses and ...
3
votes
1
answer
392
views
Node backend to run user-submitted code in a virtual machine
As per the title, I'm making a webapp that is intended to use as a JS exercise platform. Problems are shown to users, they submit code, that code is run against a few test cases, and a report of the ...
3
votes
1
answer
68
views
Find best candidates in efficient way, Django
I'm beginner in django and python. I have models :
...
3
votes
1
answer
546
views
eLearning webapp made with Django
I've been working on probably my biggest project yet, and I'd like you guys to give me some feedback on the code I wrote so far.
It's an eLearning app which offers users a host of functionalities to ...
3
votes
1
answer
61
views
Script that saving most relevant Youtube video for each database object
Due to the tightened Youtube API daily quota (that allows to use only ~ 98 search requests per project daily) I've implemented a multi-project system. For this to work you need to create a project/...
3
votes
1
answer
3k
views
Convert text file to html?
I have a script that converts a text file to html. The text file is an output of a program (needle). The function takes the text file as an input. I am aware the script is awful. I use this function ...
3
votes
1
answer
2k
views
Exporting data from PostgreSQL as CSV to S3 bucket
I have a general question regarding DRY. As you can see there are several parts such as io.StringIO(), csv.writer, ...
3
votes
1
answer
76
views
Two cases for indicating consent for a ticket
I have two cases here:
the person who ordered a ticket clicks on "Permission" and the OrderConsentUpdate View updates the database.
is the attendee him- or herself ...
3
votes
2
answers
2k
views
JWT authentication between Django and ReactJS
I am currently using Django (2.1) to build an API, and I have added djangorestframework-jwt to manage JWT.
Here is the configuration:
...
3
votes
1
answer
2k
views
Django REST Framework - PDF Generator
I created a new endpoint for an API (Django REST Framework) that generates a PDF from an HTML template. I follow the example from the plugin django-easy-pdf.
It's working, but I would like to improve ...
3
votes
1
answer
2k
views
Using mocking to test that a Django view renders as expected
I have a Django view that ends with this...
return render(request, 'define/see_all.html', context)
I have mocked the render function and
...
3
votes
1
answer
3k
views
simple form validation
i've just started to learn python /django ..
im coming from php world ...i mostly struggle with None values which are new to me .. in php i mostly did my boll checking with true/false but in python ...
3
votes
1
answer
112
views
Mapping different classes to the same database table
I have several very similar subclasses that I (think I) want to be stored in the same database table. Most of the fields are identical, with each subclass adding 1 or 2 custom fields. My code is using ...
3
votes
1
answer
889
views
Transaction.atomic with continuations
I have a view that looks like this:
...
3
votes
1
answer
557
views
Mobile content delivery system
For flexing my newly acquired Django & Python muscles, I have set up a mobile content delivery system via Wap Push (Ringtones, wallpapers, etc).
The idea is that a keyword comes in from an sms ...
3
votes
0
answers
306
views
Django form for product stock, where products from the same batch must be merged
Here is the context first. I have a 'Stock' table, in which I record all the stocks with as information: the product, the ...
3
votes
0
answers
49
views
Logical next step in Django newsfeed web app
I'm hoping to get feedback on my current code from someone more experienced in Django, and in the concepts I'm trying to implement. Let me preface by saying that I am a novice to Django. This is my ...
3
votes
0
answers
54
views
Handling System Check message identifiers with Django
Django implements a System Check framework that enables apps to perform checks on settings, runtime, etc. When creating an app, one can plug checks with the framework by following some requirements, ...