Form field label template

2018-02-09 Thread jorrit787
I want to improve the look of my forms with Materialize CSS (http://materializecss.com/forms.html), which requires some fields to have a div with class input-field around the input AND the label. I figured I could use the new template-based widget rendering, but to my surprise those templates

Re: Displaying Categories / Subcategories (Tango with Django Example)

2017-05-12 Thread jorrit787
Both, actually. The OP is looping through his cats and pages querysets multiple times unnecessarily. That can get very inefficient as those database tables get bigger. On Friday, May 12, 2017 at 6:04:01 PM UTC+2, sacrac wrote: > > {% regroup %} is elegantly or more optimized??? > > On Fri, May

Re: Displaying Categories / Subcategories (Tango with Django Example)

2017-05-12 Thread jorrit787
You can look into the {% regroup %} template tag. It will do what you are trying to do more elegantly. On Wednesday, May 10, 2017 at 7:40:26 PM UTC+2, Michael Smith wrote: > > I'm following the latest Tango book and was experimenting with different > ways of looping through categories and

Re: Django 1.11 released

2017-04-05 Thread jorrit787
Is the required version of Pillow pinned at 4.0.0? I upgraded to Django 1.11 and from Pillow 4.0.0 to 4.1.0 but now Django doesn't start because it says I can't use ImageField without installing Pillow. Downgrading to Pillow 4.0.0 fixes this. On Tuesday, April 4, 2017 at 6:09:40 PM UTC+2, Tim

Re: Making email required

2017-02-01 Thread jorrit787
You can define a single form to use for creating and updating users like this: class CustomUserChangeForm(UserChangeForm): class Meta: model = User fields = ('email', 'password', 'first_name', 'last_name', 'photo', 'is_active', 'is_staff', 'user_permissions') class

Re: "Polls" app in Django Beginners' Tutorial

2017-01-20 Thread jorrit787
Did you set a pub_date on the questions you created? Since the field doesn't have a default value it will remain empty and have no effect on ordering unless you explicitly set pub_date=timezone,now() every time you create a question. On Friday, January 20, 2017 at 2:30:37 PM UTC+1,

Re: Django Tutorial Part 5, Test detail view with a past question failure.

2017-01-20 Thread jorrit787
You mean that after you make the changes the tutorial gives you the test still fails? It is supposed to fail the first time before you make the changes. On Thursday, January 19, 2017 at 8:21:38 PM UTC+1, Vpeguero wrote: > > I'm currently working through the django tutorial for v1.10. On part 5

Re: "Polls" app in Django Beginners' Tutorial

2017-01-20 Thread jorrit787
Can you show your Question model? On Friday, January 20, 2017 at 1:33:33 PM UTC+1, DjangoUserDM wrote: > > No, definitely didn't! > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from

Re: "Polls" app in Django Beginners' Tutorial

2017-01-20 Thread jorrit787
Perhaps you forgot the '-' before pub_date? On Thursday, January 19, 2017 at 8:21:32 PM UTC+1, DjangoUserDM wrote: > > I have a question about the "Polls" app, as described in the Django > Beginners' Tutorial, https://docs.djangoproject.com/en/1.10/intro/. In > tutorial 3, the index view

Re: readonly and autofocus support in form fields?

2017-01-19 Thread jorrit787
I think the problem here is with ModelForms. Where would you define these properties for ModelForms? Putting them in your Model classes doesn't make sense because it violates loose coupling between models and forms/templates. It's already quite peculiar that Model fields can have a blank=True

Re: Creating a sample poll app 2

2017-01-17 Thread jorrit787
Because you need to import the Question model from the models.py file before you can register it in the admin. "from .models import X" means "import X from the file models which is in the same directory as the current file". On Tuesday, January 17, 2017 at 3:18:47 PM UTC+1, Rachit Tibrewal

Re: models foreign key

2017-01-12 Thread jorrit787
What exactly isn't working? Are you getting an error message? I can see a few potential problems: - You're missing a quotation mark around Author_code in the *to_field* parameter; - The fields on both models have the same name, this might cause problems. On Thursday, January 12,

Re: DateField default value in SQLite and Postgres

2017-01-04 Thread jorrit787
I use SQLite locally for development and Postgres in production. So when my migration runs fine locally I expect it to also work fine when I upload it 5 minutes later and try to apply it to my Postgres database. On Wednesday, January 4, 2017 at 3:59:52 PM UTC+1, Avraham Serour wrote: > > well

Re: DateField default value in SQLite and Postgres

2017-01-04 Thread jorrit787
I thought the whole point of an ORM was to abstract away differences between backends... That's why this seems like a bug to me. On Wednesday, January 4, 2017 at 1:02:07 PM UTC+1, Avraham Serour wrote: > > Well this is the reality right now, if you think the framework is acting > wrong you may

Re: DateField default value in SQLite and Postgres

2017-01-04 Thread jorrit787
The fact that some backends are more forgiving is exactly my point. Maybe the migrations engine should always force a datetime object (or at least a -MM-DD notation) to make it work consistently on all backends. On Wednesday, January 4, 2017 at 11:35:38 AM UTC+1, Avraham Serour wrote: > >

Re: DateField default value in SQLite and Postgres

2017-01-03 Thread jorrit787
This field: activity_date = models.DateField('Datum', default='17/06/2017') Results in this migration: class Migration(migrations.Migration): dependencies = [ ('activities', '0006_auto_20161231_1703'), ] operations = [ migrations.AlterField(

DateField default value in SQLite and Postgres

2017-01-03 Thread jorrit787
I recently set a default value in my local date format on a DateTimeField while I was using SQLite. The migration ran fine on my SQLite dev database, but when trying to apply the migration on my production Postgres database I got an error saying that a default value for DateTimeField must be in

Re: django.template.exceptions.TemplateSyntaxError: 'static' is not a registered tag library. Must be one of:

2016-12-29 Thread jorrit787
Have you added *django.contrib.staticfiles* to *INSTALLED_APPS* in your settings.py? On Thursday, December 29, 2016 at 11:30:16 AM UTC+1, ragini dahihande wrote: > > Hello Guys, > I am new to django. > I created sample project while running it I am getting following error > >

Re: Filtering in ListView

2016-11-25 Thread jorrit787
If you're ok with using an external package you can check out django-filter , it makes filtering very easy. On Thursday, November 24, 2016 at 8:35:30 PM UTC+1, Artem Bernatskyy wrote: > > Hello, > > how can i accomplish filtering in ListView via

Foreign key set template

2016-09-22 Thread jorrit787
I have a question about using *model.foreignkey_set* in Django templates. I was trying to use *model.foreignkey_set* to determine if there were any foreign keys for this model, but it appears that *model.foreignkey_set* returns something different than *model.foreignkey_set.all* - why is that?

Username in password_reset_email

2016-07-09 Thread jorrit787
I want to include a reminder of a user's username in the password reset email, but I can't seem to include the username variable in the context. I'm trying to include it via the extra_email_context parameter in the URL pattern, but that doesn't work: url(r'^password_reset/$',

Re: Password hasher for vBulletin?

2016-06-23 Thread jorrit787
As a follow-up question to this... this line gives the error "Can't convert 'bytes' object to str implicitly": vB_hash = hashlib.md5(hashlib.md5(force_bytes(password)).hexdigest() + force_bytes(salt)).hexdigest() Do I need to insert a str() somewhere? -- You received this message because

Re: Where is this warning coming from?

2016-06-12 Thread jorrit787
I have USE_TZ set to True. Thanks Tim, I will try using the date lookup! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: Adding Tinymce to Admin

2016-06-09 Thread jorrit787
Have you looked at https://github.com/aljosa/django-tinymce ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post

Where is this warning coming from?

2016-06-09 Thread jorrit787
I have a view that calculates some quick statistics: def index(request): context = { 'topics_unanswered': Topic.on_site.filter(topic_type=1, date_published__isnull=False, reply__isnull=True).count(), 'members_unapproved':

with django, how to write a grdview or table to show information and add a button or link in each row for approval?

2016-05-27 Thread jorrit787
Sounds like Formsets is what you are looking for. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this

Integer field choice list keeps triggering migration

2016-05-03 Thread jorrit787
I have the following model and choice list: BTW_TARIEF_CHOICES = { (1, '6%'), (2, '21%'), (3, '0%'), } class FactuurItem(models.Model): naam = models.CharField(max_length=100) factuur_naam = models.CharField(max_length=100) eenheid = models.CharField(max_length=10)

What's the best way to auto convert a model field values before it is rendered?

2016-04-26 Thread jorrit787
Do you need to do actual math with the converted values, or is it just a matter of displaying the original value as the converted value in the template to those users who prefer seeing Fahrenheit? In the latter case all you would have to do is create a custom template tag that takes the

Passing parameter to template in django while using url rendering

2016-04-25 Thread jorrit787
You should have a look at Django's Messages framework. It does what you are trying to achieve in a more automatic and reusable way: https://docs.djangoproject.com/en/1.9/ref/contrib/messages/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Emails to users

2016-04-11 Thread jorrit787
Django's email features are covered here: https://docs.djangoproject.com/en/1.9/topics/email/ . On Sunday, April 10, 2016 at 7:47:46 PM UTC+2, Luca Brandi wrote: > > Hi > I am wondering how the admin can communicate to his users...Is there a way > for example to create email templates and then

In a new Model with a OneToOne(User) relationship, how to get the username?

2016-04-10 Thread jorrit787
I'm not sure you can use default the way you are using on the name field, but in case you can: the names of the fields in User are username, firstname, and lastname, so you can try user.username, user.firstname or user.lastname . -- You received this message because you are subscribed to the

Trouble getting posted

2016-04-09 Thread jorrit787
Did you subscribe to the topics you posted? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group,

Re: Rendering Form Fields That Are Passed To Context Inside Of An Object

2016-04-09 Thread jorrit787
Are you sure you have the name of the fields correct? According to the documentation {{ form.fieldname }} should do what you want. It sounds like formsets would be more appropriate for what you're trying to achieve though. And yeah, if you're going to go that specific you might as well render

Re: Suggest newsletter to integrate in django project

2016-04-09 Thread jorrit787
There's a good chance you will find something that fits your needs at django-packages :) https://www.djangopackages.com/grids/g/newsletter/ On Thursday, April 7, 2016 at 12:55:08 PM UTC+2, Luca Brandi wrote: > > Hi, > followed some tutorials on the web integrating Mailchimp in my django >

Re: Should I use Django's builtin control panel for user facing purposes?

2016-04-09 Thread jorrit787
There's nothing physically stopping you from letting all your site's users use the Django Admin, but at least in spirit the Admin is only meant to be used by your staff. Even then, consider whether you need the Admin at all for your purposes: it sounds like what you're trying to do could easily

Re: inventory in Django

2016-04-09 Thread jorrit787
Have you looked into Django ecommerce packages that are already out there? They may fit most of your needs, and you could extend them where they don't. https://www.djangopackages.com/grids/g/ecommerce/ -- You received this message because you are subscribed to the Google Groups "Django users"

Re: How to know which models have changed and need make migrations?

2016-04-09 Thread jorrit787
I've run into the problem of migration files not being added to source control with PyCharm because PyCharm doesn't seem to automatically commit auto-created files unless you explicitly tell it to in the settings (and even then it doesn't always work). -- You received this message because you

Re: Problems with dumpdata/loaddata

2016-04-09 Thread jorrit787
I jus tested it again and it happens even without opening the file in an editor first. Would that be a bug then? On Friday, April 8, 2016 at 10:23:43 AM UTC+2, Ramiro Morales wrote: > > It shouldn't. Are you sure you haven't opened and saved the json file with > a text editor that might be

Re: Problems with dumpdata/loaddata

2016-04-07 Thread jorrit787
Opening the JSON file in Notepad++ certainly gives some insight... It says it's encoded in USC-2 LE BOM. Converting it to UTF-8 with BOM in Notepad++ solves the problem. Question though, why does dumpdata create files with an encoding that can not be used out of the box with loaddata? -- You

Re: Problems with dumpdata/loaddata

2016-04-06 Thread jorrit787
Thank you for the replies. *members* and *posts* are the names of my apps. The first line of the XML file when I open it in Notepad says: The JSON file has no distinguishable first line, it just starts right away with the data. On Wednesday, April 6, 2016 at 1:45:44 AM UTC+2,

Re: Architecture of multiple Sites

2016-04-05 Thread jorrit787
These are both interesting solutions. I will give them a try, thanks! On Tuesday, March 22, 2016 at 2:08:27 AM UTC+1, jorr...@gmail.com wrote: > > I'm wondering if I understand the Sites framework correctly... I'm > building a forum-like project which will initially be accessible from >

Problems with dumpdata/loaddata

2016-04-05 Thread jorrit787
I want to dump and load data for two apps that I have. Using dumpdata works fine: python manage.py dumpdata members posts > data.json or python manage.py dumpdata members posts --format=xml > data.xml However, when I try to load the same data back with loaddata I get the following errors:

Django tutorial part 3 - question_id vs question.id

2016-03-26 Thread jorrit787
I believe Django lets you access the pk field of a table (which is created automatically unless you define it explicitly on your model) in multiple ways: self.pk, self.id, and self._id. Someone correct me if I'm wrong. -- You received this message because you are subscribed to the Google

Re: get email address of the user in views

2016-03-22 Thread jorrit787
You should be able to use *request.user.email*, assuming you have the *django.contrib.auth* app installed and the user is logged in. On Tuesday, March 22, 2016 at 1:33:39 PM UTC+1, Vasu Dev Garg wrote: > > I want to get the email address of the user which i filter in views > function. How to

Re: Architecture of multiple Sites

2016-03-22 Thread jorrit787
But if I don't set the SITE_ID in settings.py I can't use the CurrentSiteManager, correct? On Tuesday, March 22, 2016 at 1:33:39 PM UTC+1, Sai Kiran wrote: > > If you need to use single projects for more than domains, create an entry > in django_site model by giving domain as well as verbose

Architecture of multiple Sites

2016-03-21 Thread jorrit787
I'm wondering if I understand the Sites framework correctly... I'm building a forum-like project which will initially be accessible from mydomain.com . The project contains several apps like posts, members, ads, etc. Eventually I would like to create myseconddomain.com, which would have unique

Re: Unable to parse connection string: "" when using django cache

2016-03-19 Thread jorrit787
As an aside, it looks like you're including CommonMiddleware twice. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.

Re: Password hasher for vBulletin?

2016-03-19 Thread jorrit787
Thanks for the help! If anyone looks at this in the future, this is the code I ended up using: *hashers.py* class PBKDF2WrappedvBPasswordHasher(PBKDF2PasswordHasher): algorithm = 'pbkdf2_vB' def encode_vB_hash(self, vB_hash, salt, iterations=None): return

Re: Documentation for User.set_unusable_password() doesn't feel complete

2016-03-15 Thread jorrit787
Does setting an unusable password on a user prevent them from using the reset password feature? On Wednesday, January 13, 2016 at 10:14:11 PM UTC+1, Brice PARENT wrote: > > When you set an usable password (using >

Re: Password hasher for vBulletin?

2016-03-15 Thread jorrit787
Holy crap, you guys have really thought of everything! Love it! Unfortunately this doesn't work on all users because some salts contain the *$* character which gives the *assert salt and '$' not in salt* error. Is there a workaround for this? On Tuesday, March 15, 2016 at 4:59:39 PM UTC+1,

Password hasher for vBulletin?

2016-03-15 Thread jorrit787
I'm converting an old vBulletin 3.8 installation to a Django web app and I'm wondering if I can migrate users over with their passwords intact. vBulletin uses *md5(md5(password) + salt)* to hash its passwords, would any of Django's built-in password hashers work with this out of the box? Some

Re: RegExp problems

2016-03-09 Thread jorrit787
Your improvements work great, thank you. And thank you for the very detailed explanations! On Tuesday, March 8, 2016 at 9:41:11 AM UTC+1, Michal Petrucha wrote: > > On Mon, Mar 07, 2016 at 05:44:08PM -0800, jorr...@gmail.com > wrote: > > I'm trying to replace *[URL]www.link.com[/URL]* with

RegExp problems

2016-03-07 Thread jorrit787
I'm trying to replace *[URL]www.link.com[/URL]* with HTML with this regexp: topic.text = re.sub("(\[URL\])(.*)(\[\/URL\])", '$2', topic .text, flags=re.I) But it's giving me the following problems: 1. The $2 capture group is only able to be repeated once, so I get $2 instead of

Re: Error running Django tutorial

2016-03-02 Thread jorrit787
Glad you got it solved!! On Monday, February 29, 2016 at 10:10:58 PM UTC+1, Mike Kipling wrote: > > I found the problem. > > When the mysite\urls.py file is created, it has this line already in it. > > from django.conf.urls import url > > The tutorial asks you to add the following lines to the

Re: Error running Django tutorial

2016-02-29 Thread jorrit787
Can you attach your entire project's code in a ZIP file? I'm curious to test this myself... On Monday, February 29, 2016 at 9:23:20 PM UTC+1, Mike Kipling wrote: > > I added polls to settings.py : > INSTALLED_APPS = [ > 'django.contrib.admin', > 'django.contrib.auth', >

Re: Error running Django tutorial

2016-02-29 Thread jorrit787
Well that's strange... The problem appears to be that your polls.urls file is not getting included in your project's URLConf (since the error message in your first post says that the only URL tried was *admin/* ). I'm not sure if adding the app to INSTALLED_APPS is necessary for an app's

Re: Error running Django tutorial

2016-02-29 Thread jorrit787
Did you add 'polls' to your list of INSTALLED_APPS in your settings.py? After that you should run > python manage.py migrate like the terminal is suggesting to you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this

Re: Home Page

2016-02-23 Thread jorrit787
I struggled with this as well. I usually end up creating a 'common' app for my homepage and project-wide templates and static files, but I don't know if that's considered a best practice. Alternatively you could put your homepage in your most used/most important app. -- You received this

Re: context dictionary

2016-02-23 Thread jorrit787
Wouldn't including the name 'user' in your context dictionary override the authenticated user object in your template? Might make for some unexpected behavior. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and

Re: django: drop down menu not displaying on template despite correct syntax

2016-02-17 Thread jorrit787
Have you tried using just {{ form }} instead of {{ form.mismatch }} ? Also, (not sure if this is related) in your MISMATCH_CHOICES tuple you are giving strings instead of integers for the key value. Try using (0, '0') instead of ('0','0') On Tuesday, February 16, 2016 at 2:16:17 PM UTC+1,

Re: Django Multiple User Login

2016-02-11 Thread jorrit787
I'm just being curious here but in what scenario would you have multiple people logging in at the same time using the same computer/browser? On Thursday, February 11, 2016 at 1:30:21 PM UTC+1, Aakash Tewari wrote: > > Hello > > > Here is new one I guess. > > We have 3 types of users say A, B,

Re: Access dynamic session variable name in template

2015-07-02 Thread jorrit787
This doesn't seem to work :( def comment_upvote(request, comment_id): comment = get_object_or_404(Comment.objects.filter(id__exact=comment_id, approved=True)) votes = request.session.setdefault('commentvotes', {}) if comment.id not in votes: comment.upvotes =

Access dynamic session variable name in template

2015-07-02 Thread jorrit787
Hi everyone, I am trying to keep track of who has voted on a comment by setting session variables like 'commentvote1', 'commentvote2', etc to True. These variable names are dynamically generated based on the id of the comment. How can I access these dynamic variables in my template? I've tried

Re: Inconsistency when importing views and models

2015-06-20 Thread jorrit787
Thank you for the very detailed explanations everyone! On Saturday, June 20, 2015 at 3:11:34 AM UTC+2, jorr...@gmail.com wrote: > > This is mostly a cosmetic question, and I could be completely wrong > because I'm fairly new to Django, or it could be that there is a perfectly > logical

Inconsistency when importing views and models

2015-06-19 Thread jorrit787
This is mostly a cosmetic question, and I could be completely wrong because I'm fairly new to Django, or it could be that there is a perfectly logical explanation for this, but here goes: It seems the code required to import views in urls.py and models in views.py is inconsistent (and in the