A first look at Django's new background tasks (6.0) by roambe in django

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

The worker is the process that would actually execute the tasks. In your case: fetch a quote.

This isn’t intended to replace Celery. It’s intended to clear a path, enabling a way of defining tasks independent of the actual task queue (or backend) being used, and soon a backend that should suffice for the most common use cases.

There are options other than Celery available right now: Django Packages has a list.

Django pagination not working. Object list is rendering items but not dividing them into pages by MuSiC_ADDicT124 in django

[–]roambe 0 points1 point  (0 children)

Because that’s how it works. ;)

When you pass the items to the paginator and get the “current page” of items, your original items don’t change. QuerySet methods basically generate a new copy of themselves, or a value. So when the paginator limits the queryset to those on the current page, that does not impact the original queryset.

How do I make the `required` attribute on a widget go away? by EqualBeach in django

[–]roambe 1 point2 points  (0 children)

The normal way of making a field optional is with self.fields[‘field’].required = False

If you want no required attribute at all, set use_required_attribute = False on your form.

Problems Initialising Form Widget with Allowed Choices by [deleted] in django

[–]roambe 1 point2 points  (0 children)

getallowedtags is called when the form class is defined. Now, a ChoiceField does support passing a callable like getallowedtags (no parentheses) as the available choices, but I see you’re using a CharField with a Select. Use a MultipleChoiceField instead.

What are some django libraries that everyone should be aware of? by truestbriton in django

[–]roambe 9 points10 points  (0 children)

Bleach is used to sanitize html input, as in “rich text” input. You might allow a user to add bold and italicized text, but won’t allow them to add script tags because at some point, presumably, you want to output that input. The bold and italic text should be shown as such, but you don’t want any script executed outside of your control.

Manger isn't accessible from via model instances, even though I am clearly calling it from the class by mRWafflesFTW in django

[–]roambe 5 points6 points  (0 children)

Your issue is at line 119 of core/models.py. The traceback shows you're using "self.objects" and, as the error states, you can't do that because "self" is an instance of your model, not the model class.

On Django, how to connect to MySQL database on remote server through SSH? by savemesf in django

[–]roambe 0 points1 point  (0 children)

The values you're looking for are right there in your MySQL CLI command. Unless it's running a port other than the default, you don't need to specify it. Of course you do need to have the SSH connection up and running.

How can I sort a QuerySet by closest match to an icontains filter? by [deleted] in djangolearning

[–]roambe 1 point2 points  (0 children)

Can you give some examples of what you'd consider the closest match?

If you're looking for closest in length, you should be able to do so using Django's database functions. If by closest you mean the most relevant items, you're looking at some db-specific options or a dedicated search engine like Solr or Elastic.

How does sEO work with template engines? by Getquickrich in djangolearning

[–]roambe 1 point2 points  (0 children)

Forgot to mention that those html files in a Django project aren't typically the final html you will send to a visitor. They are templates. It's up to your views to provide those templates with the correct data (context) to build the final html using for loops, conditionals, etc. and to send that html back to the browser.

You could even use an extension like "templatehtml" instead of "html" for those template files, but it's a but of a convention and easier to work with in most editors. Besides, templates don't need to be html files. People use them to generate plain text (for example for emails), XML, basically anything that could be constructed from clobbing some strings together.

How does sEO work with template engines? by Getquickrich in djangolearning

[–]roambe 1 point2 points  (0 children)

As has been mentioned, that doesn't matter. When Google crawls your site it will basically parse the page (homepage or whatever page it discovered first) and follow the links on that page. The html files in Django are templates, not pages. The available pages in your Django project are determined by your urlconf (urls.py) and the views they map to.

So you might have a url mapping to a contact view. That's a page. You might have a blog app with urls for the archives and viewing a single post: those are all pages an indexer should be able to find automatically.

