William
In app-1 create two models User and Post
William
You have to do only backend or fully functioning website?
shalthedeveloper
Kamran
Hello everyone, can anyone plz help me, i am creating two apps and both the apps should use a different database, do u have any idea guys how can we make it???
William
Kamran
Rajeev
Hello,
I have docker based django project with postgres as db.. I have to import CSV files into db tables to populate.. I have tried several resources from net.. can someone help how to achieve this..
Mahdi
This is django.
Mirco
!ot
Doragonsureiyā
Looks like you need an offtopic group, please continue this conversation at @pythonofftopic as it's not related to Python
Akash
I uploaded my project on heroku but now images are not showing please help 🙏🙏
Riswandi
But i want from telethon import VoIP
Mirco
Mirco
Bhashkar
Hi Guys,
I am little bit confused about (simple tag | filters). I want to create a template tag which will be used in "base.html" file, so where should I place the template tag file?
VBELLO TECH
Bhashkar
OPTIONS={
'builtins': ['myapp.builtins.app_tags'],
}
Is this also accessible by all templates ?
Mirco
Mirco
Bhashkar
Okay, thanks
Javohir
hi guys infodata=Photo.objects.all() what is the returned value of this? Photo is a model
Rohan
Anonymous
Hi guys!
I'm trying to paginate a response from an outer API. I've been reviewing DRF pagination but it only uses QuerySets.
Knowing the response is a list of dicts, do you guys have any idea of what could I use? Do you know any example?
Thank you very much 😁
Anonymous
Maxim
Anonymous
Yes, right now I'm trying with django.core.paginator
Anonymous
What?
Maxim
What?
you should have said it and said why doesn't like paginator
Javohir
guys these cards are not displayed {% for i in info %}
{% if i.category == 'Cars' %}
<div class="col-md-4 col-sm-6">
<div class="card text-center" style="padding: 20px; margin-bottom: 30px;">
<img class="card-img-top" src="{{i.image.url}}" alt="Card image cap">
<div class="card-body">
<div class="card-title">Pic Name: {{i.title}}</div>
<div class="card-text">Category:{{i.category}}</div>
<a href="#" class="btn btn-success">View</a>
</div>
</div>
</div>
{% endif %}
{% endfor %}
Javohir
where am i making mistake?
Javohir
Javohir
how can i fix it?
Maxim
how can i fix it?
how can i know what values the category field takes?
check the values in the db
Javohir
class Category(models.Model):
name=models.CharField(max_length=100)
def str(self):
return self.name
Maxim
Maxim
Javohir
def cars(request):
infodata = Photo.objects.all()
context = {
'info': infodata
}
return render(request, 'cars.html',context)
Maxim
maybe you need
{% if i.category.name == 'Cars' %}
instead of
{% if i.category == 'Cars' %}
Maxim
but it is more correct to filter in the cars() function
Mahdi
Avi
[WinError 10061] No connection could be made because the target machine actively refused it
Getting this error while using django.core.mail import send_email
Akash
How to upload images in a website during hosting on heroku??
Akash
Rajeev
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like:
- https://del.dog
- https://dpaste.org
- https://linkode.org
- https://hastebin.com
- https://bin.kv2.dev
If you posted a wall of text, go back and delete it.
Rian
Rian
In django
Youtube and Google. As simple question as this shouldn't be asked here.
Sahil
Rian
Sahil
You can use rabbitmq to set a schedule to delete after 30 days.
I'm not looking forward to add any third party libraries for this task. I've already done this task, just the issue is when I'm soft deleting the object from the Article model, I want it to be get deleted from the Comment model as well. Since, on_delete = models.CASCADE is not working here, so looking forward to have an alternate solution for this.
Rohan
Rohan
You’ll have to override save() and check for state of your object and modify the objects you want to update with it
Rohan
Да, я
Hello. I have two applications: api and news. I have a template in news. How can I make url link to url from api/urls.py?
Rohan
Trip your object’s flag along with flag of other object related to it
Да, я
Да, я
.
yep
Numa
If it works, just don't touch it.
.
use fcking ContentType
Atlas
I want to use the bulma css framework in my project. Do you recommend to install the django-bulma package? or install the npm package instead? Or maybe, something else...
Beekaaash
Any one here who use geo shapefile in their project???
Jerome
Numa
I think you can't do that in default admin panel, but in custom panel you just write a mixin to do that
Li
Hey guys, I need some help!
Technology Stack: Django/Python
What the code all about: The code tries to perform a soft deletion concept without using any third-party libraries. Whenever an object is being soft deleted, instead of getting deleted permanently, it only hides the data from the database and can unhide or revived anytime.
Problem statement: I want that whenever I'm trying to delete an object, I want its instance to be deleted as well, in the other models. For example: If I create an object Article with "title" as "The Famous Five" and "content" as "Adventurous book" and then create another object Comment (It has the title attribute as the Foreign key from the Article object) with "text" as "Good book". So, I want that whenever I try to soft delete the Article object with the "title", "The Famous Five", I want the instance (the Foreign key) also to get soft-deleted from the Comment object. Code: https://del.dog/yrfekeckim
I thought implementing soft delete is as simple as adding new model field deleted_at = models.DateTimeField(null=True, blank=True, default=None)
and it would work. But after seeing your question previous days and reading the article you posted, it is not that simple and easy to implement soft delete.
But after searching on the internet, there are a few third party libs that can use soft-delete feature. And some use audit log libs instead of soft-delete where audit log keep the deleted record history in separate table and restore when required.
Third party libs comparison on DjangoPackages
https://djangopackages.org/grids/g/deletion/
Soft Delete
https://github.com/makinacorpus/django-safedelete
https://github.com/scoursen/django-softdelete
Audit/Log
https://github.com/etianen/django-reversion
https://github.com/jazzband/django-simple-history
If you don't want to depend on third party libs you'll need to overrides a bunch of methods (update, delete) and handle (relationships) the related objects. There are articles talking about how to implement it in django and its pros and cons of using it. So you need to consider the works you need to do if you want to implement yourself.
Ard
Hi, how to recreate database from inspectdb model ? when I tried to run makemigrations nothing changed
Ps : the project used the legacy database (created manually in mysql), but the schema was gone
Anonymous
Guyss, how can we save our scraped data into our djanog model??
Data is scraped using scrapy.
Help please..
Mohit
Guys, How can we display our excel file on django html page using render ??????
Michael the wolf 🐺
use pandas and render content to html table
Michael the wolf 🐺
i think there is a direct method called to_html or something
Mohit
@IAmABigBadWolf Yes, but it showing the excel table in single line of django html page