What is a best way to display single model instances on different html? I know how it is done on single page (forloop), but could not figure out how the same would be possible on different html. i.e. single question …
I have auth_service, tpm_api and frontend enviroments. All services use the same secret_key. My users and permissions are on the auth_service. I am using jwt_simple for Authentication on auth_service. On the frontend service, I get token from auth_service with username …
I'm working on a Django backend deployed on a server, here's my settings: DEBUG = False STATIC_URL = "/staticfiles/" STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR, "media") And I want to save the users' images outside …
Coding some kind of blog with django, and I can't make homepage to contain images of the articles... It just doesn't upload a image... my Views.py : class AddPostView(CreateView): model = Post form_class = PostForm template_name = 'add_post.html' my …
I am generating a token for each logged in user. But on Get request through postman i am getting this error. please guide me what's wrong ! postman error screenshot my models.py class allmodelfields(AbstractBaseUser): USERNAME_FIELD = …
I have created an Employee CRUD in Django REST using generic views. when update view page is loaded I couldn't find the current values in the fields. so I can't update a single value. when i update a single value …
Session expires when the '/mobile-confirmation' app.route runs and the user redirects to login page @app.route("/signup", methods=["GET", "POST"]) def signup(): if request.method == "POST": #SignUp form Insert codes ...... db.execute("SELECT tempcode FROM users WHERE id = %s", [userID]) tmpcode = db.fetchall() …
In Django I have two models: class Car(models.Model): model_name = CharField(...) make_name = CharField(...) car_exterior_color= = CharField( CHOICES ) class CarWash(models.Model): car_washed = BooleanField(...) wash_date = DateTimeField(...) added_wax = BooleanField(...) car = models.OneToOneField(Car, on_delete=models.CASCADE, verbose_name="Car washed") I need to …
This view for search: class Search(generic.ListView): model = Blog template_name = 'pages/blog_list_view.html' context_object_name = 'blog' def get_queryset(self): search = self.request.GET.get("q") search_result = Blog.objects.filter( Q(title__icontains=search) | Q(description__icontains=search) | Q(active=True)) return search_result search form in _base.html <form action="{% url 'search' %}" …
I'm trying to write a search based on tuples with the Django ORM syntax. The final sql statement should look something like: SELECT * FROM mytable WHERE (field_a,field_b) IN ((1,2),(3,4)); I know I can achieve this in django using …
Class Item(models.Model): name=models.CharField(max_length=250) description = model.TextField() class Photo(models.Model): item = models.ChaField(max_length=250) title=models.ChaField(max_length=250) here is admin.py class PhotoInline(admin.StackedInline): model = Photo class ItemAdmin(admin.ModelAdmin): inlines = [PhotoInline] admin.site.register(Item,strong text ItemAdmin) admin.site.register(Photo) i want to have an inline connection between without …
So I am following a Youtube video on how to create a chatting app. Then it build a model that I don't understand. Here's the Message model I came across and can't understand how it works. class Message(models.Model): user = …
Hello I am beginner in Django while trying to create Subscription with stripe i am getting error as InvalidRequestError at /stripe/create-checkout-session Request req_M2eko0H9LwXvDz: You must provide at least one recurring price in subscription mode when using prices. This is my …
I'm using drf-spectacular to generate the swagger/redoc API documentation. I am facing issue in customising the schemas generated. I am trying to generate reference parameter using @extend_schema decorators in drf_spectacular but did'nt get the expected schema. extend_schema …
For django API, which we have written, post method is allowed but instead of get method, i am getting 405 error, but instead i want some default message like- "error". I am sharing my code. Please let me know if …
I have a django project that it should have ability to change the database's port dynamically for security reasons. for example there should be a template like ( port= ) and the administrator should enter a port and change the …
I have the following Django channels consumer but when I try to send data to the stocks group، it returns a 500 error. Also, I don't get any error logs. Here is the consumer: class AuthRequiredConsumer(JsonWebsocketConsumer): def connect(self): user = …
I'm writing something like the following: class Foo(models.Model): a = models.CharField() def f(foo: Foo) -> Foo: y = Foo( **{field.name: getattr(foo, field.name) for field in foo._meta.get_fields()} ) # copy foo with pk y.a = "c" return y …
I'm using Django 3 and the auth contrib module. I want to override the reset password procedure via an API and so I have a method that looks like this .... class CompleteResetPasswordView(PasswordResetConfirmView): @method_decorator(csrf_exempt) def dispatch(self, request): body = json.loads(request.body) …
I have uploaded stsatic files to Cloudflare R2 with python manage.py collectstatic command, and checked files are there. Also, allowed public access for the R2 bucket. I have these in my settings.py file for static related: STATIC_HOST = …
I have a problem with my code, i try to make a datable with multiple checkbox filter on Django environement. i have tried multiple code, but for now, i have this code, for each collumn there is a list and …
I recently tried to run remove_stale_contenttypes in a Django 3.1 app, after deleting some custom permissions. The first time it run it warned me that some entries would be deleted, and I went ahead and entered 'yes'. The command failed …
My Problems are as follows: Im relatively new to Django. so sorry for this mess. I've tried to implement threaded comments to my blog via MPTT. But when i pressing the 'Reply' Button django throws me a Type Error Normal …
I am working a Django Application where I want to search two Models Profile (surname or othernames fields) and Account (account_number field) using Q objects. From what I did, it is searching only one Model (Account) and any attempt to …
I have a page with the list of objects. I need a search function, but there is an error. I am in process of studying and I used from . import views and the search function worked, but then I …
By default, when inserting an image from the clipboard into the CKEDITOR editor, the images are saved in PNG format and take up a lot of disk space. I have enabled PillowBackend to be able to save images in JPG …
I want to make a model where users can create a team of users, and in these teams add the job that they did and choose recipient of the job(that is the member of this team) that they did it …
In my web page i have a for loop that displays multiple <a> tags. When one of the <a> tags is clicked the user will be redirected to another url. My problem is that all of the href="{% url 'search' …
Please help me m looking since hours for the solution but i didnt find something. Here is my HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <style> input { width: 10%; margin: 0 auto; …
I am using Django to create and update an Text area. After putting a text that have variables between {}, I want to change them using button variable. So when I click on variable it will show me all the …
I am a beginner in the docker I want deploy my django project on hostinger.com vps so I am using docker nginx and gunicorn for this I dockrized my django project a test it on the localhost every thing is …
I'm working with sensitive currency values. In my case, i have to reproduce a sheet with it's formulas. The point is that i need to round down a currency value with 2 decimal places. A practical example is the number: …
I created a function for convert the csv. The main topic is: get a csv file like: ,features,corr_dropped,var_dropped,uv_dropped 0,AghEnt,False,False,False and I want to conver it to an another csv file: …
I have a small form on django, when the button is clicked it display a django message bellow the form to tell the user that he successfully clicked on the button but it redirect the user in the top of …
I have few models, but right now I want to focus on two: class Client(models.Model): first_name last_name car # Client's car to be serviced class Service(models.Model): service_name service_type service_date client = models.OneToOneField(Client, on_delete=models.CASCADE, verbose_name="Client served") def __str__(): return f"Client {self.client} …
I have a problem. I made likes to the posts on the video from YouTube. It is possible to like a post only from post_detail view and it's works correctly! How to make it possible to like posts in the …
I am having trouble figuring out where my issue is. I am parsing a slug to the url, via my view pulling from the SlugField in my model. For an object instance that exists in my database, the slug is …
I have 2 models in my django app, the first is Tags model and the second is Post model, the problem is when i try to use mutation for the Post model to add a post from the graphql it …
I have an element - dropdown list selector. Which works and there is a choice of value. Based on the value received, I send a request to execute the code and, at the end, to change / render another element …
I'm trying to create an app which stores medical records of patients. I'm trying to get information about the patient but I have encountered a problem. When it comes to posting the medical history I receive the following error: "IntegrityError …