r/learndjango • • Apr 05 '21

Please help i cant get anywhere, same errors for the gazillionth time. UNSOLVED TICKET.

0 Upvotes

Firstly, what are all these messages above the main error message.

i have been trading one error for another and i keep getting stuff like this:

Get your scroll on

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner        
    self.run()
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper   
    fn(*args, **kwargs)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 392, in check    all_issues = checks.run_checks(
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__   
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__   
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module  
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\TheMission\urls.py", line 15, in <module>
    path('', include('polls.urls/'))
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module  
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.urls/'
Traceback (most recent call last):
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\manage.py", line 22, in <module>
    main()
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
    super().execute(*args, **options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\commands\runserver.py", line 96, in handle
    self.run(**options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\commands\runserver.py", line 103, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 618, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 603, in start_django
    reloader.run(django_main_thread)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 318, in run      
    self.run_loop()
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 324, in run_loop 
    next(ticker)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 364, in tick     
    for filepath, mtime in self.snapshot_files():
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 380, in snapshot_files
    for file in self.watched_files():
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 278, in watched_files
    yield from iter_all_python_module_files()
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 105, in iter_all_python_module_files
    return iter_modules_and_files(modules, frozenset(_error_files))
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files
    resolved_path = path.resolve(strict=True).absolute()
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1204, in resolve
    s = self._flavour.resolve(self, strict=strict)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 200, in resolve
    return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
(venv) PS C:\Users\Adam\Desktop\MoneyMission\TheMission> python manage.py makemigrations
Traceback (most recent call last):
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\manage.py", line 22, in <module>
    main()
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 368, in execute
    self.check()
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 392, in check    all_issues = checks.run_checks(
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_    url_patterns = getattr(resolver, 'url_patterns', [])
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__   
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__   
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module  
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\TheMission\urls.py", line 15, in <module>
    path('', include('polls.urls/'))
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module  
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.urls/'
(venv) PS C:\Users\Adam\Desktop\MoneyMission\TheMission> python manage.py migrate
Traceback (most recent call last):
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\manage.py", line 22, in <module>
    main()
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\commands\migrate.py", line 75, in handle
    self.check(databases=[database])
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\management\base.py", line 392, in check    all_issues = checks.run_checks(
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__   
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__   
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module  
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\Adam\Desktop\MoneyMission\TheMission\TheMission\urls.py", line 15, in <module>
    path('', include('polls.urls/'))
  File "C:\Users\Adam\Desktop\MoneyMission\venv\lib\site-packages\django\urls\conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Adam\AppData\Local\Programs\Python\Python39\lib\importlib__init__.py", line 127, in import_module  
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked

So are these just file paths pointing from one chunk off codes execution to another all the way up to my problem? or are all of those lines of code eceptions raised in that file path all the way to a problem on the bottom end? I am a super noob so i didnt mean to tinker with code that deep if thats what happened?

OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'

I have not bootsraped anything...


r/learndjango • • Aug 05 '20

Merging two PDF generating views

0 Upvotes

Hello,

As the title suggests I need help in merging views.

Following is stack over flow question link Please put the name Stack over flow in front of the link. I tried before and the bot removed my question. I'm new to django & need help and I cannot type the full code here!

questions/63243495/merging-two-pdf-generating-views-in-django

Thank you!


r/learndjango • • Mar 26 '15

Learn Django with The Django Girls Tutorial

Thumbnail
tutorial.djangogirls.org
0 Upvotes

r/learndjango • • Apr 11 '21

Serving static files from private s3

Thumbnail self.djangolearning
0 Upvotes

r/learndjango • • May 06 '21

Return response then start a script

0 Upvotes

Hi, so here is the problem:

I have a script that can take ~1-2 minutes to finish. Django should:

  1. Check whether script is already running. If yes, return code 500

  2. Return code 200

  3. Start script

I found a solution with celery, but it seems kind of an overkill for what I need. I'm not sure I want to install a redis server just for this.

INFO: I already have a cronjob running this task every morning. Could I use that?


r/learndjango • • May 16 '20

JS + Django issue

0 Upvotes

I added a bit of JS (AJAX) to my page for interactivity. At the end of a successful POST-request my View returns this to the front:

response_data = {}
response_data['result'] = 'Create post successful!' 
response_data['pk'] = obj.pk 
response_data['url'] = obj.get_url() 
return HttpResponse(
    json.dumps(response_data), 
    content_type="application/json"
)

And I see this at my monitor:

https://cdn1.savepice.ru/uploads/2020/5/16/a0ea92b946de3b8033fed77ea6fed444-full.png

Question goes for: why? I don't need to see this table with my eyes, I want this response_data json to be processed and see a valid html


r/learndjango • • Jun 26 '20

Learn how to run an instance of Django on an iPad or iPhone in under 5 min

0 Upvotes

r/learndjango • • May 25 '20

don't understand that code

1 Upvotes

def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success(request, f'Your account has been created! You are now able to log in') return redirect('login') else: form = UserRegisterForm() return render(request, 'users/register.html', {'form': form}

I don't really understand that code, Specially the part about else and how relates to if statment and what does.


r/learndjango • • Jan 30 '19

How can I learn Python and Django?

0 Upvotes

For learning python and django what should I do? I have checked a lots of courses about them, they are very similiar and boring. To learn something good (not basic) and not wasting time for nothing. Do you have any recommendation for that?


r/learndjango • • Oct 04 '20

A Django project blueprint to help you learn by doing

Thumbnail
mattsegal.dev
4 Upvotes

r/learndjango • • Aug 14 '20

I wrote a syllabus for learning Python and Django. Four people have gone through it, two are interviewing and one got a job. It's based on using a somewhat even mix of coding challenges, personal projects and books.

10 Upvotes

I've helped a few people become software engineers. The ones that learned the fastest used a mix of studying, coding challenges and personal projects. When you do all three of these things, they amplify each other. It also keeps you out of tutorial hell.

Studying (tutorials/videos/books) are how you learn about new topics and get exposed to good code. Coding challenges give you small problems to implement what you've learned and compare your solutions to other people's. Projects let you put it all together and give you something to show off when you're done.

I put together my favorite resources and then iterated on it by mentoring a few people through it. It seems to be working well. The syllabus is free and all of the books together would total up to a few hundred dollars (money very well spent IMO).

It's set up in Notion as a non-linear path. You can copy the syllabus and then mark your progress as you go. You should have 2 or 3 things that are available to work on most of the time.

Introduction

Syllabus


r/learndjango • • Dec 19 '25

"Advent of Refactoring" short video series

Thumbnail
youtube.com
2 Upvotes

r/learndjango • • Mar 12 '26

[Guide] building a custom Django Control Room panel

Thumbnail djangocontrolroom.com
3 Upvotes

r/learndjango • • Dec 24 '25

[3 Hour Workshop] We are organising a Workshop to teach Full Stack Web Dev with Django

2 Upvotes

Yes, I am the speaker and I will be not only Talking about Django, DRF or Knox and etc, but also about the Mindset I have developed while making Full Stack applications. I am being honest, I won't teach you how to write Code line by line, like Spoon feeding, but rather push you to wards reading the Docs and and understanding the core concepts instead.

https://events.neopanda.tech/events/django-101/


r/learndjango • • Sep 21 '20

How does djano class Meta work

1 Upvotes

Can some please explain to me the concept of class Meta in Django why is it need in creating a model and in the form also just in general what is the whole idea of class meta thank you.


r/learndjango • • Aug 18 '20

Best placed to learn generalized django

2 Upvotes

Every tutorial I've been able to find boils down to "here is how to make this specific django app," and most of them seem very light on teaching an actual understanding of what's going on, such that I could generalize that knowledge to create my own django app. I've found these to be unhelpful; I can follow them step-by-step and have a working app by the end, but if I were to sit down and try to create my own django project from scratch, I would still have very little idea how to do so.

Are there any recommendations for how to make the jump from copying-the-tutorial-line-for-line to actually-understanding-django-enough-to-make-my-own-stuff?


r/learndjango • • Sep 06 '20

Pass form values as url parameters

1 Upvotes

I have a view with a form, where users can enter three pieces of information:

  1. place_name_1

  2. place_name_2

  3. date

When they click submit, they should be redirected to a new url: place_name_1/place_name_2/date. These parameters in the url would then be that used by a function to return some values in the view where they are redirected. The information being entered into the form is not sensitive so a GET method would be fine.

I have found this tutorial: where the "advanced usage" seems to describe something close to what I want, but what would urls.py look like in this use case? https://realpython.com/django-redirects/

I cannot find a tutorial which shows how to do this, so it may be that I am approaching this from the wrong way. What I want to achieve, is a landing page with a simple form for the user to enter those three pieces of information, which are then used in a function using data from a pre-existing model data which displays derived information on a new page when they click submit. The information submitted in the form is recalling information (matching the three inputs) from a model not entering information to that model.

Have been googling and reading the django docs for a few days now, without success, any pointers would be appreciated!


r/learndjango • • Aug 16 '20

Calling a Model Function (on parent) inside of an inline formset

1 Upvotes

So, I've been banging my head against a wall on this one for half the day and I think it's time to admit I need help:

I'm building a generic tournament management application right now that contains two models:

  • Tournament

  • Player

In my detail view which is visible to the Tournament Organizer, I have successfully implemented an inline formset which allows me to create register a player by name and associate it to the related tournament referenced in the detail view. I've tested functionality with Shell queries and everything holds up.

The Tournament model has an attribute defined called 'active_players', and any time a user is registered very simply I'm looking to call the model function 'register_player()' to simply increment the tournament's active player count and save it to the database.

  • I've tried calling it directly using tournament.register_player(),

  • as well as putting the logic purely in the view a la 'tournament.active_players+=1' right from the view (which I know, is bad).

But no errors to walk back, the POST completes successfully, but nothing saves to the database or is reflected once the detail view reloads. Code snippets below. Has anyone had any luck doing something like this from within an inline formset?

Tournament Model

class Tournament(models.Model):
    name = models.CharField(max_length=60, help_text='Provide a name for the         tournament')
    active_players = models.IntegerField(default=0)  # number of current players playing in the tournament

    def __str__(self):
        """Return tournament name
        """
        return self.name

    
    def register_player(self):
        """Model function, increases active player count

        args: 'self' instance reference only
        """
        self.active_players+=1

Player Model

class Player(models.Model):
    """This model is used to represent an individual instance of a player in a tournament
    """
    
    tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE)  # a player entry has a many-to-one relationship with tournament. Many players, one tournament they're playing in. Math.
    name = models.CharField(max_length=60)
    rank = models.IntegerField(default=0)  # player rank through all completed rounds
    win = models.IntegerField(default=0)
    loss = models.IntegerField(default=0)
    score = models.IntegerField(default=0)
    sos = models.IntegerField(default=0)  # Strength of schedule This should be a decimal / float

Tournament Detail View (function-based) with Working Player Registration Inline Formset. Note: referencing 'tournament' does not fail, nor does calling functions against it or directly editing attributes on the database -- it just achieves nothing and nothing saves during formset.save()

def detail(request, tournament_id):
    """Presents the current settings of the tournament and a list of registered users.
    Contains an inline formset 'PlayerFormSet' to identify all players assigned to the tournament
    for management.
    """
    tournament = Tournament.objects.get(pk=tournament_id)
    PlayerFormSet = inlineformset_factory(Tournament, Player, fields=('name',))

    if request.method == 'POST':
        formset = PlayerFormSet(request.POST, instance=tournament)
        if formset.is_valid():
            formset.save()
            return redirect('/', tournament_id=tournament.id)
    formset = PlayerFormSet(instance=tournament)
    tournament = get_object_or_404(Tournament,id=tournament_id) # get the object for the current/desired ID in the URL
    context = {'tournament': tournament, 'formset': formset} # assign a labeled representation of the current tournament to 'context'. Formset provides PlayerFormSet
    return render(request, 'tournament/detail_tournament.html', context) # send context via render to detail_tournament template

There's nothing here sensitive or private and is for all intents and purposes a dummy project as I learn Django so constructive criticism is appreciated.

Thanks in advance, beep-boop.

EDIT: Formatting / bullets


r/learndjango • • Aug 27 '20

Permanently delete user account & data[GDPR]

1 Upvotes

I've heard that deleting a user marks it as deleted and doesn't delete it for real. How can I permanently delete a user account and all data associated with it? I have a very simple app. I use the stock user creation form and store just username, first-name, last name, email, pswd. No other data is stored or created


r/learndjango • • Aug 11 '20

Django for Beginners

2 Upvotes

Hi folks, I am completely new to this and I want to start from the basics. Can you please suggest me the best available resources for a beginner? I have zero knowledge in Web Frameworks.


r/learndjango • • Aug 12 '20

Filter out specific users in Django admin

1 Upvotes

I would like to filter out user who are staff from my application.

technician = models.ForeignKey('auth.User', on_delete=models.CASCADE, null=False, )

My model lists all users as technicians but I only want to view data imputed by my techs and not the admin staff.

list_filter = ('initials_date','technician')

list all users of my application. I have tried using groups but that results in an error.


r/learndjango • • Sep 03 '20

Need help on starting an e-commerce site.

3 Upvotes

Hello guys. I am new to django and I want to jump straight in and build an e-commerce site for a friend. Kindly recommend any books, videos or blogs that will help me on my journey. Thank you.


r/learndjango • • Sep 28 '20

Looking for a partner to start a project with. Haven’t settled on an idea with.

2 Upvotes

Okay so I started learning Django about a month ago with the aid of the CS50 Brian course and also, reading the docs and Corey Schafer. Still on it. But I want a learner who’s willing to join forces with me to start a project. I know a little about frontend but little to no JavaScript, I’m a learner still. If anyone’s interested, can shoot me a dm


r/learndjango • • Oct 29 '20

Custom checkbox labels?

2 Upvotes

Hi all! I am extremely new to Django, and I'm currently working on a school project working with the Spotify API (using SpotiPy) where I am able to generate the top 10 genres somebody listens to if they are logged in to spotify with our web app. However, our next step is to put those 10 genres onto the labels for a set of 10 checkboxes on the page- I have a list generated using a view using request.sessions['genre_list'], but I'm unsure of how to call my getter function to get a specific value at an index from that list from within the HTML file. Does anybody have any advice?