#web-development
2 messages ยท Page 117 of 1
only 10... wow
@hushed barn maybe change what your view returns
and does your console say anything?
but if i cant even open an empty page
console says nuthing
it worked yesterday but doesnt work anymore i didnt do anything
if ur 10 u cant be on discord
this ain't the place...
yes well i can be with a guardians permission and if i am mature enough
oh ok
@hushed barn and the other routes work fine?
Yea but the from products.views import* does nothing to my code
unused imposrt statement
you don't need that.
from products.views import * imports everything form products.views, but in your products app you import them anyway
firewall wouldnt stop you from connecting locally i think
yea true but maybeee ya know
well, I think it points to something external blocking it. Nothing shows in the console, and the routes look right
@hushed barn Can you send us a picture of your console
The "run" tab in pycharm
simpler to just send a screenshot of the run tab
well... there's your answer... since you ran into an error the server stops and when you retry the connection the server isn't running so it refuses to connect
yea well thanks a lot tryna fix this up
am i doing something wrong here. it just doesnt get redirected to the home route
res.sendFile(__dirname + '/client/test.html');
});
app.post('/test', function (req, res) {
setTimeout(function () {
res.redirect('/')
}, 5000)
})```
@blazing sapphire what if you specify the function in setTimeout outside of that block, then reference it inside setTimeout? I don't know whether that's the right usage of it.
even if i remove setTimeout, it still doesnt work
@blazing sapphire are you using react?
no
@native tide im dying here why does this show errors im doing it exactly like i read the page
read the error on the side, hover over the red for the error
you need a comma on the products path
because its a list
ok thanks
hey guys I just learned the basics of flask by watching a 1hr video by FreeCodeCamp
i'm confused what should I do now?
what projects should I make?
I tried googling but still confused lol
help
ok
so I can a covid tracker with python like this (or some other way) and deploy it using flask and heroku? @rustic pebble
Yes
and is that code the only way to make a covid tracker?
No
I want to do something by myself and not copy the code
You can create your own wrapper
wrappers = decorators?
No
You can make a background job that checks this folder:
Every day
And updates a database with all countries
Or you can just increment the day by 1 in this url
https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_daily_reports/11-24-2020.csv
It is CSV so parsing it is easy
Its not rly scraping since you have direct access to the file
oh
All you need is the raw
So basically this link
https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/11-24-2020.csv
A simple request would do it
data = requests.get(f'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/{current_month}-{current_day}-{current_year}.csv').text
As simple as that
oh
I get it
so I have to parse the repo and check for new files daily (for which I can write an automated script? or smth? idk)
then I can make a flask application that displays it on webpage
?
You can get current date with the following
from datetime import datetime
current_month = datetime.now().strftime("%m")
current_day = datetime.now().strftime("%d")
current_year = datetime.now().strftime("%Y")
The best would be to use a database
ok
I have postgrs and mysql installed on my laptop but I never used them
let me search on my own
gtg to eat
Which provides on ORM
ik that
Object Relation Map
sure
Will script(js) file be running on browser when rendering html using flask?
@rustic pebble what is that raw github link ? and from where you got that ?
I decide to first write a python code and then try to make a flask page on it
o
how to read a config key in my main route files? I thought it was something like app.config['secret_key']
secret key is set inside init
I want to read the value inside one of my routes
nvm done it, I imported app instead of doing from app import app
how does web development works with python?
@past cipher you'll also need current_app inside of a view
@native tide the same way as other languages, through a web framework. In Python, you have quite a selection but the most stable choices are Django and Flask
Django gives you more tools out of the box, Flask is extensible and relies on plugins
why would you make a web with python instead of using basic html?
thanks @pine yew I already got it sorted
@native tide you use Python for the back-end
you still need to use html
for front-end
There are two parts to a website, the backend and frontend. Your backend is usually written in pretty much any language, such as Python. Your frontend will always be a collection of html, css, and javascript.
no, not really
I use something called FastAPI because I mostly make REST APIs at work
and it has a lot of great features
but, how can you explain member everything about Django to HTML ?? sometimes Youtube or other sources are better and the best than chatting here :x it is not Negative Feedback. it is reality.. as i started python, django, html, js, css and other more... i am not pro.
when I call create_user() on a User model does this check first if the user exits?
@haughty turtle afaik the username has the unique constraint so if a user already exists with such a username you'll run into that error.
So, by that metric, yes
Cool, thanks
this is correct also for email? I mean as I am not using usernames just first and last name, email, pass
I don't think the email has the unique constraint
@haughty turtle you can expand on Django's user model with your own field constraints with AbstractUser. You'll still have the User methods such as .is_authenticated etc. maybe that's what you're looking for
def register_user(request):
if request.method =="POST":
request = json.loads(request.body.decode('utf-8'))
first_name = request['fname']
last_name = request['lname']
email = request['email']
password = request['password']
re_password = request['re_password']
if password == re_password:
u = User.objects.get(email=email)
if u:
User.objects.create_user(first_name=first_name, last_name=last_name, email=email, password=password)
else:
pass
else:
pass``` @native tide Should that be good for now in checking wether email exist
Looks fine, but in this scenario if the email already exists, the user won't know. (User will just return an error server-side if the unique constraint isn't fulfilled). So, I would manually check whether the email is available before saving the object.
Oh, and that being said, you'll have to add your own constraint for email if you want it to be unique
yeah I am going to add that in that if a email exist it will throw a setCustomValidity('Email is Already Registered.'); on the email input in my JS
Oh, cool. Are you using React? @haughty turtle
Vanilla
Ah, ouch.
Depends on your use case. If it's something simple, no bother.
But using a framework something like React is great, and the libraries available speeds up really tedious tasks such as forms, etc
I will look into it after I finish the page and rewrite from Vanilla JS into a framework, my last project had 500 lines in Vanilla JS , this one probably more
But if you can write it in vanilla JS I think that's already gave you a boost in understanding the frameworks.
I went straight into React without JS knowledge and didn't know any of the terminology (I still don't understand the DOM lol) so you'll do fine
Cool, nice to know, haha dove straight into the DOM in day 1, I mean I got the hang of JS in just one day, it was pretty straightforward.
Frameworks just offer a benefit in dev speed or more? guess I will have to look into it.
Yea, dev speed, page speed (React can manipulate the virtual DOM instead of the whole DOM, so no refreshing of the page) and makes everything AJAX and smooth.
I wouldn't have anything to compare it too as the only JS I use is within the framework
But it will differ slightly, if you use React the main language is JSX which varies but only slightly
Hello,
I need help with two question, if someone could help me.
-
What is the proper way to chain methods based on conditions?
If I have a class with multiple methods and on my object I would like to chain some of those methods only if certain conditions are met. How would I do that? -
What is the proper encoding method for transfering data to another webservice? API service.
I'm trying to send a JSON text to another service and it seems to return an error for some characters like +, <, >... etc.
Thank you.
hello everyone
Hello
Anyone here have some experience with Boto3 and S3. I have a Django application and am wanting to migrate to using S3 for media files and maybe static as well. Would this be a simple transition assuming the application is already running and I have files locally of course? If so how would I go about doing it? Setting ip boto3 normally and it will upload everything automatically?
if anyone need web hosting for your websites
join this free giveaway
by my brother
5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.
!rule 6 actually
6. No spamming or unapproved advertising, including requests for paid work. Open-source projects can be shared with others in #python-general and code reviews can be asked for in a help channel.
This is probably the 100000th time someone asked this but... Vue or React (or something else) and why - for Django or just in general?
I like vue v3's more FP approach, just personal style
I also like their use of single-file components (SFC)
class NoteSerializer(ModelSerializer):
class Meta:
model = Note
fields = ["name", "content", "notebook", "slug"]
notebook = CharField(required=False)
content = CharField(required=False, allow_null=True, allow_blank=True)
Does anyone know why even though I've specified my content field to not be required, it's still being required?
I guess the same guess for notebook
@native tide Grow your email list through Viral Giveaways Not allowed and its not a open-source project, you require a email for it. It does not belong here and you might as well remove it.
@dense slate If you are looking for a job then React as its more popular, Vue is Opened Source, I will main it for personal projects, but employers mostly look for React based on what is being shown.
Is allow_null a more recent Django change? I thought it was just null=True.
@haughty turtle Future employability aside, from ease of use and just pleasure of working with it, sounds like Vue?
VueJS I have heard alot of good things about they say its the best of both worlds between React and Angular
Its a highly active project, and making sure to stay ahead of Google and Facebook, I will make sure to learn it as my main framework when not in relation to employment
Django: real quick question, is there a way to automatically create x instance of a model if x instance doesn't exist?
I.E. (delete all model instances,) or (new django db is created): if no instances exist, a default instance automatically gets generated
Thanks, I'll take a look
for reference this is my current fix lol, but have to pass exceptions for initial migration to not throw an error
def getMainMenu(): # TODO FIX THIS SHIT
try:
# Check if menu is empty
if not MainMenuLink.objects.all():
link1 = MainMenuLink.objects.create(title='Home', url='/')
link1.save()
...
logging.error(f"No MainMenuLink objects exist, creating defaults")
except:
pass
# Return menu
return MainMenuLink.objects.all()
finally:
pass
lol
This is so strange
I'm making a new note, it's appended to my client-side "list of notes", but if I am hovering over a note when I "submit", it does not show until my mouse leaves that div (that note). I have been pondering over my code for about an hour now and im so lost...
@kindred whale thanks btw, works great
@native tide Can you show a snippet of the code
Have you include any code that would stop the function that refreshes your items on screen from running, I have accidently done this before, where inside my function I would call an if statement to check if the item hovered is not the same to the refresh my items
Dude, I actually just fixed it randomly. Holy fucking shit
It came to the point where I'm just changing stuff randomly without thinking
and it worked...
And that "snippet" would be 500+ lines ๐ณ
So thank god for that ๐
yeah would of loved to help back, but would of needed to review code. Glad you got it fixed though
you should go back step by step and undo changes until you find that ramdom piece that fixed it so you can understand the problem better for future references
@native tide
Yeah
It was totally unexpected because the functionality of my component essentially mirrors the functionality of ones I already wrote (successfully).
And going line by line, everything seemed to work fine.
Boom created a Custom User and just registered and logged in
I think it's something with the inner workings of React. I have a parent component with a child component, and when I press "submit" to make that note, that child component is updating the state of the parent component.
I realized a lot of the state changes of the child component were reverting the state of the parent component to its DEFAULT. So, I just removed the state-changes from the child component, and placed it all in the useEffect hook of the parent component. And that worked.
So I think what was happening was that there was some async stuff going on not as expected, still not sure lol, don't really want to know
@haughty turtle Nice!
You have any resources that would give me a depper understanding on how sessions work
I know there is the db, cookies, or file storage sessions
but I want to understand how this would be able to authenticate a user with user info being stored server side
Only finding detailed information on cookie based sessions
I'm pretty sure that Django gives every user a session token which is then stored client-side as a cookie, and on every request that token is included in the request header...
Actually I think I'm wrong on that one
Pretty sure that's token authentication which is different
Django uses database based sessions which are stored on the database as default
while Flask uses cookie bases sessions as default
This is giving some good info so far
"Django uses a cookie containing a special session id to identify each browser and its associated session with the site. The actual session data is stored in the site database by default (this is more secure than storing the data in a cookie, where they are more vulnerable to malicious users). You can configure Django to store the session data in other places (cache, files, "secure" cookies), but the default location is a good and relatively secure option."
That's pretty confusing to me.
So, Django stores each user's session ID in a database, and stores it as a cookie. Then on every request compares the cookie ID to the session ID...
How is that different to token authentication?
You can read it and write to request.session at any point in your view. You can edit it multiple times```
it seems to grab it from request.session but yeah have to dig into it
# Get a session value by its key (e.g. 'my_car'), raising a KeyError if the key is not present
my_car = request.session['my_car']
Yeah
The mozilla docs explain it well
I might need to use the session auth to track stuff like website visits
But I still don't get how it's different to token auth
if request.method =="POST":
new_request = json.loads(request.body.decode('utf-8'))
first_name = new_request['fname']
last_name = new_request['lname']
email = new_request['email']
password = new_request['password']
re_password = new_request['re_password']
if password == re_password:
try:
u = User.objects.get(email=email)
print('Email already in use.')
except:
User.objects.create_user(first_name=first_name, last_name=last_name, email=email, password=password)
print('User Created.')
user = authenticate(request, email=email, password=password)
if user is not None:
login(request, user)
return redirect('http://127.0.0.1:8000/portal/')```
I am trying to redirect but it does nothing
hey can someone help me here
def delete(request, pk):
order = OrderItem.objects.get(id=pk)
if request.method == 'POST' :
order.delete
elif order.DoesNotExist:
order_name = order.name
order_name.delete()
return redirect('Cart')
context = {'order': order}
return render(request, 'products/delete.html', context)
i am trying to make the user delete the an order added to the cart by the id and it removed but if i came and add it again it says it does not exist because it has new id now so i am trying to delete it using order name or idk
Im trying to raise Django's Http404 to use their 404 page, however, it 500's
https://docs.djangoproject.com/en/3.1/ref/views/#the-404-page-not-found-view
@late gale You should not be removing items from cart server side
That is something you take care of in the frontend, with JS
what you are doing is deleting the item from the database so this is the reason why you are getting such error, as users should not be allowed to delete global items that other users would need, that is an admin function.
Will save that to read later @native tide
Thanks
@haughty turtle oh so you mean i have to use javascript to delete i will try then
thank you
@late gale you can delete by order_number and every time something is put into the cart (or bought) assign it a new unique order number
Just a thought.
Could do that also, but then doing this in Django would it not be more complicated and offer worse UX, as for changes to take effect on the browser would cause for a reload, while JS does it without reloading
?
Oh yeah JS would be the better option for sure
You'd have something like the order_number thing as an API instead in that case
but how i can select an order item like if i added an id to the <h1> tag this will remove all my order items not a certain one
show me your html
ok
just a snippet is fine
</div>
{% for item in order.orderitem_set.all %}
<div class="cart-row">
<div style="flex:2"><img class="row-image" src="{{item.product.image.url}}"></div>
<div style="flex:2"><p style="font-family: inherit;">{{item.product.name}}</p></div>
<div style="flex:1"><p style="font-family: inherit;">${{item.product.price|floatformat:2}}</p></div>
<div style="flex:1"><p class="quantity" style="font-family: inherit;">{{item.quantity}}</p></div>
<div style="flex:1"><p>${{item.get_total|floatformat:2}}</p></div>
<div style="flex:1">
<a class="btn btn-sm btn-dark" href="{% url 'Products' item.product.id %}" style="font-family: inherit;">Update</a>
</div>
<div style="flex:1">
<a class="btn btn-sm btn-danger" style="font-family: inherit;" href="{% url 'Products_Delete' item.product.id %}">Remove</a>
</div>
</div>
{% endfor %}
there is the part
<a class="btn btn-sm btn-danger" style="font-family: inherit;" href="{% url 'Products_Delete' item.product.id %}">Remove</a>
thats the remove btn
hope u get what i am trying to say
you need to loop through all of your remove buttons and add a eventlistener
on click then grab its parent element
for ( let l = 0; l < pwLength; l++) {
document.querySelectorAll('.cart_trash')[l].addEventListener('click', function() {
this.parentElement.remove();
localStorage.removeItem(this.parentElement.getAttribute('id').replace(/_/g, " "))
let totalC = parseFloat( parseFloat(document.querySelector('#total_cost').innerHTML.replace(/[^.\d]/g, '')).toFixed(2) - parseFloat(this.parentElement.childNodes[6].innerHTML.replace(/[^.\d]/g, '')).toFixed(2) ).toFixed(2);
document.querySelector('#total_cost').innerHTML = `Total: $${totalC}`;
if ( cart_count () < 1 ) {
document.querySelector('#overlay_wrapper').style.display = 'none'
}
});
}```
this is an example that I just recently used
oh ok let me see
it has some extra stuff in there but just focus on the loop, the eventlistener, and this grabs the object that your item is in get the parent and delete it.
check if the item count in the cart is 0 to then exit out of the cart display
update new total price
Okay I'm admittedly new to Django but am a bit baffled on this one. I have django running in docker. Template loads fine. I have a file called main.js in my static folder that 404s when the template tries to load it. Works perfectly in my 'prod' docker-compose using nginx and gunicorn, but running in the dev server it 404s. What the am I missing?
Grabbed a shell in the container and confirmed with diffsettings that STATIC_ROOT is configured to point to that directory (/app/staticfiles), and that the file is definitely there and has the correct permissions
STATIC_ROOT = '/app/staticfiles'
file exists in that folder and has the correct permissions:
total 16
drwxr-xr-x 3 appuser appuser 4096 Nov 25 21:10 .
drwxrwxr-x 7 appuser appuser 4096 Nov 25 21:10 ..
drwxr-xr-x 6 appuser appuser 4096 Nov 25 20:57 admin
-rw-rw-r-- 1 appuser appuser 31 Nov 25 21:10 main.js```
@haughty turtle the item isnt removed yet
there is only one remove button i think no loop needed
look
<button type="submit" id="button" value="Remove" class="btn btn-sm btn-danger"></button>
</div>
</div>
{% endfor %}
<script>
document.getElementById("button").addEventListener('click', function(){
var order_item = document.getElementById("order_item").remove()
})
</script>
it just removed the button .
or wait
oh it worked @haughty turtle but the problem is if i refreshed it came back again
because you have your button wrapped in a div
so you have to remove the parent of the parent of your button
@late gale have to head out
also you need a loop because you have a button for every item {% for item in order.orderitem_set.all %}
because of the for loop, on refresh it refresh everything
i tried to click on the second button but not worked
so you have make sure to verify where you are grabbing your items from {% for item in order.orderitem_set.all %}
and how i gonna loop in this tbh
on refresh you are setting displaying all items from django again
Hello everyone. Could i represent this function view to class based ListView?
I've confused because in django documentation says, ListView - Each generic view needs to know what model it will be acting upon. This is provided using the model attribute.
as i understand with model = My_model, but if i want add more the one model to this view, how can i do that?
Thanks!
def index(request):
'''
Function for display homepage
'''
# Generate count main objects
num_books = Book.objects.filter(genre__name__icontains='').count()
num_instances = BookInstance.objects.all().count()
num_genres = Genre.objects.all().count()
# Avalible books (status='a')
num_instances_avalible = BookInstance.objects.filter(status__exact='a').count()
num_authors = Author.objects.count()
num_articles = Article.objects.filter(category__name__icontains='').count()
# Number of visits to this view, as counted in the session variable.
num_visits = request.session.get('num_visits', 0)
request.session['num_visits'] = num_visits+1
# Render HTML-tamplate index.html with data inside variables 'context'
return render(
request,
'index.html',
context={
'num_books': num_books,
'num_instances': num_instances,
'num_instances_avalible': num_instances_avalible,
'num_authors': num_authors,
'num_genres': num_genres,
'num_visits': num_visits,
'num_articles': num_articles,
},
)
I have to head out wife is waiting for me, instead of using django to display each item in your cart try to use js
So when a user clicks add to cart you send the items they added over to Django? @late gale
@late gale are you dealing with registered users?
let me know why here is not request.POST['fname'] instead of request['fname'] .. etc.. ????
Hello! I'm looking to start a personal project that needs a webserver backend. Just a few endpoints and some light DB access. Is Flask still the way to go? or is there something new/interesting I should check out?
@snow sierra because I sent a POST through fetch in JS,
My items was attached into it's body as JSON
oops sorry, yes ( request = json.loads(request.body.decode('utf-8')) )
@haughty turtle nope guest users
If you are using guest user then no reason to send this over to Django
i did i can remove all the orders using django from the remove button but cant remove specific one
Could be due to the cascade on delete, show your model, but what I want to say is that if you are logging a user in then you shouldn't be sending this over to Django until the user is ready to finalize the purchase then you cross reference your items from your models to make sure they are paying the correct price.
I am trying to run unit tests in django python3 manage.py tests and I get the following error:
django.contrib.messages.api.MessageFailure: You cannot add messages without installing django.contrib.messages.middleware.MessageMiddleware
And messages is in INSTALLED_APPS
and MIDDLEWARE
Even then if you log a user, me personally I would save this as a JSON through the use of fetch and save it under my User model. Then I would be able to grab it and loop through it. Even then point being you will still need JS to provide better UX, the way you are going would require a reload. @late gale
The way you are displaying your items in your HTML requires a reload for changes to take effect. Not recommended
@grizzled sand that doesnโt really work... it has to be one model per view.
can be nested thoughthis
@trim star did you add django.contrib.messages.middleware.MessageMiddleware' to your MIDDLEWARE settings ? https://docs.djangoproject.com/en/3.1/topics/http/middleware/#activating-middleware
i presume that you also had django.contrib.messages in your INSTALLED_APPS
BRUH no thats against discord's tos but dont worry I wont report you
import axios from 'axios';
import pixStore from '../redux/store';
axios.defaults.xsrfHeaderName = "X-CSRFToken"
axios.defaults.xsrfCookieName = 'csrftoken'
axios.defaults.headers.common['Authorization'] = JSON.parse(pixStore.getState().token);
export default axios;```
I did this to make axios default headers but still my requests are failing because they arent authorized
the api says I need the auth token in the header
But I already have it, right?
What am I doing wrong here? pls help me
I console.logged JSON.parse(pixStore.getState().token) Its the correct token
most api will also following the format of "Authorization: Bearer <token>"
xhr.js:177 POST http://127.0.0.1:8000/api/logout/ 401 (Unauthorized)
(anonymous) @ xhr.js:177
e.exports @ xhr.js:13
e.exports @ dispatchRequest.js:50
Promise.then (async)
l.request @ Axios.js:61
r.forEach.l.<computed> @ Axios.js:87
(anonymous) @ bind.js:9
onClick @ sideBar.jsx:41
We @ react-dom.production.min.js:52
Ye @ react-dom.production.min.js:52
(anonymous) @ react-dom.production.min.js:53
Er @ react-dom.production.min.js:100
Cr @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
ze @ react-dom.production.min.js:292
(anonymous) @ react-dom.production.min.js:50
Nr @ react-dom.production.min.js:105
Zt @ react-dom.production.min.js:75
Jt @ react-dom.production.min.js:74
t.unstable_runWithPriority @ scheduler.production.min.js:18
$o @ react-dom.production.min.js:122
Le @ react-dom.production.min.js:292
Gt @ react-dom.production.min.js:73
sideBar.jsx:46 Error: Request failed with status code 401
at e.exports (createError.js:16)
at e.exports (settle.js:17)
at XMLHttpRequest.p.onreadystatechange (xhr.js:62)```
ohh
axios.defaults.headers.common['Authorization'] = 'Bearer ' + JSON.parse(pixStore.getState().token);
like this?
@gaunt marlin
yeah
no need for <>
okayb thanks Ill try it
i just use it to tell it's for token
function logoutUser() {
axios.post('/api/logout/')
.then(() => {
dispatch({type: "CLEAR_AUTH"});
<Redirect to='/login/' />
})
.catch(error => {console.log(error)});
}```
can anyone suggest me some helpful tutorial for flask-security
this is how I make the request
and I import axios from here
import axios from '../../tools/csrfConfig';``` where I defined the default headers
anything wrong here?
token auth django
Yes I did
my other endpoints which dont need authentication are fine
i think you mean authToken of DRF, not Django(django don't have it)
@twilit needle then i think you would need to use the format of "Authorization: Token <token>" https://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication
as you see from the example
Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b
Django, API, REST, Authentication
jwt you use Bearer, auth token you use Token
Can Django work as a sub-domain to a SquareSpace website?
axios.defaults.headers.common['Authorization'] = 'Authorization: Token ' + JSON.parse(pixStore.getState().token);``` am trying this @gaunt marlin
@twilit needle don't do that, you don't need the after authorization
okay
lol
axios.defaults.headers.common['Authorization'] = 'Authorization ' + JSON.parse(pixStore.getState().token);```
this?
it doesnt work though
same error in console
axios.defaults.headers.common['Authorization'] = 'Token ' + JSON.parse(pixStore.getState().token);
is ok , i don't know about axios so i guess this is the way to set header
http http://127.0.0.1:8000/hello/ 'Authorization: Token 9054f7aa9305e012b3c2300408c3dfdf390fcddf'```
I saw this example
yeah but it didnt
one sec
@api_view(["POST"])
@permission_classes((IsAuthenticated,))
def logout(request):
try:
request.user.auth_token.delete()
except (AttributeError, Exception):
pass
logout(request._request)
return Response(status=HTTP_200_OK)
this is my view
what did the api return?
did you check your token? to see if it's correct?
um yes
its correct
am sure
am referring to this
GUESS WHAT IT WORKED
and I know why
axios.defaults.headers.common['Authorization'] = 'Token ' + JSON.parse(pixStore.getState().token);
we're supposed to do this
the Authorization: part was this
axios.defaults.headers.common['Authorization']
axios automatically passes it as a dict
so we shouldnt do Authorization:
well yeah that what headers.common is for
yeahh
set the header values
lol I was so stupid
so it can pack into dictionary
@twilit needle i suggested you this earlier but you said it returned 401 which make me confused
Ohh
sorry I think I mistook you
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
now I get this error duh
when I try to login
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import {useSelector} from 'react-redux';
import {IsNull} from '../../tools/easierJavascript';
const PrivateRoute = ({component: Component, ...rest}) => {
const user = JSON.parse(useSelector(state => state.user));
return (
<Route {...rest} render={props => (
(!IsNull(user)) ? <Component {...props} /> : <Redirect to='/login/' />
)} />
);
};```
problem is with this
well that is axios error which i'm no expert in
no its reactjs error
function AppRouter () {
return (
<Router>
<div className="appRouter">
<Switch>
<PrivateRoute path='/app/' component={App} exact />} />
<Route exact path="/" render={() => (<Redirect to="/app/" />)} />
<AuthenticationRoute path='/login/' component={LoginMount} />
<AuthenticationRoute path='/register/' component={RegistrationMount} />
</Switch>
</div>
</Router>
);
So I have a router for my app
well react use axios to doing requests
and it has PrivateRoute components
oh ok got it
the private route component is running an infinite loop?
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.```
I got this error
nevermind
I think I solved it
I didnt json.parse the user in another component
@trim star i think your case might be like this https://stackoverflow.com/questions/55843504/django-messages-middleware-issue-while-testing-post-request
gn everyone
I'm kinda new to web-dev, mostly the authentication part got me confused
My question is how is token more secure then username and password authentication to REST APIs?
I'm currently developing a REST API and there's a endpoint to retrieve the user token based on its username and password.
In that case is not the same thing? If someone get your password it might aswell get your token in that way
@iron beacon token is to identify which user calling the api,
you first send username/password to authenticate that user is correct and give them a short live token, for example to call /profile api you would send user token instead of sending username/password again. If you want to secure from man in the middle attack(if someone stole your token), this is where SSL come in, it's use to encrypt your network traffic. If you use authentication setting up SSL is MANDATORY. TLDR: Token itself don't have any security, it just use to identify user, if you want secure then encrypt your api host with SSL
Oh, so that's why the DRF documentation mentions that you need to use HTTPS instead of HTTP when working with tokens
yep
Anyone here who can help with a django url displaying this image
@ me if you have an answer pwease Thanks!
...at a guess, your server isn't running.
I did the wunserver command?
the what?
In terminal i did the runserver command
there is a time and place to act cute, but this isn't it IMO...
so is it actually running?
check your terminal
Can you send me the exact command i should be using
python manage.py runserver...?
python manage.py runserver
That feeling when your so dumb how did i not remember every time i restart i gotta run the server Thank you! maybe i should quit coding when i still can i probably should not code when im 10
hii
hiya
Hi
I want to compare modell value with request value ( Django )
log
{'type': 'textbox', 'group': 'content', 'name': 'textbox_00', 'settings': {'text': 'Ny text?'}}
{'type': 'inputs', 'group': 'content', 'name': 'inputs_01', 'settings': {'input1': 'Ja', 'input2': 'Nej', 'type': 'button'}}
<QuerySet [<SettingsPair: input1: Ja>, <SettingsPair: input2: Nej>, <SettingsPair: type: button>]>
None
{'type': 'textbox', 'group': 'content', 'name': 'textbox_00', 'settings': {'text': 'Ny text?'}}
{'type': 'inputs', 'group': 'content', 'name': 'inputs_01', 'settings': {'input1': 'Ja', 'input2': 'Nej', 'type': 'button'}}
code
for ui in found_question_uis:
settings = print(ui.settings.all())
print(settings)
for req_ui in request_ui_components:
print (req_ui)
@hushed barn everyone hits the point you have hit and makes silly mistakes wether you are 10 or 50 or anywhere in-between learning something new is the same for everyone. I started around that age messing with C++ and regret giving up to just pick back up on it at 23 years old. Also you should probably stop stating that you are under the age of Discord ToS might get your account suspended, either way your never to young or old to learn how to code.
๐ค
Hello guys, have you some resources from where i can learn django? i have some experience with flask
@weary dragon pretty printed / corey shafer do great django courses
alright then, thanks
am I doing it right?
hello I have this model in django ```class Trip(models.Model):
bus = models.ForeignKey(Bus, on_delete=models.PROTECT, related_name='trip_detail')
class Seat(models.Model):
bus = models.ForeignKey(Bus, on_delete=models.PROTECT, related_name='seats')
label = models.CharField(max_length=100)
x = models.PositiveIntegerField()
y = models.PositiveIntegerField()
class Bus(models.Model):
number_plate = models.CharField(max_length=100, primary_key=True)
travel_agency = models.CharField(max_length=256)```how can i serialize Seat fields from Trip?
travel_agency = serializers.ReadOnlyField(source='bus.travel_agency')gives travel_agency but couldnt reach Seat fields
I am going mad trying to work with zeep and one WSDL.. is there anyone experienced with this
@vestal dove you need to use blueprints
@feral condor Open the database in a DB viewer (SQLite browser) and see what fields were generated
Then you will know how to navigate
Anyone here who has worked with Django and ariadne? I am having a tough time implementing user authentication and want to see some example repos if you have one.
Hey guys... I am looking to build an application that is going to have two bits that need to work independently. One would be talking (mostly receiving) to a MQTT bus, the other one would offer a REST API to serve as an endpoint for a system downrange. I did something similar a couple years ago and then I decided to use Threading. I ran my server in one thread and web server in the other while they exchanged data throuh Queues.
I guess my question would be what would be the go-to approach for something like this today?
Thank you in advance for any advice you may give!
Could you not also use a text file called logs and check up on it to then see when its updated and if so then read it and perform a action, as far as best practices I do not know, I have done something similar with Sockets for apps on different system, but if they are on the same seems like a log file would serve the purpose
Ah take a look at this
@native tide
@haughty turtle yes, I have considered this option too.
https://docs.python.org/3/library/ipc.html the python docs reference the use of signal or mmap modules for IPC on same machine. Might be worth taking a look at
@native tide
anyone here?
i want help
with my django project
i am facing a error
error is '<module 'home.urls' from 'D:\\Programs\\Hello\\home\\urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
For some reason i get this when going to the django admin panel
https://haste.powercord.dev/wenosesone
are u reponding to me?
How would I respond to you with and admin panel error?
sorry
@thin dome show us urls.py
home\urls.py
ok
from django.urls import path
from home import views
urlpatterns = [
path("", views.index, name="home")
]
@verbal snow 'User' object has no attribute 'pk' What is your User object in this case?
@thin dome did you register you app in settings.py
how to? in tutorial he doent open settings.py @native tide
i m learning so idk that error and other stuff
So open settings.py and show me INSTALLED_APPS
I have a separate user model than the admin user model. Which one?
Yes I had those items but for some reason when I run the tests it fails
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]``` @native tide
what is your appname? is it home? If so, add 'home` to installed_apps
@verbal snow Do you know what file that error is in, User object has no attribute pk?
@thin dome No, just 'home'
ok
The name of the app
'home'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]```
like this?
then how?
Looks like a django file itself
Looks like admin logs
Logs.py of admin
@thin dome Yeah, that's not a django problem, that's a basic python problem. Give me an example of a list.
Now compare that to your INSTALLED_APPS
['home']?
@verbal snow I'm gonna need more information than the error, maybe you're calling .pk incorrectly? I don't know
Ok, do you have a custom User model?
is it ['home']?
No
help mememememememememeeeeeee
@verbal snow So what are your models looking like?
Flask or Django. Which is best?
And WHy?
flask for small apps django for big
@thin dome You just gave me an example of the list. Now compare it to INSTALLED_APPS.
Learning Django will be fine?
i am learning it too @native tide
you need a comma after 'home'
ok nice mentor
Ohk Thank You.
so I asked you to compare it to your list so that you'd see that you need a comma
is this right?
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',```
what type is INSTALLED_APPS
Can we do the things which JS can do like adding animations to button with django?
@native tide Not really, unless you use CSS animations
Django is a backend framework
INSTALLED APPS is list
exactly... so why are you doing this? ['home']
Ohk and can we render js(frontend js) with django.
yep
within a html?
mhm
like having a js file for html.
and we render html so that js is also rendered.
'home',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]```
Yeah and having index.js linked with html
Then its fine i can then make a nice frontend too.
Anyone here familiar with XML and XML Queries??
Do you have any project with django like having a text box linked with sql?
this is my models
but the error looks like it has to do with the admin User model
I have my own user model
this is my rootROOT_URLCONF = 'Hello.urls'
But it is not sub classing the admin one
@verbal snow Possibly, in your admin model are you setting this?:
unique_id = models.AutoField(primary_key=True)```
@native tide
@thin dome No, open up the urls.py , you should have 2
Want to see how the code looks like.
yes
For me?
this is my hello url=```from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('home.urls'))
]
no i was saying it to @native tide
Ohk
u indian?
Yes.
hi
What admin model?
I`m, luqm,an
I'm not editing any admin models, nor am I subclassing any of them
@native tide
@verbal snow But you made your own admin model, right?
Why are you asking btw?
yes
No
Thats what I've been trying to say
man help meeeeeeeeeeeeee
I'm not doing anything with any admin models
@verbal snow can u help me?
What is it?
mproperlyConfigured: The included URLconf '<module 'home.urls' from 'D:\Programs\Hello\home\urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
this error
can u come to vc i will screen share
no
ok
is this what u want
from django.urls import path
from home import views
urlpatterns = [
path("", views.index, name="home")
]
this is my app urls
give it a path, like 'example/' and see what the issue is then
i was creating fornt page
means if there is just url then it will go home page
so its just " "
Ok, it was just a debugging thing, what's your views.index?
# Create your views here.
def index(request):
return HttpResponse("this is homepage")```
this is my views.py
So if you want it in the homepage, why don't you just do
path("", views.index(whatever the route is), name="homepage") in your main urls.py
whats so hard to understand
so is your issue fixed now?
yes
but include doent work
but i think thats ok
this is my main urls```from django.contrib import admin
from django.urls import path,include
from home import views
urlpatterns = [
path('admin/', admin.site.urls),
path("", views.index, name="homepage"),
]
because in your main urls.py, you are specifying the routes for your apps.
so
path("products/", include(products.urls))```
will setup a url for `site/products`
Then in your `products` app you can do:
```py
path("product-1/", views.index, name="product-1")
which is for the url site/products/product-1/
So if you have an app, make sure it has it's own url.
use google
ok
Can we do register and login logic from a single route in django?
@native tide yep
@native tide give me some hints
how would you do that?
I want home address to be redirected to login/register page
can't you just have 2 forms which do different things when submitted
when they are not logged in or registered
oh right
Can I redirect to two different pages? (login and home) from a single (home address) route?
@native tide
why not
sure
again, I need hint for that
that would be awesome
anyway, are you working on ML project sir?
well, if Login form is submitted, redirect to x, if signup form is submitted, redirect to y
not atm but I'd be interested to hear about it
but, the project urls.py file would give me an error if I set two app with same route ('') right?
In your view @native tide
In your urls.py it would grab the first one that matches
so, how do I do that whole thing working?
@native tide Oh I misunderstood that question
say, I have an app for home route leading to dashboard with an empty route in projects, urls.py
You can have one route, have a view, that view can take information from the request (which specifies stuff, like login or register and THEN redirect you to another route)
and same for login page (app)
The norm is that you send a user to login and from there you place a link that sends them to the register page
@native tide
so, the url should be different?
Well can you explain in layman terms what you want to achieve?
He just wants to create a normal login registration page, but the thing is @native tide that you would have no way to find out if the user wants to login or register without them clicking a link for either or
I am actually trying to move the static website which was designed with html/css, now, I am trying to add blog on it. but, I designed the login/register form in a single page
then, I also don't want the login/register page routes to be url/login or url/register
got me?
Well how would you know what a user wants to do ?
wdym?
You have to have a link saying to either register or login, from there you can use JS to display the either form depending on which was clicked
You want the log in and register to be on the same page correct, you can choose to display a log in form and have a Register Account link under the form
Upon clicking the link with JS you can hide the display of the login form and show the sign up one
You send a fetch POST to the server and specify wether it's a Login or Signup and handle that in your views.
Still don't know what he wants lol. You can have the login/register on the same page, and if LoginForm.is_valid() you can redirect to (/homepage/) and you can do the same for the RegisterForm, it's got nothing to do with the routes
Can I DM one of you guys to show what I am trying to make?
I have created a page like this
And you are struggling to toggle which forms to display?
in Django all you need is a view to send a POST request through fecth in JS that contains your form data and then type of form sent wether Login or Register.. with that you either register the user and log them in or just log them in and then send them to the dashboard
Yesterday someone that was helping me with a Django issue mentioned that they hadn't done Django in a while - is that because Django isn't the best option for a python frontend and I should consider something else? I'm building a portal a user will oauth into to manage some settings (via API calls to another service) and take a subscription payment via Stripe
are you good at JS?
Writing JS for this is my first real exposure to it, so no
php?
I'd prefer not - I'm familiar enough to know I'm not a huge fan of PHP
if I did something other than python it'd be JS, but that's a bigger undertaking since I'd have so much to learn
If the answer is python is a bad option and just go learn JS I'm okay with that
I am no expert but Python isn't bad. But, if you were familiar with JS, I would suggest JS. But, if you have to start from the beginning, it doesn't worth
because django is capable of doing your things
thanks!
Django for backend, JS frontend
JS is built into the browser client side so it allows for real time changes in the browser while you secure your website and any sensitive info with Django and it's backend which handles any request sent to your server
yeah that's what I'm doing now. Using JS to do the event handling for button clicks and passing things to django for payment/etc.
in django how to add like a global filter to a model. So everytime this model is called, that filter is applied to it before.
I just wanted to make sure I shouldn't go to an all JS solution like node or something
Seems like Django offers better security and faster deployment then node.js
thats low key comparing an entire language to a framework tho
Hi guys
I have a question about the http protocole
Letโs say a client made a request and the server responded back
How does the client know how to ask new requests depending of the serversโs answer ?
Nvm, seems that the client make himself the new request depending on the response of the server
@native tide what's your ML project btw?
I just have created a fast api running in a docker container. It shows that it's running, but it's absolutely not responding to my posts. Any ideas?
This is the dockerfile:
FROM python:3.6.9-alpine
WORKDIR /fapi
COPY . /fapi
RUN pip install --upgrade pip setuptools wheel
RUN pip install -r /fapi/requirements.txt
EXPOSE 8000
CMD [ "uvicorn", "api:app" ]
And I run it via: docker run -p 8000:8000 fapi:test
And this is the output:
INFO: Started server process [1]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
have you tried localhost?
curl - X POST localhost:8000/
is your app working on this port ?
Sorry, what do you mean by address?
127.0.0.1 aka local host is reachable as localhost inside, but im not sure
I would love to if you help me, I'm kinda stuck here
Hmm
I just tried 0.0.0.0, not working either
when I run it via like uvicorn api:app, it works well. Without docker
PORTS seems right, right?
curl -X GET 0.0.0.0:8000/ i get the error curl: (56) Recv failure: Connection reset by peer
try adding output ip
Hi, The solution to mapping port while running the container. docker run -d --net=host myvnc that will expose and map the port automatically to your host Thank you Asura
This worker, thanks! But I doesn't fit for me yet, I need to understand this
What if I don't want to use host's network, isn't the isolating containers best practice?
I would tell you If I knew
I see. Thanks a lot!
Has anybody deployed a django + react application before? What hosting service did you use? Please let me know ๐
Would it be any different than a normal setup?
I don't know what the "normal" setup is
check out linode
I feel like linode doesn't have the relevant reputation to be able to discuss on a resume...
Compared to something like AWS or GCP
but I've heard AWS is not for beginners
so I think I'll use heroku or GCP
or digital ocean. but i've not heard much about that
Umm what's the difference between Linode and AWS?
Aren't they both VPS
@native tide
AWS is awesome, use S3 Buckets to host static websites
how to use render?
render of Django?
I know this is unrelated. But does anyone here have a good understanding of the library 'pyglet' in python and would be willing to help me out?
trying to implement a linear regression problem solution in my webapp
@thin dome render() is to use within your app views, it render which html template to return with values passing to that template. To read more on the function you can see this https://docs.djangoproject.com/en/3.1/topics/http/shortcuts/#render
If you haven't done the django tutorial pages it mention on how to use it https://docs.djangoproject.com/en/3.1/intro/tutorial03/#write-views-that-actually-do-something
ya i solved it
Hey there, I needed some help with html
on this page
https://leetcode.com/problems/poor-pigs/
Inspect element, and you will find a div tag like this:
<div class = "content__u3I1 question-content__JfgR" >
I'm not so good with web development, Could someone help me figure out where this class = "content__u3I1 question-content__JfgR"is?
I want to copy the question description from the page and format it just like it is formatted on leetcode
I tried looking at the link rel stylesheets thing in the <head> tag but I couldn't figure it out
it's automatically generated by some frontend framework
can anyone suggest me helpful videos and article for flask security, especially on how can I manage and personifize my own login, logout, etc websites
well how do I format the question the way they did on my page then?
...is that even legal?
that sounds really weird
nobody calls their CSS classes "content_U3I1"
anyway
lol that was the only reason?
you mean replicate the whole page?
or just the question?
Frontend framework for sure, React does that
will not be able to respond till thhen
aight I'm back
well just the question, is that doable?
Uh is there an easy way to replicate it then?
Well React is a huge frontend framework, there is nothing easy going with it lmao
@pseudo marsh
I mean
I didn't intend to have it identical, just something that looked similarly formatted to that piece of text
I don't think that would require me to invest time into react imo
define "similarly formatted"
For now I'll just do with the bareblocks html part of it and add some backticks in there to make a few words stand out and that'll suffice
Have a similar look
You cannot replicate SPA-like behavior without a SPA framework and as all things, learning one takes time and devotion
not specific enough
yeah I didn't anticipate a task as simple as this would require all that effort, is all
I have no idea what you mean by the "look"
which is a pretty subjective thing
ye
this, but which aspect of the styling?
Yes
I just wanted to have this piece of text somewhere else
and for it to have the same look as this
That's styling and has nothing to do with react
basic CSS
do you know CSS?
Right, and I figured the styling depended on the class name which was kinda what I think I asked originally
hm.
do you know how CSS classes work?
Yeah a bit, and I figured the style for this was coming from the css class I asked about earlier?
There is no css class actually, you create an element, you create a class attribute for that HTML element then you can directly edit that element's style by using its class name as an identifier in css
So basically
ie, I wanted the definition for the class so I coudl have a similar wstyle
<p class="test">this is a test paragraph</p>
This has a class with the name of test
in order to style that object you can do 2 things
either in-line styling by adding a style attribute
ah, then not really
in this specific case
those classes are for content projection
not for styling the question text itself
or by creating a css file and doing the following
.test {
/* add style here
}
I understand that, which was why
<div class = "content__u3I1 question-content__JfgR" >
I was looking for where "content__u3I1 question-content__JfgR" was defined
oh
that's for content projections yet
it probably inherits style from a parent element
so so whwere's the styling for the question text?
right
p sure it isn't even a custom style
just HTML
and a cursory examination of the HTML appears to bear that out
oh right
wait what's the difference between
content projections and well, the style for the question being displayed?
content projection basically means
dynamically creating content.
for example
workflow might be like
- fetch question data from DB
- parse question data
- render question data into its slot <- this is content projection
styling affects the process of rendering i.e. what it looks like
as opposed to what it is
content projection is just the 3rd point in that list, is that what you meant by the arrow?
so the classes you originally talked about can be thought of as internal bookkeeping data so the framework "remembers" where the content should be
on the other hand, styles are about, given certain content, what it should look like
yes
and
that's basically a bunch of strong, code, ol etc. tags.
oh so like, content projections is for structuring the page
styling is for actually formatting individual parts of the structure, did I understand that right?
and styling is a css thing, yeah?
well I guess that makes sense
Thank you both of you ๐
yw
yes, but in this case
the CSS is not really relevant
it's just HTML tags
look at the HTML generated and you can tell
oh right
so I was able to copy just the html part of it and I got this
Which looks just the same
right, this was so simple and I'd been struggling for so long
thank you ๐
yw! ๐
what is general method for returning results to user from backend ?
new route? access to resource? other?
you could return an ID and check periodically
or use WebSockets
or SSEs
you mean like
delayed right
return an ID
that lets the client do a separate GET request
then the client polls periodically
up to you
thats why I asked for general case ๐
it is literally up to you
there is no general case here
that said, for polling you would at least need some JS in either case
even if you're not running a SPA
yes yes thanks ๐
I also wonder how to make upload progress bar ๐ค , since I am runnig local I do no see when upload happens
is it when I click submit or when it is sending post request?
hm you'd need JS for this
i rephrase question
File upload happens at POST request or GET in FORM input?
POST

page without post ๐
I run js here and do basic validation then redirect to page with only POST
but your form submission is still a POST, right
yes, I get files with POST
you mean upload?
yes
Form is on GET page, and redirects to POST
<form action='{{ url_for("validate_image") }}'
method="POST" enctype="multipart/form-data"
onchange="ValidateFileIfImage()" >
...
<button id="submitBt" type="submit" class="btn btn-primary">Confirm</button>
@vestal hound Hm it works.
You just need define get_context_data in your view.
context = super(IndexListView, self).get_context_data(**kwargs)
context['team_list'] = Team.published.all()
context['servicesPackages_list'] = ServicesPackage.published.all()
return context ```
huh what works
trying to deploy via Heroku, and i'm getting internal server error
2020-11-27T11:07:45.292994+00:00 app[web.1]: Traceback (most recent call last):
2020-11-27T11:07:45.292995+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle
2020-11-27T11:07:45.292995+00:00 app[web.1]: self.handle_request(listener, req, client, addr)
2020-11-27T11:07:45.292996+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
2020-11-27T11:07:45.292996+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2020-11-27T11:07:45.293088+00:00 app[web.1]: TypeError: module.__init__() argument 1 must be str, not dict
020-11-27T11:07:45.416214+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2020-11-27T11:07:45.416214+00:00 app[web.1]: TypeError: module.__init__() argument 1 must be str, not dict
2020-11-27T11:07:45.416474+00:00 app[web.1]: 10.61.214.174 - - [27/Nov/2020:11:07:45 +0000] "GET /favicon.ico HTTP/1.1" 500 0 "-" "-"
2020-11-27T11:07:45.417231+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=thawing-dawn-32152.herokuapp.com request_id=81d3082f-9625-4693-a85c-3d1c300dfe06 fwd="82.44.25.251" dyno=web.1 connect=1ms service=3ms status=500 bytes=244 protocol=https
any idea what is wrong ?
Hi everyone who know flask?
do I need to expose port in docker?
when im using ports in dockercompose? ๐ค
@leaden perch if you have a question just ask, someone with knowledge in flask will answer
how do I get over the original template , and set up my own template for login, logout, etc in flask security
I mean I did not set up any route yet in my program,
yet this page can show up
you must of already created that page
and why use flask-security
why not flask login ?
Here is a login I created a month or two back for a digital store:
https://github.com/MrNaughtZero/Sellux/blob/master/app/auth/auth_routes.py
@karmic egret
@past cipher What is the major difference between flask security and flask login
Because my teacher suggest me to us flask security
security is dead I believe unless its started being maintained again
okay, thanks
I'm planning on creating a web crawler that collects new posts from my favorite blogs and returns the response in a JSON format. I'm familiar with how Django rest frameworks work so I decided to proceed with it. My problem is though how can I call a web crawler from an API with a post request?
Hi all I have a question if you could help me, i'm trying to sort a column by images in Wordpress (Tablepress) but i don't know how to do it, any idea?
I figure out that you can also use the session in flask to build a login in system. What is the difference between this and using flask login library
Converting to "int" failed for parameter "pep_number".
oops
hey guys, I want to know that if the logic in that jinja syntax I applied is right or not?
yeah
no
I mean I tried the for loop logic separately and it works
but idk how to implement it in jinja
it looks correct
and who can recommend me some starter article flask login
because I am still new to the library
hello guys, I need help in #help-mushroom
Can someone help me out with a feature in Django? I wanted to implement a so called "save for later" or "pins" feature to my blogs app that will save that post from that user and display it to a specific template called "pins" (just like on instagram, the save button). I'd appreciate it, thanks!
store the post id in the database and then call it on the saved later page
a
@native tide
hello
hi
I am doing a django project and I'm trying to override template and static folders, I encountered an error
@native tide wanna hear?
no
idk
about django
oh
i'm a beginner
I have a problem, you wanna hear?
let me see
I want a list (probably) of dates from the day covid started cuz i'm making a covid-tracker app (flask)
rn it only lists latest updates
it's a very basic app
I want to make a drop down menu from where we can see cases for a specific date
I think I can get the date by performing a requests on this link
@native tide ?
yeah show me the dictionary (json) data
yeah
I pasted it on hastebin
I see
how about you re read the documentation
api doc
ohk
o
