syedj
I have 2 apis one is rest api which calls rest and update the database (the rest api contains project details). So data base have to be updated if a project has been added or removed periodically
syedj
Second will fetch from that db and display on the web
Code9
What server environment are you on?
syedj
So 1st api have to run periodically for second one to be correct
syedj
Django and django rest
syedj
Hooking?
Code9
while django itself can serve a site, it is recommended that you use a web server to host the thing
e.g. Apache / nginx
Code9
anyway django is only responsible for handling the content once a request is received
Code9
as for when a request is sent, it's out of the scope
Code9
so you should do that with cron / celery
syedj
Ok will look into celery
syedj
Thanks
Anonymous
Is there a way to run image processing code on django?
R
R
Many options https://djangopackages.org/grids/g/photos/
Mirco
Code9
Code9
syedj
Windows 10
syedj
For developing
syedj
But will run it in on linux
syedj
After developing
Code9
linux: celery / cron job
Code9
google them up and ask if you have any questions
syedj
Celery-beat different from celery?
Anonymous
I'm new to this django and I'm gonna use it for my final year project. I just wanted to make a simple page and whenever i visit that page the image processing code should run in background (on servers).
So can you help me with that😅
Anonymous
Code9
Anonymous
Later I'll it on hosting server
Anonymous
Anonymous
I'll send you that soon
Code9
Mirco
Is it different from celery?
Nope, they do the same job but imho django-q is a bit better and you don't need another dependency ( celery-beat )
It's all battery-included
Harsh
I want to learn django please share or give any resource
Бакыт
Hey,Guys,
I am trying make search from user select options as in sreenshot
1)What is a better way to accomplish this ?
2)So far I try to use Form for that
Here what I got
forms.py
class FlatForm(ModelForm):
class Meta:
model = Flat
fields = ['rooms', 'category', 'district']
view.py
def topsearchbar(request):
if request.method == "POST":
form = FlatForm(request.POST)
if form.is_valid():
rooms = form.cleaned_data.get('rooms')
district = form.cleaned_data.get('district')
category = form.cleaned_data.get('category')
founded_results = Flat.objects.filter(rooms=rooms,district=district,category=category)
print(form.cleaned_data)
data = form.cleaned_data
print(data["rooms"])
else:
print("didnot work")
form = FlatForm()
return render(request, 'topsearchview.html', locals())
But,the problem is that whenever user does not select any options it becomes None,I want to make it to Any if user does not select any options
{'rooms': None, 'category': <FlatCategory: Стандарт>, 'district': <FlatDistrict: ЦОН>}
Code9
Hey,Guys,
I am trying make search from user select options as in sreenshot
1)What is a better way to accomplish this ?
2)So far I try to use Form for that
Here what I got
forms.py
class FlatForm(ModelForm):
class Meta:
model = Flat
fields = ['rooms', 'category', 'district']
view.py
def topsearchbar(request):
if request.method == "POST":
form = FlatForm(request.POST)
if form.is_valid():
rooms = form.cleaned_data.get('rooms')
district = form.cleaned_data.get('district')
category = form.cleaned_data.get('category')
founded_results = Flat.objects.filter(rooms=rooms,district=district,category=category)
print(form.cleaned_data)
data = form.cleaned_data
print(data["rooms"])
else:
print("didnot work")
form = FlatForm()
return render(request, 'topsearchview.html', locals())
But,the problem is that whenever user does not select any options it becomes None,I want to make it to Any if user does not select any options
{'rooms': None, 'category': <FlatCategory: Стандарт>, 'district': <FlatDistrict: ЦОН>}
friendly reminder: the correct English is "found" instead of "founded" in your case
if rooms == None:
found_results = Flat.objects.all()
else:
found_results = Flat.objects.filter(rooms=rooms,district=district,category=category)
Anonymous
Hi guys I have a couple of questions, pardon me if it's kindergarten.
So off recent I started using Django rest framework having used Django for a while now, I use Vue for front end now. So I wanted to ask
I) while making use of Django templates once a user is logged in, we know we just need to use @login_required(), because the system is aware of that the user is logged in, How do I acheive this in DRF, because Everytime I keep sending the User Pk to access the user table first.
2) I recently read about JWT and tried implementing it in a sample project, Now not all URLs in my project requires an authenticated User, How do I prevent Jwt from this Classes
Mirco
Mirco
Anonymous
syedj
Akash
Can I modify django default User table name to be something else?
I have an existing database that I use for a subscription service which already has a "User" table, I tried to use same database in django it created some extra columns in my User table but login ad stuff does not work correctly now.
What would be correct way to connect the existing service with new Django app
Mirco
Mirco
Mirco
feggy
is there any frontend framework which isn't JavaScript?
Mirco
Anonymous
Hi Guys i am trying to submit form using html and with the input data i am trying to get the details from database and returning to template with context but template is rendering without context why this is happening ....Form Code in HTML
<form method="post" action="{% url 'cdgslots' %}">
{% csrf_token %}
<input type="text" name="city" id="search" onclick="clearSearch()"
<input type="text" name="datetimes" value="01/01/2018 - 01/15/2018" class=" form-control no-border simplebox" />
<div class="col-md-1 fire-btn">
<button type="submit" class="btn fire">Fire</button>
</div>
</div><!-- arth-boxes -->
</form>
VIews Code
class CDGSlots(TemplateView):
def post(self, request):
context={}
if request.method == 'POST':
context['city'] = City.objects.all()
context['CDGSlots'] = "Sorry We Didn't Find Rooms For You"
else:
context['NoRooms'] = "Sorry We Didn't Find Rooms For You"
return render(request, 'fapp/rooms.html', {'context':context})
syedj
.
.
I reccomend to use Docker on Windows
Anonymous
Code9
Please read the tutorial first
Anonymous
Anonymous
I want to make this code run on server using django
Anonymous
It will start processing the image extracted from video
Anonymous
I'm following this tutorial
https://medium.com/quick-code/crud-app-using-vue-js-and-django-516edf4e4217
But I'm lost here: After it adds this line to urls.py
path('article', TemplateView.as_view(template_name='index.html')),
It tells you to:
Below this we will create a vue js instance inside script tag
But I don't understand where to put these codes that are "inside script tag"
Which file does it mean? Wich part of that file?
Mirco
Code9
Ghorz
Anders (izzno / gooood) 🇳🇴
Anders (izzno / gooood) 🇳🇴
The only bad thing is without an active admin site/page this value has to be set in psql client.
Anders (izzno / gooood) 🇳🇴
But I could just make a simple formpage for superusers...
Mirco
cj
🙄
Anders (izzno / gooood) 🇳🇴
Aadhi
Could anyone help me to perform join operation in Django.
Anonymous
2019-03-26 08:00 AM - 2019-03-31 04:00 PM
how can i split above date string as
in = 2019-03-26
out =2019-03-31
inTime = 08:00 AM
outTime = 04:00 PM
In Django