Anonymous
Hi I have a query can anyone help me on django
Anonymous
I creating a game application Rank depends on score if score is high than rank is 1. Can anyone help me
MR_X
hello
MR_X
pls tell websites for .. templates
MR_X
html,css,js
Doragonsureiyā
pls tell websites for .. templates
Please don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello I need help on $z" Just ask about your problem directly! With 42k+ people the probability that someone will help is pretty high. Also please read: http://catb.org/~esr/faqs/smart-questions.html
Muflone
Can anyone help me on this?
What's your problem in creating the rank?
Anonymous
What's your problem in creating the rank?
I dont want we put rank as input its auto generat from score
Anonymous
I tried but not able to find solution
Muflone
Just sort the results
Anonymous
In models or in view???
Muflone
In the view you extract the data from the model, sorted using Model.objects.all().order_by("score") and pass them to the template
Muflone
If you want the rank number explicitly you wrap the data in an enumerate function
Anonymous
Muflone
Use enumerate function looping the results and you'll have an index for each row
Anonymous
Muflone
A model is a single row, it shouldn't have things related to other records. You could but you shouldn't
Anonymous
Okay
Sávio
Good evening guys, could you give me a hint on how I put a value inside a django tag?
Anonymous
which page. and what do you mean by extra data
I have the product. And inside everyone form from formset i need show product name, and cost.
Germinate
unless you need to allow the user to click on each product, you do not need to use a form. you can just set the variables as dictionary of product names and costs. then send it to the html from the server using render and do the loops in html using {{variable name}} loops to display the names and costs
Germinate
even if you use a form, you still have to do the {{variable name}} loops to display. a form only helps you post data to the server from the html. to collect data, you need to indicate the form name under a form tag, after the csfr token
Anonymous
User should to full in form about everyone product (subscription term, and update frequency). And maybe I need to iterate formset, and product data together? But how are I can do it?
Yash
i am facing error when user is verfiy is mail Manager isn't available; 'auth.User' has been swapped for 'accounts.CustomUser'
Yash
anyone have solution then please help
Manik
Object of type datetime is not JSON serializable,
Manik
help me
Muflone
Object of type datetime is not JSON serializable,
Convert it to integer number using the method timestamp
Manik
its utc ,cant covert to int
Денис
Good evening guys, could you give me a hint on how I put a value inside a django tag?
Creating custom tags is described in django docs. Three types of them, IIRC
Manik
'poldate':datetime.utcnow().replace(tzinfo=tz.gettz('UTC'))
Manik
i want to post the poldate to django server with json conversion
Muflone
its utc ,cant covert to int
Why can't you? It's a normal datetime object you can convert to anything you want
Manik
resp = requests.post(BASE_URL+ENDPOINT, data=data1) —hitting error
Muflone
Just remove the milliseconds
Manik
tempdate = int(utnow) TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'
Muflone
Convert it to integer number using the method timestamp
I told you timestamp method not the int function
Muflone
The decimal part will be the milliseconds, if you don't need it just remove them (from datetime or from the timestamp) or if you need the precise time including milliseconds you could just multiply it for 1000 (like Java does)
Manik
timestamp = datetime.timestamp(utnow) and sent timestamp to server but database didnt parse it — timestamp = datetime.timestamp(utnow)
Manik
datetime_re.match(value) TypeError: expected string or bytes-like object
Muflone
timestamp = datetime.timestamp(utnow) and sent timestamp to server but database didnt parse it — timestamp = datetime.timestamp(utnow)
1) utnow.timestamp() 2) datetime.datetime.fromtimestamp(received_number) Just be sure your received_number is an integer
Anonymous
Ok
Muflone
Where did you got this "operator"?
Firdaus
I heard of isinstance... but not instance https://docs.python.org/3/library/functions.html#isinstance
Firdaus
https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.FileField.upload_to instance: An instance of the model where the FileField is defined. More specifically, this is the particular instance where the current file is being attached. In most cases, this object will not have been saved to the database yet, so if it uses the default AutoField, it might not yet have a value for its primary key field.
Firdaus
I think the example a few scrolls below that is already self explainatory
Firdaus
in the example case that would be the instance of MyModel
Mirco
Do you know what a class and instance of a class is ?
Mirco
If u are not sure, study better OOP
Mirco
I don't think so if u are still asking yourself what instance means Maybe u need more time to study better
Firdaus
also... the instance in the official doc that we just refered to... it is not an operator. It's a parameter in the user_directory_path function. Sorry, I wish I can explain better... English is not my first language. 🙏🏽
Mirco
bar = Foo() bar is an instance of Foo Imagine Foo is a model, bar is an instance of that model
Germinate
User should to full in form about everyone product (subscription term, and update frequency). And maybe I need to iterate formset, and product data together? But how are I can do it?
did you mean user will see the full list of products and their cost? and can they interact with each product item? or it is just to see
Germinate
basically an instance is a copy of whatever you are calling
Germinate
you declared a class which contains a bunch of variables. you are now calling a copy of it
Mirco
Yup
Anonymous
did you mean user will see the full list of products and their cost? and can they interact with each product item? or it is just to see
I already did it. there was need do custom template tag "for", and iterate formset together with data about product in this custom tag. And yes, user should to choice subscribe time. Thank you very much)))
Germinate
sorry having difficulty understanding you
Anonymous
Of course)
Anonymous
sorry having difficulty understanding you
yes, i need more study english
Firdaus
I think the convention is to use the word instance. The same convention that suggest we use self, and cls.
Firdaus
But you can use any word that you like.
Germinate
Wisdom
Hello please how can i convert my django project to a windows desktop app?
Reginald
Please I need a resourceful tutorial on Django it's urgent please 😁
SkyLord
Hello here is the situation: there is an application in which there is a user model UserShop with its own structure this application have registration form and of course the authorization for authorization the following URL is used: path ('login /', LoginView.as_view (template_name = 'shopapp / sign_in.html'), name = 'shop-sign-in'), Apparently I am using the standard django LoginView. Now, for example, I have 2 registered users according to the UserShop model, BUT, there is also a superuser when in the front I try to login with those 2 users, all is ok get into the dashboard of the user of this application BUT if I try to log in with the superuser, an error pops up: django.contrib.auth.models.User.usershop.RelatedObjectDoesNotExist: User has no usershop. as far as I understand, it appears from the above error that the user I am trying to authorize is not part of the usershop can someone explain to me how to check this and how to handle this error
O
Any simple and efficient way to refresh grid without refreshing page ?
Денис
Any simple and efficient way to refresh grid without refreshing page ?
JavaScript and some API-like Django views returning JSON-formatted data for your script to refresh the grid. Sorry, I don’t know a simpler way
Alexander
Between Class based views and Function based views which one should i use,am am a beginner in django for begginers am being taught class based views while in other docs for begineers its function based views,so which one should i use?
FBV is about how Instagram use Django... functions with decorators looks better IMO... If you like math, you will find functional programming is beautiful way of doing things , better way than OOP...