These are chat archives for django/django

17th
Jun 2017
Miracle Ayodele
@iammiracle
Jun 17 2017 06:10
Hi guys, I'm trying to integrate a payment platform with my application but I'm really confused of how to go about it
Paystack + Django, anyone with an idea?
Anish Shrestha
@annshress
Jun 17 2017 08:53
@flyboy1565 your get_stores should return serializer.data not serializer
I guess
Omar Lozada
@lozadaOmr
Jun 17 2017 11:07
Hi guys, I'm trying to implement a custom validation in my forms but it would seem that method calls does not get the model attribute. I tried checking print >> sys.stderr, self.repository and it returned blank, or should I be using self.cleaned_data[]?
Below is the gist of what i'm trying to do
https://gist.github.com/lozadaOmr/b17f87ea0f2e5a24b1f73c31c5136dac
Anish Shrestha
@annshress
Jun 17 2017 14:03
@lozadaOmr
if you use self.instance.check_repository_exists(), won't it return True? And hence, cause ValidationError?
And return self.cleaned_data['repository']
Anish Shrestha
@annshress
Jun 17 2017 14:08
in your clean_repository method
if os.path.exists(os.path.join(settings.REPOSITORY_DIR, self.cleaned_data['repository'])): raise ValidationError
I think ...
Omar Lozada
@lozadaOmr
Jun 17 2017 15:21
@annshress what is happening is that if in theget_dir_name() when settings.REPOSITORY and self.repository is joined. It only returns the settings.REPOSITORY which result in it always being True when check_repository_exists return the value; whereas the expected is should be False since self.repository even when accessed from forms.py is blank.
Anish Shrestha
@annshress
Jun 17 2017 16:16

I am not close to my workspace, but don't you think self.instance in only accessible when it is a changeForm otherwise if it is an addForm it will raise an AttributeError?

And when its a changeForm, the self.instance will be an instance in the Repository model which will have a repository field and hence will always return True.

So I think, your clean_repository method should be something like:

if os.path.exists(os.path.join(settings.REPOSITORY_DIR, self.cleaned_data['repository'])): 
    raise ValidationError("Repository Exists")
return self.cleaned_data['repository']
Miracle Ayodele
@iammiracle
Jun 17 2017 17:38
hi i have been trying to integrate a payment platform with mt django and i have been having few issues
Omar Lozada
@lozadaOmr
Jun 17 2017 17:38
That helped thanks @annshress , on to the next problem :clap:
Miracle Ayodele
@iammiracle
Jun 17 2017 17:40
the payment platform is processed on inline, i am confused on how to process the url and how to save it to the database
knowing that since it is inline, it can be called from any url