inchidi
This and the thing I'm suggesting is not quite different
i think overriding class method and change inheritance of a model is not "quite different". but if you think its about personal preferences i will not argue more
Anonymous
I think you misunderstood me
Anonymous
You don't need to inherit something in your model class to change it's manager
inchidi
I think you misunderstood me
omg you are correct
inchidi
You don't need to inherit something in your model class to change it's manager
so you recommend something like this right? class ValidManager(models.Manager): def save(self, ....): # i forgot the params accepted by save func if self.kyc.valid: # do your logic here .... class NotKYCModel(models.Model): kyc = models.ForeignKey(KYC) title = models.CharField(max_length=100) author = models.CharField(max_length=50) kyc_objects = ValidManager()
Anonymous
Yes
Anonymous
Also you don't need to do this
Anonymous
super.save...
Anonymous
It's already overridden
inchidi
yeah, but then the cons is you need to define your save function to the end
Anonymous
That
Anonymous
But, you so improve the situations
Anonymous
There are like lots of things that can be done
inchidi
i will prefer my solution tho 😆
Anonymous
inchidi
it would looks like class KYC(models.Model): kyc_status = models.CharField(max_length=30, choices=kyc_status) valid = models.BooleanField(default=False) def save(self, ....): # i forgot the params accepted by save func if self.valid: # do your logic here .... super().save(....) # pass the accepted params by save function
but because the case is its for many models, to escape repeated code then class KYCModel(models.Model): def save(self, ....): # i forgot the params accepted by save func if self.kyc.valid: # do your logic here .... super().save(....) # pass the accepted params by save function # and for every models use KYCModel instead models.Model class NotKYCModel(KYCModel): ...
inchidi
lol
looks like you have 2 choices
Anonymous
Or just filter objects
Anonymous
Everytime
Anonymous
Easy peasy
inchidi
Or just filter objects
filter objects?
inchidi
how is it looks like?
Anonymous
model.objects.filter(args)
inchidi
model.objects.filter(args)
i dont get it, filter for "check before save"?
Anonymous
I mean he will query for object before saving them
Anonymous
Add filter in query.
Anonymous
Btw django 2 coming soon
Anonymous
Anyone excited?
inchidi
Anyone excited?
am exited waiting python2 died 🏃
😼
i dont even have a sister
Yega
hey guys, a simple question. should I start with flask first and then Django or go straight on with Django? some people insisted to first do flask for a few weeks and then move to Django because that way one can appreciate more of the things Django does behind the scenes like creating default manage.py by itself etc.. so what do I do, spend a week on flask and start or go straight on???
Abhi
go for flask for first few weeks
inchidi
thank you, 😊
i think its good choice, nothing to lose i recommend creating login, logout with flask then go to django
Yega
K, then I'll start with flask as of now...
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
hey guys, please take a look at my project directory skeleton, and tell me is it right to put the core App like this or not. https://github.com/D0nQuixote/boodygram/
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
and if you have free time, take a look inside the files
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
i'm learning how to convert function-based views to class-based views. and i'll add get_absloute_url in User model and fix views.py and the templates to remove the hard-coded User urls.
8la
Anyone have the stack with systemd gunicorn + apache mod_proxy?
Anonymous
What does "stack with" mean?
8la
django stack
8la
I dont know if stack is the most accurate term
Anonymous
There surely would be some guide out the
Anonymous
But, why Apache and mod_proxy?
8la
Yeah, sure im not a ask before search on google guy ;)
8la
It sounds a little uncomon to me also. But a work partner has configured the service...
8la
I would have choosed nginx for that
8la
But the thing is that im here to ask about a problem we are having with gunicorn worker exceptions
Anonymous
Ahh
Anonymous
Share the error
8la
I wanted to know if anyone share our config first . Ok there i go: We have a non reproducible Worker exception on gunicorn.. and the errors shown are like "No module named django.core.wsgi , no module named utils.encoding... this is while systemd trying to start the service on a burst.
8la
It seems to me like environment is wrong.. but service starts and works nice until it crashes
8la
So, if there were an error on the venv or environment config server wont start never
Anonymous
Can you show the config file?
8la
The systemd unit?
Anonymous
Yeah
8la
https://pastebin.com/FYFfnUWC
Anonymous
https://pastebin.com/FYFfnUWC
I would suggest to stop using local host
Anonymous
Use sockets instead
Anonymous
They are faster and reliable
8la
Ok
8la
Dont think if that will fix anything
8la
But makes sense
8la
👍
Anonymous
I don't see anything wrong
Anonymous
Except this
Essa
Anyone have the stack with systemd gunicorn + apache mod_proxy?
Lock at digital ocean tutorial section they showed how it is done βœ… With apache and nginx
Django Bot
>> Links - Django Content Management System | Wagtail CMS - Some Wagtail V1 Streamfield examples
8la
found the problem
8la
whas at layer 8
8la
XD
biswaz
Use sockets instead
Sockets instead of local host? Could you explain?
8la
You use unix sockets instead a tcp connection
8la
That way you keep out the overhead of the network stack
Anonymous
And there isn't much configuration for doing it
Anonymous
Just bind to a sock file