Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to manage relationships between models in django
i want to make a system where when a student select some course then only this selected course's price and duration should be appeared while adding price and duration for the student course.py class Course(models.Model): title = models.CharField(max_length=250) slug = AutoSlugField(populate_from='title') basic_price = models.CharField(max_length=50) advanced_price = models.CharField(max_length=50) basic_duration = models.CharField(max_length=100) advanced_duration = models.CharField(max_length=100) def __str__(self): return self.title class Meta: verbose_name_plural = 'Add Courses Details' > students.py class Student(models.Model): name = models.CharField(max_length=200) slug = AutoSlugField(populate_from='name') phone = models.CharField(max_length=50) email = models.EmailField() address = models.CharField(max_length=200) course = models.ForeignKey(Course,on_delete=CASCADE) price = models.ForeignKey(Course,on_delete=CASCADE) duration = models.ForeignKey(Course,on_delete=CASCADE) def __str__(self): return self.name class Meta: verbose_name_plural = 'Add Student Details' -
HTML dropdown list not returning Python module in Flask route
I have two scripts that end in dataframes loaded into my app.py. The dropdown lists in my first HTML page are the column names of both dataframes. When clicking submit, I'm trying to route the selections to a third module regrplot in app.py. This module would use the selection to determine the dataframes, join the two on the year column, and run a regression plot image generator. Error I'm getting: UnboundLocalError: local variable 'y1' referenced before assignment When getting to the dropdown.html page. I am able to see the dropdown lists populated, as well as the submit button. dropdown.html <body> <form name="var1" action="/dropdown_x"> <fieldset> <legend>Table Variable 1</legend> <p> <label>Select</label> <select name="df_variable1"> {% for each in dropdown_fields %} <option value="{{each}}">{{each}}</option> {% endfor %} </select> </p> </fieldset> </form> <form name = "var2" action="/dropdown_y"> <fieldset> <legend>Table Variable 2</legend> <p> <label>Select</label> <select name="df_variable2"> {% for each in dropdown_fields %} <option value="{{each}}">{{each}}</option> {% endfor %} </select> </p> </fieldset> <button><input name="regrplt" method="GET" action="/regrplot" type="submit" class="btn btn-default" value="Submit"></button> </form> </body> app.py app = Flask(__name__) book_fields= list(book_data.year_book_data) census1_fields = list(censusLoad.df_full1) census2_fields = list(censusLoad.df_full2) dropdown_fields = book_fields + census1_fields + census2_fields @app.route("/dropdown") def dropdownList(): return render_template('dropdown.html', dropdown_fields=dropdown_fields) @app.route("/dropdown_x", methods=['GET', 'POST']) def testt1(): if request.method == 'POST': df_variable1 = request.form['df_variable1'] … -
how to store multiple PRODUCTS's 'primary key' field in one ORDER's 'Order_Product' field?
in a nutshell, i want to select multiple PRODUCT per one ORDER entry. should i use some string manipulation method to compose all selected product in one string and save it into single field ? it sounds obvious but i don't think its way to go because its like majority of database design confronts the order and its multiple products and there should be a better way to deal with it. please suggest a better practice or something magical like one can store multiple primary key in one foreign key field but seems like thats not the best practice somehow. so what should i do ? Order_Product = models.ForeignKey(Product, on_delete=models.CASCADE) # im thinking of making below field into a string holding container # and join many primary key and just outright save it separating by commas Order_SelectedProduct = models.CharField(max_length=1000) Order_Amount = models.CharField(max_length=10) Order_Qty = models.CharField(max_length=10) Order_Date = models.CharField(max_length=10) Order_Deadline = models.CharField(max_length=10) Order_Reference = models.CharField(max_length=128) def __str__(self): return self.Order_Id obviously that Order_SelectedProduct field is not ideal way because one primary takes 14 spaces so say one order can only be limited to store only 71 products per order, thats more than enough but thats not scalable. i hope it yields something … -
Positivly insert NULL (not blank!) with Django
Null is not an empty string! select count(*) from table where xyz is null is not the same as select count(*) from table where xyz == ''! If I have a unique constraint on a column, multiple NULL values can exist. Multiple empty strings cannot! I know what the difference is. I don't need an explanation. All I want to know is how to insert a NULL value in Django admin. I have tried: default=None null=True No I don't want blank. I want NULL. When I look at my schemas from my migrations, I clearly see the columns allow NULL. So, what is the fiddly little syntax in dynamically typed python that seems to be burred on the by the SEO of people who don't understand what constraints are? This field is required. No it's not. I can clearly see that from the table structure. -
Mail function doesn't send mail in Django
I wrote code in basic HTML tags like and there was no problem. Mail was sent correctly. But when I changed its place and HTML tags mail function didn't work. What problem can be? It works <h1>Contact Us</h1> <form method="post"> {% csrf_token %} {{ form.as_p }} <div class="form-actions"> <button type="submit">Send</button> </div> </form> It doesn't work. <form class="contact-form" action="" method="GET"> {% csrf_token %} {% for field in form %} {{ field|add_class:"input" }} {% endfor %} <button class="button" type="submit">Send</button> </form> -
Raise validation error in email which accept yahoo, gmail and outlook only
I'm raising custom validation error in email field which accept only yahoo, gmail and outlook only. What am I doing wrong here? from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Profile, Testimonial class UserSignupForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'username', 'password1', 'password2'] def clean_email(self): email = self.cleaned_data.get('email') email_exists = User.objects.filter(email=email) if email_exists.exists(): raise forms.ValidationError("Email is taken") elif not "gmail.com" in email or not "yahoo.com" in email or not "outlook.com" in email: raise forms.ValidationError("Email should be gmail, yahoo and outlook only") return email -
Generic way to get all ForeignKey models attached to a model
Say I have a model like this class MyModel(models.Model): name = models.ForeignKey("Name", on_delete=models.CASCADE) addr = models.ForeignKey("Address", on_delete=models.CASCADE) non_fk = models.CharField(...) I want to be able to get a list of the models that are linked by foreign key. Something like the following would be nice: mymodel = MyModel name_and_addr_as_list = mymodel._child_models() # returns [Name, Address] Is there a way to do this? -
Sentry not getting errors from localhost (onpremise)
Sentry is not picking up any errors from my django project. I am setting up sentry using docker(onpremise) to track errors from my project. I have sentry up and running on aws server and it looks running fine as I can send verification emails (smpt set up with sendgrid) and can add organisations, projects and etc. My project uses django and I am trying to set up with unified sdk (sentry-sdk). After setting up the client with DNS. >>> from sentry_sdk import capture_message >>> capture_message('test') '07d8c4c1eb1f4b6bb5e0766d5078a9c4' When I run the above code, I can't see anything on the sentry UI. Not even filtered errors. I am very new to this so not sure what I am missing. Should I configure logging?? Only thing sentry picks up now is, if there is an error occurred on the sentry docker container. -
Trying to show latest record - Django
Models class Category(models.Model): class Meta(): verbose_name_plural = "Categories" cat_name = models.CharField(max_length=50) description = models.TextField() def get_forums(self): get_forum = Forum.objects.filter(category=self) return get_forum def __str__(self): return f"{self.cat_name}" class Forum(models.Model): class Meta(): verbose_name_plural = "Forums" category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name="forums") parent = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE) forum_name = models.CharField(max_length=50) description = models.TextField() def __str__(self): return f"{self.forum_name}" class Thread(models.Model): class Meta(): verbose_name_plural = "Threads" get_latest_by = "date_posted" forum = models.ForeignKey(Forum, on_delete=models.CASCADE, related_name="threads") author = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=50) content = models.TextField() date_posted = models.DateTimeField(default=timezone.now) def __str__(self): return f"{self.title} by: {self.author}" View class Home(ListView): model = Category template_name = 'forums/index.html' context_object_name = 'category' def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super().get_context_data(**kwargs) # Add in a QuerySet of all the Cat context['category'] = Category.objects.all() return context HTML {% block content %} {% for cat in category %} <div style="padding-top: 20px;"> <div class="row"> <div class="bg-success rounded-top border border-dark" style="width:100%; padding-left:8px;"> <a href="{% url 'catview' cat.id %}"> {{ cat.cat_name }}</a> </div> </div> {% for forum in cat.forums.all %} <div class="row"> <div class="bg-secondary border border-dark" style="width:100%; padding-left:16px;"> <a href="{% url 'forumview' forum.id %}"> {{ forum.forum_name }}</a> {% for threads in forum.threads.all %} <div class="float-right" id="latest-post"> <p>{{ threads.title }}</p> <p> <a … -
My Model form for Django is not saving because it's invalid but I can't see what's wrong
I'm very new to Django and part of the assignment was to create our own blog model form. I followed the previous examples of the youtube tutorial but was unable to create my own blog model form. The form will not save because it's invalid and I have been busting my head for 2 days to solve it but can't find what is wrong. Also, every time I submit my form, it redirects me to another page which I don't quite understand why. Please help. I'm using Django version 2.0.7. My models.py from django.db import models class Article(models.Model): title = models.CharField(max_length=120) # Max length required content = models.TextField() active = models.BooleanField(default=True) My forms.py from django import forms from .models import Article class ArticleForm(forms.ModelForm): class Meta: model = Article fields = [ 'title', 'content', 'active' ] my views.py from django.shortcuts import render, get_object_or_404, redirect from .forms import ArticleForm from .models import Article def article_list_view(request): print("this is article_list.html") queryset = Article.objects.all() context ={ "object_list": queryset } return render(request, "blogs/article_list.html", context) def article_create_view(request): form = ArticleForm(request.POST or None) print(ArticleForm.errors) if form.is_valid(): print("Valid form") form.save() else: print("invalid") print(ArticleForm.errors) context = { "form": form } return render(request, "blogs/article_create.html", context) article_create.html {% extends 'base.html' %} {% … -
Missing connection_alias argument in django-haystack and elasticsearch
Django-haystack with elasticsearch missing 'connection_alias' argument. I am setting up a django app, with django-haystack using elasticsearch for the search engine backend. However, 'connection_alias' argument is missing in the module The HAYSTACK_CONNECTIONS in the settings.py is setup with elasticsearch HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchBackend', 'URL': 'http://127.0.0.1:9200', 'INDEX_NAME': 'haystack', } } And the search_indexes.py model is setup below as well: from haystack import indexes from .models import Post class PostIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) publish = indexes.DateTimeField(model_attr='publish') def get_model(self): return Post def index_queryset(self): return self.get_model().published.all() However, when running the rebuild_index command in the manage.py for django apps: ./manage.py rebuild_index An error occurs showing that there is a missing argument for 'connection_alias' Traceback (most recent call last): File "./manage.py", line 21, in <module> main() File "./manage.py", line 17, in main execute_from_command_line(sys.argv) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/haystack/management/commands/rebuild_index.py", line 41, in handle call_command('clear_index', **clear_options) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 148, in call_command return command.execute(*args, **defaults) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/home/giddyupyup/Documents/Development/Python/projects/blogapp/venv/lib/python3.6/site-packages/haystack/management/commands/clear_index.py", line 52, in handle backend = connections[backend_name].get_backend() … -
How to save each file in request.FILES with for loop in Django?
Okay so I've looked at many of the answers on the internet but none seem to solve this problem. I'm trying to save each from a multifile upload but it keeps saving the same file f number of times. Something with my 'form' attribute is causing this problem but i can't seem to figure out why. def upload_book(request): if request.method == 'POST': for f in request.FILES.getlist('pdf'): form = BookForm() form = BookForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('book_list') else: form = BookForm() return render(request, 'upload_book.html', { 'form': form }) -
Why does django queryset.extra() throws OperationalError: (1242, 'Subquery returns more than 1 row')?
I'm using Django ORM with MySQL and wasting a lot of time with querys. For some "advanced" cases i decided to go for raw queries, since for those, i couldn't make it with annotations. The problem with raw queries is that the don't add a "field" to the queryset like annotations or aggregations. So, i'm using extra. But now i'm facing a problem: qs_products = Productos.objects.all() qs_productos.extra({ "stock": """ SELECT SUM(items.cantidad) FROM `encargosProveedor_listado_articulos` AS encargos, `itemArticulosProveedor`AS items, `articulos` as articulos WHERE encargos.itemarticulosproveedor_id=items.id and articulos.id=items.articulos_id GROUP BY articulos.producto_id """ }) This is the result for this query directly from my db admin: +---------------------+ | SUM(items.cantidad) | +---------------------+ | 14 | +---------------------+ | 4 | +---------------------+ But when running this code under django using extra() MySQLdb._exceptions.OperationalError: (1242, 'Subquery returns more than 1 row') What is the problem for returning more than one row? The query is returning two rows because i have two products, its reasonable. I want to assign stock to each one of the products. Alternatives? Suggestions? Hints? -
How to set DateTimeField input_formats without losing date/time picker widget in Django Admin
I've been searching for an efficient way on how to achieve one seemingly simple task in Django by setting DateTimeField's input_formats property. Currently, the default DateTimeFormat is Y-m-d for the date, and the time has trailing seconds. I would like to change this around to m-d-Y and I:M respectively, but any kind of edit to the form removes the date and time picker widgets. For example, when I do something like this in admin.py: class PromoForm(forms.ModelForm): start_time = DateTimeField(input_formats=settings.DATE_INPUT_FORMATS) The resulting form in admin looks like: Is there a straightforward way to make this work? Gracias. -
Login registration that redirects to different page according to user type in django
I am creating login registration in djanog. and I am unable to redirect login based on different usertype. If any example could be given it will be highly appreciated. -
Admin login forbbiden 403 csrf verification on django 1.2.5
i know this have been asked already but i still can't get the answer to it. When i try to log in on django admin, (just created an app and straigh to admin, without modifications) and in google chrome it doesnt allow me to log in, instead it pops up this error. just to add, if i log in on admin in chrome by incognito tab it works! and i can log in. also i can log in on internet Explorer last version, so it means that it is happening on my regular google chrome windows, what can i do?? i tried many solutions and noone gave to the answer but interstingly some of the solutions let the app work, with like no other effect. this is my setting app: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', ] MIDDLEWARE = [ 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'django_project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] i know i can ignore it for now but i feel it will bring a lot of problems later on if i dont … -
Merging Django projects into one with multiple apps and muliple user models
I am trying to migrate data from an old django project into a new one. I have extracted my django models into a resuable app to be used in my new project. The problem i am facing is that each app has thier own user model and group model. How can i make my new django project read my old user/group data and migrate it into my new project. My new project has a custom user model and old one has the default user model. What i have tried is just define a user model and group model and use that just to access the data from my old project db. Is there a better way to solve this? -
How to add django back-end after making a frontend website with reactjs?
I made the front-end of my website with the Materialize framework and ReactJS to make it dynamic. My goal is to make a upvote/downvote system so I need a back-end ORM to use with a database. I decided to go with Django as I'm more experienced with python, but when I was following a tutorial, I did the command: npx create-react-app frontend with the intention of replacing the new files with my "homemade frontend" to make it work except the directory structures were completely different. Tree made with the command: ├── frontend │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ └── manifest.json │ ├── README.md │ ├── node_modules │ ├── src │ │ ├── App.css │ │ ├── App.js │ │ ├── App.test.js │ │ ├── index.css │ │ ├── index.js │ │ ├── logo.svg │ │ └── registerServiceWorker.js My original frontend tree: ├── frontend │ ├── Components │ ├── index.html │ ├── css │ │ ├── style.css │ │ ├── materialize.css │ │ └── materialize.min.css │ ├── README.md │ ├── node_modules │ ├── js │ │ ├── init.js │ │ ├── materialize.js │ │ └── materialize.min.js │ ├── src │ │ … -
Django admin save() doesn't get data from ManyToManyField
I'm trying to get chosen objects from affiliate_networks in Django admin when the user clicks the submit button. When I choose one from affiliate_networks and submit it, the console prints an empty of affiliate_networks, and then I come back to the page and the chosen object is stored properly. So, I submit it again, then the console prints the chosen object. save() only receives objects that are already stored, not objects that I choose before saving. Is there a way, that I can have save() to notice affiliate_networks to have any object chosen? class Store(models.Model): ... affiliate_networks = models.ManyToManyField(AffiliateNetwork, blank=True) def save(self, *args, **kwargs): print(self.affiliate_networks.all()) -
Django Dependencies
Sorry to ask I am new to python and django and I just wanna ask and wanna use the django-audiofield app and I am following a certain installation process in a site https://django-audiofield.readthedocs.io/en/stable/ and in the installation process there's install dependencies, Do i need to change my OS cause I just found out that debian is an os but i don't wanna change my OS is there anyway to use django-audiofield without installing the dependencies or is it necessary to install those?? -
Django Alternative to PK in Form Action Parameter
I have two models in a parent-child relationship: Idea and Comment. I am using DRF and nested DataTables to serve these models to the browser. To create a comment, the corresponding idea ID must be known. The button to create a new comment looks like this with parentObjData being the Idea id: <button type="button" class="btn btn-primary js-create-idea-comment" data-url="/platform/ideas/comments/' + parentObjData + '/create/"><span class="fa fa-plus"></span> New Comment</button> This works, and a request to the proper URL is sent when each button is clicked. What's supposed to happen with a successful request is demonstrated by these views: def save_comment_form_create(request, form, template_name, parent_id): data = dict() if request.method == 'POST': if form.is_valid(): instance = form.save(commit=False) instance.created_by_id = request.user.id instance.idea_id = parent_id form.save() data['form_is_valid'] = True comments = IdeaComment.objects.all() data['html_idea_comment_list'] = render_to_string('ic/includes/partial_idea_comment_list.html', { 'comments': comments }) else: data['form_is_valid'] = False context = {'form': form} data['html_form'] = render_to_string(template_name, context, request=request) return JsonResponse(data) def idea_comment_create(request, parent_id): idea_id = parent_id if request.method == 'POST': form = IdeaCommentForm(request.POST) else: form = IdeaCommentForm() return save_comment_form_create(request, form, 'ic/includes/partial_idea_comment_create.html', idea_id) partial_idea_comment_create.html resolves to this form: <form method="post" action="{% url 'idea_comment_create' parent_id %}" class="js-idea-comment-create-form"> {% csrf_token %} <div class="modal-header"> <h4 class="modal-title">New Comment</h4> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div … -
Django: Run Constantly Running Background Task On IIS-Hosted Application
I have a Django web application hosted on IIS. I subprocess should ALWAYS BE running alongside the web application. When I run the application locally using python manage.py runserver the background task runs perfectly while the application is running. However, hosted on IIS the background task does not appear to run. How do I make the task run even when hosted on IIS? In the manage.py file of Django I have the following code: def run_background(): return subprocess.Popen(["python", "background.py"], creationflag=subprocess.CREATE_NEW_PROCESS_GROUP) run_background() execute_from_command_line(sys.argv) I do not know how to resolve this issue. Would something like Celery work to indefinitely run a task? How would I do this? Please give step by step instructions. -
django parallel test return multiprocessing.pool error
When I try to run my django tests on Travis CI in parallel using --parallel, I run into this error Traceback (most recent call last): File "manage.py", line 43, in <module> execute_from_command_line(sys.argv) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv super(Command, self).run_from_argv(argv) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/core/management/commands/test.py", line 62, in handle failures = test_runner.run_tests(test_labels) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/test/runner.py", line 603, in run_tests result = self.run_suite(suite) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/test/runner.py", line 567, in run_suite return runner.run(suite) File "/opt/python/2.7.6/lib/python2.7/unittest/runner.py", line 151, in run test(result) File "/opt/python/2.7.6/lib/python2.7/unittest/suite.py", line 70, in __call__ return self.run(*args, **kwds) File "/home/travis/virtualenv/python2.7.6/lib/python2.7/site-packages/django/test/runner.py", line 370, in run subsuite_index, events = test_results.next(timeout=0.1) File "/opt/python/2.7.6/lib/python2.7/multiprocessing/pool.py", line 655, in next raise value TypeError: __init__() takes exactly 3 arguments (2 given) I cannot find any support anywhere with this and this is within Django. I don't know what's the third arg init() is expecting in this case. My django version is 1.11.18 The command is python manage.py test --parapllel=4 -
How to use drf-writable-nested to create-or-update?
I took the Django drf-writable-nested package and made it a complete implementation called drf-writable-example by adding a bit of REST code (see below). (See drf-writable-nested page for the models and serializers.) If I POST their JSON example (see below) twice, it creates every object in the JSON twice. So, two Site objects with url "http://google.com", two Avatar objects with image "image-1.png", etc. How do I instead modify that code to create-or-update? That is, if the "http://google.com" site already exists, then just use it, and if the avatar object with "image-1.png" already exists, just use it, etc.? REST code: from rest_framework import routers, viewsets from .serializers import UserSerializer from .models import User class UserModelViewSet(viewsets.ModelViewSet): queryset = ExampleUser.objects.all() serializer_class = UserSerializer router = routers.DefaultRouter() router.register(r'users', UserModelViewSet) and registering that router to a URL. Now I can POST the example from their docs (user-example.json) using httpie: http POST http://localhost:8000/api/users/ \ < examples/user-example.json > my.log If I POST that twice, I get two complete sets of stuff: GET /api/users/ HTTP 200 OK Allow: GET, POST, HEAD, OPTIONS Content-Type: application/json Vary: Accept [ { "pk": 1, "profile": { "pk": 1, "sites": [ { "pk": 1, "url": "http://google.com" }, { "pk": 2, "url": "http://yahoo.com" } ], … -
Is there a (new) way to edit a PDF form , sign and save it in DJANGO?
Is there a new way of achieving the question title? I have a few articles about these on stackoverflow but they are old for the most part.