Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Celery Daily Scheduled Tasks with Crontab
I have problem with daily scheduled tasks with crontab. Here is my celery.py app.conf.beat_schedule = { 'run-cache-updater': { 'task': 'tasks.run_cache_updater', 'schedule': crontab( minute=0, hour='1-4' ), } } Below is my tasks.py What I am doing there is, getting all records from DB. Triggering other jobs to update my caches on Redis. @app.task def run_cache_updater(): batch_size = 1000 cache_records = models.CacheRecords.objects.all() def _chunk_list(all_records, size_of_batch): for i in range(0, len(all_records), size_of_batch): yield [item.id for item in all_records[i: i + batch_size]] for items in _chunk_list(cache_records, batch_size): update_cache.delay(items) @app.task def update_cache(ids_in_chunks): for id in ids_in_chunks: # Some calls are done here. Then sleep for 200 ms. time.sleep(0.2) My tasks are running good. However, they start to run between 1 and 4 and then they start again every 4 hours like 8-11, 15-18.. What I am doing wrong here and how can I fix it? -
Can't connect to Django database in Heroku
I am trying to deploy a Django application in Heroku and connect it to a database using dj-database-url. The app runs fine locally (with python manage.py runserver) but both the heroku local web command and the Heroku deployment fail with the message: 9:47:06 PM web.1 | ModuleNotFoundError: No module named 'dj_database_url' However, when I go into Heroku's shell and try to install the package, it says that the requirement is already satisfied ~ $ pip install dj-database-url Requirement already satisfied: dj-database-url in ./.heroku/python/lib/python3.6/site-packages As a side note, I have another module called django_hosts which I use and doesn't have any problems. Here is my requirements.txt file: dj-database-url==0.5.0 Django==2.1.1 django-hosts==3.0 psycopg2==2.7.5 pytz==2018.5 And here are the lines in production.py settings file that uses dj_database_url: import dj_database_url ... db_from_env = dj_database_url.config() DATABASES['default'].update(db_from_env) I don't know if it helps, but here are my installed apps: I NSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # third party 'django_hosts', # custom apps 'analytics', 'shortener', ] I thought that maybe I need to add dj_databse_url underneath django_hosts, but it didn't work. If you need any more information, please let me know in the comments. Cheers! -
Django project architecture tips/hints/advices
Intro I'm kinda new in django and python and to learn it in proper way I decided to start my first little bit more complicated project. To cut long story short I need a advice/help if I'm thinking in right direction. Description of the app Whole app is about page were users are able to pict a page template and than modify the content of the page by them self. Architecture I've decided that each template (the look of the user page) will be separate django app. I created the simple app mgmt to manage ordinary stuff a.k.a User profile extending etc. Requirements Users can not modify/view each ohther elements of the same template Link for a user page should look like mysite.tld/user Solution The solution I've taken: urls.py tweaking project urls.py urlpatterns = [ path('admin/', admin.site.urls), path('jet/', include('jet.urls', 'jet')), # Django JET URLS path('<username>/',include('mgmt.urls','mgmt')),] template urls.py urlpatterns = [ path('<username>/', views.index, name='index'),] mgmt app urls.py urlpatterns = [ path('', views.route, name='route'),] mgmt.route def route(request, username): u = User.objects.get(username=username) templRender = __import__(u.profile.template+'.views', fromlist=[u.profile.template]) return templRender.index(request, username) Question1: What is the better way to get arround this solution? admin interface permission tweaking I've solved the permission problem with set of following … -
TypeError: loadshortlink() got multiple values for argument 'shortlink'
Error: TypeError: loadshortlink() got multiple values for argument 'shortlink' My urls.py: path('s/<str:shortlink>',views.loadshortlink, name="get_longlink") views.py: def loadshortlink(shortlink): print("Translating short link %s" % shortlink) link = get_longlink(shortlink) return render(request, 'shortlinks/openlong.html', { 'link': link }) def get_longlink(shortlink): print('Short link is %s' % shortlink) links = Links.objects.filter(shortlink=shortlink) if len(links)>1 or len(links)==1: link = links[0].longlink return link else: return 'No matched long links' When I visit the url: http://127.0.0.1:8000/s/4nI I get the error: Internal Server Error: /s/4nI Traceback (most recent call last): File "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) TypeError: loadshortlink() got multiple values for argument 'shortlink' Why is this happening? -
Character/Inventory/Equipment DB structure - Django/SQLite
I'm teaching myself django and wanted a simple set up for users to have multiple characters, each with their own equipment/inventory. I've never worked with databases so getting the relations correct is something I need help/guidance on. My thinking: A User can have multiple UserCharacters, which each have reference to a base Character instance, along with some BaseAttributes and AttributeModifiers. Each UserCharacter also has an inventory made of of InventoryItems which, like UserCharacters, reference an Item instance, and have BaseAttributes and AttributeModifiers. I was wondering if it was wise/possible to re-use identical InventoryItems (and BaseAttributes, AttributeModifiers, etc) across UserCharacters. IE if two UserCharacters each have an inventory that contains a "Sword" Item with identical stats, could I assign that Sword InventoryItem to both UserCharacters inventories? The models I have right now: ======================================== | User |--- | username ======================================== ======================================== | AttributedObject |--- | attributes | modifiers ======================================== ======================================== | Attribute |--- | name | description ======================================== ======================================== | BaseAttribute |--- | object >- ForeignKey(AttributedObject.id), related_name='attributes' | attribute >- ForeignKey(Attribute.id) | value ======================================== ======================================== | AttributeModifier |--- | object >- ForeignKey(AttributedObject.id), related_name='modifiers' | attribute >- ForeignKey(Attribute.id) | value | method | duration ======================================== ======================================== | Item(AttributedObject) |--- | name | stack_size … -
Django test UpdateView with post request
I have a simple UpdateView which I want to test: def test_valid(self): response = self.client.post(self.path, { 'name': self.obj.name, 'country': self.obj.country, 'gender': self.obj.gender, 'about': self.obj.about, 'email': self.obj.email, 'city': 'new city name', 'zip': self.obj.zip, }) self.assertEqual(response.status_code, 200) self.obj.refresh_from_db() self.assertEqual(self.obj.city, 'new city name') How can I avoid to write all the values that I don't want to update again? -
Django rest framework probleme
here is my code : from rest_framework import routers from rest_framework.routers import DefaultRouter from .api import ListViewSet, CardViewSet router = DefaultRouter() router.register(r'lists', ListViewSet,'lists') router.register(r'cards', CardViewSet, 'cards') urlpatterns = router.urls but When i run the server i got this error : Page not found (404) Request Method: GET Request URL: http://localhost:8000/scrumboard/cards Using the URLconf defined in djangularApp.urls, Django tried these URL patterns, in this order: ^admin/ ^$ ^scrumboard ^lists/$ [name='lists-list'] ^scrumboard ^lists.(?P[a-z0-9]+)/?$ [name='lists-list'] ^scrumboard ^lists/(?P[^/.]+)/$ [name='lists-detail'] ^scrumboard ^lists/(?P[^/.]+).(?P[a-z0-9]+)/?$ [name='lists-detail'] ^scrumboard ^cards/$ [name='cards-list'] ^scrumboard ^cards.(?P[a-z0-9]+)/?$ [name='cards-list'] ^scrumboard ^cards/(?P[^/.]+)/$ [name='cards-detail'] ^scrumboard ^cards/(?P[^/.]+).(?P[a-z0-9]+)/?$ [name='cards-detail'] ^scrumboard ^$ [name='api-root'] ^scrumboard ^.(?P[a-z0-9]+)/?$ [name='api-root'] The current path, scrumboard/cards, didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. -
Multiple options in Django Rest Framework
class ReservationSerializer(serializers.ModelSerializer): class Meta: model = Booking fields = [ 'pk', 'persons', 'date', 'time', 'table_number', 'restaurants', 'menu' ] This is my serializer class and I want the menu field to be a multiple checkbox fields Below is my model class and here menu is a ManyToManyField. But I figured this is not the right way to go. class Booking(models.Model): persons = models.IntegerField() date = models.DateField() time = models.TimeField() table_number = models.IntegerField() restaurants = models.ForeignKey('sb_comp.Restraurant', on_delete=models.CASCADE) menu = models.ManyToManyField('sb_comp.Menu') def __str__(self): return '%s' % self.restaurants -
__init__() missing 1 required positional argument: 'request'
I'm trying to upgrade a django project from 1.8 to 1.10. Following: Django error: render_to_response() got an unexpected keyword argument 'context_instance' I have changed a view function from from django.shortcuts import render from django.http import HttpResponse from django.template import RequestContext, loader from django.shortcuts import render from django.core.mail import EmailMessage from django.http import HttpResponseRedirect from sellmyland.settings import DEFAULT_FROM_EMAIL from ipware.ip import get_ip import json from myapp.forms import myform def index(request): form = myform() # return render('longform.html', {"form": form}, context_instance=RequestContext(request)) return render(request,'longform.html',RequestContext()) You can see the commented out version in the code. I'm getting the error above. Here is the traceback: Traceback: File "....\lib\site-packages\django\core\handlers\exception.py" in inner 39. response = get_response(request) File "....\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response 249. response = self._get_response(request) File "....\lib\site-packages\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "....\lib\site-packages\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "....myapp\views.py" in index 31. return render(request,'longform.html',RequestContext()) Exception Type: TypeError at / Exception Value: __init__() missing 1 required positional argument: 'request' How can I get this working? -
Python / Django pdfkit wkhtmltopdf UnknownContentError
I'm getting an UnknownContentError when generating a PDF document from a project URL (https://ourcodeworld.com/articles/read/241/how-to-create-a-pdf-from-html-in-django) - using pdfkit (wkhtmltopdf). This line causes the error: pdf = pdfkit.from_url('http://127.0.0.1:8000/cbib/open_detailed_research_outputs/', False, options) The URL is valid and displays the way it should in the browser. Could someone please advise where I'm going wrong. [Other URLs in my web app project seem to work except for this one.] For example, this works: pdf = pdfkit.from_url('http://127.0.0.1:8000/cbib/research_outputs/', False, options) Further error info: OSError at /cbib/open_detailed_research_outputs/download/ wkhtmltopdf reported an error: Loading pages (1/6) [> ] 0% [======> ] 10% [=======> ] 13% [==============================> ] 50% Error: Failed to load http://127.0.0.1:8000/cbib/open_detailed_research_outputs/, with network status code 299 and http status code 500 - Error downloading http://127.0.0.1:8000/cbib/open_detailed_research_outputs/ - server replied: Internal Server Error [============================================================] 100% Counting pages (2/6) [============================================================] Object 1 of 1 Resolving links (4/6) [============================================================] Object 1 of 1 Loading headers and footers (5/6) Printing pages (6/6) [> ] Preparing [============> ] Page 1 of 5 [========================> ] Page 2 of 5 [====================================> ] Page 3 of 5 [================================================> ] Page 4 of 5 [============================================================] Page 5 of 5 Done Exit with code 1 due to network error: UnknownContentError Request Method: POST Request URL: http://127.0.0.1:8000/cbib/open_detailed_research_outputs/download/ Django Version: 2.0.2 Exception … -
How to get values from ForeignKey's related model in Django queryset?
I'm having trouble accessing a field in a related model using a foreign key. I have two models, Person and Party as outlined below: class Person(models.Model): title = models.CharField(max_length = 4, blank=True, null=True) first = models.CharField(max_length = 30, blank=True, null=True) last = models.CharField(max_length = 30, blank=True, null=True) party = models.ForeignKey(Party, related_name = 'parties', on_delete=models.CASCADE, blank=True, null=True) def __str__(self): return self.id class Party(models.Model): party_name = models.CharField(max_length = 50) party_code = models.CharField(max_length = 5) def __str__(self): return self.party_name I'm trying to get a count of people in each party. I'd like the result to look like: [{ "party_name": "Democrat", "total_members": 93 }, { "party_name": "Republican", "total_members": 32 }, { "party_name": "Non-Partisan", "total_members": 34 }] My serializer is as follows: class CountPartiesSerializer(serializers.ModelSerializer): total_members = serializers.IntegerField() class Meta: model = Person fields = ('id', 'party', 'total_members') And my viewset is as follows: class CountPartiesViewSet(DefaultsMixin, viewsets.ModelViewSet): queryset = Person.objects.values('party__party_name').annotate(total_members = Count('id')) serializer_class = CountPartiesSerializer But this results in the following: [{ "party": null, "total_members": 34 }, { "party": null, "total_members": 93 }, { "party": null, "total_members": 32 }] I've tried a million different things and I know I'm missing something, but I can't figure out how to get this working. Any advice would be much … -
Django email verification URL with token parameter
I'm trying to create email verification auth but not able to access this url url: 127.0.0.1:8000/activate/d34324/KYJsqYMoV5DJ0vewSBdC9KZlZtnOAU7KE please sugess how can i create proper routes for this code urls.py url(r'^logout/$', OwnerRegister.logout_view), url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',OwnerRegister.activate,name='activate'), viwes.py class OwnerRegister(TemplateView): template_name = "owner_register.html" def get_context_data(self, * args, ** kwargs): context = super(OwnerRegister, self).get_context_data() return context def logout_view(request): logout(request) return HttpResponseRedirect("/") def activate(request, uidb64, token): try: print ('\n\n request',request) user_id=request.GET.get('uid') token=request.GET.get('token') user = User.objects.get(username=user_id) profile = OwnerInfo.objects.get(user=user) print(user.date_joined) if profile.confirmation_code == token and user.date_joined > (datetime.datetime.now()-datetime.timedelta(days=1)): print("test") user.is_active = True user.save() user.backend='django.contrib.auth.backends.ModelBackend' auth_login(request,user) return HttpResponseRedirect('You have activated this account') except: return HttpResponseRedirect('') def send_registration_confirmation(self,user,request): p=OwnerInfo.objects.get(user=user) current_site = get_current_site(request) content = current_site.domain+"/activate" + user.username + "/" + str(p.confirmation_code) send_mail("Email Verify", content, 'no-reply@gsick.com', [user.email], fail_silently=False) -
How to execute python script from html page [on hold]
So i have a python script which has some functions like fetching, searching and etc from a database which is there on my pc. Now i want to create an html page with a form which on submitting can execute the functions in that python script. I searched a lot and found that can be done using Django, flask and cgi and etc. But all these things require a lot of setup and are too complex. 1) is there any simple way to do it? 2) if not can you give simple beginners guide to implement this -
Why we need to use 'get_absolute_url()' instead of custom defined similar methods?
Below is the method get_absolute_url() used in my Tag model class: def get_absolute_url(self): return reverse('post_by_tag', args=[self.slug]) Below is the way I access it in my template: <a href="{{ tag.get_absolute_url }}">{{ tag }}</a> It works fine. However, if I changed it to method name like get_abs() in both model and template files, still it works. As I can use custom method, I just want to know if there is any specfic reason to use get_absolute_url() as the method name to get the URI. Or, is it just a convention ? I am using Python 3.6.6 and Django 2.1. -
OneToOne Model delete Cascade in both ways
I have 2 models: class A(models.Model): name = models.CharField(max_length=50) def __str__(self): return "%s the place" % self.name class B(models.Model): a = models.OneToOneField(Place,on_delete=models.CASCADE) name = models.CharField(max_length=50) I want: If A is deleted B will be deleted (works) If B is deleted also A is deleted -
Correct usage for Django's `django.utils._os` (TypeError: expected str, bytes or os.PathLike object, not module)
I'm attempting to extend the runserver management command functionality that ships with Django by default . However, I'm running into an issue with the django.utils._os.upath module. I have a method defined as the following (this method will look for the default directory with which to find the application's SSL certificate and key-file): def default_ssl_certificates_dir(): import runsecureserver as runsecureserver_module path = os.path.dirname(upath(runsecureserver_module)) ssl_dirc = os.path.join(path, "certs") return ssl_dirc However, on calling my custom management command it seems to be breaking at the point at which the path variable is designated, path = .... Essentially, I receive the following error: TypeError: expected str, bytes or os.PathLike object, not module So, I'm seeing that runsecureserver_module is not undefined but instead a module ... I'm not too sure how to run with things from here? Is there any easy way around this, perhaps specifying so some of os.path.join using settings.BASE_DIR? Any help or advice would be greatly appreciated! -
POST CSRF Token with Django Rest Framework and React
I am trying to build an authentication system using django'authentication system to log users in. When I try to post the form's values to the correct endpoint, however, I get a 403 response because the CSRF token is missing. I have tried some articles like getting the cookie for the token and including it in the form itself, but nothing seems to work. Form is a basic form using ant design's components. Requests are made with axios axios.post("http://localhost:8000/login/", values) Can you help me? -
Bootstrap 4 carousel doesn't work with Django tags
I would to show a carousel for the highlighted post in to my Django blog. I've used Bootstrap 4 and this is my code: {% extends 'base.html' %} {% load static %} {% block head_title %}{{ block.super }} | Gis-Blog{% endblock head_title %} {% block content %} <div class="container-fluid"> <div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel"> <div class="carousel-inner"> {# area articoli in evidenza #} {% for posts in object_list %} {% if posts.post_highlighted %} <div class="carousel-item"> <img class="d-block w-100 img-fluid" src="{% static 'manuscriptus/img/demo_img.png' %}" alt="Header image"> <div class="carousel-caption d-none d-md-block"> <p class="h2 text-uppercase"><a class="" href="{{ posts.get_absolute_url }}">{{ posts.post_title }}</a></p> </div> </div> {% endif %} {% endfor %} </div> <a class="carousel-control-prev" href="#carouselExampleFade" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#carouselExampleFade" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> <div class="container"> <div class="row"> <div class="col-sm-9 mb-1 mt-5 pt-2 shadow"> {% for posts in object_list %} <div id="news" class="container"> <div class="row"> <img class="img-fluid" src="{% static 'manuscriptus/img/demo_img.png' %}" alt="Header image"> </div> <div class="row"> <div class="col-3"> <div class="row"> <small class="text-muted">Pubblicato il <strong>{{ posts.post_publishing_date|date }}</strong></small> </div> <div class="row"> {% for keyword in object_list.all %} <p>{{ keyword }}</p> {% endfor %} </div> </div> <div class="col-9"> <div class="row"> <p class="h3"><a href="{{ posts.get_absolute_url }}">{{ posts.post_title }}</a></p> … -
Integrating Angular with Django
Can anyone share a working example of a project which has Angular alongside Django as Backend. Also the steps to integrate Angular with Django. Also an example of integrating the Django CSRF Token within Angular Component! -
partition a string by dash (-) python
I want to get a string and divide it into parts separated by "-". input: aabbcc and output: aa-bb-cc is there a way to do so? -
Django custom field to handle datefield with only month and year
My app displays formsets where users can create objects. Once validated, the formset is displayed again and user can add new objects. Dates should only be month and year ("%m/%Y"). I could work on the input field (though jquery) to add '01/' in front of the date entered. But after submitting, the field now displays "%d/%m/%Y" (normal). So, I'm looking for a way to translate input string (ex : 09/2018) to dateField to store in the database, and then a translate this dateField to string when datas are retrieved from database. I know, I could simply use a form charfield for months and another one for years. But I would like to keep it as a date object, so, in templates, I could perform date formatting ({{ edu.start_date |date:"D, d M, Y" }}) Django custom model fields sound made for this : Django custom model fields. I could do something like this in the custom field: def string_to_date(value): value = '01/' + value la_date = datetime.strptime(value, "%d/%m/%Y").date() return la_date def date_to_string(la_date_date): la_date_str = la_date_date.strftime('%m/%Y') return la_date_str class DateYearMonth(models.DateField): def get_prep_value(self, value): return string_to_date(value) def to_python(self, value): return date_to_string(value) Well, this does not work so far. But I don't even know … -
Dynamic var name with content of another var in template
I try to generate a var name from another var value. To be more specific I'm in a loop and I try to display all parameters of an object, based on the loop incrementation. Example: I have a list of objects categories. I have an object diplayer which contain parameters cat_1, cat_2, cat_3 etc I try to do something like this {% for category in categories %} {{ displayer.cat_(category.id) }} {% endfor %} Of course my probleme is (category_id) I really don't know how to get value of category.id to use it in the param name of the object. For information I can not use a dictionary in place of the object displayer. An idea? Thanks a lot -
How Django validates form?
I have a little issue. For example, I have this view: def post_create(request): form = PostForm(request.POST or None) if form.is_valid(): instance = form.save(commit=False) instance.save() # message success messages.success(request, "Successfully Created") return HttpResponseRedirect(instance.get_absolute_url()) else: messages.error(request, "Not Successfully Created") context = { "form": form, } return render(request, "post_form.html", context) Main problem: after redirect I have both messages (if and else at the same time). WHY? Solution is: ... ... return HttpResponseRedirect(instance.get_absolute_url()) elif form.errors: messages.error(request, "Not Successfully Created") context = { "form": form, } return render(request, "post_form.html", context) But why I see both of messages when I redirect after success validation (1st variant)? -
Nginx 504 Timeout Error within Docker container running Django and loading Scikit-learn model into memory
I'm building a web app with Django that uses a pre-trained scikit-learn model to process data that an user inputs through a web form. During development I'm able to load the model into memory by running the following command in urls.py modelRF = joblib.load('model.pkl') However, when I try to deploy the app inside a Docker container I receive a 504 Gateway Timeout Error. I've tried increasing the timeout limits in the nginx.conf file without any success. I was wondering whether this could also be a problem with the amount of memory assigned to the container. I'm not sure whether the problem is related to Docker or to the way I'm loading the model into memory while in deployment (rather than in development). I'm using docker-compose with nginx, supervisor and uwsgi. My nginx.conf file looks like this: upstream django { server unix:///tmp/uwsgi.sock; # for a file socket } server { listen 80 default_server; server_name .example.com; charset utf-8; # max upload size client_max_body_size 75M; # Django media location /media { alias /home/docker/code/media; } location /static { alias /home/docker/code/static; } location / { uwsgi_pass django; include /home/docker/code/uwsgi_params; } } Cheers! -
Creating Notifications about User Actions, and include as data FK up to the chain
I have multiple interconnected models. class Item(models.Model): entity = models.ForeignKey(Entity, blank=True, null=True, related_name='items', on_delete=models.CASCADE) class Entity(models.Model): account = models.OneToOneField(Account, related_name='entity', on_delete=models.CASCADE) class User(models.Model): user = models.OneToOneField(User, related_name='account', on_delete=models.CASCADE) When a person do an operation(save,update,activate etc) a Notification is created. actor - who did the operation # User recipient - who owns the Object # User action_object - the object that received the operation class Notification(models.Model): actor = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='actor_notification', on_delete=models.SET_NULL) recipient = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name='recipient_notification', on_delete=models.SET_NULL) verb = models.CharField(choices=NOTIFICATION_VERB_CHOICES, max_length=5, blank=True, null=True) The action_object should be a ForeignKey also but, when the Notification is created I want to get his 'parents' if exists, for example: Actor | Recipient | Account | Entity | Item | Verb users1 user2 acc-user2 e32 i14 create user1 user3 acc-user3 -- --- create user1 user4 acc-user4 e34 --- update user1 user5 ----- --- --- create Obs. I know that Django has GenericForeignKey but is not an option for me. I checked other Notifications App they don't do exactlly what I want I'm thinking to use a separate class for action_object because I can have more classes than the ones above, because I think is clearer, even if I'm adding a new table. …