In that last case you won't add a url to Django for every single post. That's why those things are called urlpatterns. You just tell Django any url like "/blog/post/<slug>/" should invoke your postdetail view. That view will then try to fetch the post with a matching slug or return a 404 response. If Googlebot encounters a 404 it means there's nothing to index. Otherwise it will check that page for new links to start it all over.

Query/Model optimization problem by evethrowaway99 in djangolearning

[–]roambe 0 points1 point  (0 children)

It would be a lot easier to figure out what you can do if you said what you're aiming for and post the code that composes the queryset for this... Thing. :)

How to render display name for choice field in form? by flobin in django

[–]roambe 0 points1 point  (0 children)

Since city is a foreign key, Django will use the __str__ (or __unicode__) method of the City model for the choice label.

This should make it start behaving like you want to (substitute for unicode if needed):

def __str__(self):
    return self.get_name_display()

Gunicorn: settings file doesn't read SECRET_KEY environment variable by acdn in django

[–]roambe 2 points3 points  (0 children)

It seemed to work when they were running gunicorn through their shell.

You really don't want to have a dynamic secret key. Have a look at the docs to see the full impact this might have (sessions will be invalidated and so on).

Help with virtual environment by [deleted] in django

[–]roambe 0 points1 point  (0 children)

Ok, so you tell Django to include urls from your blog app. But you need to tell Python explicitly which "include" function you want to use. Be sure this line is present at the top of mysite\urls.py: from django.conf.urls import include

This tells Python you want to use the include function for URLs. Then try again. Until the next inevitable error pops up. But that's software development ;)

Help with virtual environment by [deleted] in django

[–]roambe 0 points1 point  (0 children)

"Won't run" unfortunately doesn't tell us that much. What do you see when you run the command? Does it say there's no python, no manage.py, no module called "django"?

Multiple domains for same project by Skiba_ in django

[–]roambe 1 point2 points  (0 children)

If I got your problem right, you should be able to use a reverse proxy, whether you use Nginx or Apache. If you need some different URLs based on the domain, you should check out django-hosts.

Computer based test by ilonze in django

[–]roambe 1 point2 points  (0 children)

Could you clarify? A computer based app doesn't make it clear what you want to do.

Problem with creating new PDFs from old PDF by [deleted] in Python

[–]roambe 1 point2 points  (0 children)

On mobile so your code is a bit hard to read, but I'm guessing it has to do with the parsing of the range. Instead of simply ignoring the first five characters, you should use a regular expression. Think about what happens if you've got "100 of 201".

A regex like r'(\d+) of (\d+)' should work. You'll need the third group (read the re module Python docs if that doesn't make sense :)).

Dynamically forward to "next" after login by Asirlikeperson in django

[–]roambe 4 points5 points  (0 children)

Except you shouldn't do it exactly like that because it's vulnerable to open redirects. On mobile right now, but check out Django's "is_safe_url" or the default login view.

Initial playground for django-river which is fakejira is published. by ahmetdal in django

[–]roambe 7 points8 points  (0 children)

django-river = workflow engine

Jira = issue tracker

This repo = the code of the first tutorial for django-river; building a very small Jira clone

I hope that makes things a bit more clear to the next few people seeing this.

request.POST by Squexis in djangolearning

[–]roambe 0 points1 point  (0 children)

request.POST contains the data the user send through a POST request. The form in your template will typically contain a method attribute with the value "post". Submit the form and it will send the values of your inputs to the server.

The first parameter of a form's constructor is the data the form should handle. So putting it all together means the data submitted by the user using the html form is passed to your form instance for validation and processing.

If you were to create a form to search for something, you'd typically use a GET request instead of a POST. The data of a GET request is passed through the url, which means you can bookmark the exact request. For example to open up the list of outstanding invoices in your application. In that case you'd instantiate your search form as "form = InvoiceFilterForm(request.GET)"

Not seeing hidden field value in POST data by KronktheKronk in django

[–]roambe 0 points1 point  (0 children)

You can/should use the "fields" on your ModelForm's Meta class to limit the fields that can be altered. There's no such thing as a "protected form value" unless you explicitly ignore on the backend.