Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How should I model data in django when datasource is grpc instead of db?
My friends and I are building a website and we decided to separate the server into an api layer and backend service ( in case we want to switch to C++ in the future). Frontend will be React. For the REST api layer, I want to use Django but I'm really just making use of its url routing and REST functionalities (django-rest-framework). And pretty much all the data will be backed by grpc at this stage. What's the best design for my data structures in django, should I forget about the models in django and just write my own class for each data type, and use custom serializer still use models but make its data somehow sourced from grpc ( not sure if there's such thing) -
Django form unknown fields error for forms.py
. i have used the debug tool on my vscode to debug the forms.py and my views.py. it returns this. Exception has occurred: ImproperlyConfigured Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings this is the error i get when i run manage.py runserver Exception in thread django-main-thread: Traceback (most recent call last): File "c:\users\user\appdata\local\programs\python\python37\lib\threading.py", line 926, in _bootstrap_inner self.run() File "c:\users\user\appdata\local\programs\python\python37\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run self.check(display_num_errors=True) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\core\management\base.py", line 395, in check include_deployment_checks=include_deployment_checks, File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\core\management\base.py", line 382, in _run_checks return checks.run_checks(**kwargs) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config return check_resolver(resolver) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver return check_method() File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\urls\resolvers.py", line 407, in check for pattern in self.url_patterns: File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\utils\functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\utils\functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\USER\Desktop\bio\apitests\crypt\cert\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module return import_module(self.urlconf_name) File "c:\users\user\appdata\local\programs\python\python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", … -
Cant figure out infinite scrolling with Waypoints
Trying to apply infinite scrolling using Waypoints but cant seem to get it working. I have the following scripts loaded in my base.html after downloading them and saving in my static folder: <script src="{% static 'js/jquery-3.5.1.min.js' %}"></script> <script src="{% static 'js/jquery.waypoints.min.js' %}"></script> <script src="{% static 'js/infinite.min.js' %}"></script> Then I have the following code in my template exteded from the base: {% extends "base.html" %} {% load static %} {% block css %} <link rel="stylesheet" href="{% static 'home/main.css' %}"> {% endblock css %} {% block content %} <br> <div class="container status-update"> <div class="container"> <form> <div class="input-group-lg"> <input type="text" class="form-control" value="What's new?"> </div> <br style="height:20px"> <button type="submit" class="btn btn-primary btn-lg" name="button">Post</button> </form> </div> </div> <br> <div class="container"> <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #6298bf"> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="navbar-nav"> <a class="nav-link active" href="{% url 'home' %}">Activity Feed</a> <a class="nav-link" href="{% url 'vehicle_updates' %}">Vehicle Updates<span class="sr-only">(current)</span></a> <a class="nav-link" href="/space.html">Garage Updates</a> </div> </div> </nav> </div> <br> <div class="container"> <div class="primary-segments"> <h2>Activity Updates</h2> <div class="infinite-container"> {% for post in posts %} <div class="infinite-item"> <div class="card m-3"> <div class="card-body" style="background-color:#bdcade; padding-bottom:0px"> <div class="media mb-3"> <img src="{{ user.profile.image.url }}" class="d-block ui-w-40 rounded-circle" style="width:40px;height:auto;" alt=""> <div class="media-body ml-3"> <h5 style="color:#ffffff">{{ post.user.first_name }} {{ post.user.last_name }}</h5> <div class="small text-muted">Yesterday</div> … -
Make a dynamic sidebar based on permissions of users Django
I have multiple users with multiple permission (admin and user). example: admin is able to see sidebar a,b but user can only see sidebar c. How i can make it With Django ? Thanks -
Cross Platform HTML5 Video for Webpage
Problem: The issue is that when users upload videos they are usually in MP4 format and so the video isn't able to be played on IOS mobile devices or some other web browsers. Current Setup: I have an admin/manager panel where the site owner/manager can go in and upload a video that gets saved in a media directory on the server and I store the path to that video in MySQL. When someone visits the site the file path is dynamically injected into the src attribute in the source element on the server before being sent to the client. So the main issue is that I only have one video format for the player. Question: Is there an API I can work with that will convert the uploaded video into multiple formats and send them back so I can save them on my server to be dynamically outputted into the video element? That may be a terrible approach to solving this problem. I am honestly stuck and not sure how to solve this problem. Asking the user to upload multiple video formats seems cumbersome and not a good solution. I'm using Django and Python to build out the backend. Any … -
Add User full_name in list_filter admin site
I can't figure out how to add the User full_name in the list_filter. My Blog model is as follows: from django.db import models from django.contrib.auth.models import AbstractUser from django.utils import timezone class User(AbstractUser): pass class Post(models.Model): POST_STATUS = (('borrador', 'Borrador'), ('publicado', 'Publicado')) title = models.CharField('titulo', max_length=100) body = models.TextField('cuerpo') author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts', verbose_name='autor') created = models.DateTimeField('creado', auto_now_add=True) published = models.DateTimeField('publicado', auto_now=True) updated = models.DateTimeField('actualizado', auto_now=True) slug = models.SlugField(max_length=100, unique_for_date='published') status = models.CharField(max_length=10, choices=POST_STATUS, default='borrador') class Meta: ordering = ('-published',) def __str__(self): return self.title As you can see, I have created a custom user model just in case I have to change it in the future. In the Blog model, there is a 'author' field which uses the User as FK. I want to add the posibility to filter by 'author' in the Blog's admin site. To do this I tried the following: from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import User, Post admin.site.register(User, UserAdmin) @admin.register(Post) class PostAdmin(admin.ModelAdmin): list_display = ('title', 'author', 'status', 'published') list_filter = ('author' , 'status', 'published') search_fields = [('title',), ('body',)] prepopulated_fields = {'slug': ('title',)} raw_id_fields = ('author',) # Reemplaza el drop-down para que parezca una lupa (para FKs) date_hierarchy = 'published' ordering … -
The view account.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead
This is the screenshot of decorators.py This is the screenshot of views.py. I am getting error like pic3 This is the error showing pic -
Rendering to PDF values from a specific table in the database.- Django
I am working in a project which involves printing some medical receipts containing the medicine, the dose and many other treatments, so before printing the receipt i must fill a form with many fields related to a patient's symptoms or how he feels, so in this form there is a section called Medicine and Treaments where here, i will fill the fields with the medicine, doses and treatments for the patient, my problem is the following, i would like to render these specific fields into a PDF File so the doctor would be able to print it and signed it by himself, until now i know how to create pdf using xhtml2pdf library, but using some random text, what i would like is that for every specific consult, render the medicine and treatments and be able to print them, but i have not accomplished it. Model class Consults(models.Model): #General Consult Info Paciente = models.ForeignKey(Patient,on_delete=models.CASCADE,related_name='Paciente') Fecha = models.DateField() Motivo = models.CharField(max_length=500,null=True) Padecimiento = models.CharField(max_length=500,null=True) #Main Patient Info Presion = models.CharField(max_length=20,blank=True,null=True) Temperatura = models.FloatField(blank=True,null=True) Peso = models.FloatField(blank=True,null=True) Talla = models.FloatField(blank=True,null=True) #Any Exams done before Estudios = models.ImageField(upload_to='studies',blank=True) #Interrogatory by System Digestivo = models.CharField(max_length=500,blank=True,null=True) Endocrino = models.CharField(max_length=500,blank=True,null=True) Renal = models.CharField(max_length=500,blank=True,null=True) Linfativo = models.CharField(max_length=500,blank=True,null=True) … -
Call specific fields of nested/child form in template
I have created a nested form using forms.inlineformset_factory. In views.py I define the parent form (form) and form set (form_set) variables. When I call the variables in the template, I am able to select specific fields of the parent (i.e. {{ form.var1 }} and {{ form.var2 }}) but I cannot do the same with the child form (i.e. {{ form_set.var3 }}). I have confirmed that {{ form_set }} works and the child field appears. How can I call specific child fields? The end goal (and I may be approaching this the wrong way; any suggestion is appreciated) is for the user to supply any desired number nested forms to a single parent (i.e. an author can write many books) or this information can be supplied via csv upload (note var3 is a FileField). I would like for there to be a single file upload option (var3) but multiple other child options as desired. For example, var3 should always appear once but var4, var5, and var6 can appear any number of times as a set. A csv upload would overwrite the keyed in entry. Thanks for any help in advance! Code below: models.py class Parent(models.Model): var1= models.CharField(max_length=128) var2= models.CharField(max_length=128) class Child(models.Model): … -
Adding Ajax to a like button in Django
I need some help writing the ajax code for a like button instead of refreshing every time a like is posted. I have tried several codes but it all failed. Any recommendations on how to add a like without the page refreshing? here is the template: <form action="{% url 'score:like_post' post.pk %}" method='POST'> {% csrf_token %} {% if user.is_authenticated %} {% if liked %} <button type='submit' name='post_id' class= "btn btn-danger btn-sm" value="{{post.id}}"> Unlike </button> {% else %} <button type='submit' name='post_id' class= "btn btn-primary btn-sm" value="{{post.id}}"> Like </button> {% endif %} {% else %} <small><a href="{% url 'login' %}"> Login</a> to Like </small> {% endif %} <strong>{{total_likes}} Likes </strong> </form> Here is the urls: path('like/<int:pk>', LikeView, name='like_post'), here is the views: def LikeView(request, pk): post = get_object_or_404(Post, id=request.POST.get('post_id')) like = False if post.likes.filter(id=request.user.id).exists(): post.likes.remove(request.user) like = False else: post.likes.add(request.user) like = True return redirect('score:post-detail', pk=pk) class PostDetailView(DetailView): model = Post template_name = "post_detail.html" def get_context_data(self, *args, **kwargs): context = super(PostDetailView, self).get_context_data() stuff = get_object_or_404(Post, id=self.kwargs['pk']) total_likes = stuff.total_likes() liked = False if stuff.likes.filter(id=self.request.user.id).exists(): liked = True context["total_likes"] = total_likes context["liked"] = liked return context -
Make button disabled if no value found in database
I have a dropdown and when the user selects a value I want to check that value in the database & if there are no other similar values then make the button disable. I'm using Django in the backend? -
Why my uwsgi started 50 workers, but only used two workers
My application is very heavy, I want 50 workers all runingenter image description here -
Show users that liked a post on django
Well, I have one of the functions of my project is to give likes to posts and when that is done the users that liked the post are suposed to apear next to the like count, the problem is that the users dont appear for some reason. I think that error is in the models, I think it should have a definition to show the users or something like that. views.py def like_post(request): user = request.user if request.method == 'POST': post_id = request.POST.get('post_id') post_obj = Post.objects.get(id=post_id) if user in post_obj.liked.all(): post_obj.liked.remove(user) else: post_obj.liked.add(user) like, created = Like.objects.get_or_create(author=user, post_id=post_id) if not created: if like.value == 'Like': like.value == 'Unlike' else: like.value = 'Like' like.save() return redirect('imagelist') def imagelist(request): images = Post.objects.all() context2 = { "images": images, } return render(request, 'imagelist.html', context2) Models.py class Like(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) value = models.CharField(choices=LIKE_CHOICES, default='Like', max_length=10) def __str__(self): return str(self.post) class Post(models.Model): text = models.CharField(max_length=200) posti = models.ImageField(upload_to='media/images', null=True, blank="True") video = models.FileField(upload_to='media/images', null=True, blank="True") user = models.ForeignKey(User, related_name='imageuser', on_delete=models.CASCADE, default='username') liked = models.ManyToManyField(User, default=None, blank=True, related_name='liked') updated = models.DateTimeField(auto_now=True) created =models.DateTimeField(auto_now_add=True) def __str__(self): return str(self.tittle) @property def num_likes(self): return self.liked.all().count() imagelist.html <strong>{{ image.liked.user }}</strong> -
django.db.utils.IntegrityError: The row in table 'Event_event' with primary key '1' has an invalid foreign key:
my Event Model class Event(models.Model): name = models.CharField(max_length=100) start_date = models.DateField() end_date = models.DateField() TIMEZONES = tuple(zip(pytz.all_timezones, pytz.all_timezones)) timezone = models.CharField(max_length=32, choices=TIMEZONES) session=models.ForeignKey(Session,on_delete=models.CASCADE) slug = models.SlugField(unique=True, editable=False, max_length=100) and my session model class Session(models.Model): name=models.CharField(max_length=100) start_date=models.DateField() end_date=models.DateField() speaker=models.CharField(max_length=100) slug = models.SlugField(unique=True, editable=False, max_length=100) I get an error when I create a test. What should I do in the session section? this is my test code class CreateTest(APITestCase): def test_create_event(self): url = 'http://127.0.0.1:8000/api/event/create' data = Event.objects.create( name="deneme 5", start_date="2020-05-23", end_date="2020-05-26", timezone="Etc/GMT", session_id='1' ) response = self.client.post(url,data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) -
How to implement a transaction and account system in Django?
I am building a personal finance app that stores transactions and accounts. Each transaction will affect the balance of the account. How would I implement this in my app? I haven't found a specific answer despite searching the internet for a while. models.py class Account(models.Model): DateCreated = models.DateTimeField() AccountName = models.SlugField(max_length= 100, primary_key=True) UserID = models.ForeignKey(MyUser, on_delete=models.CASCADE) Type = models.CharField(max_length= 20) Balance = models.DecimalField(max_digits=19, decimal_places=8) Value = models.DecimalField(max_digits=19, decimal_places=8) class Transaction(models.Model): TypeChoices = ( ('Income', 'Income'), ('Expense', 'Expense'), ('Transfer', 'Transfer'), ) CategoryChoices = ( ('Rent', 'Rent'), ('Utilities', 'Utilities'), ('Food', 'Food'), ('Leisure', 'Leisure'), ('Insurance', 'Insurance'), ('Gas', 'Gas'), ('Savings', 'Savings'), ('Investment', 'Investment'), ('Phone Payment', 'Phone Payment'), ('Gym Payment','Gym Payment'), ('Salary', 'Salary'), ('Asset', 'Asset'), ('Miscellaneous', 'Miscellaneous'), ('Transfer', 'Transfer'), ) AccountName = models.ForeignKey(Account, on_delete=models.CASCADE) UserID = models.ForeignKey(MyUser, on_delete=models.CASCADE) Date = models.DateField() Type = models.CharField(max_length = 8, choices = TypeChoices) Entity = models.CharField(max_length = 100) Description = models.CharField(max_length = 200) BudgetType = models.CharField(max_length = 20, choices = CategoryChoices) Amount = models.DecimalField(max_digits=19, decimal_places=8) I currently have created views that will allow the user to create, update, and delete transactions and accounts, but do not have the transactions affecting the balances of the account. What is the best way to implement this? -
How to send as paramters floar in Django 2.0 using path(), or what us the beast aproach?
I have developed a python script with arguments. It has functions to perform the differents operations depending on the arguments received. Now I am trying to pass that arguments or parameters through the API. I am using path() new function of Django 2.0 (Specifically this is the version I am using: 2.2.9) What is the way that passing floats in url in Django? Is working with integers but not with float. What is the best ways to pass float? do you convert to HEX for example? Example Using GET to point to the API anf fire a task: Not wrking: http://x.x.x.x:8000/proveedores/api/pruebascelery/buy/0/1.1287 (last parameters is a float) works with interger: http://x.x.x.x:8000/proveedores/api/pruebascelery/buy/0/2 Django: (urls.py) path('pruebascelery///', lanzador_task_start), Django: (views.py) def lanzador_task_start(request, post_id, post_id2, post_id3): comando = "python /home/developer/venvpruebas/recibirparametros.py " + str(post_id) +str(" ")+ str(post_id2)+str(" ")+ str(post_id3) lanzar.delay(comando) return HttpResponse('<h1>Done</h1') python side: #!/usr/bin/env python # -*- coding: utf-8 -*- import sys import struct def RecibirParametros(recibir_todo): print("Received: ", recibir_todo) if __name__ == "__main__": recibir_todo = sys.argv[1], sys.argv[2], sys.argv[3] #-------------------------------------------------------------- #[1] test1 #[2] test2 #[3] test3 #-------------------------------------------------------------- RecibirParametros(recibir_todo) -
Adding Class To Crispy Checkboxes
I am rendering an 'InlineCheckboxes' which will allow the user to select multiple checkboxes. I can give the whole element a class, but cannot figure out how to set classes to the individual checkbox options. I am wanting to give each a col-3 so they will align neatly. I have been stuck on this for days and read everything I can find on it but still cant figure it out. form.py preferred_topics = forms.MultipleChoiceField(choices=TOPICS, required=False, widget=forms.CheckboxSelectMultiple()) def __init__(self, *args, **kwargs): super(NeedsAnalysisForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.add_input(Submit('submit', 'Submit')) self.helper.layout = Layout( '[..text form..]', '[..text form..]', InlineCheckboxes('preferred_topics'), '[..text form..]') What is rendered: <div id="div_id_preferred_topics" class="form-group"> <label for="" class=""> Preferred topics </label> <div class=""> <div class="custom-control custom-checkbox custom-control-inline"> <input type="checkbox" class="custom-control-input" name="preferred_topics" id="id_preferred_topics_1" value="ANI"> <label class="custom-control-label" for="id_preferred_topics_1"> Animals </label> </div> <div class="custom-control custom-checkbox custom-control-inline"> <input type="checkbox" class="custom-control-input" name="preferred_topics" id="id_preferred_topics_2" value="ART"> <label class="custom-control-label" for="id_preferred_topics_2"> Art </label> </div> [..cont..] but what I want is: <div id="div_id_preferred_topics" class="form-group"> <label for="" class=""> Preferred topics </label> <div class=""> <div class="col-3 custom-control custom-checkbox custom-control-inline"> <input type="checkbox" class="custom-control-input" name="preferred_topics" id="id_preferred_topics_1" value="ANI"> <label class="custom-control-label" for="id_preferred_topics_1"> Animals </label> </div> <div class="col-3 custom-control custom-checkbox custom-control-inline"> <input type="checkbox" class="custom-control-input" name="preferred_topics" id="id_preferred_topics_2" value="ART"> <label class="custom-control-label" for="id_preferred_topics_2"> Art </label> </div> [..cont..] Thank … -
Django ManifestStaticFilesStorage + DEBUG = False gives error in uploaded files: They don't show
I have a problem and I will do the best to explain it, to see if you can help me out. CONTEXT I have a system running in a test server, which is set up like a production environment in order to test my code before merging to master and give the go to the production server provider of my client to update the code. This means it runs in DEBUG = False. All good, all perfect for months. I decided to activate the ManifestStaticFilesStorage setting in order to have a hash number added in my static files, I've used it before and it's a good way to break cache rules when updating files (like CSS rules that refuse to load). Theere is an issue with cache that may be solvable messing around with the server but that's not an option in this case. Everything went smoothly: No issues in collectstatic other than a few missing static files (already solved) Static files loaded perfectly BUT... THE PROBLEM This system manages content (images, audio files and custom fonts). When I activated the ManifestStaticFilesStorage setting, all uploaded files started to throw 404 errors (and some occasional 500 error) in the server access … -
How to delete column before clicking on import using Django import export in admin
I want to delete some coloumns from a csv before i import it to the model. It has some overridable functions in https://django-import-export.readthedocs.io/en/latest/api_resources.html#import_export.resources.Resource.after_import_row but i donot know how to edit it. -
Celery Redis ConnectionError('max number of clients reached',)
I have a django application leveraging celery for asynchronous tasks. I've been running into an issue where I reach the max number of redis connections. I am fairly new to both celery and redis. I'm confused because in my config I define - CELERY_REDIS_MAX_CONNECTIONS = 20 which is the limit on my redis plan. For experimentation, I bumped the plan up and that solved the issue. I am confused, however, that I am running into this problem again after defining the max number of connections. I downgraded the plan and set the limit to the plans max. I am wondering if the BROKER_POOL_LIMIT needs to be changed. Is there anything I am missing to help solve connection errors and celery. Is it possible to figure out how many connections all of my tasks need? I have 16 jobs running every minute. -
Django: How do I create a form where I can set vaules for model fields and ForeignKey related models' fields?
I am trying to make a form that I can Create a Workout and set Workout, Muscle, and Exercise(preferably multiple) that are all related by ForeignKey. I'm brand new to Django and to programming as a whole and I am really struggling with forms, specifically forms that relate to models with ForeignKeys. Any help would be GREATLY appreciated! My code is: models.py from django.db import models from django.utils import timezone from django.urls import reverse class Workout(models.Model): title = models.CharField(max_length=100) def __str__(self): return self.title @property def muscle(self): return self.workout.all() class Muscle(models.Model): workout = models.ForeignKey(Workout, on_delete=models.CASCADE, related_name='workout') title = models.CharField(max_length=100) def __str__(self): return self.title @property def exercise(self): return self.muscle.all() class Exercise(models.Model): muscle = models.ForeignKey(Muscle, on_delete=models.CASCADE, related_name='muscle') title = models.CharField(max_length=100) def __str__(self): return self.title @property def weights(self): return self.exercise.all() def get_absolute_url(self): return reverse('workout_home') class Weight(models.Model): exercise = models.ForeignKey(Exercise, on_delete=models.CASCADE, related_name='exercise') pounds = models.DecimalField(decimal_places=0, max_digits=10000) date_posted = models.DateTimeField(default=timezone.now) views.py from django.shortcuts import render from .models import Workout, Exercise from django.views.generic import ListView, DetailView, CreateView class WorkoutListView(ListView): model = Workout class WorkoutDetailView(DetailView): model = Workout class WorkoutCreateView(CreateView): model = Workout fields = ['title'] -
Django: Adding custom CSS in UpdateView
I'm trying to find a method of adding custom css to the form that is generated. What would be an appropriate way of adding custom css to those fields? views.py class ProfileUpdateView(UpdateView): template_name = "users/profileUpdate.html" model = models.User fields = ( "first_name", "last_name", "about", "displayImg", ) def get_object(self, queryset=None): return self.request.user models.py class User(AbstractUser): about = models.TextField(default="") displayImg = models.ImageField(blank=True, upload_to="users") profileUpdate.html <form method="POST" enctype="multipart/form-data"> {% csrf_token %} {{ form.as_p }} <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline w-full">Update</button> </form> -
Django Star Ratings Responsive Stars
How do you make the django-star-ratings stars responsive? Using bootstrap v4 if it makes things easier. https://django-star-ratings.readthedocs.io/en/latest/ https://github.com/wildfish/django-star-ratings https://github.com/wildfish/django-star-ratings/blob/develop/star_ratings/templates/star_ratings/widget_base.html https://github.com/wildfish/django-star-ratings/blob/develop/star_ratings/templates/star_ratings/widget.html https://github.com/wildfish/django-star-ratings/blob/develop/star_ratings/static/star-ratings/css/star-ratings.css -
Storing static fields in Django models
I have a web-application with Django and I'm using PostgreSQL. I want to store static data about objects that won't change depending on the user. What is the most optimal way to go about this? For example, I currently have something resembling this stored in my models.py but it seems sub-optimal to say the least. class Alphabet(models.Model): first = models.CharField(max_length=1, default = 'a') second = models.CharField(max_length=1, default = 'b') third = models.CharField(max_length=1, default = 'c') Should I even be storing this kind of data in my models.py folder? -
I need an advice as a beginner web developer [closed]
To begin with I am regularly coding for almost 7 months every day. I want to be a full stack web developer. What I have done so far is some Python Automation projects with Selenium, a simple social network and blog with Flask and random projects that is not related to web developing. But I am not really sure what I want to do next. Most people that I asked help for is telling me: Learn Django and go with it. Learn Javascript. After learning Javascript learn Node.js and React (I don't really understand Javascript and I am highly unexperienced with it.) As you can understand I am a bit confused. I would be glad if you share your advices with me. Thank you.