Questions tagged [django]

Django is a Python-based framework for creating web applications.

Filter by
Sorted by
Tagged with
1
vote
0answers
8 views

Django: View method that outputs large context data into an html dashboard template

I'm a beginner in Django3 and just wrote an overview function to pass on some data to the template in a context variable. I am definitely passing a lot more than I should as I only need only a few ...
13
votes
0answers
864 views

Django on virtual machine - watching changes in static files and autocompiling LESS without inotify

I'm setting up a Django development environment using Vagrant to run an Ubuntu virtual machine on VirtualBox. As this is a student project run mostly by very amateur coders and I want everyone to be ...
5
votes
1answer
46 views

Twitter contact scraper with Tweepy & Django

I created a project for academic purposes that works on Twitter data. It should: Get all friends and follows of the user Store them in MongoDB Display them in a table I'm using django + plain HTML, ...
1
vote
0answers
36 views

List some things that to make it less verbose and more robust

I am quite new in django forms. I am woking on problem where in function name generate_outage_form passed two parameters name settings and segment Now I have to make function less verbose and more ...
1
vote
1answer
37 views

Test django URLs

I started learning Django and now I want to write some tests for my application. After reading some blog posts and watching youtube tutorials I wrote tests for URLs. Look at below. urls.py ...
6
votes
0answers
34 views

Xero API Client in Django

I'm not actually that new to writing Python. But I've no formal training and have only learnt to build applications to solve problems for my job out of necessity. Starting to bring my existing skills ...
2
votes
0answers
38 views

Model and form validation in class based view

In an app which it is possible to transfer money between accounts I have the following logic: View: ...
2
votes
1answer
35 views

Keeping history of Django model (by using memoization?)

I'm working on a Django project for which I'll need to store the historic information of many models. So far, I'm using the following strategy: Memoize the relevant values in ...
3
votes
0answers
27 views

Command Line Utility for Starting Django Projects and Apps with Custom Files

What I'm Doing I'm writing a command line utility for starting Django projects and apps with custom files. The custom files build upon what Django offers, to make sure things like a custom auth user ...
1
vote
0answers
21 views

Disabling the delete() method in Django managers and querysets

I had problems with related objects not deleted when deleting objects in bulk in Django, so I disabled the delete() method in Django managers and querysets. I also ...
1
vote
0answers
13 views

How to eliminate repetitive serializers and API Viewsets in Django Rest Framework

I built an backend using Django and the django-rest-framework and realized that a lot of the code snippets (mainly classes) are similar. Is there any better way? I tried to wrap them into a very ...
3
votes
1answer
46 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 ...
1
vote
0answers
41 views

Limit choices for Django admin filter_horizontal interface

The Django ModelAdmin offers a filter_horizontal (or filter_vertical) interface for many-to-many relations, which allows the ...
8
votes
1answer
2k views

Django shopping cart, and testing

For an e-commerce web application I have written a shopping cart, and some tests for it. I have used a course on Lynda.com, on building an e-commerce website, as inspiration on how to build the ...
2
votes
1answer
38 views

Custom model to count user interaction in application

In language dictionary application users can add new words and do other staff with this word such as adding additional information to the word (description, etymology, speech parts, noun class etc.) I'...
3
votes
1answer
96 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: ...
1
vote
1answer
53 views

Best practice for URL's architectural Design in Django [closed]

I have been designing websites with Django for a while and I have also designed various sites. But here is a question that comes to mind at the beginning of any new project: What is the best URLs ...
3
votes
2answers
95 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 ...
0
votes
1answer
104 views

changing from function based view to class based view in Django [closed]

This is my attempt to convert my password reset function based view to a class based view. Please suggest improvements. This is my function based view ...
3
votes
0answers
82 views

Product inventory database with attributes and variants

I have design a model for product apps. This is the first time I am trying to create a product's database schema and then model it in Django. My code handles the following: A product type can have ...
4
votes
1answer
117 views

Use django engine to fill in a .html file on storage (no template) and use weasyPrint to convert it to PDF

I 'm new here. I wrote the following django code. I 'm opening, closing files here and saving them temporarily and deleting them. I tried to use Python's tempfile and was getting Permission Error and ...
0
votes
0answers
30 views

Customizing Django built-in views such as LoginView

Which way is preferred to customize Django built-in views such as LoginView: Define a line in urls.py: ...
1
vote
1answer
37 views

Statistics function

