Abdulloh
Hi everyone
I am connecting django to postgresql
but don't know what to write in settings.py:
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.postgresql_psycopg2’,
‘NAME’: ‘yourproject’, < ———-
‘USER’: ‘yourprojectuser’, < ———-
‘PASSWORD’: ‘password’,
‘HOST’: ‘localhost’,
‘PORT’: ‘’,
}
}
# shown with < ——
Abdulloh
they are same thing I think
Abdulloh
I got username from property of postgresql 13 in pgAdmin in browser
username: postgres
Mirco
Abdulloh
Abdulloh
I created
Mirco
I created
Nice so the database name goes into NAME property
Abdulloh
ok
Mirco
USER is the user that is able to access your database
PASSWORD the user's pwd
Abdulloh
Just type the problem !
Aram
i have a problem any one can help me? " backend = load_backend(db['ENGINE'])
File "C:\Users\Saba\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 122, in load_backend
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: 'django.db.backends.postgresql' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'sqlite3'"
Abdulloh
Thank you very much @pyflare
Abdulloh
Mirco
Mirco
Doragonsureiyā
Aram
Aram
Anurag
$ scp -r $(pwd)/{app,nginx,.env.staging,.env.staging.db,.env.staging.proxy-companion,docker-compose.staging.yml} user@your-ip-or-domain:/path/to/django-on-docker
This command should be run in my local computer or remote ec2 instance
Abdulloh
I have table in my connected postgresql
but don't know how to use it
is there any documentation for this ?
Mirco
Abdulloh
from existing table
Abdulloh
any tutorial?
Mirco
learn how to read documentation
Mirco
any tutorial?
https://docs.djangoproject.com/en/3.1/ref/django-admin/#inspectdb
Abdulloh
Sadra
i have problem with these commands : su postgres
createuser -dP blog
hold on..! Postgres has its own default username.
user: postgresql
pass: postgresql
Are u running the postgresql as a docker container? If so, you can disable the authentication part by creating an environment variable in your docker-compose file as follow.
POSTGRES_HOST_AUTH_METHOD=trust
Sadra
Google for how you can authenticate in postgresql.
You'll find a ton of results.
Mirco
complex to me
if u cannot read you cannot start a journey with Django
documentation has all info u always need
Abdulloh
ok thanks
Abdulloh
I will try
Sadra
Sadra
https://django-star-ratings.readthedocs.io/en/latest/?badge=latest/
Sadra
clean it up dude. really confusing. rated -1!
separate the codes and the errors you get. explain more about what you wanna do.
Igor
Hello! I need to copy information from one database and roll it into another, but I have an error.
What I did:
python3 manage.py dumpdata> out.json
python3 manage.py loaddata out.json
Error:
django.core.serializers.base.DeserializationError: Problem installing fixture '/home/igor/prom/projects/django/nginx_unit/mysite/out.json': Invalid model identifier: 'small_parser.dailydata'
I would be grateful for any help!
Sadra
Igor
Rushikesh
What do I do to automate django tasks??
Rushikesh
Or schedule tasks in django??
Rushikesh
Omair
Rushikesh
Aram
Lipau3n
Hi guys! I need help with formsets! I want use inlineformset_factory and edit:
1. parent form
2. many child objects
in one page
Like django admin uses inlines
SkyLord
Hi to all.
Help please to solve the problem. I have this model structure:
Model1:
Name= charfield
Model2:
Title = charfiel
Etity = manytomany(model1)
To model2 i added post_save reciever and in this reciever i try to get the values of entity field but in instance.entity is equal null. This values i need for save it in other models
Eg.
Model1 = <v1, v2, v3>
Model2 = <
Title = t1,
Entity = [v1,v2, v3]
>
In post_save(sender=Model2):
Model3 = v1, v2, v3
Enes
Hi
Enes
I am trying to add comments section for my blog project. I have an error in views.py but i cannot solve. Can anyone help me
Enes
https://dpaste.com/47QPY4PQ8
This is views.py
Enes
https://dpaste.com/42KDBY4C8
This is browser side
Enes
Exception Value:
render() got an unexpected keyword argument 'pk'
Enes
Please help me guys thank you
Sadra
You need to change the parameter pk=post.pk to context={'pk': post.pk}
explained more here:
https://docs.djangoproject.com/en/3.1/topics/http/shortcuts/
Pavel
Hey friends, help me please!! “End of extended support” - what does it mean? our’s company project based on django 2.2 within about 70 3rd party libraries. Do i understand correct that after 2022 this version of django becomes unsupported (by whom?) and my webapp, including 3rd party libraries won’t be workable anymore?? It’s very important!!! I often say to my ctf, that we should upgrade permanently our tools, but he has opposite point of view on this case.
cj
cj
check this graphic to see the versions and their release/end dates
cj
also if you have dependency on over 70 3rd party libraries, check the support date for each of them 🤷🏻♂️
Firdaus
Salutations,
Long time lurker, first time asking question here. Anyone can help regarding django-import-export dealing with self-referring model?
# Model
class Location(models.Model):
name = models.CharField(max_length=40)
parent = models.ForeignKey(
to="self",
on_delete=models.CASCADE,
related_name="children",
blank=True,
null=True,
default=None,
)
depth = models.PositiveSmallIntegerField(default=0, editable=False)
def save(self, *args, **kwargs):
if self.parent and self.parent.depth < 6:
self.depth = self.parent.depth + 1
super().save(*args, **kwargs)
# Resource
class LocationResource(resources.ModelResource):
parent = fields.Field(
column_name="parent",
attribute="parent",
widget=ForeignKeyWidget(Location, "id"),
)
class Meta:
model = Location
# Error
location.location.models.DoesNotExist: Location matching query does not exist.
python: 3.8.5
django: 3.1.2
django-import-export: 2.4.0
Pavel
Pavel
i need some strong reason to ensure my chief than we definitely need to upgrade both django and all of packages.. What is the best way to do it? What should i say him in 4 hours?)
cj
Pavel
Leonardo
guys, i'm doing a update on a model, but my FileField is saving just the file name without upload_to path
Jimmies San
Random
any refrences for SEO in django
Random
?
cj
Jimmies San
badumtss :P