Enes
I have a problem
Hemant
I have a problem
explain it before you get warned XD
Doragonsureiyā
I have a problem
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z!" Just ask directly! The better you are at explaining the problem, the more likely you are to get help. Asking smart questions
Sina
Hi. Which is better for Normal projects, Django Channel or node js Socket
myii
no, but don't upgrade directly to 3.2 3.0 then 3.1 and 3.2 so you can update part of your code that needs refactoring
Hi, replying to this older message aftering finding it using the search — since this is exactly what my query is about. I've seen this method recommended in these references: https://github.com/django/django/pull/8751 & https://code.djangoproject.com/ticket/28349. Quoting the key point: "The recommended way to upgrade from LTS to LTS is to upgrade one major version at a time, e.g. 1.8.x -> 1.9.y -> 1.10.z -> 1.11.a." So referring to 2.2 => 3.2, the suggestion is 2.2 => 3.0 => 3.1 => 3.2. The issue is that 2.2.26 (2022-01-04) was released a long time after 3.0.14 (2021-04-06) and even after 3.1.14 (2021-12-07). So isn't this upgrading by going through "older" versions?
myii
So relating to migrations, for example. Aren't there migrations that have been applied in the 2.2 series that aren't available in the 3.0 and 3.1 series? I suppose I'm asking -- isn't it safer to upgrade straight from 2.2 => 3.2?
Mirco
So relating to migrations, for example. Aren't there migrations that have been applied in the 2.2 series that aren't available in the 3.0 and 3.1 series? I suppose I'm asking -- isn't it safer to upgrade straight from 2.2 => 3.2?
No, the safer way is to do 2.2 , 3.0, 3.1 and 3.2 And nowadays you can use django-upgrade tool to update your syntax to be compatible with a target version e.g. 3.0 Ref -> https://adamj.eu/tech/2021/09/16/introducing-django-upgrade/
Mirco
You're welcome
myii
No, the safer way is to do 2.2 , 3.0, 3.1 and 3.2 And nowadays you can use django-upgrade tool to update your syntax to be compatible with a target version e.g. 3.0 Ref -> https://adamj.eu/tech/2021/09/16/introducing-django-upgrade/
One thing I will say, though — when it comes to upgrade time, it feels like it would have been much easier just to upgrade through all of the minor versions immediately, since you really have to go through them anyway from LTS to LTS.
Mirco
One thing I will say, though — when it comes to upgrade time, it feels like it would have been much easier just to upgrade through all of the minor versions immediately, since you really have to go through them anyway from LTS to LTS.
Especially if your code is old or strongly based on some external dependencies by upgrading minor per minor will be able to spot easily possible errors And even if they are "minor" from 3.1 and 3.2 some important stuff changed a lot
myii
Especially if your code is old or strongly based on some external dependencies by upgrading minor per minor will be able to spot easily possible errors And even if they are "minor" from 3.1 and 3.2 some important stuff changed a lot
It looks like I made a bad assumption that LTS to LTS upgrade was acceptable. Meaning, LTS to the next LTS directly, without having to go through the minor versions first.
Mirco
It looks like I made a bad assumption that LTS to LTS upgrade was acceptable. Meaning, LTS to the next LTS directly, without having to go through the minor versions first.
Yeah the final goal is to have the latest LTS up and running But to achieve that goal, you need to check minors first
.
Hi, who using django oscar?!
Doragonsureiyā
Hi, who using django oscar?!
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z!" Just ask directly! The better you are at explaining the problem, the more likely you are to get help. Asking smart questions
.
How can I remove an item from the customer's basket in django oscar? The following line just acts as an <a href="#"></a> link: <a href="#" data-id="{{ forloop.counter0 }}" data-behaviours="remove" class="inline">{% trans "Remove" %}</a> I want to make custom basket without using Ajax
Jean-Yves
hello, how to make a shopping cart in django with class views , and use sessions from it, how to do it please
Doragonsureiyā
hello, how to make a shopping cart in django with class views , and use sessions from it, how to do it please
So, why don't you do it yourself first? When you have an issue with the Python code you wrote (read rule 5️⃣ to show your code), come back here and people will help you. 😉
Nisha
I'm not able to add background image to my index. Html file, in djangi can anyone help me
Anonymous
How to solve Module not found error
Maxim
How to solve Module not found error
be specific show the code
Doragonsureiyā
How to solve Module not found error
To share code or error tracebacks, use a pasting service, like: - https://linkode.org - https://dpaste.org
Hemant
the only thing which is left is no matter if the user have changed password or not, if we directly try to open this url, it opens up
Hemant
my_website.com/password_change/done always shows a success message without checking if the user have really changed its password
Hemant
!paste
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - 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.
Hemant
here is my class code
Hemant
here is my class code
btw overriding form_valid is just useless here
Sp
Am not able to update my database from form am a beginner in webapp
Sp
i am pasting my views.py
Sp
am able to add data to my database but update is not working
Sp
here is my update.html
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - 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.
AK
i am pasting my views.py
Code not available bro
Raad
Hello, I'm trying to create a webhook that receive a payload contain an order information. If the order status completed, I will do the following: Pseudo code if order status == completed check if the user exist with same email if email exist: check if got subscription» if so, update the subscription else create new one if email not exist: create new user account, then crate new subscription I will ignore other order statuses by using break I need help with subscriptions query where i need to get the subscription if he has any and update the record or create a new one Code here https://pastebin.com/a3zVJZSk
kam
Should I use class based views or functions? I know that functions give more control, but still. What are use cases for CBV
Hemant
Guys I've added the readme with local host deployment and contributing guidelines Can someone take some time to read and tell if I am missing any important aspect to be mentioned? (I'll add the app fevicon later)
Hemant
CBVs require less code to write in my opinion
Hemant
 
