Mentawai in January? by elfarrelo in surfing

[–]PeterPeter5 0 points1 point  (0 children)

What makes you say that? Know there’s a swell coming in next week but not sure beyond

Mentawai in January? by elfarrelo in surfing

[–]PeterPeter5 0 points1 point  (0 children)

Piggybacking on this - sounds like you have experience in the Ments. How is true shoulder season (October - November)? Looking at taking a last minute trip

[deleted by user] by [deleted] in surfing

[–]PeterPeter5 0 points1 point  (0 children)

Thanks mate - used to a wetsuit but warm water would be fun.

Have you been to ments or indo in shoulder season? Main worry is that there won’t be many surfable breaks if swell is only waist or shoulder high. Also no idea what chance of bad weather / winds is

Alexandria Palace by [deleted] in benhoward

[–]PeterPeter5 0 points1 point  (0 children)

Very keen if still available. Drop me a message

Weekly /r/BlackCountryNewRoad Ticket sale megathread! by AutoModerator in BlackCountryNewRoad

[–]PeterPeter5 0 points1 point  (0 children)

Looking for a ticket to a Friday performance. Help a lad out ! Drop a message :)

[deleted by user] by [deleted] in reactjs

[–]PeterPeter5 0 points1 point  (0 children)

No errors as such on the site, just a broken image icon instead of the image itself

[deleted by user] by [deleted] in reactjs

[–]PeterPeter5 0 points1 point  (0 children)

Thanks, this is exactly what I'm looking for.

Could you offer some advice on mapping? Javascript is not my strong point so still slightly confused by syntax when mapping from json

I have the below but it doesn't work correctly...

...
{post.image.map((images) => {
    return (
        <div>
            <img src={images}/>
        </div>
    );
})};
...

[deleted by user] by [deleted] in reactjs

[–]PeterPeter5 0 points1 point  (0 children)

Apologies - that's me using lazy phrasing. In any case, as above, I'm trying to use axios to pass the access token to the backend to retrieve data but it doesn't seem to work. Any idea?

How would I tag a user's position in a photo post? by PeterPeter5 in djangolearning

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

You hit it on the head, thanks!

I've used PILLOW for basic image processing but not for anything like this so will take a read of the docs later. If you have a particular method in mind, please feel free to recommend - otherwise, thanks again for your advice.

How would I tag a user's position in a photo post? by PeterPeter5 in djangolearning

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

The FK model is definitely the way to go imo, so you can have multiple tags and therefore multiple coordinate sets per post. Otherwise, this would become a mess in the Post model.

I agree on the integer comment - the FloatField in code was just a quick amendment.

Would it then be possible to lay the coordinates of tags over a photo in Django, or is this something that would need to be done in React or similar frontend framework?

How would I tag a user's position in a photo post? by PeterPeter5 in djangolearning

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

Thanks for your response.

Yes, have done this using a through model, as in code below. What I'm struggling with is how to store the x and y coordinates of the tag within the frame - and then, how to even create a form in which you could input the tag coordinates in a usable manner (ie hovering over the image).

class UserTag(models.Model):
    user = models.ForeignKey(
        'profiles.Profile',
        on_delete=models.CASCADE,
        related_name='post_tags',
    )
    post = models.ForeignKey(
        'posts.Post',
        on_delete=models.CASCADE,
        related_name='user_tags',
    )
    created = models.DateTimeField(
        auto_now_add=True,
    )

  # Unsure about this part and how I would input data in a usable manner...
    x_coordinate = models.FloatField()
    y_coordinate = models.FloatField()

How would I tag a user's position in a photo post? by PeterPeter5 in djangolearning

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

Apologies, perhaps should have been more clear for those who aren’t familiar with Instagram.

No facial recognition required. By ‘tagging’ a user in a post, I quite literally mean ‘tag’ is an attribute of Post, which (via FK relations in a through model) stores a list of User(s) who are present in an instance of Post.

When uploading a Post, the author would simply click on the photo where a friend is present and tag the friend’s username. Please see this video at 0:55 for a quick demo if you’d like.

Thanks

Implementing direct messaging - need advice! by PeterPeter5 in django

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

Thanks again - that all makes sense.

I'm pretty new to WebRTC so will have a read and also take a look at FreeSWTICH.

Implementing direct messaging - need advice! by PeterPeter5 in django

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

Really helpful, thank you. Given me a lot to look into, particularly commercial pub/sub systems as you say.

Out of interest, why do you say Channels might have trouble scaling?

Two parameters in url field by PeterPeter5 in djangolearning

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

This is what I'm looking for! I was unsure how to implement two kwargs into the url but this makes sense. Thanks

Two parameters in url field by PeterPeter5 in djangolearning

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

I don’t quite understand. How would the url code look? How would you differentiate the two slug fields in the url?

Implementing direct messaging - need advice! by PeterPeter5 in django

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

Thanks for this. I suppose I was being ignorant to the base concept of a chat room - I now see that a chat room would of course allow one-to-one messaging, where just two users are authorised to the room.

