Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I've tried to set my default python version as python3 but is still coming up with python 2.7
I'm trying to install Django on my mac (2013) and i have set my default python version to python3 but when i try install django i get an a warning saying python 2.7 has reached the end of it's life. Then it says that i can only install django versions 1.x.y DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Defaulting to user installation because normal site-packages is not writeable ERROR: Could not find a version that satisfies the requirement django==2.0.7 (from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11, 1.5.12, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10, 1.7.11, … -
How to sort key:value output with structlog?
I use structlog with Django and noticed that key:value output is alphabetical, which means that when I bind a new key beginning with _ like log.bind('_id'=id) then it is added at the very first. The documentation mentions a processor boolean parameter sort_keys but it doesn't seems to have an effect. How can I sort key:value based on time they are binded? This is my config: LOGGING = { "version": 1, "disable_existing_loggers": False, "formatters": { "json_formatter": { "()": structlog.stdlib.ProcessorFormatter, "processor": structlog.processors.JSONRenderer(sort_keys=False), }, "plain_console": { "()": structlog.stdlib.ProcessorFormatter, "processor": structlog.dev.ConsoleRenderer(pad_event=43, colors=True, force_colors=True ), }, "key_value": { "()": structlog.stdlib.ProcessorFormatter, "processor": structlog.processors.KeyValueRenderer( key_order=['timestamp', 'level', 'logger', 'event'], sort_keys=False ), }, }, "handlers": { "console": { "class": "logging.StreamHandler", "formatter": "plain_console", }, "json_file": { "class": "logging.handlers.WatchedFileHandler", "filename": "json.log", "formatter": "json_formatter", }, "flat_line_file": { "class": "logging.handlers.WatchedFileHandler", "filename": "flat_line.log", "formatter": "key_value", }, }, "loggers": { '': { "handlers": ["console", "flat_line_file", "json_file"], "level": "WARNING", 'propagate': False, }, 'app1': { "handlers": ["console", "flat_line_file", "json_file"], "level": "INFO", 'propagate': False, }, 'app2': { "handlers": ["console", "flat_line_file", "json_file"], "level": "INFO", 'propagate': False, }, 'app3': { "handlers": ["console", "flat_line_file", "json_file"], "level": "INFO", 'propagate': False, } } } structlog.configure( processors=[ structlog.stdlib.filter_by_level, structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S.%f"), # (fmt="iso"), structlog.stdlib.add_logger_name, structlog.stdlib.add_log_level, structlog.stdlib.PositionalArgumentsFormatter(), structlog.processors.StackInfoRenderer(), structlog.processors.format_exc_info, structlog.processors.UnicodeDecoder(), structlog.stdlib.ProcessorFormatter.wrap_for_formatter, ], context_class=structlog.threadlocal.wrap_dict(dict), logger_factory=structlog.stdlib.LoggerFactory(), wrapper_class=structlog.stdlib.BoundLogger, cache_logger_on_first_use=True, … -
model linked with model through M2O relation which is further linked with model through M2O relation raises error
I am working on an online-shop in django. I have linked the order model with the cart model through ForeignKey which is further linked with products model through ForeignKey. models.py: class products(models.Model): image = models.ImageField(upload_to='products/') name = models.CharField(max_length=50) slug = models.SlugField(blank=True, unique=True) title = models.CharField(max_length=50) price = models.FloatField() def __str__(self): return self.name class cart(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) item = models.ForeignKey(products, on_delete=models.CASCADE) ### slug = models.CharField(max_length=50, default='#') quantity = models.IntegerField(default=1) created_on = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.quantity} of {self.item.name}' def get_total(self): total = self.item.price * self.quantity floattotal = float("{0:.2f}".format(total)) return floattotal class order(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) item = models.ForeignKey(cart, on_delete=models.CASCADE) ### slug = models.SlugField() quantity = models.IntegerField() created_on = models.DateTimeField(auto_now_add=True) def __str__(self): return f'{self.quantity} of {self.item.item__name}' I wanted to create object of order as: def order_view(request, slug): cart_qs = cart.objects.filter(user=request.user, slug=slug) cart_item = cart_qs[0] order.objects.create(user=request.user, item=cart_item.item.name, slug=slug, quantity=cart_item.quantity) #### It raises error as: Cannot assign "'The latest one'": "order.item" must be a "cart" instance. Why this error arises and how can I resolve this? -
Django, how to set inline formset factory with two ForeingKey?
I have create a code that works perfectly except for one little problem. I have created an inline formset factory utilizing two models: Lavorazione and Costi_materiale. class Lavorazione(models.Model): codice_commessa=models.ForeignKey(Informazioni_Generali, ) numero_lavorazione=models.IntegerField() class Costi_materiale(models.Model): codice_commessa=models.ForeignKey(Informazioni_Generali) numero_lavorazione=models.ForeignKey(Lavorazione) prezzo=models.DecimalField() After I have created the inline formset facotry as the following: CostiMaterialeFormSet = inlineformset_factory( Lavorazione, Costi_materiale, form=CostiMaterialeForm, fields="__all__", exclude=('codice_commessa',), can_delete=True, extra=1 ) But I have in Costi_materiale two ForeignKey, instead in the form the formset recognise only numero_lavorazione and not also codice_commesse. I want that the formset set in the first model the codice commesse and lavorazione fields and subsequently in the inline formset the other fields. In other word: How can I set two ForeignKey in a inline formset factory? -
Convert String of List to List in Python
I need to convert a string of list to List in Python ..... I have seen many of the similar questiions but none of them are works in this case ..... I am passing some values through PostMan ..... The key passing as a form data Key = controls value = [CR1,CR2] I am fetching the data like this c_list = self._kwargs['data'].get('controls', []) print(c-list) print(type(c-list)) I am getting the following o/p [CC-2,CC-3] <class 'str'> But I need to get it as a list so I have tried the following method import ast c_list = self._kwargs['data'].get('controls', []) res = ast.literal_eval(c_list) But I am getting the following Error malformed node or string: <_ast.Name object at 0x7f82966942b0> -
How to make calculationa dn assign condition in ManytoMany models in Django
Guys i am new in Django and explore its docs and youtube. But i can't find answer to my specific questions as i am sure i am making an error in my code. models.py class Profiles(models.Model): name=models.CharField(max_length=200) surname=models.CharField(max_length=200) class Meta: db_table='profiles' class Year20(models.Model): name=models.CharField(max_length=200) profiless=models.ManyToManyField(Profiles) math=models.DecimalField(decimal_places=2,max_digits=1000) english=models.DecimalField(decimal_places=2,max_digits=1000) class Meta: db_table='year20' class Year19(models.Model): name=models.CharField(max_length=200) profiless=models.ManyToManyField(Profiles) math=models.DecimalField(decimal_places=2,max_digits=1000) english=models.DecimalField(decimal_places=2,max_digits=1000) class Meta: db_table='year19' class Faculty(models.Model): name=models.CharField(max_length=200) profiless=models.ManyToManyField(Profiles) acting=models.DecimalField(decimal_places=2,max_digits=1000) class Meta: db_table='faculty' i have 2 questions: Wheather i am doing right assiging ManytoMany model in such way? Profiles model relates to all tables as it contains their name and surname. How to filter values from multiple tables , conduct calculation and assign condition? I assigned ManytoMany model to each table in hope be able to make calculations using variables form different tables. I do not want you think i ask without researching and trying. What i could do is filtering and calculation just from 1 table. score_merit=Year19.objects.annotate( final_grade=F('math') / F('english')).filter(final_grade__gt=61,) However i want to get final score which is : ath_avrg=(year19.math+year20.math)/2 eng_avrg=(year19.eng+year20.eng)/2 final_score=(math_avrg+eng_avrg+acting)/3 and finally print name and surname of student where final_score > 70 I want to learn how to combine values from diferent tables and make calculations and finally filter based on conditions … -
Different leaderboards for different levels using Redis
I'm new to Redis, and I'm trying to create leaderboards for different levels in a game (e.g. the game might have 20 levels, and I would like to create 20 different leaderboards). Reading the documentation from AWS, it seems that sorted sets are the way to go, but would I need to create 20 different elastic cache instances? Or would I do something like ZADD leaderboard:1, ZADD:leaderboard:2, where 1 or 2 corresponds to the id of the game? Apologies if this is a stupid question as this is my first attempt at Redis. -
AttributeError: type object 'AuthUserGroup' has no attribute 'REQUIRED_FIELDS'
I am using Django 3.0.5 and trying to make migrations but I get this error AttributeError: type object 'AuthUserGroup' has no attribute 'REQUIRED_FIELDS'. I have added the AUTH_USER_MODEL=mins_auth.AuthUserGroup in settings.py. This is the class model AuthUserGroup: class AuthUserGroup(models.Model): appuser = models.ForeignKey(AppUser, blank=True, null=True, on_delete=models.SET_NULL) group = models.ForeignKey(AuthGroups, blank=False, null=True, on_delete=models.SET_NULL) class Meta: """Override table details.""" db_table = 'auth_user_groups' verbose_name = 'AuthUserGroup' verbose_name_plural = 'AuthUserGroups' What am I doing wrong? -
Django Rest Framework Related Query?
There is 3 models, Article(post) Follow(To follow a user) User, How can I get all the post of user I'm following? class Article(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE) slug = models.SlugField(db_index=True, unique=True, max_length=255) title = models.CharField(max_length=255) subtitle = models.CharField(blank=True, max_length=400) body = RichTextUploadingField() class Follow(models.Model): user_from = models.ForeignKey(User, related_name='rel_from_set', on_delete=models.CASCADE) user_to = models.ForeignKey(User, related_name='rel_to_set', on_delete=models.CASCADE) created = models.DateTimeField(auto_now_add=True, db_index=True) class User(models.Model): pass -
Action decorator with API view in Django is not working
I have created following API view. class LandingFlowViewSet(APIView): @action(detail=True, methods=['GET']) def get_mobile_number(self, request, pk=None, *args, **kwargs): return Response(('ok'), status=200) urls.py path('landing-flows/', views.LandingFlowViewSet.as_view()), request format :- /landing-flows/get_mobile_number/ I am getting 404 error.It is working fine with model view set. -
Hide a button in jQuery after an AJAX call
I have a list of items from a database displayed thanks to a for-loop in Django. I have a "save button" next to each one to save them to a favorite database thanks to an AJAX call. Everything works like a charm. But I want the "save button" to .hide() whenever the AJAX call is a "success". But if I do so, every "save button" from the page is hidden. So I tried to use .parent() or .closest() to select only the <div> where my "save is button" with no luck. My HTML: {% for sub_product in products %} <div class='sub_button'> <form class="add_btn" method='post'>{% csrf_token %} <button class='added btn' value= '{{product.id }} {{ sub_product.id }}' ><i class=' fas fa-save'></i></button> </div> {% endfor %} My AJAX: $(".added").on('click', function(event) { event.preventDefault(); var product = $(this).val(); var url = '/finder/add/'; $.ajax({ url: url, type: "POST", data:{ 'product': product, 'csrfmiddlewaretoken': $('input[name=csrfmiddlewaretoken]').val() }, datatype:'json', success: function(data) { if (data['success']) $(this).parent('.sub_button').hide(); } }); }); -
How to serve an image variable in a response?
When serving a file, we normally include it in the Response as such: response['Content-Disposition'] = f'attatchment; filename="<file-path>"' My issue however is I need to serve an image file from a variable. The image is stored on a different server which is downloaded, stored as a variable, and then needs to be attached to my Response object. Is this possible? Something like the following: import PIL, io from django.http import HttpResponse img = PIL.Image.open(io.BytesIO(photo_bytes)) response = HttpResponse(content-type='image/png') response['Content-Disposition'] = f'attatchment; filebytes="{photobytes}"' -
Django how to filter ManyToMany Field
I am trying to build a form with filtered many-to-many field. so i created Objects: Dayname 1) name=sunday 2) name=monday Submain 1) name:Math days(ManytoMany field): Sunday Monday 2) name: Sport days(ManytoMany field): Tuesday 3) name:Dance days(ManytoMany field): Sunday Tuesday Day 1)name(Char field)="Sunday" hog1(ManytoMany field, filterd): will show me only Dance and Math to pick. how can i filted this hog1 manytomany field in the form.py ? should i change the Name of Day model into forginkey of dayname? thank you for any help. I Have 3 Models: Models.py class Dayname(models.Model): name = models.CharField(verbose_name="day", max_length=200, null=True) def __str__(self): return self.name class Submain(models.Model): name = models.CharField(verbose_name="שם החוג", max_length=200, null=True) days = models.ManyToManyField(Dayname, verbose_name="ימי פעילות", related_name="active", max_length=200, null=True, ) def __str__(self): return self.name class Day(models.Model): name = models.CharField(verbose_name="יום", max_length=200, null=True) hog2 = models.ManyToManyField(Submain, verbose_name="חוג 2 ביום", related_name="hog2", max_length=200, null=True, ) def __str__(self): return self.name forms.py class DaysForm(ModelForm): def __init__(self, *args, **kwargs): super(DaysForm, self).__init__(*args, **kwargs) self.fields['hog1'].required = False self.fields["hog1"].widget = CheckboxSelectMultiple() self.field['hog1'].queryset = Submain.objects.filter(days__in__name="sunday") -
Django ModelForm not saving any data
Using django 3, I have a model and a modelform: class Upload(models.Model): content = models.TextField(blank=True, null=True) image = models.FileField(upload_to='images/', blank=True, null=True) class UploadForm(forms.ModelForm): class Meta: model = Upload fields = ['content',] def clean_content(self): content = self.cleaned_data.get('content') if len(content) > MAX_CONTENT_LENGTH: raise forms.ValidationError('This content is too long') The view looks like this: def upload_view(request, *args, **kwargs): form = UploadForm(request.POST or None) if form.is_valid(): instance = form.save(commit=False) instance = instance.save() form = TweetForm() I am prompting the user to upload the contents only. After saving the form, even if I input some text inside the form, in the database it gets a value of NULL. How do I fix this? -
Django ORM: child's fields & values not inherited. Objects duplicated. (Using Django admin interface)
I'm trying to have a variety of dishes (Pizza, Subs, etc) that inherit from a common (concrete) parent class Dish. (Logically, I have no reason for it to be concrete other than having had difficulties implementing it). Every pizza (or other concrete dish) corresponds to exactly one dish ID (implemented as FK here) and every dish (ID) is exactly one pizza. I am new to this, but based on my understanding, the shared fields (name, type price, size and dish ID (PK for Dish = FK dish_id for Pizza)) in Dish as well as their values are inherited by children such as Pizza. So much for the theory. Now I implemented the classes as per below. And then I use the Django Admin interface to create objects, but against expectations, when I create a Dish object of type 'Pizza', automatically a Pizza object is created. Now when I go into that Pizza object, the name, type, price and size fields are blank. Shouldn't they be aready set when I select Pizza's dish attribute as the Dish-object I just created? And also when I start by creating a Pizza, selecting the corresponding parent (or creating it in the Django admin interface), … -
How to query links present in database from data I've got from user in Python?
I have cruciblelinks that I'm getting from a user in the form of: ['https://crucible05.cerner.com/viewer/cru/CCS-28483', 'https://crucible05.cerner.com/viewer/cru/CCS-28520'] It's a list data type. My Python model looks like this - (this is just to get a clearer picture) class reviewComments(models.Model): reviewID = models.CharField(max_length=20, blank=True) commentID = models.CharField(max_length=20, primary_key=True) solution = models.CharField(max_length=50) comment = models.TextField() dateCreated = models.DateField() type = models.CharField(max_length=20, blank=True) **crucibleLink = models.URLField(blank=True)** authorID = models.CharField(max_length=20) reviewerID = models.CharField(max_length=20) def __str__(self): # pragma: no cover return self.commentID In MongoDb, I have crucibleLink's that are present in the form of https://crucible05.cerner.com/viewer/cru/CCS-26041#CFR-2549575 (notice the extra # part) How do I query in Python so that I am able to get the data from MongoDb of the links that I was getting from the user in the beginning? -
DRF_simplejwt authentication does'nt work
i have an user_auth with drf_simplejwt, but only the super user can make login, when i try to make login with a normal user its not work #serializers.py class TokenSerializer(serializers.Serializer): username = serializers.CharField() password = serializers.CharField() def validate(self, data): user = authenticate(**data) if user and user.is_active: return user return serializers.ValidationError('Incorret cridentials') #views.py from rest_framework_simplejwt.tokens import RefreshToken class TokenView(generics.GenericAPIView): serializer_class = TokenSerializer def post(self, request, *args, **Kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.validated_data refresh = RefreshToken.for_user(user) return Response({ 'user': UserSerializer(user, context=self.get_serializer_context()).data, 'token': { 'refresh': str(refresh), 'access': str(refresh.access_token) } }) -
Djnago Razorpay integration
I want to integrate my website with razorpay, but I am lacking with the correct resource or tutorial for that. Actually I want a wallet in my website in which a user add money in his/her wallet by simply entering the amount in form and submitting the form. But I don't known how to link all files like models.py views.py urls.py and as well as the templates file. The attempt is given below please help! class PaymentDtails(models.Model): paymentby=models.OneToOneField(User,on_delete='CASCADE',null=True) razorpay_id = models.CharField(max_length=255) payment = JSONField(null=True, blank=True) amount=models.IntegerField(default=0) forms.py class AddMoneyForm(forms.ModelForm): class Meta: model= PaymentDetails fields=('amount',) please help me to integrate all that -
Chat application between user and customers
want to create a simple chat application between users and customers with the help of Django Channels.. this is my model. class ExternalMessageModel(models.Model): """ This class represents a chat message. It has a owner (user), timestamp and the message body. """ customers = models.ForeignKey('customers.Contact', on_delete=models.CASCADE, verbose_name='customer', related_name='from_customer', db_index=True) users = models.ForeignKey('users.UserProfile', on_delete=models.CASCADE, verbose_name='users', related_name='to_user', db_index=True) timestamp = models.DateTimeField('timestamp', auto_now_add=True, editable=False, db_index=True) body = models.TextField('body') I know how to create a chat application between users and users. but here my requirement is a bit different I have two tables one or user and another for customer.so my requirements are reals time communication between users and customers -
Django: the post isn't selected automatically of particular user
hi am working on a project where am using multiple user data a user did a post onto the site and when driver see that post he adds their offer to that post but when driver submit the post ...at the admin level the particular is selected automatically but the post is not selected on which he adds price this is my post model.py class Loader_post(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE ,related_name="Loader") pick_up_station = models.CharField(max_length=150) destination_station = models.CharField(max_length=150) sender_name = models.CharField(max_length=150) phone_number = PhoneNumberField(null=False, blank=False, unique=True) receiver_name = models.CharField(max_length=150) this is my second model of adding price to a particular post class price(models.Model): my_post = models.ManyToManyField(Loader_post, related_name='prices') user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, default='') driver_price = models.CharField(max_length=150, null=True) driver_name = models.CharField(max_length=150, null=True) approved_price = models.BooleanField(default=False) status = models.BooleanField(default=False) this is my adding price to the post views.py @login_required def add_price_to_post(request, pk): post = get_object_or_404(Loader_post, pk=pk) user = request.user if request.method == "POST": form = price_form(request.POST) if form.is_valid(): ps = form.save(commit=False) ps.user = request.user ps.status = True ps.post = post ps.save() return redirect('Driver:Driverview') else: form = price_form() return render(request, 'price_form.html', {'form': form}) this is my html add post button {% for loader in Loader %} this is loop and this is button <a … -
Linking Foreign key between tables in django models
I am just starting out with Django and so please help me out with my doubt. Currently, I have three tables Topic, Webpage, and AccessRecord. In the third table AccessRecord, I have used a ForeignKey with the second table Webpage. But Webpage table has three attributes topic, name, and URL ..so my doubt is which attribute of these three will be treated as a Foreign key to AccessRecord table. Any help will be greatly appreciated. class Topic(models.Model): top_name = models.CharField(max_length=264,unique = True) def __str__(self): return(self.top_name) class Webpage(models.Model): topic = models.ForeignKey(Topic,on_delete=models.CASCADE) name = models.CharField(max_length=264,unique=True) url = models.URLField(unique=True) def __str__(self): return self.name class AccessRecord(models.Model): name = models.ForeignKey(Webpage,on_delete=models.CASCADE) date = models.DateField() def __str__(self): return str(self.date) -
Sentry cloud database migration: Cannot see the migrated data in the new Sentry install
Here is the issue I am seeking to resolve: I am in the process of migrating a production Sentry instance (hosted on Nomad) onto a new new install (hosted on AWS ECS), both currently on version 9.0.0. Both the current and the new Postgres databases are hosted in AWS RDS. Same for Redis, they are both managed by AWS (i.e. ElasticCache). I have used two methods to migrate the database: (1) AWS RDS snapshot/restore, and (2) pg_dump, and pg_restore methods; and both worked successfully from the database perspective. The new database seems fine to me, with all tables exactly the same as the original database. However, when loading and hitting the new hosted Sentry instance, I can only see one empty Sentry organization, no teams, no project. Empty. I haven’t migrated the Redis database, but I can’t see why this would be the cause of it, given it’s a cache mechanism only. The source Sentry install instance also uses SAML2 for SSO. I cannot see any of that configuration, and any of that original data in the new install. What am I missing? Thank you. -
conect django to datastax casandra
I am try to conect django to datastax casandra but i cant do this. my database conection is here : DATABASES = { from cassandra.auth import PlainTextAuthProvider from cassandra.cluster import Cluster 'default': { cloud_config= { ` 'secure_connect_bundle': 'secure-connect-okul.zip'` } auth_provider = PlainTextAuthProvider('mahmut215', 'm11223344m') cluster = Cluster(cloud=cloud_config, auth_provider=auth_provider) session = cluster.connect() } } ` Help me please . -
How can I solve "cannot import name 'main' from 'virtualenv'"?
When I try running virtualenv I get the following error: [jelly@laptop Getskilled]$ virtualenv venv Traceback (most recent call last): File "/usr/bin/virtualenv", line 6, in <module> from virtualenv import main ImportError: cannot import name 'main' from 'virtualenv' (/home/jelly/.local/lib/python3.8/site-packages/virtualenv/__init__.py) Virtualenv was working when I last used it for a project so I am guessing that an update cause it to break. I have tried reinstalling virtualenv and pip. The closest post I could find was this one: virtualenv: cannot import name 'main' I tried following this post so I ran the following in the python interpreter: import virtualenv virtualenv.__file__ Which returned: '/home/jelly/.local/lib/python3.8/site-packages/virtualenv/init.py' However, there was no file /usr/local/bin/virtualenv.py and there is no virtualenv.py in the .local directory so that solution in that post won't work for me. What can I try next? -
Send Form Content to Endpoint in Different App Django
Say I have an app called App1 - inside of which there is a template that has a form with name and email. Now, say I have an app called App2 - that has an endpoint which takes in a name and email and sends an email to that email. Now, I want to combine the two, so that I can make the form contents go to the endpoint in App2 on submit, thus sending an email to the email in the form. How would I do this? Would it be better to just put them in the same app? When would someone use 2 apps over 1? Does this make sense? Thanks for your help!