I have a very basic Django instance set up on a RPi model 3. Important as this may indeed be the issue. I'm using Django 3.2, Python 3.7, Mod_WSGI, compiled from source against this version of python and Apache2, installed …
I am having a problem around the Class Based Views in Django. I need to create JSON responses, instead of rendering to a template. class AllItem(ListView): model = MyModel context_object_name = 'items' template_name = 'mymodel/index.html' I also have a …
I added 10 tasks in celery process. It picks one by one (default celery process). After the completion of first task it picks the second task received and executed . Those tasks are not depending on each other. so I …
I have this: user = request.user notifications = Notification.objects.filter(user=user) budget = Budget.objects.filter(user=user) Is there a way to get this data into one query? I was looking into a Subquery or a join query, but I don't know if it …
I need to replace _points property by annotation so that I have the opportunity to sort entries in the Django admin panel by this value. My model: class CustomUser(models.Model): inviter = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True) @property def _points(self): res = …
I have a serializer as follow: class MySerializer(serializers.ModelSerializer): """ Serializer for mymodel """ version = VersionSerializer() device = DeviceSerializer() camera = CameraSerializer(many=True) My code needs to be able to create instance of mymodel knowing only one field on my …
I am a student who is learning Django. Code created in view to float an optionless product. I want to change this to a template tag and print out p-tags only for products without options, how can I change it? …
I'm having a problem with the debugger in Django (which I've run both by pressing the green arrow as well as F5). I've set a number of breakpoints on the URLs and the Views, and the debugger stops on the …
How customize the admin dashboard for a specific model in Django? I have some models. I want to add a JS or CSS file in the admin dashboard when I add an object?
I am currently working on a project in which we can make html table with the backend data(For more instance you can check the below given link ). I have made some try to make its model but unable to …
This is my view.py file class UploadTemplateView(TemplateView): template_name = 'reports/from_file.html' This is my urls.py file urlpatterns = [ path('save/', create_report_view, name='create-report'), path('', ReportListView.as_view(), name='main'), path('from_file/', UploadTemplateView.as_view(), name='form-file'), path('<pk>/', ReportDetailView.as_view(), name='detail'), path('upload/', csv_upload_view, name='upload'), path('<pk>/pdf/', render_pdf_view, name='pdf'), ] When …
I am creating a web-app using the django + react + nginx + docker tech-stack. I can successfully serve my django REST API, admin panel and its static files using nginx but cannot serve the react app after build. I …
Future<List> fetchGraduates() async { var response = await http.get( Uri.parse('http://127.0.0.1:8000/graduates/image_api/A/ur4444/09')); var response2=await http.get( Uri.parse('http://127.0.0.1:8000/graduates/student_api/A/ur4444/09')); Map<String, dynamic> studentData = jsonDecode(response.body); Map<String, dynamic> imageData = jsonDecode(response2.body); Map<String, dynamic> data = { 'id': studentData['student'], 'first_name': studentData['first_name'], 'middle_name': studentData['middle_name'], 'last_name': studentData['last_name'], 'image': imageData['image'], 'institution': …
How to use serializer field in DRF models.py class User(models.Model): id = models.AutoField(primary_key=True) first_name = models.CharField(max_length=255, null=True, unique=True) birthdate = models.DateField(null=True, blank=False) gender_choice = [ ('male','male'), ('female','female') ] gender = models.CharField(max_length=255, choices=gender_choice, default='male', null=True) the rest ans is in …
I am trying to create a custom Limit and Offset Paginator but first page starts from zero which I don't know why!. The offset limit is set to 1 but within url it starts from 0, what I want is …
In my Django project I have an .env file which holds my DJANGO_SECRET_KEY environment variable: export DJANGO_SECRET_KEY=dummysecretkey123 I added a reference to the .env file in my .gitignore file before I initialized the repo, so the SECRET_KEY should not …
I have tried to solve this issue for at least 8 hours and I am probably missing something very simple. But since I am very new to programming I want to reach out for a little help. I am working …
Is there a way to use the wrappers provided by Django to send signed or even encrypted emails? We use S/MIME in our company and it's required that all mails are signed. I currently send emails via SendGrid: …
I have the following page right now which is using django form with 3 different models and they are all linked upon saving. Image:Page shown upon adding new device But if i add another module and save. …
I'm trying to send a request from react to django that has the following body: { "category":"string" } I send the request from react like this: axiosInstance .get(`answers/`, { category:currentQuiz }).then((res) => { console.log(res.data) }) .catch((function (error) { console.log(error) …