I have created a database using Django. I have a small statistics page as shown below. Can I improve this code? View file ...
1
vote
0answers
180 views

One form for multiple models in Django

I must allow user to add city, state and country if it is not already present in the drop-down. Then I must create the respective model instances and then update the city in the userprofile. The below ...
2
votes
1answer
2k views

Django Model field naming convention for lookup tables

I'm currently in the process of refactoring a Django app to use Django REST Framework. Within the existing code there are 15 models for lookup tables. The structure of each model is as follows (using ...
1
vote
0answers
11 views

normalizing django models

i try to make an app for a mobile store ...
1
vote
1answer
47 views

Am I dynamic filtering correctly in Django?

I needed a way to get URL parameters and put them and their values into a query set's .filter() if they exist. After a day of piecing together information from the ...
1
vote
0answers
28 views

Modelling articals and authors in Django

I need to understand if the way I am modelling data in a Django application is correct. The idea is of a news site that has sources, authors and articles. I want: ...
3
votes
1answer
53 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 ...
4
votes
1answer
87 views

Python/Django Class based saving

I'm creating multiple Django apps with vote possibilities, so I made an app vote to handle all this votes. In my templates I'm including an ajax-function named <...
3
votes
1answer
40 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
0answers
22 views

Django migration script to add metadata

I made a simple django migration that adds two field to our Invoices model : first_payment and first_paying_month. ...
5
votes
2answers
6k views

Model design for Online Food order app

I have been trying to develop online food order application. I have taken the concept of zomato.com where a user or say owner registers his/her restaurant. After adding the restaurant, an executive ...
2
votes
1answer
46 views

My Django custom user model

I followed a video on YouTube to create a custom user model, this is my attempt: ...
16
votes
1answer
7k views

Django Rest Framework - add/remove to a list

I have a model Collection which has a many to many relation to a model Item. I want to be able to add or remove items to this collection using Django Rest Framework. Option1 - make an action: ...
2
votes
0answers
16 views

Representing LXC component configuration in django

I want to represent components of LXC in django; so I defined them in models: Container, Network, Profile and Devices where each one of them have a set of attributs, but when it comes to representing ...
17
votes
2answers
12k views

Django Rest Framework - ManyToMany relationship through intermediate model

I'm new to Django and have just started to learn the basics. I have some questions about how to structure the code, how relationships should be written, and where the business logic should live. I ...
1
vote
0answers
114 views

two foreign keys in one django model [closed]

I'm working on a project the scenario: teacher model then is the teacher has not a profile the institute which working at will upload the courses does this is written the way I have tried in the ...
1
vote
1answer
29 views
0
votes
0answers
26 views

Django model manager improvments

I'm trying to get a computed field at my Project model. It should calculate all foreign key data specific field. At first, I created a model property with a ...
0
votes
0answers
262 views

Django auditing fields created_by, created_at, etc

I wanted to add auditing fields to a model in Django and they would take care of themselves. The fields would be: created_by created_at modified_by modified_at I want to add new columns to existing ...
2
votes
1answer
54 views

Speed up Django migration that adds two fields into one

Currently trying to migrate two fields of information into one field. We have many, many objects to go through and it takes roughly 12 minutes to loop through all the objects. That would mean the ...
2
votes
1answer
41 views

Backend for chore management app

This is my first go at Django, so I'm looking first to learn how to make this more idiomatic. Also, is there a better way to set up my tests? To my HTTP status codes make sense? chores/tests.py <...
2
votes
0answers
92 views

Django add comment to article

I have recently finished a "django for beginners" book that ended with creating a small articles site. The last chapter adds a Comment model which is linked to <...
1
vote
0answers
31 views

Document storage models and Django Unit Testing

My question is about proper testing procedures for Django models. The project is for a startup building a very basic HR system due to excel sheet data integrity problems. I am trying to figure out the ...
4
votes
1answer
268 views

Tournament Management model

I'm creating tournament management web-app using wagtail and after searching for different solutions on the Internet came to the following: ...
3
votes
1answer
72 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 ...
2
votes
0answers
32 views

Django View tests [closed]

I am working my way through a Django book and part of that covers the test cases. In the current chapter I have the following code form the start of the test cases but some of it feels like it ...
4
votes
0answers
54 views

Download Fasta protein sequences as a file from the selected categories

I have the following function in Django to download the Fasta sequences (protein) through the selected categories as a file. This works well. I would like to improve the following script. ...

1
2 3 4 5
7