Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add sub category in models.py django
I'm trying to create a blog where one category may have some subcategory. I did this in my models.py class Category(models.Model): title = models.CharField(max_length=50, unique=True) def __str__(self): return f"{self.title}" class SubCategory(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE) title = models.CharField(max_length=50, unique=True) def __str__(self): return f"{self.title}" But I think It's not right to create two different class for the same task. So is there any other way to do it? Thank you. -
How to raise Dajngo Datetime validation Error?
I have a model where i want to raise error when user puts backdates in date_fields or enter earlier dates to today. class Leave_Management(models.Model): employee = models.ForeignKey('employeeModel', on_delete=models.CASCADE) name = models.CharField(max_length=50) reason = models.TextField(max_length=200) date_to = models.DateField(null=True) date_from = models.DateField(null=True) forms.py class LeaveForm(forms.ModelForm): class Meta: model = Leave_Management fields = ('__all__') def clean_date_to(self): date_to = self.cleaned_data.get('date_to') if not date_to > datetime.date.today(): raise ValidationError('Enter Valid Date') return date_to I tried to write this validation code But its showing error TypeError at /home/leave '>' not supported between instances of 'NoneType' and 'datetime.date' what am i doing wrong? -
Django-allauth; How can I create template without using the templates that are given by the library?
I'm new to Django. I'm trying to create home page users can log in and log out using a social account. What I want to do is just to create templates by myself without using the tetmplates that are already given by the extension.But I'm not sure how I can do that. I want to create a home page users can log in or log out anyway. Here is index.html. {% load socialaccount %} <h1>Home Page</h1> {% if user.is_authenticated %} <p>Welcome {{ user.username }}</p> <!-- Insert logout link here --> {% else %} <p><a href="{% provider_login_url 'google' %}">Log in with Gmail</a></p> {% endif %} But for now after users log in with their gmail, it redirects to sign up template which is given by allauth. I want to just attach the login and logout link on the index.html and I don't want to use sign up template. Even if the user login first time, I want to just add the user to db. Seems like I can override from allauth. But I want to do more simple. What I want to do is after users login or logout, it redirects to index page, also I don't want to use sign … -
show image file after choosing it before uploading , django
I have a table with ImageField and I want to show an image thumb line near the choose file button before the user submits in form,, when the user picks the image the link is already provided like this : and I want to catch the path to the file ( add_user_but.png) after use picks it .. how to do it !? -
Can i put the code starting tensorflow session on the top of django views.py like global variable?
i'm definity new in tensorflow and django i want to make a couple of tensorflow session always on RAM while django server is still running. so i put the code starting session like below on the top of views.py def load_model(model_path): graph=tf.Graph() sess = tf.Session(graph = graph) with graph.as_default(): saver = tf.train.import_meta_graph(meta_graph_or_file=model_path+'.meta' , clear_devices=True) #example model path ./models/fundus_300/5/model_1.ckpt saver.restore(sess, save_path=model_path) # example model path ./models/fundus_300/5/model_1.ckpt x_ = tf.get_default_graph().get_tensor_by_name('x_:0') y_ = tf.get_default_graph().get_tensor_by_name('y_:0') pred_ = tf.get_default_graph().get_tensor_by_name('softmax:0') is_training_=tf.get_default_graph().get_tensor_by_name('is_training:0') top_conv = tf.get_default_graph().get_tensor_by_name('top_conv:0') logits = tf.get_default_graph().get_tensor_by_name('logits:0') cam_ = tf.get_default_graph().get_tensor_by_name('classmap:0') cam_ind = tf.get_default_graph().get_tensor_by_name('cam_ind:0') #gap_w= tf.get_default_graph().get_tensor_by_name('gap/w:0') return sess ,pred_ , x_ , y_ , is_training_ , top_conv ,cam_ , cam_ind , logits # starting multiple Session and keeping multi session model_path_ret= '/home/ubuntu/web_classifier/models/step_23300_acc_0.892063558102/model' model_path_gla= '/home/ubuntu/web_classifier/models/step_34200_acc_0.882777810097/model' model_path_cat= '/home/ubuntu/web_classifier/models/step_6300_acc_0.966666698456/model' sess_ret_ops= load_model(model_path_ret) sess_gla_ops= load_model(model_path_gla) sess_cat_ops= load_model(model_path_cat) # run def upload_files on request def upload_files(request): pred = sess.run(...) it works well for a while after tuning on server(and i use apache) but if i don't throw request to the server for a while (about 6 hours?) and i send request again, html page was work , but upload_files(request): isn't work and cannot import name pywrap_tensorflow error is occured or sometimes i didn't get any response without limit so i have to restart … -
Django, getting access to parent's fields and method in Many to One relations
I have the below example for demonstration only, the relationship between the authors and books one to may, each book can be written by one author only. Let's say I have created 1 record for the author, and the created a book written by that author. When I want to update the Book's details, I would like to get the author age as well, and getting access to any method in the Author model to bes how in the book tempalte. {{form.author}} will return the author name, I tried {{form.author.age}} and {{form.author.find_age}} without success. My real example involves a formset of books, but I thought making it simple as a single book as in the below will be easier for getting an answer. Model: class Author(models.Model): name = models.CharField(max_length=300) age = models.DecimalField(max_digits=3, decimal_places=1, default=3.0, blank = True ) def __str__(self): return self.name def find_age(self): return self.age class Book(models.Model): author = models.ForeignKey(Author, on_delete=models.PROTECT) title = models.CharField(max_length=300) publish = models.CharField(max_length=300) def __str__(self): return self.title View: class BookCreate(CreateView): model = Book fields = '__all__' success_url = reverse_lazy('books-list') class BookUpdate(UpdateView): model = Book success_url = reverse_lazy('books-list') fields = '__all__' class AuthorCreate(CreateView): model = Author fields = '__all__' success_url = reverse_lazy('authors-list') class AuthorUpdate(UpdateView): model = … -
Django: NoReverseMatch at ' '. ' ' is not a valid view function or pattern name
I am trying to retrieve data from form inputs and insert them into the model. But I receive this error: [Error NoReverseMatch. 'test-management/test/add_test/' is not a valid view function or pattern name.1 The .html file that contain form. <form class="form" method="POST" action="{% url 'test-management/test/add_test/' %}"> {% csrf_token %} <h2>Add Test</h2> <div class="card-body"> <div class="form-group bmd-form-group"> <div class="input-group"> <p>Name :</p> <input type="text" class="form-control" name="name" placeholder="Test Name..."> </div> </div> <div class="form-group bmd-form-group"> <div class="input-group"> <p>Type :</p> <input type="text" class="form-control" name="type" placeholder="Test Type..."> </div> </div> <div class="form-group bmd-form-group"> <div class="input-group"> <p>Date :</p> <input type="date" class="form-control" name="date" placeholder="Test Date..."> </div> </div> </div> <div class="modal-footer justify-content-right"> <input type="submit" value="Add"> <a href="." class="btn btn-primary btn-link btn-wd btn-lg" id="close">Close</a> <a href="#pablo" class="btn btn-primary btn-link btn-wd btn-lg" id="add_new">Add & New</a> <a href="." class="btn btn-primary btn-link btn-wd btn-lg" id="add">Add</a> </div> </form> The error might be caused by action of the form, but I don't know how to correct it. urls.py from test_management.views import (test_list, subject_list, topic_list, question_list, import_question, add_test) urlpatterns = [ url(r'^test-management/test/add_test/', add_test, name='add_test'), ]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) views.py from django.shortcuts import render from django.http import HttpResponse from django.http import HttpResponseRedirect from .models import Test def add_test(request): if request.method == 'POST': test_name = request.POST.get('name') test_type = request.POST.get('type') test_date = … -
Django: Extract dict for save.method
Currently I am adding data to my model form in that way:new_order = order.save(commit=False) new_order.total_gross = total_amount new_order.total_tax = total_tax_amount new_order.total_gross_converted = total_amount # TODO Marc new_order.event = event new_order.order_reference = session_order_reference new_order.status = 'pending' # TODO Marc new_order.save() I am now wondering if there is a 'better'/cleaner way with a dict. Anyone did that before? This is unfortunately doesn't work: new_order_dict = { 'total_gross': total_amount, 'total_tax': total_tax_amount, 'total_gross_converted': total_amount, 'event': event, 'order_reference': session_order_reference, 'status': 'pending', } new_order = order.save(commit=False) new_order.append(**new_order_dict) new_order.save() -
How to convert .cshtml code to html?
I have to make an app in Django/Python and I already have the templates in .cshtml as the app was earlier made in .net, How can I convert the .cshtml code into .html code, I am new to this so please explain in detail, below is the code in .cshtml format. Also is there any online tool that can convert this directly for me? I also want to know how to open these .cshtml file because when I try to open them in chrome only few lines of the code gets executed. Any help is appreciated. @model XYZ.Model.ViewModel.qwertyViewModel @{ ViewBag.Title = "CreateUser"; Layout = "~/Views/Shared/_MainLayout.cshtml"; } <div class="main-container" id="main-container"> <div class="main-content"> <div class="main-content-inner"> <div class="breadcrumbs" id="breadcrumbs"> <ul class="breadcrumb"> <li> <i class="ace-icon fa fa-home home-icon"></i> <a href="@Url.Action("Index", "Home")">Home</a> </li> <li> <a href="@Url.Action("Index", "Organizations")">Organizations</a> </li> <li> <a href="@Url.Action("Users", "Organizations",new { id=Model.OrganizationId})">Users</a> </li> <li class="active">Add User</li> </ul><!-- /.breadcrumb --> </div> <br /> <div class="page-content"> @using (Html.BeginForm("CreateUser", "Organizations", FormMethod.Post, new { @class = "form", id = "frmDpuConfig" })) { @Html.AntiForgeryToken() <div class="row"> <div class="col-md-10"> <div class="card"> <div class="card-head style-primary"> <header>Add @Model.OrganizationName<span>'s</span> User</header> </div> <div class="col-md-8 col-md-offset-1"> <!-- FORM CONTENT BEGINS --> <div class="card-body"> @Html.ValidationSummary(true, "", new { @class = "ValidationErrorMessage help-block" }) @Html.HiddenFor(model=>model.OrganizationId) <div … -
How to restrucutre my Django code?
I am new to Django.I want to create app that would enable selected users to login and then upload files that would latter be processed. models.py class Profile(models.Model): username = models.OneToOneField(User, on_delete=models.CASCADE) password = models.TextField(max_length=80,blank=True) company = models.TextField(max_length=80, blank=True) @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): instance.profile.save() class Document(models.Model): uploaded_by = models.ForeignKey(Profile,on_delete=models.CASCADE) date_uploaded = models.DateTimeField(auto_now_add=True) forms.py class LoginForm(forms.Form): username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput) company = forms.CharField() class DocumentForm(forms.Form): docfile = forms.FileField(label='Select a file') malex.urls(application urls) from malex.views import list from malex.views import login urlpatterns = [ url(r'^list/$', list, name='list'), url(r'^login/$', login, name='login'), ] project/urls urlpatterns = [ path('admin/', admin.site.urls), url(r'^newp/', include('malex.urls')), ] Now the login and upload operations are separated. How to change my views and urls to have login first and upload latter? Do I need to use Class based views with decorators? -
Django how to save time to the forms?
I want to book a car if user click on the available time . how to save the clicked time to the field of time in form . [![This is the time available picture i want one of this time that user clicked to save to the forms and redirect to the booking form -
Protocol error, got "H" as reply type byte
I am trying to use django channels for the first time and i am following the tutorial in the documentation. But when I use python manage.py runserver and try to connect i get this error. Protocol error, got "H" as reply type byte Here is the whole console(I'm using anaconda): Quit the server with CTRL-BREAK. 2018-06-20 15:59:25,665 - INFO - server - HTTP/2 support not enabled (install the http2 and tls Twisted extras) 2018-06-20 15:59:25,665 - INFO - server - Configuring endpoint tcp:port=8000:interface=127.0.0.1 2018-06-20 15:59:25,665 - INFO - server - Listening on TCP address 127.0.0.1:8000 [2018/06/20 15:59:36] HTTP GET /chat/lobby/ 200 [0.12, 127.0.0.1:62590] [2018/06/20 15:59:36] WebSocket HANDSHAKING /ws/chat/lobby/ [127.0.0.1:62594] 2018-06-20 15:59:37,694 - ERROR - server - Exception inside application: Protocol error, got "H" as reply type byte File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels\sessions.py", line 175, in __call__ return await self.inner(receive, self.send) File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels\middleware.py", line 41, in coroutine_call await inner_instance(receive, send) File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels\consumer.py", line 54, in __call__ await await_many_dispatch([receive, self.channel_receive], self.dispatch) File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels\utils.py", line 50, in await_many_dispatch await dispatch(result) File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels\consumer.py", line 67, in dispatch await handler(message) File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels\generic\websocket.py", line 173, in websocket_connect await self.connect() File "C:\Users\Pc\Documents\tutorial\django-channel-tut\chat\consumers.py", line 11, in connect self.channel_name File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 282, in group_add channel, File "C:\Users\Pc\Anaconda3\envs\django\lib\site-packages\aioredis\connection.py", line 181, in _read_data … -
ImproperlyConfigured: Requested settings DATABASES
I have seen 10 different ways of configuring the MySQL database with Django, and none of them work. I am running MySQL 8.0 and Django 2.0 I updated the Project/settings.py with the database settings as followed: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'name_of_db', 'USER': 'root_user', 'PASSWORD': 'not_telling_u_my_pass_:)', 'HOST': 'localhost', 'PORT': '3306', } } When I run the command to test the connectivity: python manage.py dbshell I get error: django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. No other settings have been made, however, I have tried to follow a few guides which say that I must declare: set DJANGO_SETTINGS_MODULE=mysite.settings With no luck. I am running Windows 7 as well. I have all of the mysql dependencies installed for connecting from Python to MySQL. I know this question has been asked a number of times, but a thread should exist with clear instructions. Many of the other threads do not have clear and concise instructions, and I'm using a later version of MySQL so hopefully this will help solve others issues experiencing the same. -
How can I optimize queries django rest-framework
I have the following serilizers class AutoSerializer(serializers.ModelSerializer): class Meta: model = Auto fields = ("nombre",) class MarcaSerializer(WritableNestedModelSerializer): autos = AutoSerializer(many=True) class Meta: model = Marca fields = ("codigo", "descripcion", "autos") ModelViewSet class MarcaViewSet(viewsets.ModelViewSet): queryset = Marca.objects.all() serializer_class = MarcaSerializer def list(self, request, *args, **kwargs): queryset = self.queryset serializer = self.get_serializer(queryset, many=True) return Response(serializer.data) Querys How can you optimize access to the base, that is, make fewer inquiries -
Equivalent of Rails' seed file in Django with Python3
I would like to manually populate the database in my Django app. In Rails, I just have to enter the info in the seed file and that's it. The db.sqlite3 file has many numbers in it which I don't get. My questions are how can I manually create a database and in which directory should I put it, and how can I retrieve the info to display it in my view? Thanks! -
Changing the id attribute of select tags within Django's SelectDateField
I'm looking for a way to modify in code the ids of the select tags created by SelectDateField. Specifically, I'd like to have, for example, <select name='date_year' id='date_year'> rather than the default <select name='date_year' id='id_date_year'>. From my reading, subclassing SelectDateField is generally the way to customise the HTML generated but this seems rather unfortunately inelegant for such a trivial change. Is there an alternative I've overlooked? -
How to save HTML template data to mySQL database in Django?
I am using django and want to store the information from html template to a mySQL database. When I click on the submit botton it redirects me to the same page and no data is saved in the database. How can I solve this error? This is my views file from django.http import HttpResponse from django.template import loader from . models import adduser from django.shortcuts import render def user(request): all_users = adduser.objects.all() template = loader.get_template('p1/adduser.html') context = { 'all_users':all_users, } return HttpResponse(template.render(context, request)) def createpost(request): if request.method == 'POST': if request.POST.get('Name') and request.POST.get('Designation') and request.POST.get('Email') and request.POST.get('Password') and request.POST.get('Confirmpassword') and request.POST.get('ContactNumber'): post = adduser() post.Name = request.POST.get('Name') post.Designation = request.POST.get('content') post.Email = request.POST.get('Email') post.password = request.POST.get('password') post.confirmpassword = request.POST.get('confirmpassword') post.contactnumber = request.POST.get('contactnumber') post.save() return render(request, 'p1/adduser.html') This is my models file from django.db import models class adduser(models.Model): name = models.CharField(max_length=255) designation = models.CharField(max_length=255) email = models.CharField(max_length=255) password = models.CharField(max_length=255) confirmpassword = models.CharField(max_length=255) ContactNumber = models.IntegerField() This is my adduser.html template <!DOCTYPE html> <html> <body> <h2>Add User</h2> <form action="" method="POST"> {% csrf_token %} Name:<br> <input type="text" name="Name"><br> Designation:<br> <input type="text" name="Designation"><br> Email:<br> <input type="Email" name="Email"><br> Password:<br> <input type="password" name="Password"><br> Confirm Password:<br> <input type="password" name="Confirm Password"><br> Contact Number:<br> <input type="number" name="Number" ><br> … -
Recieve a file as response to an Ajax request from Django view
I'm working on a project with Python(3.6) and Django(1.11) in which I have implemented a Django view which calls by an ajax request and the view will return an audio mp3 file. How can I get this file response and send to the browser (should be downloaded to the user)? Here's My code: views.py: if form.is_valid(): obj = form obj.textFile = form.cleaned_data['textFile'] obj.gender = form.cleaned_data['gender'] obj.pitch = form.cleaned_data['pitch'] obj.speed = form.cleaned_data['speed'] obj.voice_type = form.cleaned_data['voice_type'] obj.save() text_path = os.path.join(settings.MEDIA_ROOT, 'texts/', obj.textFile.name) text = text_path txt = Path(text).read_text(encoding='cp1252') fileName = obj.textFile.name[:-4] print('File Name is: {}'.format(fileName)) input_text = {'text': txt} voice = { 'language_code': 'en-US', 'ssml_gender': obj.gender, } audio_config = { 'audio_encoding': texttospeech_v1beta1.enums.AudioEncoding.MP3, 'pitch': float(obj.pitch), 'speaking_rate': float(obj.speed), } client = texttospeech_v1beta1.TextToSpeechClient(credentials=credentials) response = client.synthesize_speech(input_=input_text, voice=voice, audio_config=audio_config) with open('media/audios/' + str(fileName) + '.mp3', 'wb') as out: out.write(response.audio_content) print('Audio content written to file "output.mp3"') # dict_response = dict(response) response_file = FileResponse('media/audios/output.mp3', content_type='mp3') response_file['Content-Disposition'] = 'attachment; filename="output.mp3"' return HttpResponse(response_file) return HttpResponse('Get post request along with files', status=200) Ajax request code: $(document).on('submit', '#fileForm', function (e) { e.preventDefault(); var data = new FormData($('#fileForm').get(0)); $.ajax({ type: 'POST', url: '{% url 'home' %}', data: data, processData: false, contentType: false, success: function () { console.log('Succcess'); $('#success').attr('hidden', false); } }); }); Help … -
Form is not displaying ValidationError
It is not showing any validation error but reloading the empty form till the all form fields behavior validation. views.py def Leave_management(request): if request.user.is_superuser: form = LeaveForm(request.POST or None) if form.is_valid(): form.save() return redirect('leave_list') else: form = LeaveForm() return render(request, 'leave_management.html', {'form': form}) if not request.user.is_superuser and not request.user.is_anonymous: form = LeaveForm(request.POST or None) form.fields['status'].disabled = True if form.is_valid(): form.save() return redirect('leave_list') else: form = LeaveForm() return render(request, 'leave_management.html', {'form': form}) template <hr><h1>Leave Application</h1><hr> <form method="post"> {% csrf_token %} {{form|crispy}} <input type="submit" value="submit" > </form> -
Django & Postgres: DB delivers None instead of ""
I am migrating a Django website from 1.8 to 2.0. Also Postgres-DB is upgraded from v8 to v9. I have a model defined like this: class CMSMailTemplates(models.Model): email_cc = models.CharField(max_length=200, default='', blank=True, null=True, verbose_name=u"Email cc:") temp = CMSMailTemplates.objects.get(id=1) In the old world if the DB field was empty: temp.email_cc == "" Now after migration if the field is empty temp.email_cc is None Can anybody help me with an explanation? Is there a way to get "" instead of None for these attributes? -
Transparently inherit Django model attributes
I've been wracking my brain about how to implement the following functionality on Django 1.7. I've got two Django models. Some of the fields on one are duplicated on the other. They are related with a foreign key, like so. class MyModelGroup(models.Model): name = models.CharField(max_length=128) shared_attr1 = models.NullBooleanField() shared_attr2 = models.CharField(max_length=512, null=True, blank=True) class MyModel(models.Model): group = models.ForeignKey(MyModelGroup, null=True, blank=True) name = models.CharField(max_length=128) shared_attr1 = models.NullBooleanField() shared_attr2 = models.CharField(max_length=512, null=True, blank=True) MyModel may be related to a MyModelGroup record. When shared_attr1 or shared_attr2 are changed on MyModel I want to implement the following behaviour: If the foreign key is null, just save the value on MyModel. If the foreign key is not null, and the value is different to the value shared on the record linked with the foreign key, save the value on MyModel. Otherwise, leave the value blank. Then, when I retrieve the value from either of the shared attributes on MyModel, I want it to do the following: If the foreign key is null, return the value of the attribute on MyModel. If the foreign key is not null, and the value on MyModel is different to the value on MyModelGroup, return the value on MyModel. If … -
Installing Django-channels error
I've tried to install Django-Channels, but this error occurred: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/4c/xy3rtg_165l0650j4tq7fvrh0000gn/T/pip-install-7anqvzhg/twisted/ -
Django query: the last Mail received from a conversation grouped by Conversations
My Model: class Mail(models.Model): subject = models.CharField(max_length=300) message = models.TextField() receiver = models.ForeignKey(User, related_name='receiver', on_delete=models.CASCADE) sender = models.ForeignKey(User, related_name='sender', on_delete=models.CASCADE) sent_date = models.DateTimeField(auto_now_add=True) conversation = models.ForeignKey(Conversation, on_delete=models.CASCADE) read = models.BooleanField(default=False) My query: Conversation.objects.filter(mail__receiver=request.user).annotate(latest_msg=Max('mail__id')).values('id','mail__id','mail__subject','mail__message','mail__sender__username','mail__sent_date','mail__read').order_by('-latest_msg') It returns all the Conversations which contains any Mail received by the logged user (request.user). Why? I want the last message received grouped by Conversations, like Gmail. -
Use Foreign Key to access other object Django
I want to access other objects of foreign key. models.py from django.db import models class Box(models.Model): name = models.CharField(max_length=200,null=True) apples= models.IntegerField(blank=True, null=True) banana = models.IntegerField(blank=True, null=True) mango = models.IntegerField(blank=True, null=True) def __str__(self): return self.name class Buyer(models.Model): name_of_buyer = models.CharField(max_length=200,null=True) address_of_buyer = models.CharField(max_length=200,null=True) interested_in = models.ForeignKey(Box,on_delete=models.CASCADE,null=True) Pickup_dt = models.DateField(null=True) Pickup_time = models.CharField(max_length=80,null=True) forms.py from .models import Price class Sale(forms.ModelForm): def clean_interested_in(self): buyer_interested_in_box = self.cleaned_data['interested_in'] #if the selected box contains less than 10 apples,10 banans and 10 mangos: raise forms.ValidationError('Not enough fruits.Please select another box') class Meta: model = Buyer widgets = { 'Pickup_dt': forms.DateInput(attrs={'class':'datepicker'}), 'Pickup_time': forms.DateInput(attrs={'class':'timepicker'}), } fields = '__all__' How can I validate this form by using the foreign key id. -
How to make an article disapper in django app
I 'm new in web development and I started with django My question if I have article in my blog and a I like to make timing that it disapper afet a specific time or date Delete the full field of the article from the database after a specific time