Quantcast
Channel: User Johndt - Stack Overflow
Browsing latest articles
Browse All 33 View Live

Comment by Johndt on PyQt QListView Issue with Drag and Drop for both...

Thanks for including the code here, as the link you provided is dead.

View Article



Comment by Johndt on Python - Accessing instance attribute without `self.`...

@wim The latter is correct; fixed.

View Article

Comment by Johndt on Reset sorl Thumbnail for a Django site

@Brian Yes, I solved the issue we were having; however, I don't think we did so by resetting sorl. As stated in the "LATE EDIT" to the question, the problem was quite unrelated. That's why I didn't...

View Article

Comment by Johndt on How to drop a custom QStandardItem into a QListView

I asked this question a bit earlier. I have attempted to follow your solution, however I am still not able to maintain custom data across a move event. I am not sure how to properly implement the...

View Article

Comment by Johndt on QT Layouts, how to make widgets in horizontal layout...

Your first link is dead

View Article


Comment by Johndt on Disable horizontal scrolling in QScrollArea completely,...

Wow, this worked beautifully! So much simpler than overriding events. Disabling the vertical scrollbar through this method even allows the mouse scroll-wheel to move the horizontal scroll.

View Article

Comment by Johndt on How do I install a Python package with a .whl file?

Thank you, was having trouble finding this info! However, I'm not sure how to read the output to determine which version I need.

View Article

Comment by Johndt on DJANGO background task always on

Check out using Celery + Redis for asynchronous tasks.

View Article


Comment by Johndt on Why does a checkbox input designed this way on a...

@Carcigenicate I'd imagine that the OP is asking, "Is this actually the design, or am I doing something wrong? If this is actually the default design, how can I change it to match the other fields?"

View Article


Comment by Johndt on How do I Scroll parent page to top when child page is...

Should parent / child origin just be the domain, or the full URL of the parent / child? i.e. should the parent_origin be https://test.testsite.com, or should it be...

View Article

Comment by Johndt on Trying to convert Excel Fuzzy logic to Python function

Hi Brook! Welcome to SO! It's not entirely clear to me what the issue you are trying to solve is. What does your function return and how is this different from the expected output? Is your function...

View Article

Comment by Johndt on Trying to convert Excel Fuzzy logic to Python function

@BrookHurd, this is because the process function is likely expecting strings rather than numbers. I'll update my answer to reflect this.

View Article

send() and recv() functions

I am attempting to set up a server/client model. The client will receive two matrices from the user, then send these two matrices to the server, which will then compute their product and send the...

View Article


Django Migrating to a new Database

I just joined a project using Django, and am attempting to initialize my own development server. When I attempt to do so, the migration fails for one of my apps. A model for this app has a...

View Article

Answer by Johndt for rewrite get_absolute_url method in a template- django 1.6.5

You are attempting to pass the name of the urls as an argument, when they should be a keyword argument, specifying name. So, an example would be as follows:url(r'^$', 'index', {'template_name':...

View Article


Answer by Johndt for Django - ModelForm display the item but insert the...

Rather than displaying the user as read only form field, it would probably be better to exclude the field from your form, and display the user's name in the template, wherever you wish, as follows: {{...

View Article

Answer by Johndt for Loading timestamp upon page load and comparing it to...

You could use a context processor to add a timestamp context variable to every template. Your context processor is a simple Python function which takes an HttpRequest argument and returns a dictionary...

View Article


Answer by Johndt for Django query limit and streamingHttpResponse

You can limit queries quite easily in Django, using Python's array-splicing notation. You can use this on any query. Here are some examples:# Will return only the first 1000 objects in the...

View Article

Answer by Johndt for Python: Inline if statement else do nothing

No, you can't do exactly what you are describing, as it wouldn't make sense. You are assigning to the variable g.data_version... so you must assign something. What you describe would be like...

View Article

Answer by Johndt for Django: nested template commands

The static tag is not loaded into the template. So, at the top of the template, add:{% load static %}Everything else with the posted template looks fine.

View Article

Answer by Johndt for Django add two fields to user profile

Have you read the warning in Django's documentation?Changing AUTH_USER_MODEL has a big effect on your database structure. It changes the tables that are available, and it will affect the construction...

View Article


Answer by Johndt for ManyToMany Query (Django)

To get the shows that an artist has played, you can do this:artist = Artist.objects.get(name="johndt6")artist.show_set.all() # Will return all shows related to the artistA recommendation is to set a...

View Article


Answer by Johndt for forloop.counter indicates how many times the for tag has...

The template variable forloop.counter returns the current iteration of the current for loop, indexed from one. There are plenty of cases where one might use this variable. An example is...

View Article

Answer by Johndt for How to calculate field not included in ModelForm after...

You may do as follows:def some_view(request): if request.method == "POST": form = AForm(request.POST) # Initialize form with POST data if form.is_valid(): model = form.save(commit=False) # Initialize...

View Article

Answer by Johndt for django change foreignkey Field

If you want a form for your Equipment model which displays only the equipment_Number field, then you would define it as follows in your forms.py:class EquipmentNumberForm(ModelForm): class Meta: model...

View Article


Answer by Johndt for Profile User object displaying all user django

This is a question specific to the form you are using, rather than the model. What you want to do is specify a queryset for the field user.You may do this after instantiating your initial form. The...

View Article

Answer by Johndt for I have two views that are really similar. How can I...

This is very easy to do with Class Based Views (CBV).For example, you may use django.views.generic.FormView, as follows in your views.py:from django.views import genericclass...

View Article

Answer by Johndt for Django: name of many to many items in the admin interface

You need to define the __unicode__ (or __str__ if you are using Python 3) method on your models, so:class ASGGroup(Model): name = CharField(max_length=63, null=True) def __unicode__(self): return...

View Article

Answer by Johndt for Combine data from several forms Django

Instead of using some_form.items(), use some_form.cleaned_data, which will return a dictionary of the validated POST data.So, as you figured out, it would read:FORMS = [("questions", Questions),...

View Article



Answer by Johndt for django REST framework - limited queryset for nested...

In your View Set you may specify the queryset like follows:from rest_framework import serializers, viewsetsclass MyModelSerializer(serializers.ModelSerializer): class Meta: model = MyModelclass...

View Article

PySide - QListView creating new item during drag and drop rather than passing...

I am writing a PySide application with a QListView. This QListView allows drag and drop events to change the order of the items it displays. The QListView uses a QStandardItemModel, and the...

View Article

Answer by Johndt for Whats the difference between a OneToOne, ManyToMany, and...

Well, there's essentially two questions here:What is the difference (in general) between one to one, many to many, and foreign key relationsWhat are their differences specific to Django. Both of these...

View Article

Creating arrays in C

I am attempting to create a UNIX shell in C. If it were in Java, it would be a piece of cake, but I am not so experienced in C. Arrays in C confuse me a bit. I am not sure how to declare or access...

View Article

Browsing latest articles
Browse All 33 View Live




Latest Images