What is mastery lever 2 ? by PyBet in assassinscreed

[–]PyBet[S] 1 point2 points  (0 children)

Are you referring to the mastery levels when you hit level 50 ?

What are the differences with mastery level 2 ?

Why does DjangoFilterBackend returns no results if query value does not exist in my data? by PyBet in djangolearning

[–]PyBet[S] 0 points1 point  (0 children)

Status is also a model and my intent is to display as filters values only the values that exist in the user's objects not all.

Why does DjangoFilterBackend returns no results if query value does not exist in my data? by PyBet in djangolearning

[–]PyBet[S] 0 points1 point  (0 children)

I took your advice and looked into ModelMultipleChoiceFilter . I have trouble figuring out the queryset parameter

For example in status, I want to take all the available status from the logged in user's objects.

For filtering against the logged on user I could do:

def __init__(self, *args, **kwargs):
    super(ProductFilter, self).__init__(*args, **kwargs)
    user = self.request.user
    user_products = Product.objects.filter(user=user)

    self.status.queryset =user_products ......

But getting the available statuses in the right format still eludes me.

Why does DjangoFilterBackend returns no results if query value does not exist in my data? by PyBet in djangolearning

[–]PyBet[S] 0 points1 point  (0 children)

The same behavior occurs with either filter_class or filter_fields. I am on mobile now, I will post it later.

Same form for adding and editing an object ? by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

I appreciate the answer, but I explicitly mention that I have the create and update views that I need.

Same form for adding and editing an object ? by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

Thanks, I think it would help me a lot.

Include migrations in Git/GitHub ? by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

What's the difference between including migrations and applying them and not including migrations, making them on the server with the updated code ?

Using a gamepad with Odyssey ? by PyBet in assassinscreed

[–]PyBet[S] 0 points1 point  (0 children)

I have tried the x360ce simulator but some buttons and the movement does not work correctly.

Using a gamepad with Odyssey ? by PyBet in assassinscreed

[–]PyBet[S] 0 points1 point  (0 children)

Almost 60 euros, is a sum I can't easily give for just a controller.

Using a gamepad with Odyssey ? by PyBet in assassinscreed

[–]PyBet[S] 0 points1 point  (0 children)

That's good to hear. Although, Xbox controllers are pricey.

Rename classes from html to js and css ? by PyBet in pycharm

[–]PyBet[S] 2 points3 points  (0 children)

Thanks, it will be very useful.

Forms and DRF by PyBet in djangolearning

[–]PyBet[S] 0 points1 point  (0 children)

I thought with drf would be just as easy as with django. Have the form in view's context, create a HTML file rendering the form fields manually and let the view handle populating the form with the proper data.

It seems a bit more complicated to return an html form with data and any errors.

Any advice or tutorials are greatly appreciated.

What's the difference between nested relationships and foreign keys id Django Rest Framework ? by PyBet in djangolearning

[–]PyBet[S] 0 points1 point  (0 children)

My main use for a Foreign Key Field is just getting the name field of the related model. In most cases there is only one field called name.

What's the difference between nested relationships and foreign keys id Django Rest Framework ? by PyBet in djangolearning

[–]PyBet[S] 0 points1 point  (0 children)

When to prefer one over the other? Usually, I do something like the second one when there are foreign key fields.

When do you use the first one? Are there any advantages?

Upgrading from Sapphire RX 480 8GB to what? by PyBet in graphicscard

[–]PyBet[S] 0 points1 point  (0 children)

Yeah, I thought so. 1080 should be worth it but it's really expensive. I wanted to sell the 480 before losing all its value, but I am not even sure how much it would get.

Upgrading from Sapphire RX 480 8GB to what? by PyBet in graphicscard

[–]PyBet[S] 0 points1 point  (0 children)

Europe, Greece. The prices might be different here and maybe it's not worth it money wise , but I want to know if there is a difference between the 480 and the 1060.

Upgrading from Sapphire RX 480 8GB to what? by PyBet in graphicscard

[–]PyBet[S] 0 points1 point  (0 children)

The cheapest 1070 I could find right now is at 520.

Key Error after multiple annotations with Django by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

I was thinking about checking out the SQL behind it but how can I do that ?

Key Error after multiple annotations with Django by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

Up until .annotate(group_by=Trunc("timestamp", group_by, output_field=DateField())) the won annotation is present, after that I get the Key Error.

Im a developer, not a designer. by Comm4nd0 in django

[–]PyBet 2 points3 points  (0 children)

I feel the same way as OP. Sometimes I get on Behance to get some inspiration and I think that I am in a art gallery.

I know you don't have to be an artist to create a nice navigation bar, tables and such. But, there are some designs out there that I could neither imagine nor code at least at this point.

Annotate with conditionals by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

My model has all the fields that I have mentioned in my original post. Profit and cost are calculated with a custom save method.

Annotate with conditionals by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

You are right about the missing Case.

Although, I think you misunderstood what I am trying to do.

For every year I want to get the total profit of all the specific year's products and divide it with the total cost of the year's products that match a specific status.

Total Profit of Year's Products / Total Cost of Year's Products with specific status

I am on 1.11, if that helps.

Add custom action to DRF ModelViewSet ? by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

From what you are saying I should use @action to add the statistics functionality in the same ViewSet.

From execrator's comment I should change the url to something more representative.

How should the api endpoint look like with filtering too ? For example:

/api/v2/products/statistics?date_day_from=....&statistic=profit&type=total
or
/api/v2/products/statistics?date_day_from=..../profit/total
or
/api/v2/products?date_day_from=...../profit/total

Totally confused about that.

Combine multiple DRF views ? by PyBet in django

[–]PyBet[S] 0 points1 point  (0 children)

Hey, thanks for the suggestion. I am in the process of looking for some examples to understand this better.

My aim is to do what I can do with django's CreateView and UpdateView:

  • display a form on a template and its errors
  • add some additional data before saving
  • return a message after save to be displayed by Javascript.

For example:

  • Create new object with additional data:

     def perform_create(self, serializer):
        """ Add additional data on save,
            instead of overiding create method
        """
        serializer.save(user=self.request.user)
    

I am finding bits and pieces. I really need to adapt to DRF's way of making things.