Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to solve error frame-ancestor iframe on mobile app
I try to embed an iframe on a website + mobile app. No problem with the website, but I get the error "Refused to display 'https://website.com' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors ' Do you know if a special CSP directive is specific to mobile apps ? Thanks! -
ModelForm object has no attribute 'fields'
I am using a django (3.0) ModelMultipleChoice field for a form. I am trying to modify the queryset to make some restrictions on it. here is the views : def nouvelle_tache(request,id_livrable): livrable=Livrable.objects.get(pk=id_livrable) projet = livrable.projet if request.method == "POST": form = NouvelleTache(request.POST,projet=projet) tache = form.save(commit=False) tache.livrable = livrable tache.id_tache = livrable.id_derniere_tache() + Decimal(0.01) tache.save() form.save_m2m() etat = Temps_etat_tache(etat=form.cleaned_data['etat_initial'],tache=tache) etat.save() return redirect('tache',tache.pk) else: form = NouvelleTache(projet=projet) return render(request, 'application_gestion_projets_AMVALOR/nouvelle_tache.html', locals()) And the forms : class NouvelleTache(forms.ModelForm): def __init__(self, *args, **kwargs): projet = kwargs.pop('projet', None) queryset = Utilisateur.objects.all() for utilisateur in projet.utilisateurs: queryset = queryset.exclude(pk=utilisateur.pk) self.fields['ressources'].queryset = queryset super(NouvelleTache, self).__init__(*args, **kwargs) ressources= forms.ModelMultipleChoiceField(queryset=Utilisateur.objects.all() ,widget =forms.CheckboxSelectMultiple ) etat_initial = forms.ModelChoiceField(queryset=Etat_tache.objects.none()) class Meta: model = Tache fields = ['libelle'] I have the followig error : 'NouvelleTache' object has no attribute 'fields' I don't understand why because many other users seems to have similar code and it works. Any help would be appreciate. -
Django_tables2 with delete buttom
How is going? I'm learning to programming in django. For the moment I'm building a simple app that utilizing a form update the referenced table. Now I'm try to add a delete button in each row of my table but, beside I have tried a lot of solutions, I didn't find one that works correctly. Below my code: urls from django.urls import path from app import views app_name = 'main' urlpatterns = [ path('', views.homepage, name='homepage'), path('delete_item/<int:pk>', views.delete_item, name="delete_item"), ] forms from django import forms from .models import Income class IncomeModelForm(forms.ModelForm): class Meta: model = Income fields = "__all__" tables import django_tables2 as tables from django_tables2.utils import A from .models import Income class PersonTable(tables.Table): delete = tables.LinkColumn('main:delete_item', args=[A('delete-id')], attrs={'a': {'class': 'btn'}}) class Meta: model = Income template_name = "django_tables2/bootstrap.html" views from django.shortcuts import render from django.http import HttpResponse from django.views.generic import ListView from .models import Income from .tables import PersonTable from .forms import IncomeModelForm def homepage(request): table = PersonTable(Income.objects.all()) if request.method == 'POST': form = IncomeModelForm(request.POST) if form.is_valid(): print("Il form è valido") new_input = form.save() else : form = IncomeModelForm() context= {"form": form, "table":table } return render(request, "app/base.html", context) def delete_item(request, pk): Income.objects.filter(id=pk).delete() items = Income.objects.all() context = { 'items': … -
Getting "int" accepted as an instance of my Django model
I'm writing a decorator to allow my functions to accept either an instance of one of my Django models or its primary key, and the function itself will always receive an instance regardless of which was passed in. While testing it, I'm getting a weird error that sometimes, an integer (the usual type for the primary key) is being considered a valid instance of my model. For example: log.debug((value, type(value), model, isinstance(value, model))) # Outputs: (1, <class 'int'>, <class 'myapp.models.MyModel'>, True) This behavior is consistent within my decorator function, but I can't replicate it from a bare Django shell; I've tried using 1, valid primary keys for MyModel, and other values, and it always returns False properly. This check also works properly in some other test cases using other models, returning False when a key is passed in rather than an object instance. MyModel does have a couple of extra inheritances, in particular it overrides __str__ and __repr__, and inherits from natural_keys.NaturalKeyModel, which doesn't override anything that seems relevant to this issue. Otherwise, it's just a typical Django model, no special definition of __eq__ or anything like that. Any ideas why my isinstance check is behaving this way? For completeness, … -
Django filter queryset returning foreign key values
Here again with a Django question. I've got models as follows: class A(models.Model): id = models.IntegerField(primary_key=True) description = models.TextField() class Meta: managed = False db_table = 'table_a' class B(models.Model): id = models.IntegerField(primary_key=True) description = models.TextField() class Meta: managed = False db_table = 'table_b' class C(models.Model): id = models.IntegerField(primary_key=True) description = models.TextField() class Meta: managed = False db_table = 'table_c' class D(models.Model): id = models.IntegerField(primary_key=True) description = models.TextField() class Meta: managed = False db_table = 'table_d' class ABCD(models.Model): id = models.IntegerField(primary_key=True) a = models.ForeignKey(A, on_delete=models.DO_NOTHING) b = models.ForeignKey(B, on_delete=models.DO_NOTHING) c = models.ForeignKey(C, on_delete=models.DO_NOTHING) d = models.ForeignKey(D, on_delete=models.DO_NOTHING) class Meta: managed = False db_table = 'table_abcd' I also have the filter declared in filters.py using django-filters: class HostServiceFilter(django_filters.FilterSet): class Meta: model = HostService fields = { 'host': ['icontains',], 'ip': ['icontains',], 'service': ['icontains',], 'port': ['icontains'] } the filter is called in the view: class ABCDView(ListView): model = ABCD template_name = 'myapp/abcd_list.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['filter'] = ABCDFilter(self.request.GET, queryset=self.get_queryset()) return context Finally, the html file where the filter is called: <div class="container"> <form method="GET"> {{ filter.form }} <button type="submit" class="btn btn-primary">Search</button> </form> <table> {% for abcd in filter.qs %} <tr> <td>{{ abcd.a.description }}</td> <td>{{ abcd.b.description }}</td> <td>{{ abcd.c.description }}</td> <td>{{ abcd.d.description … -
Django DetailView without 404 redirect
I have a little news app with a DetailView class like the following: class DetailView(LoginRequiredMixin,generic.DetailView): model = NewsItem template_name = 'news/detail.html' def get_object(self): obj = super().get_object() if self.request.user.is_superuser or obj.published: return obj and an urls.py config like this: urlpatterns = [ path('', views.IndexView.as_view(), name='index'), path('<int:pk>/', views.DetailView.as_view(), name='detail'), path('<int:itemId>/publish', views.publish, name='publish'), ] Now when i pass an invalid ID to the detail view it automatically redirects to 404. I wanted to know if it's possible to just pass an empty object to the DetailView instead. The template then would handle the 404 on its own. Also:Even though it works so far I feel like the way i handled the permission requirements (overriding the get_object method) isn't the correct way/Django way to do things -
django cannot find static files
I am building login page application. Intended login page application shown in below link. This login page has two images and alignment done using css and other files in django. When I run django server I am able to see login textboxes and static text labels, but not images and alignments is not proper, path for which is fetched from STATIC_URL or STATIC_ROOT in settings.py. When I run the serer I am seeing error like this [10/Mar/2020 20:18:41] "GET / HTTP/1.1" 302 0 [10/Mar/2020 20:18:41] "GET /login/?next=/ HTTP/1.1" 200 2607 [10/Mar/2020 20:18:41] "GET /login/static/dau_gui_app/fontawesome-free-5.3.1-web/css/all.min.css HTTP/1.1" 404 141 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/style.css HTTP/1.1" 404 102 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/w3.css HTTP/1.1" 404 99 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/bootstrap.min.css HTTP/1.1" 404 110 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/dataTables/datatables.css HTTP/1.1" 404 118 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/dataTables/jQuery-3.3.1/jquery-3.3.1.js HTTP/1.1" 404 132 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/dataTables/datatables.js HTTP/1.1" 404 117 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/images/logo.png HTTP/1.1" 404 108 [10/Mar/2020 20:18:41] "GET /static/dau_gui_app/images/alstom_logo.png HTTP/1.1" 404 115 My login.html looks like this: {% load i18n %} {% load admin_static %}{% load firstof from future %}<!DOCTYPE html> <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="static/dau_gui_app/fontawesome-free-5.3.1-web/css/all.min.css"> <link rel='shortcut icon' type='image/x-icon' … -
How to rename a python-react project in vs code teminal
I'm new to django framework. I'm trying to rename a python project from the vs code terminal but it is giving me error. Any help will be appreciated. Below is the deatails: python manage.py rename max_ecommerce usage: manage.py rename [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] current [current ...] new [new ...] manage.py rename: error: the following arguments are required: new -
Django Mongodb connection error ServerSelectionTimeoutError
I'm trying to connect my django application to a mongodb. When connecting I got following error. Anyone knows why? app_1 | File "/opt/project/backend/util/mongodb/client.py", line 23, in __init__ app_1 | self.collection.create_indexes(indexes) app_1 | File "/usr/local/lib/python3.6/site-packages/pymongo/collection.py", line 1820, in create_indexes app_1 | with self._socket_for_writes() as sock_info: app_1 | File "/usr/local/lib/python3.6/site-packages/pymongo/collection.py", line 197, in _socket_for_writes app_1 | return self.__database.client._socket_for_writes() app_1 | File "/usr/local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1121, in _socket_for_writes app_1 | server = self._get_topology().select_server(writable_server_selector) app_1 | File "/usr/local/lib/python3.6/site-packages/pymongo/topology.py", line 226, in select_server app_1 | address)) app_1 | File "/usr/local/lib/python3.6/site-packages/pymongo/topology.py", line 184, in select_servers app_1 | selector, server_timeout, address) app_1 | File "/usr/local/lib/python3.6/site-packages/pymongo/topology.py", line 200, in _select_servers_loop app_1 | self._error_message(selector)) app_1 | pymongo.errors.ServerSelectionTimeoutError: sg-backendstagingmongodb-25690.servers.mongodirector.com:27017: [Errno 104] Connection reset by peer -
Depending on field value change nested serializer
I am currently trying to implement the following serializer to the Profile serializer. But I would like to add a condition to it. Profile serializer class UserProfileSerializer(serializers.ModelSerializer): role = serializers.ChoiceField(choices=(('Reader', u'Reader'), ('Author', u'Author'), ('Admin', u'Admin'))) role_display = serializers.SerializerMethodField() class Meta: model = Profile fields = ('gender', 'birthday', 'icon', 'role', 'role_display') depth = 1 Author serializer class AuthorSerializer(serializers.ModelSerializer): class Meta: model = Author fields = '__all__' Reader serializer class ReaderSerializer(serializers.ModelSerializer): class Meta: model = Reader fields = '__all__' Both author and reader table has a one-to-one relationship towards profile table. Depending on the role option I would like to show a specific nested serializer. Example: { "id": 19, "username": "maoji1", "password": "pbkdf2_sha256$180000$YhzDiqzJ4OyC$syzkwR5X3/H2p5NTB0JEK2zS5nvYu5ddHrTgy3cYU/E=", "email": "pbkdf2_sha256$180000$YhzDiqzJ4OyC$syzkwR5X3/H2p5NTB0JEK2zS5nvYu5ddHrTgy3cYU/E=", "profile": { "gender": "male", "birthday": "2020-03-10", "icon": null, "role": { is_vip:True, validate_date:... } } } -
Filter select options by another models field
I'm building a project manager app, and I want to make that the options for the 'assigned_to' field in Task only show the participants in the grandparent Project. Is it possible? models.py class Project(models.Model): name = models.CharField(max_length=250) description = models.TextField(blank=True) project_lead = models.ForeignKey(User, on_delete=models.CASCADE, related_name='jefe_user', default='EGINBOOK') participants = models.ManyToManyField(User, related_name='participantes_user', blank=True) class Milestone(models.Model): project = models.ForeignKey(Project, on_delete=models.CASCADE, null=True) name = models.CharField(max_length=250) deadline = models.DateField(default=timezone.now) class Task(models.Model): milestone = models.ForeignKey(Milestone, on_delete=models.CASCADE) name = models.CharField(max_length=250) description = models.TextField(blank=True) assigned_to = models.ManyToManyField(User) status = models.CharField(max_length=5, choices=[(tag, tag.value) for tag in Taskstatus], default='Pendiente') deadline = models.DateField(default=timezone.now) -
How to filter a queryset for the highest value in one field grouped by each value in another field?
If I have a model like this from django.db import models class Thing(models.Model): name = models.CharField(max_length=255, unique = True, null=False) version = models.IntegerField(null = False) type = models.CharField(max_length=255, null=False) and I have a bunch of entries like Thing.objects.create(name = "foo1", version = 1, type = "A") Thing.objects.create(name = "foo2", version = 2, type = "A") Thing.objects.create(name = "bar1", version = 1, type = "B") Thing.objects.create(name = "bar2", version = 2, type = "B") Thing.objects.create(name = "bar3", version = 3, type = "B") How do I write a single Django query that will give me one entry for each of type type with the highest version? So, this result: Queryset< Thing(name = "foo2", version = 2, type = "A"), Thing(name = "bar3", version = 3, type = "B") > I was looking at the docs here; https://docs.djangoproject.com/en/3.0/topics/db/aggregation/ And its easy to do something like this; Thing.objects.aggregate(Max('version')) But this would only give me Thing(name = "bar3", version = 3, type = "B") -
I am trying to run the django wagtail demo app on google app engine. The app has been deployed and there are no errors on the GCP error reporting
I have allowed traffic on firewall port 8080, but I believe the issue lies in the app.yaml file and have added: entrypoint: uwsgi --http-socket :8080 --wsgi-file main.py, still the same error. My app.yaml is as below: runtime: python37 entrypoint: uwsgi --http-socket :8080 --wsgi-file main.py handlers: - url: /static static_dir: static/ - url: /.* script: auto env_variables: DJANGO_SETTINGS_MODULE: mysite.settings.production -
Twilio on Django, send SMS to numbers from database [closed]
I need to send SMS to all numbers from my database on Django, This is the code on twilio on python, how am I going to integrate this code to my django app and execute it in a button. And also from the body="As of {timestamp}, how to do that getting time.now? Thanks! from twilio.rest import Client account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' auth_token = 'your_auth_token' client = Client(account_sid, auth_token) message = client.messages \ .create( body="As of {timestamp}, the level is critical", from_='+15017122661', to='+15558675310' ) print(message.sid) -
Displaying Progressbar on same page using Ajax
I am using [https://github.com/czue/celery-progress][1] to display progressbar in django celery, I am able to display progressbar on redirecting the result to new-page but when I am trying to display on same page using ajax using following code I am unable to display the progress: $('#yuvform').on('submit', function(e) { //Alert.render('You will receive error email if generation fails'); e.preventDefault(); //e.stopImmediatePropagation(); //alert("Hello"); //var extern = document.querySelector('link[rel="import"]').import; //alert("Hello"); //alert($(extern).val()); $.ajax({ data: $(this).serialize(), // get the form data type: $(this).attr('method'), // GET or POST url: $(this).attr('action'), success: function(data) { if(data.frame_width_absent){ Alert.render('Please enter frame-width'); } else if(data.frame_height_absent){ Alert.render('Please enter frame-height'); } else if(data.frame_fps_absent){ Alert.render('Please Enter frame-fps'); } else if(data.bit_rate_absent){ Alert.render('Please Enter Bit-Rate'); } else if(data.bit_depth_absent){ Alert.render('Please Enter bit-depth'); } else if(data.container_absent){ Alert.render('Please Enter container'); } else if(data.duration_absent){ Alert.render('Please Enter container'); } /* else{ Alert.render('Success If generation fails you will receive an email'); }*/ //$('#frame').html(response); } }); //Alert.render('Success If generation fails you will receive an email'); //return false; }); }); If I remove the e.preventDefault(); line the progressbar is displayed on different page. -
Double calling of methods
I’m trying to get the value of method in django I’m getting get_object when I try to print It calls twice, one with value and second is None def get_object(self): section = ... return get_object_or_404(Section, pk=section) I’m using that object on my get_context_data and tried to print but I get two values of none and with values. Can someone explain what when wrong here. Thanks -
Django adding new models, Exception Type: OperationalError Exception Value: no such table:
I am trying to learn how to use Django and I made a new model, and when syncing the db and making migrations i am keep getting this error. How can I fix this or what am I doing wrong? I have tried running python manage.py makemigrations, manage.py migration, manage.py makemigrations --syncdb nothing seems to work. Environment: Request Method: GET Request URL: http://127.0.0.1:8080/admin/terra/terraformrepolist/ Django Version: 3.0.3 Python Version: 3.7.3 Installed Applications: ['terra.apps.TerraConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 396, in execute return Database.Cursor.execute(self, query, params) The above exception (no such table: terra_terraformrepolist) was the direct cause of the following exception: File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\contrib\admin\options.py", line 607, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\contrib\admin\sites.py", line 231, in inner return view(request, *args, **kwargs) File "C:\Users\User\PycharmProjects\WonderUS\venv\lib\site-packages\django\utils\decorators.py", line … -
Debug in settings is causing issues with images in media folder
In Django, I have set DEBUG = False and ALLOWED_HOSTS = ['localhost', '127.0.0.1']. But due to it, images tend to get hide even if they are shown in the TERMINAL. I always do clear the cache of both Google Chrome and Mozilla Firefox. Below is the screenshot from chrome Also their seems to an issue with Firefox At a moment, Chrome was showing all the images while firefox didn't show any of them in the below screenshot -
When crawling the text from the website by using the scrapy ,it will crawl all the content but not crawl the link content ,how to solve the issue
when crawl the data full content is not crawled ,here tag content is not crawled and also how to crawl tag href at a time. Html.code <p class="gnt_ar_b_p"> 24/7 Tempo has compiled a list of drugs in short supply from information provided by the <p class="gnt_ar_b_p"> However, drugs are frequently announced to be in short supply. In fact, the FDA has a running list of drug shortages due to anything from increasing demand to regulatory factors as well as supply disruptions. </p> <a href="https://www.accessdata.fda.gov/scripts/drugshortages/default.cfm" data-t- l="|inline|intext|n/a" class="gnt_ar_b_a"> Food and Drug Administration</a>. </p> shell response.css('p.gnt_ar_b_p').xpath("text()").extract() output 24/7 Tempo has compiled a list of drugs in short supply from information provided by the However, drugs are frequently announced to be in short supply. In fact, the FDA has a running list of drug shortages due to anything from increasing demand to regulatory factors as well as supply disruptions. -
Dynamically creating a list of F combined expressions Django
I am trying to create a formula field in the database for a project I am working on, at the moment I am having trouble with the numerical side of the operators, I am trying to create a list of Combined Expressions so that I can add use it in an annotation. Example of working: return F('field1') + F('field2') I am trying to dynamically create the fields it should return and the operator. Any help would be appreciated. Thanks. -
Django Foreignkey reverse access when parent model has multiple Foreignkeys
I am using the standard Django User-model and wrote this cutom Model: class Messages(models.Model): sender = models.ForeignKey(User, related_name="sender", on_delete=models.CASCADE) receiver = models.ForeignKey(User, related_name="receiver", on_delete=models.CASCADE) content = models.TextField() date = models.DateTimeField(default=timezone.now) Now, given a User-object user i want to access all the Messages he either sent or received. I tried: user.messages_set.all() but i am getting the following Error: 'User' object has no attribute 'messages_set'. How do i fix this? Thanks for your Answers! -
Display rating in html
I am working on a project in django, where I have created a toplist based on the rating given in the reviews. Is there a way I can get the rating of the films showed in the html? from models.py class Film(models.Model): title = models.CharField(max_length=100) title_short = models.CharField(max_length=17, default=None, null=True) plot = models.TextField() poster = models.ImageField(default="default.png", upload_to="posters") release_date = models.DateField(blank=True, null=True) date_posted = models.DateTimeField(default=timezone.now) class Review(models.Model): writer = models.ForeignKey(User, on_delete=models.CASCADE) reviewed_film = models.ForeignKey(Film, related_name='reviews', on_delete=models.CASCADE) title = models.CharField(max_length=100) content = models.TextField() rating = models.IntegerField( default=1, validators=[MinValueValidator(1), MaxValueValidator(5)] ) def __str__(self): # pragma: no cover return f"{self.reviewed_film.title} reviewed by {self.writer.username}" from toplist.html {% extends "board/base.html" %} {% block content %} <h1>Toplist</h1> {% for film in films %} <div class="col s12 m7"> <h2 class="header"></h2> <div class="card horizontal"> <div class="card-image"> <img src="/media/{{film.poster}}"> </div> <div class="card-stacked"> <div class="card-content"> <h5>{{forloop.counter}}. {{film.title}}</h5> <p>{{}}/5.0</p> </div> <div class="card-action"> <a href="#">Read more</a> </div> </div> </div> </div> {% endfor %} {% endblock content %} -
how can i print all array data to template page in browser not in console in django
How can I print all data of array or list of Django Framework in browser HTML Page instead of console of django just like PHP echo '<pre>'; print_r($data); in PHP, is there any way as it is really hectic to check the output in console. -
Django virtual model pretending a real one
I need to move one of my Django apps into microservice, it's Files app, that have File and Folder models inside of it. Other apps using this app, and it's models to attach files to some other models, for example, User has "avatar" field, which is linked to a File model, Blog has "folders" field, which linked to a list of Folder models, and so on. Microservice would be accessible by REST API, and whould have methods for quering files and folders rich enought to satisfact all the needs of existing code. Now, to make my transition easier, I don't wont to change models, that are using my old File and Folder models. I want to create "virtual" models, named as File and Folder, that doens't have any tables in the database, and not the DjangoORM models at all. But they should mimic behavior of usual models, being just a "proxy" of "facade" to the REST API. So, it should be possible to use models as usual: # Quering files (this actually does request like GET files-service/api/files/all/filter?object_id=157&object_type=user): user_files = File.objects.filter(object_id=157, object_type='user').all() # Getting single file (this actually does request like GET files-service/api/files/7611): single_file = File.objects.get_for_id(7611) # Using linked object (avatar … -
Does django have some inbuilt model getter functionality? I've "lost" a function
I'm just.. I dunno. The model is calling self.get_next_by_context_start(). And it works. I can call it in a shell. But I've grepped the entire codebase and... it's just... not there. grep -r "get_next_by_context_start" - this lists just two instances of the string, both times where the function is being called. There's no def get_next_by_context_start anywhere. How am I being this stupid? How can I lose an entire function?