These are chat archives for django/django

1st
Nov 2017
Miracle Ayodele
@iammiracle
Nov 01 2017 01:42
anyone with a scrapy knowledge?
i have been trying to scrap a website
i was able to get few things like h3 text on the website, but the news titles i could not get it out
i will like to know why i am not able to crawl the site...i really need this help guys...
MuhammadRahman-awin
@MuhammadRahman-awin
Nov 01 2017 01:47
@koderNeptune you need something like phantomjs or splash server running to render them. The content is not available in html. It is available in the DOM after js load
Miracle Ayodele
@iammiracle
Nov 01 2017 01:48
@MuhammadRahman-awin so scrapy wont be able to do this right?
MuhammadRahman-awin
@MuhammadRahman-awin
Nov 01 2017 01:48
correct
look at scrapy-splash project
Miracle Ayodele
@iammiracle
Nov 01 2017 01:49
okay @MuhammadRahman-awin
Thanks @MuhammadRahman-awin , i will get back to you on it
Anish Shrestha
@annshress
Nov 01 2017 04:13

Error response from daemon: manifest for circleci/python:2.7.3 not found

Circle CI with bitbucket project

config.yml has

      - image: circleci/python:2.7.3
      - image: circleci/postgres:9.5.9

but circle ci shows above response... anyone know what's wrong? Need Help.

Anish Shrestha
@annshress
Nov 01 2017 04:23
But if I replace python version with 3.6.1, it finds it image. But my code is written in 2.7.12
So while running test, errors populate.
Anish Shrestha
@annshress
Nov 01 2017 05:14
[SOLVED]
so python 2.7.3 is not in the circle ci images list
but 2.7 and 2.7.14 are in the list
Varun
@varunamrutiya
Nov 01 2017 05:43

Hi,
I am trying to apply filter on a specific permission using django admin model.

class StudentProfileAdmin(admin.ModelAdmin):

    model = StudentProfile
        list_display = ('user','reg_no','first_name','last_name','student_permission')
        list_filter = ('student_permission',)
        def student_permission(self,obj):
            return obj.user.has_perm('auth.isStudent')

It is showing filter can only be applied to fields, so how to resolve this... ?

Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 10:59
@Wahtdb_twitter sorry nopes .
Miracle Ayodele
@iammiracle
Nov 01 2017 17:03
Hi guys, has anyone used Selenium with django
i used Selenium to scrap a website, but i will like to save the informations in the database
jy95
@jy95
Nov 01 2017 18:38

Hello,

I am on django 1.11 and I need to unit test something. I got this message :

File
"C:\Users\jy95\PycharmProjects\oscareducation\student_collaboration\tests.py",
line 49, in testSkills
object_id=self.newuser.id ValueError: Cannot query "jy95": Must be "User" instance.

My set up

def setUp(self):
    self.settings1 = CollaborativeSettings.objects.create()  # un settings par défaut
    self.settings2 = CollaborativeSettings.objects.create(distance=10)  # un settings random
    self.newuser = User.objects.create(username="jy95")
    self.student = Student.objects.create(user=self.newuser)
    """ Le StudentCollaborator associé devrait être crée """
    self.founduser = StudentCollaborator.objects.get(user=self.newuser)
    self.skill_1 = Skill.objects.create(code="B0124", name="Maths", description="Les MATHS")
    self.skill_2 = Skill.objects.create(code="B0125", name="Logique", description="La Logique")

The function where the problem occurrs :

def testSkills(self):
    """ L'étudiant est bon en maths """
    SkillHistory.objects.create(
        skill=self.skill_1,
        student=self.founduser.user.student,
        value="acquired",
        by_who=self.founduser.user,
        reason="ACQUIS",
        # n'importe quoi ; juste pour faire en sorte que SkillHistory soi content
        content_type=ContentType.objects.get_for_model(self.founduser.user),
        object_id=self.newuser.id
    )
thanks for helping :)
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:40
@jy95 object_id= self.newuser
jy95
@jy95
Nov 01 2017 18:40
With this , It becomes : "TypeError: int() argument must be a string or a number, not 'User'
"
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:41
@jy95 can you show me the SkillHistory model
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:44
@jy95 both these fields are related content_type, object_id
jy95
@jy95
Nov 01 2017 18:45
So, how can It works in my example ? (I don't care about their content the since it is unit test)
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:46
check you have given related values. content_type of user in content_type and user_id of user in object_id
generic foreign key depends on both not on single
jy95
@jy95
Nov 01 2017 18:49
.... thanks for explain : what can I do to make my unit test works ?
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:51
@jy95 ContentType.objects.get_for_model(<user model>)
jy95
@jy95
Nov 01 2017 18:53
ContentType.objects.get_for_model(self.founduser.user) shoudn't provide the User model ?
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:53
no
ContentType.objects.get_for_model(User)
jy95
@jy95
Nov 01 2017 18:55
Same stacktrace ...
ValueError: Cannot query "jy95": Must be "User" instance.
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 18:57
content_type=ContentType.objects.get_for_model(User), object_id=self.newuser.id
Update in testSkills
jy95
@jy95
Nov 01 2017 18:59
"ValueError: invalid literal for int() with base 10: 'utilisateur'"
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 19:00
@jy95 updated check again
jy95
@jy95
Nov 01 2017 19:01
Same as before : ValueError: Cannot query "jy95": Must be "User" instance.
SkillHistory.objects.create(
            skill=self.skill_1,
            student=self.founduser.user.student,
            value="acquired",
            by_who=self.founduser.user,
            reason="ACQUIS",
            # n'importe quoi ; juste pour faire en sorte que SkillHistory soi content
            # content_type=ContentType.objects.get_for_model(User),
            # object_id=self.newuser.id
            content_type=ContentType.objects.get_for_model(User),
            object_id=self.newuser.id
        )
Pushplata Ranjan
@pl_b2_twitter
Nov 01 2017 19:05
save user's id in any variable and put that variable in object_id and please check once
or update in testSKills (content_type_id=str(ContentType.objects.get_for_model(User).id), object_id=self.newuser.id)
@jy95 have to tried (content_type_id=str(ContentType.objects.get_for_model(User).id), object_id=self.newuser.id)
jy95
@jy95
Nov 01 2017 19:47
I tried and same way : ValueError: Cannot query "jy95": Must be "User" instance.
Miracle Ayodele
@iammiracle
Nov 01 2017 21:27
Hi guys i really need help on using selenium with Django
My selenium works okay, but i need to save my data in a database