hello i try to write login page i try bellow code but returns a none object with correct username and password: if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) auth_login(request, user) i change user model to a custom model
Sukuna
Check your template
 
Check your template
i try this but returns none if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username='morteza201', password='1234') auth_login(request, user)
 
Check your db
username and password is correct what is important settings for custom user model?
 
user = auth.authenticate(username=username,password=password)
i don't have an error returns none object
Fan / Ac
i don't have an error returns none object
because the password is incorrect
 
because the password is incorrect
i copy from admin panel so password is correct
Fan / Ac
i copy from admin panel so password is correct
admin panel does not hash password unless you specify
Fan / Ac
authenticate method hashes the password and try to authenticate
 
authenticate method hashes the password and try to authenticate
i write custom user model what to do in model that model hash password and save it?
Fan / Ac
i write custom user model what to do in model that model hash password and save it?
https://stackoverflow.com/questions/15514912/django-admin-not-hashing-custom-user-password
Arslan
Anybody know how to create tree model structure ?
Arslan
parent = models.ForeignKey('self', null=True, blank=True, on_delete=models.CASCADE)
Arslan
This doesn't work
Arslan
sorry, i realised what doesn't work)
Arslan
What was it
I haven’t done migrations
Arslan
)))
Alex
Should I use class based views or functions? I know that functions give more control, but still. What are use cases for CBV
CBVs are about boilerplate. In the web programming there are many typical tasks - get a row from a DB, manipulate or delete it. So CBVs allows you to accomplish such tasks in a few lines of code. Actually that's not true that FBVs give more control - you always can create a very custom View descendant.
Alex
Hello, I'm trying to create a webhook that receive a payload contain an order information. If the order status completed, I will do the following: Pseudo code if order status == completed check if the user exist with same email if email exist: check if got subscription» if so, update the subscription else create new one if email not exist: create new user account, then crate new subscription I will ignore other order statuses by using break I need help with subscriptions query where i need to get the subscription if he has any and update the record or create a new one Code here https://pastebin.com/a3zVJZSk
Something like try: user = User.objects.get(email=client_email) except User.DoesNotExist: user = User.objects.create(**credentials) sub = Subscription.objects.filter(user_set=client_email).filters(<some-another-criteria-to-get-current-sub>) if not sub: sub = Subscription() sub.some_attr = attr sub.some_other_attr = <value> sub.save() But there are many questions to your data model. Does a user can have multiple subscriptions? Or you just track history? Because you have a fk from the subscription model to the user model. Maybe it should be one2one? How do you determines what data corresponds to which subscriptions?
Alex
Thank you Alex for the answer, User can have only one subscription and you are right the relationship needs to be one2one. There are two more attributes such as length of subscription and renewal date which I'm aware of. I have also another table contain the plan information such as name, price, etc.. User can have one plan so in this case the relationship between subscription and plan is one2one too?
> User can have one plan so in this case the relationship between subscription and plan is one2one too? Of course as it's your project it's up to you, but that way it would sound strange. You can make a fk from Subscription your Plan. So that way a user have a subscription and there only one plan. But a plan can have multiple subscriptions and therefore multiple users. Actually, since it's a payment processing (as I understand) there is no need for user creation. Therefore you can do just sub = Subscription.objects.get(user__email=client_email). Of course if you don't need that instance later in you code.
Raad
> User can have one plan so in this case the relationship between subscription and plan is one2one too? Of course as it's your project it's up to you, but that way it would sound strange. You can make a fk from Subscription your Plan. So that way a user have a subscription and there only one plan. But a plan can have multiple subscriptions and therefore multiple users. Actually, since it's a payment processing (as I understand) there is no need for user creation. Therefore you can do just sub = Subscription.objects.get(user__email=client_email). Of course if you don't need that instance later in you code.
To make things clear I will share my method of processing payments because it might be useful to others. I have a WordPress site with WooCommerce on it. WooCommerce allow you to create a webhook to send events such as order created or order updated to a specific url where you can process as you like. clients can subscribe and make the payment through WooCommerce. When payment received, the order status change to completed which make the webhook send the update event to the django url that I'm trying to make now. The data come in a JSON format contain all the information that i need including payments info. For sure i need a payment table later to save the payment details but my plan is to make the subscription work first and then work on the rest.
Raad
> User can have one plan so in this case the relationship between subscription and plan is one2one too? Of course as it's your project it's up to you, but that way it would sound strange. You can make a fk from Subscription your Plan. So that way a user have a subscription and there only one plan. But a plan can have multiple subscriptions and therefore multiple users. Actually, since it's a payment processing (as I understand) there is no need for user creation. Therefore you can do just sub = Subscription.objects.get(user__email=client_email). Of course if you don't need that instance later in you code.
To explain it better, User can have one subscription I have 3 plans FREE, STANDARD, PREMIUM User can have one subscription and the subscription that belong to the user can have only one plan Regarding user creation, I'm making the registration throught the WordPress and I'm hiding the registration url in django. I'm pointing the success subscription order to the sign-up function internally. So there are cases where the user is new and i have to crate an account for him or maybe a user who already have an account where i have to update the subscription or change the plan
Sherry
obj,created = Model_name.objects.get_or_create(**data)
Raad
@alkalit Any idea how the query looks like to get the email from the Subscription table through the relationship between them?
Alex
@alkalit Any idea how the query looks like to get the email from the Subscription table through the relationship between them?
I don't understand. Do you want to get user's email through Subscription table as if they were related one2one?