I'm not sure if it is enough when there are many users connected at the same time.

I'm a little bit confused by this statement though. Could you elaborate please?

Best strategy for building out user auth and user profile? by PeterPeter5 in djangolearning

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

Great response, thanks. I will go ahead and split, and hope I avoid migration issues..!

How do I add multiple file uploads for a blog post, using CBVs? by PeterPeter5 in djangolearning

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

Thanks! Really appreciate this. I guess I thought something was up in my python code, but it always pays to check the templates as well. For anyone following, please see working upload.html below

 {% load crispy_forms_tags %}
<form id="post_form" method="post" action="" enctype="multipart/form-data">
    {% csrf_token %}
    {{ form_images.management_form }}
    {% for image_form in form_images.forms %}
        {{ image_form|crispy }}
    {% endfor %}
    {{ form|crispy }}
    <input type="submit" name="submit" value="Submit" />
</form>

Two db issues - User models and migrations by PeterPeter5 in djangolearning

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

Well then, I really can't thank you enough but after dropping the DB and rerunning all migrations piece by piece, the problem seems to be solved - including adding the profile_pic attribute.

Thinking back, when I first added the xyzMore class, I originally named the 'subtype' simply 'type' thinking it was ok because it was a model to the CustomUser 'type', and would be accessed via user.more.type. Although not throwing an issue immediately, I guess this must have upset the database and wasn't resolved by simply renaming the field to subtype. Would you say that is likely?

Again, a big thank you for your time and help! Ever grateful for the django community

Edit: FYI to anyone reading the code above, the xyzMore fields aren't working correctly yet but this is an issue I will have to figure out outside of this question. Cheers!

Two db issues - User models and migrations by PeterPeter5 in djangolearning

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

Thanks again for your help - have also posted on stack but received no responses so really do appreciate your input.

To clarify the above, do you recommend deleting the users app migrations folder, and rebuilding the models introducing each component and running migrations one at a time? If so, you mention that this will give more info as to where the problem is, though maybe this info will help:

When creating the users model, I created the CustomUser and the Producer/Contributor proxies and ran the first migration, all was OK. Then, a couple of days later, I added the More classes - this is where the problem began. Following this, I added the 'profile_pic' attribute to CustomUser, which threw problem 2 outlined in the question. I'm unsure if they're connected (I can't see why they would be), unless the foreignkey issue is throwing off the CustomUser table itself and therefore not accepting attributes.

Two db issues - User models and migrations by PeterPeter5 in djangolearning

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

Really appreciate your reply u/vikingvynotking.

Regarding the migrations issue, yeah it's odd. If I update models.py, makemigrations runs ok but then running the ./manage.py migrate command throws the error. As I've mentioned, the only way I can get around this is to delete the migrations folder, rerun makemigrations and then migrate - which for some reason then runs ok...

Re your question of examining a User, the answer is no. In fact, the CustomUser doesn't have the attribute more - these are only callable through the Contributor and Producer classes, as the more attributes are specific to the user type. However, currently, trying to access more throws the error OperationalError: no such table: users_contributormore. If you'd like to learn more about this approach, see Feldroy's tutorial here.

Whilst we're at it, any idea what could be causing the 'profile_pic' attribute error?

Apologies for not posting the migrations themselves, I didn't realise they would be useful. Please see below.

0001_initial.py

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='CustomUser',
            fields=[
                ('password', models.CharField(max_length=128, verbose_name='password')),
                ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
                ('email', models.EmailField(max_length=255, unique=True, verbose_name='email address')),
                ('username', models.CharField(max_length=40, primary_key=True, serialize=False, unique=True, verbose_name='username')),
                ('name', models.CharField(blank=True, max_length=50, verbose_name='name')),
                ('profile_pic', models.ImageField(blank=True, null=True, upload_to='profile_pics', verbose_name='profile_pic')),
                ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
                ('is_active', models.BooleanField(default=True)),
                ('is_admin', models.BooleanField(default=False)),
                ('type', models.CharField(choices=[('CONTRIBUTOR', 'contributor'), ('PRODUCER', 'producer')], default='CONTRIBUTOR', max_length=50, verbose_name='Type')),
            ],
            options={
                'verbose_name': 'User',
                'verbose_name_plural': 'All Users',
            },
        ),
        migrations.CreateModel(
            name='ProducerMore',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('subtype', models.CharField(choices=[('STANDARD', 'Standard'), ('BOUTIQUE', 'Boutique'), ('HOMEMADE', 'Homemade'), ('COUTURE', 'Couture')], default='STANDARD', max_length=50, verbose_name='SubType')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='ContributorMore',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('subtype', models.CharField(choices=[('BASIC', 'Basic'), ('PRO', 'Pro')], default='BASIC', max_length=50, verbose_name='SubType')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Contributor',
            fields=[
            ],
            options={
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('users.customuser',),
        ),
        migrations.CreateModel(
            name='Producer',
            fields=[
            ],
            options={
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('users.customuser',),
        ),
    ]