Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Passing generator object to Django template
I am developing a Django dictionary application and I am writing a helper function, get_tags(), to collect all the Tags that there are in a list of tagged Definitions. I would then use get_tags() in my views.py as follows to basically return all the Tags in my dictionary: def index(request): tags = get_tags(Definition.objects.all())) return render(request, "index.html", {"tags": tags}) As per the implementation of get_tags(), I am dubious whether a list comprehension or a generator expression would be more performant in the context I described above. Which version of get_tags() would be more efficient? List comprehension: def get_tags(objects): return [t for o in objects for t in o.tags.all()] Or generator expression? def get_tags(objects): return (t for o in objects for t in o.tags.all()) -
Python django ecommerce application to android apps? How to create?
I have an eCommerce website that created using python Django framework. Now I need an android app. like this website how to create this please help me. -
How do i get the highest ID of an item within a database in djngo?
When I try to save a new item I need to find the item with the highest ID in the database in order to add 1 to it and save the next item in the order in the database. Simply counting the items in the DB will not work as if an item is deleted the count will be incorrect. I have no code to fix but pseudo looks something like: look at all the items in the DB Find the item with the highest ID Add one to that number save the new item with the new highest id in the DB I am using Django. as such it should use the querysets within Django and or python. -
Why Django JQuery Infinitescroll not working (Cannot set property 'Infinite' of undefined, Waypoint is not defined)
I want to make an infinite scroll but it's not working and throws errors in the console: Here is my HTML: {% extends 'base.html' %} {% load static %} {% block imports %} <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> <script src="https://kit.fontawesome.com/a076d05399.js"></script> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" /> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> {% endblock imports %} {% block main %} <h1 class="title">Was soll es denn heute geben?</h1> <div class="all-recipes infinite-container" id="all-recipes"> {% for recipe in queryset_recipes %} <div class="recipe-box infinite-item"> <a href="{{recipe.get_absolute_url}}" class="recipe-link"> <img src="{{recipe.images}}" alt="Rezept Bild" class="image" /> <h3 class="recipe-title">{{recipe.title}}</h3> </a> </div> {% endfor %} </div> {% if page_obj.has_next %} <a class="infinite-more-link" href="?page={{ page_obj.next_page_number }}"></a> {% endif %} <div class="d-flex justify-content-center" style="display:none;"> <div class="spinner-border" role="status"> <span class="sr-only">Loading...</span> </div> </div> {% endblock main %} {% block scripts %} <script src="/static/js/jquery-2.2.4.min.js"></script> <script src="/static/js/waypoints.min.js"></script> <script src="/static/js/infinite.min.js"></script> <script> var infinite = new Waypoint.Infinite({ element: $('.infinite-container')[0], onBeforePageLoad: function () { $('.loading').show(); }, onAfterPageLoad: function ($items) { $('.loading').hide(); } }); </script> {% endblock scripts %} And here are the Errors: 1. infinite.min.js:57 Uncaught TypeError: Cannot set property 'Infinite' of undefined at infinite.min.js:57 at infinite.min.js:58 (index):329 Uncaught ReferenceError: Waypoint is not defined at (index):329 I really hope that somebody could help me solving those errors because I have no idea why this … -
Foreign key data as text field
I am new to Django. I am developing an app in which I have following three models. class Vessel(models.Model): vessel = models.CharField(max_length=100,unique=True) def __str__(self): return self.vessel class Method(models.Model): method_name = models.CharField(max_length=100,unique=True) active = models.BooleanField(default=True) valid_from = models.DateField(null=False, blank=False,help_text='Enter Date in YYYY-MM-DD format') valid_to = models.DateField(null=False, blank=False,help_text='Enter Date in YYYY-MM-DD format') created_by = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True) updated_at = models.DateTimeField(auto_now=True, null=True, blank=True) def __str__(self): return self.method_name class VesselRate(models.Model): cem = models.ForeignKey(Method,related_name='vessels', on_delete=models.CASCADE) vessel_name = models.ForeignKey(Vessel,on_delete=models.CASCADE,null=True,blank=True) rate = models.PositiveIntegerField(null=True) created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True) updated_at = models.DateTimeField(auto_now=True, null=True, blank=True) def __str__(self): return self.vessel_name This is my form for Vessel Rate. class VesselRateForm(ModelForm): class Meta: model = VesselRate fields = ['vessel_name','rate',] labels = {'rate':'Rate in USD'} In the above form in vessel_name, all fields are coming in list form, while I want to display all the names included in the vessel model to be displayed as a non-editable text field. Please help me to get the solution. Thank you. -
How to create a brand page, which will contain all the categories related to that brand in Django
I have 2 models: Brand and Categories: class Brand(models.Model): name = models.CharField(max_length=250, unique=True, default='Undefined') slug = models.SlugField(max_length=250, null=True) brand_lower = models.CharField(max_length=250) site = models.CharField(max_length=250) url = models.CharField(max_length=500, unique=True) letter = models.CharField(max_length=1, default='Undefined') created = models.DateField(auto_now_add=True) updated = models.DateField(auto_now=True) status = models.CharField(max_length=25, default='New') def __str__(self): return self.name def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(self.name) super().save(*args, **kwargs) def get_absolute_url(self): return reverse('manuals:brand', args=[str(self.pk)]) class Meta: ordering = ('name', ) class Category(models.Model): brand = models.ForeignKey(Brand, on_delete=models.CASCADE, default='Undefined') name = models.CharField(max_length=250, unique=True, blank=True, null=True, default='Undefined') slug = models.SlugField(max_length=250, null=True, unique=True) name_lower = models.CharField(max_length=250) url = models.CharField(max_length=500) status = models.CharField(max_length=25, default='New') def __str__(self): return self.name class Meta: ordering = ('name', ) I want to create a separate page for each brand. And that page should list all the categories of the selected brand. For example. The page should be: site.com/samsung/ And that page should have all the categories: - TV - Phones - Dishwashes and so on... I use ListView to get all the categories. But I cannot get the correct url. Here is the View: class BrandCategoryListView(ListView): # List of Categories of a Brand model = Category template_name = 'brand_categories_list.html' and here is the urls.py path('category/<int:pk>/', BrandCategoryListView.as_view(), name='brand_categories_list'), What am I doing … -
Hosting python-java backend with Py4j on AppEngine
Recently I have been working on a project to make a RESTapi using Django rest_framework. This framework requires some processing and objects which need to be done in java. I came across this library called Py4J which allows us to access Java objects, collections etc from a python environment and from what I could understand was that To make JVM accessible to python I had to interact with sockets on another server localhost:25333. I have written a very basic code to test: Views.py from py4j.java_gateway import JavaGateway class TestClass(APIView): permission_classes = [AllowAny] authentication_classes = [] @staticmethod def post(request): gateway = JavaGateway() fn = gateway.entry_point.getFunc() response = Response() response.data = {"res": fn.print()} return response Func.java public class Func{ public String print() { return "Hello from java"; } } TestGateway.java import py4j.GatewayServer; public class TestGateway { private Func func; public TestGateway() { func = new Func(); } public Stack getFunc() { return func; } public static void main(String[] args) { GatewayServer gatewayServer = new GatewayServer(new TestGateway()); gatewayServer.start(); System.out.println("Gateway Server Started"); } } This code works as expected since every interaction is happening on the localhost. But I need to deploy both the java application and django rest api on Google AppEngine. How … -
How to filter blogphoto_set by Catgery from Urls django?
Hello I created a model called BlogPhoto that connect to Blog model and i create a serializer where contain create and update funtion , and also i have url where category and id contain and i want to filter blogphoto_set by category that will be in urls. here is my code so far i did. models.py CATEGORY = [ ("vehicle-photo", _("Vehicle photo")), ("Vehicle-registration", _("Vehicle registration")), ("insurance-police",_("Insurance police")), ("other",_("Other")), ] class BlogPhoto(models.Model): created_by = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE) blog = models.ForeignKey(Blog, models.CASCADE, verbose_name=_('blog')) category = models.CharField(max_length=255, choices=CATEGORY, null=True, blank=True) name = models.CharField(_("Description about image"),max_length=255, null=True, blank=True) file = models.FileField( _("Upload documents image"), null=True, blank=True, upload_to=generic_upload_blog, max_length=500 ) urls.py there in urls there is category and i want to use in queryset to get filter blogphot_set urlpatterns = [ path("list/<int:pk>/<slug:category>/image/", views.BlogImagelView.as_view()), ] views.py here i am getting all category photo of specific blog id but i want also filter here blogphot_set by category from urls value. class BlogImagelView(generics.RetrieveUpdateDestroyAPIView): permission_classes = (IsAuthenticated,) serializer_class = PhotoBlogSerializer def get_queryset(self): blog = Blog.objects.all() return blog serializers.py class BlogPhotoSerializer(serializers.ModelSerializer): id = serializers.IntegerField(required=False) file = Base64ImageField( max_length=None, use_url=True, required=False, allow_null=True, allow_empty_file=True ) class Meta: model = BlogPhoto exclude = ['created_by', 'blog'] def create(self, validated_data): validated_data['created_by'] = self.context['request'].user return super().create(validated_data) class … -
TypeError at /accounts/verification/ save() missing 1 required positional argument: 'self'
Well I am actually trying to add a functionality of email code verification. i am sending four digit number (5577) in email and than comparing that number in my if condition. All I want to do is that if the set numbered is equal to the number enter by the user in verification template form than redirect user to the login page and also set user equal to activate or user.is_active = True. But I am having an error (in the title of this question), So if you guys can help me than please help. If more detail or code is required for help than tell me. I will update my question with that information. I shall be very thankful to you. If you guys spend some of your precious time to answering me with a wonderful and helpful information! class SignUp(CreateView): form_class = forms.UserCreateForm def form_valid(self, form): if form.is_valid: email = form.cleaned_data.get('email') user = form.save(commit=False) user.is_active = False user.save() send_mail( 'Verification code', '5577', #Sending code on gmail 'coolahmed21@gmail.com', [email,], fail_silently=False, ) # messages.success('Successful sent email') return super(SignUp, self).form_valid(form) success_url = reverse_lazy('accounts:code_verification') template_name = "accounts/signup.html" class CodeCreateView(CreateView,SuccessMessageMixin): form_class = CodeForm def form_valid(self,form): vcode = form.cleaned_data.get('vcode') if vcode == 5577: user.is_active … -
login page in django username to email-id
I have to input email-id and password to login to my page but even after giving the right data it is showing "invalid login details supplied"(a print statement in views.py). here is my code: def user_login(request): if request.method == "POST" : email = request.POST.get('email') password = request.POST.get('password') user = authenticate(email=email,password=password) if user: if user.is_active: login(request,user) return HttpResponseRedirect(reverse('index')) #HttpResponse('you are logged in') else: return HttpResponse('account not active') else: print("someone tried to login and failed!") print('email: {} and password: {}' .format(email,password)) return HttpResponse("invalid login details supplied!") else: return render(request,'basicapp/login.html',{}) The below code is login.html {% extends "basicapp/base.html" %} {% load static %} {% block body_block %} <div class='jumbotron'> <h1>plaese login</h1> <form action="{%url 'basicapp:user_login' %}" method="post"> {%csrf_token%} <label for="email">email:</label> <input type="text" name="email" placeholder="email"> <label for="password">password:</label> <input type="password" name="password"> <input type="submit" value="login"> </form></div> {%endblock%} -
how to use absolute and relative path in redirection in django framework
I started learning django and i'm currently writing my first app but i have encountered a weird error, in my url.py i wrote that : path("/wiki/<title>/" , views.view_entry , name="view_entry"), path("search" , views.search , name="search_entry") and in my view.py i wrote that: return redirect('view_entry' , title=entry) when I run that code I get an error saying Page Not Found but when i make a small detail in url.py like that : path("search/" , views.search , name="search_entry") it works why? -
Django: Displaying rendered template with JavaScript - other JS does not work
I converted one of my pages to use render_to_string shortcut from Django. I essentially have just a shell page and JS code with fetch that gets this rendered page and displays it. Everything works as before the change but my JS code included with script tags is not being run. The scripts are part of the page, just not executed. I don't know what exactly to Google in this situation.. I am using the static Django tag to get the scripts URLs. This is my code used to get the output of render_to_string: <script> function writeBody() { fetch('{% url 'load-detail' lookup_id %}') .then(res => { return res.text(); }) .then(data => { document.querySelector('html').innerHTML = data; }); } -
How do I list a model's objects in a different model's list view?
I'm building a small accounting module to track the payments we make for our clients. I want to display the payments made for a client in the client's detail view page. I couldn't get the for loop to work. How do I go about this? I tried adding the other model as a context but it didn't work. Thanks in advance. models.py class Client(models.Model): client_title = models.CharField(max_length=200) client_initial_balance = models.DecimalField(max_digits=10, decimal_places=2, default=0) client_balance = models.DecimalField(max_digits=10, decimal_places=2, default=0) client_total_deposit = models.DecimalField(max_digits=10, decimal_places=2, default=0) client_total_spent = models.DecimalField(max_digits=10, decimal_places=2, default=0) def get_absolute_url(self): return reverse("books:client-detail", kwargs={"id": self.id}) class Transaction(models.Model): client_title = models.ForeignKey(Client, on_delete=models.CASCADE, related_name="transactions") transaction_spender = models.ForeignKey(Spender, on_delete=models.CASCADE) transaction_amount = models.DecimalField(max_digits=10, decimal_places=2, default=0) transaction_details = models.TextField() views.py class ClientDetailView(DetailView): template_name = 'clients/client_detail.html' def get_object(self): id_ = self.kwargs.get("id") return get_object_or_404(Client, id=id_) def get_context_data(self, **kwargs): context = super(ClientDetailView, self).get_context_data(**kwargs) context["transaction_list"] = Transaction.objects.all() return context class TransactionListView(ListView): template_name = 'clients/client_detail.html' queryset = Client.objects.all() model = Transaction def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) return context client_detail.html <div class="container"> <h1> {{ object.client_title }}</h1> <section class="section section-stats"> <div class="row"> <div class="col s12 m4"> <div class="card-panel"> <h6 class="bold">Total Spending</h6> <h1 class="bold">$... </h1> </div> </div> <div class="col s12 m4"> <div class="card-panel"> <h6 class="bold">Total Deposits</h6> <h1 class="bold">$... </h1> </div> </div> <div class="col s12 … -
follower() missing 1 required positional argument: 'profile'
I'm trying to implement a followers/following system in my Django app. But get this error: follower() missing 1 required positional argument: 'profile' But in my views.py where the argument is missing as the program says is not actually missing. views.py def follower(request, profile): # data = json.loads(request.body) # followers = data.get("followers", "") # return JsonResponse([follower.serialze() for follower in followers], safe=False) newFollower = Follow.objects.create(user_from=User.objects.get(username=request.user.username), user_to=User.objects.get(username=profile)) newFollower.save() data = serialize("json", Follow.objects.all(), cls="LazyEncoder") return render(request, "network/follow.html", { "profile": User.objects.get(username=profile), "json": JsonResponse(data, safe=False) }) follow model in models.py class Follow(models.Model): user_from = models.ForeignKey(User, on_delete=models.CASCADE, related_name="rel_from_set") user_to = models.ForeignKey(User, on_delete=models.CASCADE, related_name="rel_to_set") created = models.DateTimeField(auto_now_add=True, db_index=True) class Meta: ordering = ('-created',) def __str__(self): return '{} follows {}'.format(self.user_from, self.user_to) # Add following field to User dynamically User.add_to_class('following', models.ManyToManyField('self', through=Follow, related_name="followers", symmetrical=False))``` -
Django inheritance avoid to create many html file
i am new in Django. I have task , i have Horoscope website , there is 12 Zodiac signs Aquarius,Aries and etc.... In Aquarius.html are subcategory like Aquarius love , Aquarius finance .... Template is similar, when visitor click love button i want to show love content of Aquarius ( i do not want to copy paste Aquarius.htmland create another love file and then show) how can do this? For example when user open Aquarius i want to show {% for aqua in aquas %} {% if forloop.last %} Aqua Content text{{aqua.body_text}} {% endif %} {% endfor %} When open Aquarius Love (click love button) show Love content {% for Love in Loves %} {% if forloop.last %} love Content text {{aqua.love_body_text}} {% endif %} {% endfor %} how can do this? if else ? -
Django - Assign & limit every logged-in user to create only one instance
How to limit every logged-in user to create only one instance/object from the frontend? here's my model looks like: class MyModel(models.Model): u_name = models.OneToOneField(User, on_delete=models.CASCADE) category = models.ForeignKey(Category, blank=True, null=True, on_delete=models.CASCADE) ... ... my_linkedin = models.URLField(unique=True, blank=True, null=True) my_price = models.CharField(max_length=20, default=0) joined = models.DateTimeField(default=now, editable=False) def __str__(self): return self.my_name def clean(self): model = self.__class__ if model.objects.count() > 0 and \ self.id != model.objects.get().u_name_id: print('hell') raise ValidationError("You can only create 1 profile ") my views: class MyCreateView(LoginRequiredMixin, CreateView): model = MyModel fields = [ 'category', .... .... ] template_name = 'index/form.html' success_url = '/' def form_valid(self, form): form.instance.u_name = self.request.user return super().form_valid(form) And my form: class MyModelForm(forms.ModelForm): class Meta: model = MyProfile fields = '__all__' exclude = ['u_name'] The problem is, that the current code here, they can't assign on every logged-in user. So when I try to login using a different user, The error looks like: get() returned more than one MyProfile -- it returned 3! How can I achieve this? -
Upload very large files directly on NGINX without Django server interaction
I have spent many hours on this but could not find a solution. Problem: I have as simple django server in production and I need to upload files on it using a curl --form command. NGINX latest version 1.16 is working fine on the Ubunut 16 server. Things I tried NGINX upload module (version mismatch)* NGINX upload module's needs a lower version and upon adding the module and making the module, NGINX server fails. I tried installing NGINX from source. The version mismatch occurs. A trick to use client_body_in_file_only to directly upload a file without backend(too many files open)** I followed Nginx PHP Failing with Large File Uploads (Over 6 GB) I can see lots of empty files created in the specified path but at the end it gives 502 bad gateway error. Also, I tried to increase the limit of open files but it is not working either https://medium.com/@cubxi/nginx-too-many-open-files-error-solution-for-ubuntu-b2adaf155dc5#:~:text=If%20you%20run%20an%20Nginx,want%20to%20view%20limits%20on. Can someone point out my mistake or mention a detailed tutorial that handles file uploads in NGINX which can be downloaded using curl? NGINX config location /upload { limit_except POST { deny all; } client_body_temp_path /home/<project folder>/media/uploads; client_body_in_file_only on; client_body_buffer_size 25000M; client_max_body_size 25000M; proxy_pass_request_headers on; #proxy_set_header content-type "text/html"; proxy_set_header Content-Length … -
Django - Two or more Many-to-many relationships based on the same intermediary model
In a medical application using Django, there are both Patient and Medication models (with only "name" fields, for the purpose of this question), where three many-to-many relationships need to be established: allergies: Needs no extra fields, so a simple ManyToManyField would suffice other_medication: Table that refers to medication taken by patients for other medical reasons (would also have a 'dose' column) prescriptions: Table that refers to medication prescribed to patients in our clinic (would also have 'dose' and 'duration' columns) I thought about a few possible solutions. My question is basically which is preferrable: Making two unrelated intermediary models (seems a bad idea since it violates DRY principles) class Prescription(models.Model): medication = models.ForeignKey(Medication, on_delete=models.CASCADE) patient = models.ForeignKey(Patient, on_delete=models.CASCADE) dose = models.CharField(max_length=32) class OtherMedication(models.Model): medication = models.ForeignKey(Medication, on_delete=models.CASCADE) patient = models.ForeignKey(Patient, on_delete=models.CASCADE) dose = models.CharField(max_length=32) duration_in_days = models.IntegerField() Making an abstract model and inheriting from it, which works around the DRY violation but still seems too verbose (Don't even know if this works in Django) class PatientMedicationRelationship(models.Model): class Meta: abstract = True medication = models.ForeignKey(Medication, on_delete=models.CASCADE) patient = models.ForeignKey(Patient, on_delete=models.CASCADE) dose = models.CharField(max_length=32) class Prescription(PatientMedicationRelationship): pass class OtherMedication(PatientMedicationRelationship): duration_in_days = models.IntegerField() Also, would the solution for this problem be different if … -
Django + Svelte styles not working, MIME type ('text/html') is not a supported stylesheet MIME type
I am trying to connect my Django app to a Svelte front-end. I directed my template finder to the build directory of the Svelte folder. I won't be using the template features of Django, will be just using DRF with a Svelte frontend so that functionality I do not need. I just want Django to serve the compiled files. TEMPLATES = [ { ... 'DIRS': [ BASE_DIR / '../frontend/public/' ], ... }, ] Then in my view I can just use: urlpatterns = [ path('', TemplateView.as_view(template_name="index.html")) ] When I open my home view on localhost:8000 it loads the index.html just fine. The only problem is that my styles are not being loaded. This is the folder structure: backend app settings.py frontend public build bundle.js bundle.css index.html global.css As my STATIC_ROOT and STATIC_URL I use this: STATIC_URL = '/build/' STATIC_ROOT = BASE_DIR / '../frontend/public/' This works also fine, if I use python3 manage.py collectstatic I get the admin styles in my build directory and I can access the Django admin completey fine. However, when I try to access my homepage on my development server I get these errors in my console: Refused to apply style from 'http://localhost:8000/global.css' because its MIME type … -
How to create a login and registration form using (username, email, password, age and gender) using postgres database in django?
I don't know much about the Django forms or Django ORM but i need this urgently so i can submit this. I have already connected with postgres SQL and set the URLs. but don't know how to authenticate the user. -
Multiple Primary key while migrating | Django Models
Even i have made only one primary key.I don't know why it says error as multiple primary key when I migrate the changes. class Userinfo(models.Model): ''' User info ''' user_name = models.CharField(max_length=30, unique=True, null=False,primary_key=True) full_name = models.CharField(max_length=50, null=False) user_email = models.EmailField(max_length=254,primary_key=False) college_name = models.CharField(max_length=50) city = models.CharField(max_length=50) country = models.CharField(max_length=50) profile_img = models.ImageField(upload_to=upload_rename, blank=True) Can some help with this ?? -
Unable to open SQLite database file in Cloud9 IDE for a Django app
I was working on an app that seemed to work fine in the Cloud9 IDE, but when I tried to pip install django-ckeditor, I kept getting a [Errno 28] No space left on device message in the console. When I looked the problem up, I came across a post https://github.com/pypa/pip/issues/5816 in Github covering this same issue where someone was trying to install tensorflow into their Django app. Someone in the thread recommended TMPDIR=/data/vincents/ pip install --cache-dir=/data/vincents/ --build /data/vincents/ tensorflow-gpu in the terminal. I tried this, changing tensorflow-gpu to django-ckeditor because that was the package I was trying to install. Without doing enough research on this, I pasted this into my terminal and still got the same message I did intitally, [Errno 28] No space left on device. This caused a major issue with my database. Now, whenever my Django app is running, if I make any interaction with the database, I get the error unable to open database file . This happens if I try to add a post, delete, etc. Basically any CRUD interaction with SQLite3. Also if I try and logout I get the same issue. [![error message][2]][2] I also get this message in my Cloud9 terminal The … -
Celery Workers not doing all write transactions to database with Django
I am using Django with Celery. My celery worker uses Django and its models to perform database transactions. I have several tasks in my worker and each task makes read/write calls to database multiple times. I am running 6 workers, each with a concurrency of 10 threads. The issue I am facing is that it does all read transactions from database correctly, but it misses doing some write transactions to the database. And those write transactions that it misses are consistent. It always fails to write to the database at the same point, though never raises any exception for it. I have tried putting time.sleep(5) between transactions to give it time but no help. I am starting to think its some kind of connection pooling issue. Does anyone else have any ideas on this or gone through same issue? -
mdbootstrap 5 not showing in Django 2.1.15
I have a simple django project. I want to add material design bootstrap in it. settings.py: STATIC_URL = '/static/' # _______________________________________________________________________ STATIC_ROOT = os.path.join(BASE_DIR, '/assets') # _______________________________________________________________________ STATICFILES_DIRS = [ os.path.join(BASE_DIR, '/static') ] urls.py: from .views import index, core, other urlpatterns = [ path('', index, name='startpage'), path('core/', core, name = 'homepage'), ] views.py: from django.shortcuts import render def index(request): return render(request, 'index.html') def core(request): return render(request, 'base.html') index.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <meta http-equiv="x-ua-compatible" content="ie=edge" /> <title>Material Design for Bootstrap</title> <!-- MDB icon --> <link rel="icon" href="{% static 'assets/img/mdb-favicon.ico' %}" type="image/x-icon" /> <!-- Font Awesome --> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css" /> <!-- Google Fonts Roboto --> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" /> <!-- MDB --> <link rel="stylesheet" href="{% static 'assets/css/mdb.min.css' %}" > <!-- Custom styles --> <style></style> </head> <body> <!-- Start your project here--> <header> <!-- Navbar --> <nav class="navbar navbar-expand-lg navbar-light bg-white"> <div class="container-fluid"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarExample01" aria-controls="navbarExample01" aria-expanded="false" aria-label="Toggle navigation" > <i class="fas fa-bars"></i> </button> <div class="collapse navbar-collapse" id="navbarExample01"> <ul class="navbar-nav mr-auto mb-2 mb-lg-0"> <li class="nav-item active"> <a class="nav-link" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Features</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Pricing</a> </li> <li class="nav-item"> <a class="nav-link" href="#">About</a> … -
How to send meeting invite on email in django form
I would like to implement a form in django, from where i can send meeting invitation. for that I have created a form where a user can enter sender email , start date and end time. now i want when user click on submit button after entering email and time then an email calendar should sent to sender mail through Django admin panel. enter image description here