William
In app-1 create two models User and Post
William
You have to do only backend or fully functioning website?
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???
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
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..
Postgres have a command to do so. You can search it. Before doing so You must create database And run Manage.py migrate on the database Then you should populate tables that django created by the migrate command. Order of what i have told is critical.
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
I uploaded my project on heroku but now images are not showing please help 🙏🙏
Django official docs -> How to deploy Statics and Media
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?
Bhashkar
OPTIONS={ 'builtins': ['myapp.builtins.app_tags'], } Is this also accessible by all templates ?
Mirco
OPTIONS={ 'builtins': ['myapp.builtins.app_tags'], } Is this also accessible by all templates ?
https://docs.djangoproject.com/en/3.2/howto/custom-template-tags/ Everything u need is here
Bhashkar
https://docs.djangoproject.com/en/3.2/howto/custom-template-tags/ Everything u need is here
Yes I got it, I just want to know if there are some tags which is used in multiple apps then, should I create package folder and place inside it or need to access from apps of templatetags folder.
Mirco
Yes I got it, I just want to know if there are some tags which is used in multiple apps then, should I create package folder and place inside it or need to access from apps of templatetags folder.
If they are commons to the whole project, you have to place them outside the apps You can create a package called site and put them there
Bhashkar
Okay, thanks
Rajeev
Postgres have a command to do so. You can search it. Before doing so You must create database And run Manage.py migrate on the database Then you should populate tables that django created by the migrate command. Order of what i have told is critical.
All the things have been done already.. only issue with csv import.. I have tried command like docker exec -it container psql - U user - d db -c "\COPY table from 'E:\test.csv' Delimiter ',' CSV HEADER;".... It gives error directory or file not found error
Javohir
hi guys infodata=Photo.objects.all() what is the returned value of this? Photo is a model
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
Yes, right now I'm trying with django.core.paginator
Maxim
Yes, right now I'm trying with django.core.paginator
then it was worth mentioning and adding what he does not like P.S. I use an online translator, sorry. read a clearer version below
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?
Maxim
where am i making mistake?
maybe i.category == 'Cars' condition is never met?
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
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
All the things have been done already.. only issue with csv import.. I have tried command like docker exec -it container psql - U user - d db -c "\COPY table from 'E:\test.csv' Delimiter ',' CSV HEADER;".... It gives error directory or file not found error
It is because you did not copy the csv file to your container Docker have a command to copy file from host to container After copy the file to the container give the address of the csv file within the container to psql
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??
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.
Sahil
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
Rian
In django
Youtube and Google. As simple question as this shouldn't be asked here.
Sahil
Haven't heard of soft deletion, but why would you want to do that in database level if you can implement a logic in the model to hide it? Example: You have a model "Profile" which have a status = models.BoleanField() just put a status = false to hide.
Not this way, it's not only hide but more than that, like if you delete your Facebook account, Facebook gives you an option that if you signin back with 30days, your profile will be reactivated so from the database you delete the credentials but instead of permanently delete it, you store it in a flag to revive it afterwards if needed
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
You’ll have to override save() and check for state of your object and modify the objects you want to update with it
Sahil
Obviously cascade won’t work on “soft delete”
Exactly!!! That's what I'm trying to do, figuring out another way to do so on soft delete
Да, я
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
Да, я
Trip your object’s flag along with flag of other object related to it
I have app_name = "api" in api/urls.py. Is it enough?
.
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???
Numa
I think you can't do that in default admin panel, but in custom panel you just write a mixin to do that
Akshay
There's lots of open source project already
Ya there is but i need the simple one no crispy forms used ,no bootstrap ,just the simplest nd basic level
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